c++ - fftshift / ifftshift in terms of circshift -


and trying relate fftshift/ifftshift circular shift.

n = 5  y = 0:n-1  x = [0 1 2 3 4]  

when fftshift(x),

[3 4 0 1 2]  

when ifftshift(x), get

[2 3 4 0 1]  

how relate fftshift/ifftshift circular shift? moving numbers in x in different directions?

i need know i'm trying implement these 2 functions in terms of circular shift in c++, function have done.

many thanks.

after looking @ matlab codes, doesn't directly use circular shift, rather matlab syntax.

say n = no. of elements

to implement fftshift,

circularshiftrightby = floor(n/2) 

to implement ifftshift,

circularshiftrightby = ceil(n/2)  

being n/2, there difference between fftshift , ifftshift if n odd.

where circular shift code is:

template<typename ty> void circshift(ty *out, const ty *in, int xdim, int ydim, int xshift, int yshift) {  (int =0; < xdim; i++) {    int ii = (i + xshift) % xdim;    if (ii<0) ii = xdim + ii;    (int j = 0; j < ydim; j++) {      int jj = (j + yshift) % ydim;      if (jj<0) jj = ydim + jj;      out[ii * ydim + jj] = in[i * ydim + j];    }  } } 

(modified fftshift/ifftshift c/c++ source code support left (-ve) shifting well. )

edit: i've since found better way this: https://kerpanic.wordpress.com/2016/04/08/more-efficient-ifftshift-fftshift-in-c/


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -