From: Paul K. <pki...@us...> - 2004-04-24 02:15:32
|
Update of /cvsroot/octave/octave-forge/main/general In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1534 Modified Files: ifftshift.m Log Message: [for David Bateman] NDArray support Index: ifftshift.m =================================================================== RCS file: /cvsroot/octave/octave-forge/main/general/ifftshift.m,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ifftshift.m 10 Oct 2001 19:54:49 -0000 1.1.1.1 +++ ifftshift.m 24 Apr 2004 02:15:23 -0000 1.2 @@ -24,26 +24,46 @@ ## Created: July 1997 ## Adapted-By: jwe ## Modified-By: Paul Kienzle, converted from fftshift +## Modified-By: David Bateman, add NDArray capability and option dim arg function retval = ifftshift (V) retval = 0; - if (nargin != 1) - usage ("usage: ifftshift (X)"); + if (nargin != 1 && nargin != 2) + usage ("usage: ifftshift (X, dim)"); endif - if (is_vector (V)) - x = length (V); - xx = floor (x/2); - retval = V([xx+1:x, 1:xx]); - elseif (is_matrix (V)) - [x, y] = size (V); - xx = floor (x/2); - yy = floor (y/2); - retval = V([xx+1:x, 1:xx], [yy+1:y, 1:yy]); + if (nargin == 2) + if (!isscalar (dim)) + error ("ifftshift: dimension must be an integer scalar"); + endif + nd = ndims (V); + sz = size (V); + sz2 = floor (sz(dim) / 2); + idx = cell (); + for i=1:nd + idx {i} = 1:sz(i); + endfor + idx {dim} = [sz2+1:sz(dim), 1:sz2]; + retval = V (idx{:}); else - error ("ifftshift: expecting vector or matrix argument"); + if (isvector (V)) + x = length (V); + xx = floor (x/2); + retval = V([xx+1:x, 1:xx]); + elseif (ismatrix (V)) + nd = ndims (V); + sz = size (V); + sz2 = floor (sz ./ 2); + idx = cell (); + for i=1:nd + idx{i} = [sz2(i)+1:sz(i), 1:sz2(i)]; + endfor + retval = V (idx{:}); + else + error ("ifftshift: expecting vector or matrix argument"); + endif endif endfunction |