Mercurial > hg > octave-lyh
changeset 4895:9df0048ae0a1
[project @ 2004-06-03 19:34:07 by jwe]
author | jwe |
---|---|
date | Thu, 03 Jun 2004 19:34:07 +0000 |
parents | ab5870f984d9 |
children | b8a5e0bc63fe |
files | scripts/general/circshift.m scripts/general/shiftdim.m |
diffstat | 2 files changed, 11 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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)