ifftshift implementation is not coherent with that of fftshift
Reported by Antoine Monmayrant
BUG DESCRIPTION:
----------------
ifftshift and fftshift should:
- accept similar arguments,
- be based on similar code.
The current implementation of ifftshit rely on a code completely unrelated to that of fftshift.
It does not have the same arguments than fftshift.
In particular, for 1D ifftshift on a multiD array (hypermatrix), it lacks the dim argument present in fftshift.
As a consequence, 1D fftshift on an hypermatrix is possible, but 1D ifftshift on an hypermatrix is not possible.
ERROR LOG:
----------
None, current implementation of ifftshift is not coherent.
HOW TO REPRODUCE THE BUG:
-------------------------
OTHER INFORMATION:
------------------
We could base ifftshift and fftshift on the same source code, maybe merging both functions in one.
Indeed, an implementation of ifftshift coherent with that of fftshift is proposed below: ifftshift and fftshift only differ by a "ceil" instead of a "floor".
function x = ifftshift(x,job)
if argn(2)<2 then job="all",end
//deff("sel=fun(sk)","c=ceil(sk/2);sel=[c+1:sk,1:c]") // that's ffthshift version
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