code: def _fftshift_single(d_g, res_g, ax = 0):
      
  
      dtype_kernel_name = {np.float32:"fftshift_1_f",
                     np.complex64:"fftshift_1_c"
                     }
  
      N = d_g.shape[ax]
      N1 = 1 if ax==0 else np.prod(d_g.shape[:ax])
      N2 = 1 if ax == len(d_g.shape)-1 else np.prod(d_g.shape[ax+1:])
  
      dtype = d_g.dtype.type
  
      prog = OCLProgram(abspath("kernels/fftshift.cl"))
      prog.run_kernel(dtype_kernel_name[dtype],(N2,N//2,N1),None,
                      d_g.data, res_g.data,
                      np.int32(N),
                      np.int32(N2))
  
  
      return res_g
docs: basic fftshift of an OCLArray
  
  
      shape(d_g) =  [N_0,N_1...., N, .... N_{k-1, N_k]
      = [N1, N, N2]
  
      the we can address each element in the flat buffer by
  
       index = i + N2*j + N2*N*k
  
      where   i = 1 .. N2
              j = 1 .. N
              k = 1 .. N1
  
      and the swap of elements is performed on the index j