annotate test/func.tst @ 25054:6652d3823428 stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Fri, 30 Mar 2018 09:19:05 -0400
parents b658e0fa0cb3
children ecdced9fe445
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24691
diff changeset
1 ## Copyright (C) 2008-2018 David Bateman
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
2 ##
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 ## This file is part of Octave.
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
4 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24467
diff changeset
5 ## Octave is free software: you can redistribute it and/or modify it
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 ## 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: 24467
diff changeset
7 ## 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
8 ## (at your option) any later version.
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## GNU General Public License for more details.
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 ##
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
16 ## 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: 24467
diff changeset
17 ## <https://www.gnu.org/licenses/>.
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
18
16215
6fe6ac8bbfdb test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents: 16213
diff changeset
19 ## This piece of test code ensures that all operations which work on
6fe6ac8bbfdb test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents: 16213
diff changeset
20 ## dimensions alone (squeeze, triu, etc.) work for all objects and
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
21 ## preserve type. Even if the object is an empty matrix. This code is
24467
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## not to check that the function itself returns the correct result,
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
23 ## just that the results are consistent for all types.
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
24
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
25 %!function __fntestfunc__ (fn, mn, varargin)
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
26 %! typ = {"double", "complex", "logical", "sparse", "complex sparse", ...
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
27 %! "logical sparse", "int8", "int16", "int32", "int64", "uint8", ...
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
28 %! "uint16", "uint32", "uint64", "char", "cell", "struct", ...
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
29 %! "single", "single complex"};
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
30 %!
7815
a41df65f3f00 Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents: 7618
diff changeset
31 %! cmplx = [2, 5, 18];
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
32 %! nlogical = [3, 6];
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
33 %! ninteger = [7, 8, 9, 10, 11, 12, 13, 14];
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
34 %! nsparse = [4, 5, 6];
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
35 %! skip = {};
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
36 %!
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
37 %! if (length (varargin) > 0 && iscell (varargin{1}))
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
38 %! skip = varargin{1};
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
39 %! varargin(1) = [];
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
40 %! endif
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
41 %!
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
42 %! for i = 1 : length (typ)
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
43 %! if (any (strcmp (skip, typ {i})))
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
44 %! continue;
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
45 %! endif
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
46 %! m = mn;
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
47 %!
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
48 %! if (any (nsparse == i))
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
49 %! if (ndims (m) > 2)
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
50 %! sz = size (m);
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
51 %! m = reshape (m, [sz(1), prod(sz(2:end))]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
52 %! endif
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
53 %! if (any (cmplx == i))
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
54 %! m = sparse ((1 + 1i) * m);
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
55 %! else
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
56 %! m = sparse (m);
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 %! endif
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
58 %! else
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
59 %! if (any (cmplx == i))
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
60 %! m = (1 + 1i) * m;
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
61 %! endif
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
62 %! endif
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
63 %! if (any (nlogical == i))
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
64 %! m = cast (m, "logical");
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
65 %! endif
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
66 %! if (any (ninteger == i))
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
67 %! m = cast (m, typ{i});
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
68 %! endif
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
69 %! if (strcmp (typ{i}, "cell"))
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
70 %! m = num2cell (m);
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
71 %! elseif (strcmp (typ{i}, "struct"))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
72 %! m = struct ("fld", num2cell (m));
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
73 %! endif
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
74 %!
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
75 %! y = feval (fn, m, varargin{:});
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
76 %! y2 = feval (fn, reshape (mn, size (m)), varargin{:});
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
77 %! if (!strcmp (class (y), class (m)) ||
11033
d9c8916bb9dd Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
78 %! issparse (y) != issparse (m) || !size_equal (y, y2))
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
79 %! error ("failed for type %s\n", typ{i});
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
80 %! endif
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
81 %! if (!(strcmp (typ{i}, "cell") || strcmp (typ{i}, "struct")) &&
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
82 %! any (vec (cast (real (y), "double")) !=
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
83 %! vec (feval (fn , cast (real (m), "double"), varargin{:}))))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
84 %! error ("failed for type %s\n", typ{i});
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
85 %! endif
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
86 %! endfor
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
87 %!endfunction
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
88
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
89 %!shared m0, m1, m2, m3
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
90 %! m0 = [1:5];
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
91 %! m1 = reshape ([1 : 30], [5, 6]);
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
92 %! m2 = reshape ([1 : 30], [5, 1, 6]);
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
93 %! m3 = [];
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
94
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
95 %!test
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
96 %! __fntestfunc__ ("triu", m1, {"struct"});
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
97 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
98 %! __fntestfunc__ ("triu", m1, {"struct"}, -1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
99 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
100 %! __fntestfunc__ ("triu", m1, {"struct"}, 1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
101 %!test
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
102 %! __fntestfunc__ ("triu", m3, {"struct"});
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
103 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
104 %! __fntestfunc__ ("tril", m1, {"struct"});
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
105 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
106 %! __fntestfunc__ ("tril", m1, {"struct"}, -1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
107 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
108 %! __fntestfunc__ ("tril", m1, {"struct"}, 1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
109 %!test
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
110 %! __fntestfunc__ ("tril", m3, {"struct"});
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
111 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
112 %! __fntestfunc__ ("squeeze", m2);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
113 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
114 %! __fntestfunc__ ("squeeze", m3);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
115 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
116 %! __fntestfunc__ ("permute", m1, [2, 1]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
117 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
118 %! __fntestfunc__ ("permute", m2, {"sparse", "logical sparse", "complex sparse"}, [3, 1, 2]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
119 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
120 %! __fntestfunc__ ("permute", m3, [2, 1]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
121 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
122 %! __fntestfunc__ ("ipermute", m1, [2, 1]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
123 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
124 %! __fntestfunc__ ("ipermute", m2, {"sparse", "logical sparse", "complex sparse"}, [3, 1, 2]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
125 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
126 %! __fntestfunc__ ("ipermute", m3, [2, 1]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
127 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
128 %! __fntestfunc__ ("shiftdim", m2, 1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
129 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
130 %! __fntestfunc__ ("shiftdim", m2, {"sparse", "logical sparse", "complex sparse"}, -1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
131 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
132 %! __fntestfunc__ ("shiftdim", m3, 1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
133 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
134 %! __fntestfunc__ ("circshift", m2, 1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
135 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
136 %! __fntestfunc__ ("circshift", m2, [1, -1]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
137 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
138 %! __fntestfunc__ ("circshift", m3, 1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
139 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
140 %! __fntestfunc__ ("reshape", m2, [6, 5]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
141 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
142 %! __fntestfunc__ ("reshape", m3, [1, 0]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
143 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
144 %! __fntestfunc__ ("diag", m0, {"struct"});
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
145 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
146 %! __fntestfunc__ ("diag", m0, {"struct"}, 1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
147 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
148 %! __fntestfunc__ ("diag", m0, {"struct"}, -1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
149 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
150 %! __fntestfunc__ ("diag", m1, {"struct"});
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
151 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
152 %! __fntestfunc__ ("diag", m1, {"struct"}, 1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
153 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
154 %! __fntestfunc__ ("diag", m1, {"struct"}, -1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
155 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
156 %! __fntestfunc__ ("diag", m3, {"struct"});
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
157 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
158 %! __fntestfunc__ ("fliplr", m1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
159 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
160 %! __fntestfunc__ ("fliplr", m3);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
161 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
162 %! __fntestfunc__ ("flipud", m1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
163 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
164 %! __fntestfunc__ ("flipud", m3);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
165 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
166 %! __fntestfunc__ ("flipdim", m1, 2);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
167 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
168 %! __fntestfunc__ ("flipdim", m3, 2);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
169 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
170 %! __fntestfunc__ ("transpose", m1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
171 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
172 %! __fntestfunc__ ("transpose", m3);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
173 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
174 %! __fntestfunc__ ("ctranspose", m1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
175 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
176 %! __fntestfunc__ ("ctranspose", m3);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
177 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
178 %! __fntestfunc__ ("rot90", m1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
179 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
180 %! __fntestfunc__ ("rot90", m1, 2);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
181 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
182 %! __fntestfunc__ ("rot90", m1, -1);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
183 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
184 %! __fntestfunc__ ("rot90", m3);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
185 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
186 %! __fntestfunc__ ("rotdim", m2, 1, [1, 2]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
187 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
188 %! __fntestfunc__ ("rotdim", m2, 2, [1, 2]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
189 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
190 %! __fntestfunc__ ("rotdim", m2, -1, [1, 2]);
7613
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
191 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
192 %! __fntestfunc__ ("rotdim", m3, 1, [1, 2]);
24467
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
193
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24534
diff changeset
194 ## Check for error if function parameter is made persistent
24467
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
195 %!function retval = __fnpersist1__ (in1)
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
196 %! persistent retval;
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24534
diff changeset
197 %!
24467
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
198 %! retval = 1;
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
199 %!endfunction
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
200
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
201 %!function retval = __fnpersist2__ (in1)
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
202 %! persistent in1;
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24534
diff changeset
203 %!
24467
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
204 %! retval = in1;
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
205 %!endfunction
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
206
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
207 %!error <can't make function parameter retval persistent> __fnpersist1__ (1);
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
208 %!error <can't make function parameter in1 persistent> __fnpersist2__ (1);