# HG changeset patch # User jwe # Date 1086291247 0 # Node ID 9df0048ae0a1877c6cd50a612222e700386c9b77 # Parent ab5870f984d953b6bd8869cdbdcc07d529566d33 [project @ 2004-06-03 19:34:07 by jwe] diff --git a/scripts/general/circshift.m b/scripts/general/circshift.m --- a/scripts/general/circshift.m +++ b/scripts/general/circshift.m @@ -46,39 +46,39 @@ ## @end deftypefn ## @seealso {permute, ipermute, shiftdim} -function y = circshift (x, n) +function y = circshift (x, n) if (nargin == 2) nd = ndims (x); sz = size (x); - if (!isvector(n) && length(n) > nd) + if (! isvector (n) && length (n) > nd) error ("circshift: n must be a vector, no longer than the number of dimension in x"); endif - if (any(n != floor(n))) + if (any (n != floor (n))) error ("circshift: all values of n must be integers"); endif idx = cell (); - for i = 1 : length(n); + for i = 1:length (n); nn = n(i); if (nn < 0) - while (sz(i) <= - nn) + while (sz(i) <= -nn) nn = nn + sz(i); endwhile - idx {i} = [(1-nn):sz(i),1:-nn]; + idx{i} = [(1-nn):sz(i), 1:-nn]; else while (sz(i) <= nn) nn = nn - sz(i); endwhile - idx {i} = [(sz(i)-nn+1):sz(i),1:(sz(i)-nn)]; + idx{i} = [(sz(i)-nn+1):sz(i), 1:(sz(i)-nn)]; endif endfor for i = (length(n) + 1) : nd idx{i} = 1:sz(i); endfor - y = x (idx{:}); + y = x(idx{:}); else usage ("circshift (x, n)"); endif diff --git a/scripts/general/shiftdim.m b/scripts/general/shiftdim.m --- a/scripts/general/shiftdim.m +++ b/scripts/general/shiftdim.m @@ -51,7 +51,7 @@ function [y, ns] = shiftdim (x, n) if (nargin == 1) - ## Find the first singleton dimension + ## Find the first singleton dimension. nd = ndims (x); orig_dims = size (x); ns = 1; @@ -61,10 +61,10 @@ if (ns > nd) ns = 1; endif - y = reshape (x, orig_dims ([ns:end])); + y = reshape (x, orig_dims(ns:end)); ns = ns - 1; elseif (nargin == 2) - if (!isscalar(n) && floor(n) != n) + if (! isscalar (n) && floor (n) != n) error ("shiftdim: n must be an scalar integer"); endif if (n < 0)