annotate test/func.tst @ 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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) 2008-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
2 ##
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
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: 26376
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: 26376
diff changeset
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
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
7 ## 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
8 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24467
diff changeset
9 ## 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
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: 24467
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.
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
13 ##
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 ## 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
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.
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 ##
4fc7c16ee564 Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ## 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
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: 24467
diff changeset
21 ## <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
22
16215
6fe6ac8bbfdb test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents: 16213
diff changeset
23 ## 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
24 ## 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
25 ## 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
26 ## 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
27 ## 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
28
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
29 %!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
30 %! 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
31 %! "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
32 %! "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
33 %! "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
34 %!
7815
a41df65f3f00 Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents: 7618
diff changeset
35 %! 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
36 %! 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
37 %! 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
38 %! 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
39 %! 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
40 %!
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
41 %! 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
42 %! 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
43 %! 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
44 %! 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
45 %!
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
46 %! 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
47 %! 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
48 %! 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
49 %! endif
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
50 %! 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
51 %!
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 %! 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
53 %! 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
54 %! 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
55 %! 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
56 %! 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
57 %! 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
58 %! 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
59 %! 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
60 %! 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
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 %! 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
63 %! 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
64 %! 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
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 %! 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
67 %! 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
68 %! 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
69 %! 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
70 %! 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
71 %! 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
72 %! endif
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
73 %! 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
74 %! 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
75 %! 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
76 %! 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
77 %! 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
78 %!
7618
3209a584e1ac Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents: 7613
diff changeset
79 %! 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
80 %! 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
81 %! if (!strcmp (class (y), class (m)) ||
11033
d9c8916bb9dd Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents: 8920
diff changeset
82 %! 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
83 %! 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
84 %! endif
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
85 %! 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
86 %! 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
87 %! 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
88 %! 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
89 %! 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
90 %! endfor
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
91 %!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
92
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 %!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
94 %! 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
95 %! 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
96 %! 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
97 %! 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
98
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
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
100 %! __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
101 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
102 %! __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
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__ ("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
105 %!test
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
106 %! __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
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"});
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
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
110 %! __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
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__ ("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
113 %!test
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
114 %! __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
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__ ("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
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__ ("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
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", 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
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__ ("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
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__ ("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
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", 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
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__ ("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
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__ ("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
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", 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
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__ ("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
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__ ("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
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", 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
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__ ("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
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__ ("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
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__ ("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
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__ ("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
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"});
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", 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
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", 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
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"});
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", 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
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__ ("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
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__ ("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
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__ ("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
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__ ("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
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__ ("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
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__ ("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
169 %!test
25759
ecdced9fe445 flipdim.m: Make m-file a legacy function.
Rik <rik@octave.org>
parents: 25054
diff changeset
170 %! __fntestfunc__ ("flip", 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
171 %!test
25759
ecdced9fe445 flipdim.m: Make m-file a legacy function.
Rik <rik@octave.org>
parents: 25054
diff changeset
172 %! __fntestfunc__ ("flip", 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
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__ ("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
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__ ("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
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__ ("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
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__ ("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
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);
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", 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
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__ ("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
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__ ("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
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", 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
193 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
194 %! __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
195 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
196 %! __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
197
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24534
diff changeset
198 ## 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
199 %!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
200 %! persistent retval;
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24534
diff changeset
201 %!
24467
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
202 %! retval = 1;
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
203 %!endfunction
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
204
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
205 %!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
206 %! persistent in1;
24691
b658e0fa0cb3 maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents: 24534
diff changeset
207 %!
24467
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
208 %! retval = in1;
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
209 %!endfunction
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
210
2dc926274bce func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents: 23220
diff changeset
211 %!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
212 %!error <can't make function parameter in1 persistent> __fnpersist2__ (1);