Mercurial > octave
annotate scripts/general/circshift.m @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
1 ## Copyright (C) 2004-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26600
diff
changeset
|
2 ## |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26600
diff
changeset
|
3 ## See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26600
diff
changeset
|
4 ## or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26600
diff
changeset
|
5 ## |
4894 | 6 ## |
7 ## This file is part of Octave. | |
8 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
9 ## Octave is free software: you can redistribute it and/or modify it |
4894 | 10 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
11 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
12 ## (at your option) any later version. |
4894 | 13 ## |
14 ## Octave is distributed in the hope that it will be useful, but | |
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## GNU General Public License for more details. |
4894 | 18 ## |
19 ## You should have received a copy of the GNU General Public License | |
7016 | 20 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
21 ## <https://www.gnu.org/licenses/>. |
4894 | 22 |
23 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20749
diff
changeset
|
24 ## @deftypefn {} {@var{y} =} circshift (@var{x}, @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20749
diff
changeset
|
25 ## @deftypefnx {} {@var{y} =} circshift (@var{x}, @var{n}, @var{dim}) |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
26 ## Circularly shift the values of the array @var{x}. |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
27 ## |
20749
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
28 ## @var{n} must be a vector of integers no longer than the number of dimensions |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
29 ## in @var{x}. The values of @var{n} can be either positive or negative, which |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
30 ## determines the direction in which the values of @var{x} are shifted. If an |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
31 ## element of @var{n} is zero, then the corresponding dimension of @var{x} will |
26155
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
32 ## not be shifted. If @var{n} is a scalar and no @var{dim} is specified then |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
33 ## the shift is applied to the first non-singular dimension. |
20749
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
34 ## |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
35 ## If a scalar @var{dim} is given then operate along the specified dimension. |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
36 ## In this case @var{n} must be a scalar as well. |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
37 ## |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
38 ## Examples: |
4894 | 39 ## |
40 ## @example | |
26155
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
41 ## x = [1, 2, 3; |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
42 ## 4, 5, 6; |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
43 ## 7, 8, 9]; |
26577
ae1542fb58ba
documentation: Avoid some overfull lines in the PDF manual.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
44 ## ## positive shift on rows (1st non-singular dim) |
ae1542fb58ba
documentation: Avoid some overfull lines in the PDF manual.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
45 ## circshift (x, 1) |
26600
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
46 ## @result{} |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
47 ## 7 8 9 |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
48 ## 1 2 3 |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
49 ## 4 5 6 |
26577
ae1542fb58ba
documentation: Avoid some overfull lines in the PDF manual.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
50 ## ## negative shift on rows (1st non-singular dim) |
ae1542fb58ba
documentation: Avoid some overfull lines in the PDF manual.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
51 ## circshift (x, -2) |
26600
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
52 ## @result{} |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
53 ## 7 8 9 |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
54 ## 1 2 3 |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
55 ## 4 5 6 |
26577
ae1542fb58ba
documentation: Avoid some overfull lines in the PDF manual.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
56 ## ## no shift of rows, shift columns by 1 (2nd dimension) |
ae1542fb58ba
documentation: Avoid some overfull lines in the PDF manual.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
57 ## circshift (x, [0,1]) |
26600
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
58 ## @result{} |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
59 ## 3 1 2 |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
60 ## 6 4 5 |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
61 ## 9 7 8 |
26577
ae1542fb58ba
documentation: Avoid some overfull lines in the PDF manual.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
62 ## ## shift columns (2nd dimension) |
ae1542fb58ba
documentation: Avoid some overfull lines in the PDF manual.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
63 ## circshift (x, 1, 2) |
26600
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
64 ## @result{} |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
65 ## 3 1 2 |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
66 ## 6 4 5 |
f6730533820e
doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents:
26577
diff
changeset
|
67 ## 9 7 8 |
4894 | 68 ## @end example |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
69 ## @seealso{permute, ipermute, shiftdim} |
4894 | 70 ## @end deftypefn |
71 | |
20749
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
72 function y = circshift (x, n, dim) |
4894 | 73 |
20749
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
74 if (nargin < 2 || nargin > 3) |
6046 | 75 print_usage (); |
4894 | 76 endif |
13277
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
77 |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
78 if (isempty (x)) |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
79 y = x; |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
80 return; |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
81 endif |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
82 |
26155
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
83 nd = ndims (x); |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
84 sz = size (x); |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
85 |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
86 if (nargin == 2) |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
87 if (isscalar (n)) |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
88 ## Find the first non-singleton dimension. |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
89 (dim = find (sz > 1, 1)) || (dim = 1); |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
90 n = [zeros(1, dim-1), n]; |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
91 endif |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
92 elseif (nargin == 3) |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
93 if ( ! isscalar (n)) |
20749
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
94 error ("circshift: N must be a scalar when DIM is also specified"); |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
95 endif |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
96 n = [zeros(1, dim-1), n]; |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
97 endif |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
98 |
13277
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
99 if (! isvector (n) || length (n) > nd) |
20749
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
100 error ("circshift: N must be a vector, no longer than the number of dimensions in X"); |
13277
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
101 elseif (any (n != fix (n))) |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
102 error ("circshift: all values of N must be integers"); |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
103 endif |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
104 |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
105 idx = repmat ({':'}, 1, nd); |
26268
6dd232798997
maint: Remove useless ';' from end of for, if, while, etc. statements.
Rik <rik@octave.org>
parents:
26155
diff
changeset
|
106 for i = 1:length (n) |
13277
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
107 b = n(i); |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
108 d = sz(i); |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
109 if (b > 0) |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
110 b = rem (b, d); |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
111 idx{i} = [d-b+1:d, 1:d-b]; |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
112 elseif (b < 0) |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
113 b = rem (abs (b), d); |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
114 idx{i} = [b+1:d, 1:b]; |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
115 endif |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
116 endfor |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
117 |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
118 y = x(idx{:}); |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
119 |
4894 | 120 endfunction |
7614
52f90c7adac6
Avoid infinite loop in circshift for infinite matrices
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
121 |
13277
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
122 |
7614
52f90c7adac6
Avoid infinite loop in circshift for infinite matrices
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
123 %!shared x |
52f90c7adac6
Avoid infinite loop in circshift for infinite matrices
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
124 %! x = [1, 2, 3; 4, 5, 6; 7, 8, 9]; |
52f90c7adac6
Avoid infinite loop in circshift for infinite matrices
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
125 |
52f90c7adac6
Avoid infinite loop in circshift for infinite matrices
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
126 %!assert (circshift (x, 1), [7, 8, 9; 1, 2, 3; 4, 5, 6]) |
52f90c7adac6
Avoid infinite loop in circshift for infinite matrices
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
127 %!assert (circshift (x, -2), [7, 8, 9; 1, 2, 3; 4, 5, 6]) |
13277
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
128 %!assert (circshift (x, [0, 1]), [3, 1, 2; 6, 4, 5; 9, 7, 8]) |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
129 %!assert (circshift ([], 1), []) |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
130 |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
131 %!assert (circshift (eye (3), 1), circshift (eye (3), 1)) |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
132 %!assert (circshift (eye (3), 1), [0,0,1;1,0,0;0,1,0]) |
12351
ca1190196d26
PermMatrix.cc (operator*): fix mixed row/column case
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
133 |
20749
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
134 %!assert (circshift (x, -2, 1), [7, 8, 9; 1, 2, 3; 4, 5, 6]) |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
135 %!assert (circshift (x, 1, 2), [3, 1, 2; 6, 4, 5; 9, 7, 8]) |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
136 |
26155
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
137 %!test <*53178> assert (circshift (1:4, 1), [4 1 2 3]) |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
138 %!test <*53178> assert (circshift (1:4, 1, 1), 1:4) |
8be616a0b9aa
circshift.m: shift first non-singleton dimension if DIM not provided (bug #53178).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
139 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
140 ## Test input validation |
13277
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
141 %!error circshift () |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
142 %!error circshift (1) |
9f2e568123ea
circshift.m: Recode to do away with some for loops.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
143 %!error circshift (1,2,3) |
20749
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
144 %!error <N must be a scalar> circshift (1, [2 3], 4) |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
145 %!error <N must be a vector> circshift (1, ones (2,2)) |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
146 %!error <no longer than the number of dimensions in X> circshift (1, [1 2 3]) |
74cc8ae4e2b0
circshift.m: Overhaul function to support a third argument DIM (bug #46514).
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
147 %!error <all values of N must be integers> circshift (1, 1.5) |