Hello Antoine, fttshift() switches all halves along all dimensions. This is mandatory. So for instance in 2D, opposite quadrants (wrt the center) are switched. In 3D, opposite cubes are switched. etc.
To me, the current implementation is right: --> m=grand(3,5,"uin",0,9) m = 2. 5. 9. 3. 0. 2. 4. 5. 5. 6. 4. 1. 8. 5. 9. --> fftshift(m) ans = 5. 9. 4. 1. 8. 3. 0. 2. 5. 9. 5. 6. 2. 4. 5. --> ifftshift(fftshift(m)) ans = 2. 5. 9. 3. 0. 2. 4. 5. 5. 6. 4. 1. 8. 5. 9. --> and(ifftshift(fftshift(m))==m) ans = T BR Samuel ----- Mail d'origine ----- De: antoine monmayrant+scilab <[email protected]> À: International users mailing list for Scilab. <[email protected]>, List dedicated to development questions <[email protected]> Envoyé: Tue, 09 Oct 2018 11:02:20 +0200 (CEST) Objet: [Scilab-users] fftshift and ifftshift are way too different Hello all, From what I understand of fast Fourier transforms, fftshift and ifftshift should be almost identical. The only difference is when there are an odd number of elements in the dimension along which the shift is performed (ie fftshift([1:4])==ifftshift([1:4]) but fftshift([1:5])!=ifftshift([1:5])). However, it seems that in scilab6.x fftshift and ifftshift are based on completely different codes and do not accept the same arguments. In particular, with fftshift, one can specify the dimension along which to perform the shift, while it is not the case for ifftshift. I think some update of ifftshift would be welcome. I propose to use the code below (myifftshift), where I just changed "ceil" by "floor" in the definition if fftshift. What do you think, does it look right to you? Cheers, Antoine function x = myifftshift(x,job) if argn(2)<2 then job="all",end deff("sel=fun(sk)","c=floor(sk/2);sel=[c+1:sk,1:c]") if job=="r" then job=1,elseif job=="c" then job=2,end ind=list() if job=="all" then for sk=size(x),ind($+1)=fun(sk),end else for sk=size(x),ind($+1)=:,end; ind(job)=fun(size(x,job)) end x=x(ind(:)) endfunction _______________________________________________ users mailing list [email protected] http://lists.scilab.org/mailman/listinfo/users
