annotate scripts/general/rotdim.m @ 19833:9fc020886ae9

maint: Clean up m-files to follow Octave coding conventions. Try to trim long lines to < 80 chars. Use '##' for single line comments. Use '(...)' around tests for if/elseif/switch/while. Abut cell indexing operator '{' next to variable. Abut array indexing operator '(' next to variable. Use space between negation operator '!' and following expression. Use two newlines between endfunction and start of %!test or %!demo code. Remove unnecessary parens grouping between short-circuit operators. Remove stray extra spaces (typos) between variables and assignment operators. Remove stray extra spaces from ends of lines.
author Rik <rik@octave.org>
date Mon, 23 Feb 2015 14:54:39 -0800
parents 4197fc428c7d
children 7503499a252b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19166
diff changeset
1 ## Copyright (C) 2004-2015 David Bateman
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
2 ##
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
4 ##
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## your option) any later version.
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
9 ##
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
14 ##
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
15 ## 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
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
18
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
20 ## @deftypefn {Function File} {} rotdim (@var{x})
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
21 ## @deftypefnx {Function File} {} rotdim (@var{x}, @var{n})
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
22 ## @deftypefnx {Function File} {} rotdim (@var{x}, @var{n}, @var{plane})
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
23 ## Return a copy of @var{x} with the elements rotated counterclockwise in
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
24 ## 90-degree increments.
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
25 ## The second argument @var{n} is optional, and specifies how many 90-degree
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
26 ## rotations are to be applied (the default value is 1).
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
27 ## The third argument is also optional and defines the plane of the
12639
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
28 ## rotation. If present, @var{plane} is a two element vector containing two
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
29 ## different valid dimensions of the matrix. When @var{plane} is not given
4d777e05d47c doc: Review and update documentation for "Matrix Manipulation" chapter.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
30 ## the first two non-singleton dimensions are used.
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
31 ##
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
32 ## Negative values of @var{n} rotate the matrix in a clockwise direction.
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
33 ## For example,
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
34 ##
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
35 ## @example
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
36 ## @group
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
37 ## rotdim ([1, 2; 3, 4], -1, [1, 2])
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
38 ## @result{} 3 1
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
39 ## 4 2
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
40 ## @end group
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
41 ## @end example
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
42 ##
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
43 ## @noindent
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
44 ## rotates the given matrix clockwise by 90 degrees. The following are all
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
45 ## equivalent statements:
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
46 ##
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
47 ## @example
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
48 ## @group
5487
fcf8a15a2081 [project @ 2005-10-12 21:23:47 by jwe]
jwe
parents: 5307
diff changeset
49 ## rotdim ([1, 2; 3, 4], -1, [1, 2])
fcf8a15a2081 [project @ 2005-10-12 21:23:47 by jwe]
jwe
parents: 5307
diff changeset
50 ## rotdim ([1, 2; 3, 4], 3, [1, 2])
fcf8a15a2081 [project @ 2005-10-12 21:23:47 by jwe]
jwe
parents: 5307
diff changeset
51 ## rotdim ([1, 2; 3, 4], 7, [1, 2])
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
52 ## @end group
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
53 ## @end example
19166
767103303974 doc: Re-order seealso references in rot90, rotdim.
Rik <rik@octave.org>
parents: 19126
diff changeset
54 ## @seealso{rot90, fliplr, flipud, flip}
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
55 ## @end deftypefn
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
56
10689
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
57 function y = rotdim (x, n, plane)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
58
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
59 if (nargin < 1 || nargin > 3)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
60 print_usage ();
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
61 endif
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
62
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
63 if (nargin > 1 && ! isempty (n))
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
64 if (! isscalar (n) || ! isreal (n) || fix (n) != n)
10689
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
65 error ("rotdim: N must be a scalar integer");
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
66 endif
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
67 else
10689
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
68 n = 1;
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
69 endif
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
70
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
71 nd = ndims (x);
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
72 sz = size (x);
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
73 if (nargin < 3)
12795
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
74 if (nd > 2)
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
75 ## Find the first two non-singleton dimension.
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
76 plane = [];
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
77 dim = 0;
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
78 while (dim < nd)
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
79 dim = dim + 1;
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
80 if (sz (dim) != 1)
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
81 plane = [plane, dim];
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
82 if (length (plane) == 2)
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
83 break;
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
84 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
85 endif
12795
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
86 endwhile
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
87 if (length (plane) < 1)
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
88 plane = [1, 2];
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
89 elseif (length (plane) < 2)
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
90 plane = [1, plane];
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
91 endif
12795
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
92 else
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
93 plane = [1, 2];
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
94 endif
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
95 else
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
96 if (! (isvector (plane) && length (plane) == 2
13279
984359717d71 Use common code idiom for checking whether a double value is an integer.
Rik <octave@nomad.inbox5.com>
parents: 12795
diff changeset
97 && all (plane == fix (plane)) && all (plane > 0)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
98 && all (plane < (nd + 1)) && plane(1) != plane(2)))
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 10689
diff changeset
99 error ("rotdim: PLANE must be a 2 element integer vector defining a valid PLANE");
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
100 endif
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
101 endif
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
102
10689
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
103 n = rem (n, 4);
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
104 if (n < 0)
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
105 n = n + 4;
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
106 endif
10689
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
107 if (n == 0)
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
108 y = x;
10689
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
109 elseif (n == 2)
19126
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 18857
diff changeset
110 y = flip (flip (x, plane(1)), plane(2));
10689
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
111 elseif (n == 1 || n == 3)
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
112 perm = 1:nd;
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
113 perm(plane(1)) = plane(2);
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
114 perm(plane(2)) = plane(1);
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
115 y = permute (x, perm);
10689
6622772a0add rotdim.m: Modify function to use same variable names as documentation
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
116 if (n == 1)
19126
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 18857
diff changeset
117 y = flip (y, min (plane));
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
118 else
19126
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 18857
diff changeset
119 y = flip (y, max (plane));
5012
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
120 endif
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
121 else
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
122 error ("rotdim: internal error!");
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
123 endif
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
124
ed25bed43409 [project @ 2004-09-21 15:45:48 by jwe]
jwe
parents:
diff changeset
125 endfunction
12795
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
126
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
127
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
128 %!shared r, rr
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
129 %! r = [1,2,3]; rr = [3,2,1];
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
130 %!assert (rotdim (r, 0), r)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
131 %!assert (rotdim (r, 1), rr')
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
132 %!assert (rotdim (r, 2), rr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
133 %!assert (rotdim (r, 3), r')
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
134 %!assert (rotdim (r, 3), rotdim (r, -1))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
135 %!assert (rotdim (r, 1), rotdim (r))
12795
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
136
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
137 %!shared c, cr
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
138 %! c = [1;2;3]; cr = [3;2;1];
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
139 %!assert (rotdim (c, 0), c)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
140 %!assert (rotdim (c, 1), c')
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
141 %!assert (rotdim (c, 2), cr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
142 %!assert (rotdim (c, 3), cr')
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
143 %!assert (rotdim (c, 3), rotdim (c, -1))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
144 %!assert (rotdim (c, 1), rotdim (c))
12795
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
145
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
146 %!shared m
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
147 %! m = [1,2;3,4];
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
148 %!assert (rotdim (m, 0), m)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
149 %!assert (rotdim (m, 1), [2,4;1,3])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
150 %!assert (rotdim (m, 2), [4,3;2,1])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
151 %!assert (rotdim (m, 3), [3,1;4,2])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
152 %!assert (rotdim (m, 3), rotdim (m, -1))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
153 %!assert (rotdim (m, 1), rotdim (m))
12795
9e7ebbaf69ff codesprint: new tests for files in scripts/general directory
John W. Eaton <jwe@octave.org>
parents: 12639
diff changeset
154
18857
7bbe3658c5ef maint: Use "FIXME:" coding convention in m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
155 ## FIXME: We need tests for multidimensional arrays
7bbe3658c5ef maint: Use "FIXME:" coding convention in m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
156 ## and different values of PLANE.
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
157
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
158 %!error rotdim ()
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
159 %!error rotdim (1, 2, 3, 4)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
160