Code:

from numarray import *
temp = zeros([6,6])
A = array([[1,2,3,4,5,6],[7,8,9,10,11,12],[13,14,15,16,17,18],[19,20,21,22,23,24],[25,26,27,28,29,30],[31,32,33,34,35,36]])
A = A + 2j #makes A complex
#used to define limits on for loops below
nx = len(A)
ny = len(A)
kx = nx/2
ky = ny/2
print A #just to see if everything looks all right
#reassigns values in quadrant 2 to 4 and quadrant 3 to 1
for j in arange(kx-1):
for i in arange(kx-1):
temp[i+kx+1,j+kx+1] = A[i,j]
for i in arange(kx-1,ny):
temp[i-kx+1,j-kx+1] = A[i,j]
#reassigns values in quadrant 4 to 2 and quadrant 1 to 3
for j in arange(kx-1,ny):
for i in arange(kx-1):
temp[i-kx+1,j-kx+1] = A[i,j]
for i in arange(kx-1,ny):
temp[i-kx+1,j-kx+1] = A[i,j]
print temp

Tweet This+ 1 thisPost To Linkedin