annotate scripts/general/rot90.m @ 29359:7854d5752dd2

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 10:10:40 -0500
parents d8318c12d903 0a5b15007766
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 ## Copyright (C) 1993-2021 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27898
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
7 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
8 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
11 ## 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
12 ## 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
13 ## (at your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
19 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
20 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
21 ## 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
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 4
diff changeset
25
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20158
diff changeset
27 ## @deftypefn {} {} rot90 (@var{A})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20158
diff changeset
28 ## @deftypefnx {} {} rot90 (@var{A}, @var{k})
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
29 ## Rotate array by 90 degree increments.
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
30 ##
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
31 ## Return a copy of @var{A} with the elements rotated counterclockwise in
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
32 ## 90-degree increments.
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
33 ##
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
34 ## The second argument is optional, and specifies how many 90-degree rotations
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
35 ## are to be applied (the default value is 1). Negative values of @var{k}
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
36 ## rotate the matrix in a clockwise direction.
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
37 ## For example,
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
38 ##
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
39 ## @example
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
40 ## @group
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
41 ## rot90 ([1, 2; 3, 4], -1)
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
42 ## @result{} 3 1
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
43 ## 4 2
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
44 ## @end group
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
45 ## @end example
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
46 ##
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
47 ## @noindent
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
48 ## rotates the given matrix clockwise by 90 degrees. The following are all
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
49 ## equivalent statements:
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3408
diff changeset
50 ##
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
51 ## @example
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
52 ## @group
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
53 ## rot90 ([1, 2; 3, 4], -1)
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
54 ## rot90 ([1, 2; 3, 4], 3)
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
55 ## rot90 ([1, 2; 3, 4], 7)
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
56 ## @end group
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
57 ## @end example
4869
b92d59213e63 [project @ 2004-04-21 17:03:02 by jwe]
jwe
parents: 3456
diff changeset
58 ##
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
59 ## The rotation is always performed on the plane of the first two dimensions,
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
60 ## i.e., rows and columns. To perform a rotation on any other plane, use
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
61 ## @code{rotdim}.
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
62 ##
19166
767103303974 doc: Re-order seealso references in rot90, rotdim.
Rik <rik@octave.org>
parents: 19147
diff changeset
63 ## @seealso{rotdim, fliplr, flipud, flip}
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 3238
diff changeset
64 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
65
12862
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
66 function B = rot90 (A, k = 1)
4869
b92d59213e63 [project @ 2004-04-21 17:03:02 by jwe]
jwe
parents: 3456
diff changeset
67
28789
28de41192f3c Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents: 27923
diff changeset
68 if (nargin < 1)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
69 print_usage ();
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
70 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
71
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
72 if (! (isscalar (k) && isreal (k) && k == fix (k)))
12862
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
73 error ("rot90: K must be a single real integer");
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
74 endif
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
75
13287
5c22edebf2e8 rot90.m: Simplify function by using mod() rather than rem()
Rik <octave@nomad.inbox5.com>
parents: 12862
diff changeset
76 k = mod (k, 4);
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
77 nd = ndims (A);
12862
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
78
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
79 if (k == 0)
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
80 B = A;
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
81 elseif (k == 1)
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
82 B = flipud (permute (A, [2 1 3:1:nd]));
12862
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
83 elseif (k == 2)
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
84 idx(1:nd) = {':'};
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
85 idx{1} = rows (A):-1:1;
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
86 idx{2} = columns (A):-1:1;
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
87 B = A(idx{:});
12862
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
88 elseif (k == 3)
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
89 B = permute (flipud (A), [2 1 3:1:nd]);
12862
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
90 else
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
91 error ("rot90: internal error!");
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
92 endif
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
93
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
94 endfunction
7411
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
95
12862
a9d292ce5489 rot90.m: Put input validation first. Update tests to include input validation.
Rik <octave@nomad.inbox5.com>
parents: 12639
diff changeset
96
7411
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
97 %!test
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
98 %! x1 = [1, 2; 3, 4];
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
99 %! x2 = [2, 4; 1, 3];
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
100 %! x3 = [4, 3; 2, 1];
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
101 %! x4 = [3, 1; 4, 2];
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
102 %!
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
103 %! assert (rot90 (x1), x2);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
104 %! assert (rot90 (x1, 2), x3);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
105 %! assert (rot90 (x1, 3), x4);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
106 %! assert (rot90 (x1, 4), x1);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
107 %! assert (rot90 (x1, 5), x2);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
108 %! assert (rot90 (x1, -1), x4);
7411
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
109
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
110 ## Test NDArrays
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
111 %!test
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
112 %! a(1:2,1:2,1) = [1 2; 3 4];
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
113 %! a(1:2,1:2,2) = [5 6; 7 8];
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
114 %! b(1:2,1:2,1) = [2 4; 1 3];
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
115 %! b(1:2,1:2,2) = [6 8; 5 7];
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
116 %! assert (rot90 (a, 1), b);
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
117 %! assert (rot90 (a, 2), rot90 (b, 1));
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
118 %! assert (rot90 (a, 3), rot90 (b, 2));
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
119
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
120 %!test
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
121 %! a = b = zeros (2, 2, 1, 2);
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
122 %! a(1:2,1:2,:,1) = [1 2; 3 4];
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
123 %! a(1:2,1:2,:,2) = [5 6; 7 8];
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
124 %! b(1:2,1:2,:,1) = [2 4; 1 3];
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
125 %! b(1:2,1:2,:,2) = [6 8; 5 7];
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
126 %! assert (rot90 (a, 1), b);
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
127 %! assert (rot90 (a, 2), rot90 (b, 1));
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
128 %! assert (rot90 (a, 3), rot90 (b, 2));
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
129
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
130 ## With non-square matrices
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
131 %!test
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
132 %! a = zeros (3, 2, 1, 2);
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
133 %! b = zeros (2, 3, 1, 2);
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
134 %! a(1:2,1:3,:,1) = [ 1 2 3; 4 5 6];
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
135 %! a(1:2,1:3,:,2) = [ 7 8 9; 10 11 12];
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
136 %! b(1:3,1:2,:,1) = [ 3 6; 2 5; 1 4];
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
137 %! b(1:3,1:2,:,2) = [ 9 12; 8 11; 7 10];
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
138 %! assert (rot90 (a, 1), b);
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
139 %! assert (rot90 (a, 2), rot90 (b, 1));
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
140 %! assert (rot90 (a, 3), rot90 (b, 2));
19147
8b2a919d24bc rot90.m: add support for N-dimensional arrays.
Carnë Draug <carandraug@octave.org>
parents: 19126
diff changeset
141
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
142 ## Test input validation
28886
d8318c12d903 test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents: 28789
diff changeset
143 %!error <Invalid call> rot90 ()
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
144 %!error rot90 (1, ones (2))
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
145 %!error rot90 (1, 1.5)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
146 %!error rot90 (1, 1+i)