GOt the vectorized version of the code working for even matrices only. Need to handle the odd size matrix edge cases