Mercurial > octave-nkf
comparison scripts/general/circshift.m @ 10549:95c3e38098bf
Untabify .m scripts
author | Rik <code@nomad.inbox5.com> |
---|---|
date | Fri, 23 Apr 2010 11:28:50 -0700 |
parents | 16f53d29049f |
children | 693e22af08ae |
comparison
equal
deleted
inserted
replaced
10548:479536c5bb10 | 10549:95c3e38098bf |
---|---|
53 else | 53 else |
54 nd = ndims (x); | 54 nd = ndims (x); |
55 sz = size (x); | 55 sz = size (x); |
56 | 56 |
57 if (! isvector (n) && length (n) > nd) | 57 if (! isvector (n) && length (n) > nd) |
58 error ("circshift: n must be a vector, no longer than the number of dimension in x"); | 58 error ("circshift: n must be a vector, no longer than the number of dimension in x"); |
59 endif | 59 endif |
60 | 60 |
61 if (any (n != floor (n))) | 61 if (any (n != floor (n))) |
62 error ("circshift: all values of n must be integers"); | 62 error ("circshift: all values of n must be integers"); |
63 endif | 63 endif |
64 | 64 |
65 idx = cell (); | 65 idx = cell (); |
66 for i = 1:length (n); | 66 for i = 1:length (n); |
67 nn = n(i); | 67 nn = n(i); |
68 if (nn < 0) | 68 if (nn < 0) |
69 while (sz(i) <= -nn) | 69 while (sz(i) <= -nn) |
70 nn = nn + sz(i); | 70 nn = nn + sz(i); |
71 endwhile | 71 endwhile |
72 idx{i} = [(1-nn):sz(i), 1:-nn]; | 72 idx{i} = [(1-nn):sz(i), 1:-nn]; |
73 else | 73 else |
74 while (sz(i) <= nn) | 74 while (sz(i) <= nn) |
75 nn = nn - sz(i); | 75 nn = nn - sz(i); |
76 endwhile | 76 endwhile |
77 idx{i} = [(sz(i)-nn+1):sz(i), 1:(sz(i)-nn)]; | 77 idx{i} = [(sz(i)-nn+1):sz(i), 1:(sz(i)-nn)]; |
78 endif | 78 endif |
79 endfor | 79 endfor |
80 for i = (length(n) + 1) : nd | 80 for i = (length(n) + 1) : nd |
81 idx{i} = 1:sz(i); | 81 idx{i} = 1:sz(i); |
82 endfor | 82 endfor |
83 y = x(idx{:}); | 83 y = x(idx{:}); |
84 endif | 84 endif |
85 else | 85 else |
86 print_usage (); | 86 print_usage (); |