7017
|
1 ## Copyright (C) 2006, 2007 John W. Eaton |
7016
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
|
18 |
5590
|
19 %% Automatically generated from DejaGNU files |
|
20 |
|
21 %% test/octave.test/matrix/all-1.m |
|
22 %!test |
|
23 %! x = ones (3); |
|
24 %! x(1,1) = 0; |
|
25 %! assert((all (all (rand (3) + 1) == [1, 1, 1]) == 1 |
|
26 %! && all (all (x) == [0, 1, 1]) == 1 |
|
27 %! && all (x, 1) == [0, 1, 1] |
|
28 %! && all (x, 2) == [0; 1; 1])); |
|
29 |
|
30 %% test/octave.test/matrix/all-2.m |
5751
|
31 %!error <Invalid call to all.*> all (); |
5590
|
32 |
|
33 %% test/octave.test/matrix/all-3.m |
5751
|
34 %!error <Invalid call to all.*> all (1, 2, 3); |
5590
|
35 |
|
36 %% test/octave.test/matrix/any-1.m |
|
37 %!test |
|
38 %! x = zeros (3); |
|
39 %! x(3,3) = 1; |
|
40 %! assert((all (any (x) == [0, 0, 1]) == 1 |
|
41 %! && all (any (ones (3)) == [1, 1, 1]) == 1 |
|
42 %! && any (x, 1) == [0, 0, 1] |
|
43 %! && any (x, 2) == [0; 0; 1])); |
|
44 |
|
45 %% test/octave.test/matrix/any-2.m |
5751
|
46 %!error <Invalid call to any.*> any (); |
5590
|
47 |
|
48 %% test/octave.test/matrix/any-3.m |
5751
|
49 %!error <Invalid call to any.*> any (1, 2, 3); |
5590
|
50 |
|
51 %% test/octave.test/matrix/find-1.m |
|
52 %!assert((find ([1, 0, 1, 0, 1]) == [1, 3, 5] |
|
53 %! && find ([1; 0; 3; 0; 1]) == [1; 3; 5] |
|
54 %! && find ([0, 0, 2; 0, 3, 0; -1, 0, 0]) == [3; 5; 7])); |
|
55 |
|
56 %% test/octave.test/matrix/find-2.m |
|
57 %!test |
|
58 %! [i, j, v] = find ([0, 0, 2; 0, 3, 0; -1, 0, 0]); |
|
59 %! |
|
60 %! assert(i == [3; 2; 1] && j == [1; 2; 3] && v == [-1; 3; 2]); |
|
61 |
|
62 %% test/octave.test/matrix/find-3.m |
5751
|
63 %!error <Invalid call to find.*> find (); |
5590
|
64 |
|
65 %% test/octave.test/matrix/reshape-1.m |
|
66 %!assert((size (reshape (rand (4, 4), 2, 8)) == [2, 8] |
|
67 %! && size (reshape (rand (4, 4), 8, 2)) == [8, 2] |
|
68 %! && size (reshape (rand (15, 4), 1, 60)) == [1, 60] |
|
69 %! && size (reshape (rand (15, 4), 60, 1)) == [60, 1])); |
|
70 |
|
71 %% test/octave.test/matrix/reshape-2.m |
|
72 %!test |
|
73 %! s.a = 1; |
|
74 %! fail("reshape (s, 2, 3)"); |
|
75 |
|
76 %% test/octave.test/matrix/reshape-3.m |
5751
|
77 %!error <Invalid call to reshape.*> reshape (); |
5590
|
78 |
|
79 %% test/octave.test/matrix/reshape-4.m |
|
80 %!error reshape (1, 2, 3, 4); |
|
81 |
|
82 %% test/octave.test/matrix/sort-1.m |
|
83 %!test |
|
84 %! a = [1, 2; 2, 3; 3, 1]; |
|
85 %! s = [1, 1; 2, 2; 3, 3]; |
|
86 %! i = [1, 3; 2, 1; 3, 2]; |
|
87 %! [xs, xi] = sort (a); |
|
88 %! assert(sort (a) == s && xs == s && xi == i); |
|
89 |
|
90 %% test/octave.test/matrix/sort-2.m |
5751
|
91 %!error <Invalid call to sort.*> sort (); |
5590
|
92 |
|
93 %% test/octave.test/matrix/sort-3.m |
5751
|
94 %!error <Invalid call to sort.*> sort (1, 2, 3, 4); |
5590
|
95 |
|
96 |
|
97 |
|
98 %% test/octave.test/matrix/eye-1.m |
|
99 %!test |
|
100 %! i33 = [1, 0, 0; 0, 1, 0; 0, 0, 1]; |
|
101 %! i23 = [1, 0, 0; 0, 1, 0]; |
|
102 %! assert((eye (3) == i33 && eye (size (i33)) == i33 && eye (3, 3) == i33 |
|
103 %! && eye (2, 3) == i23 && eye (3, 2) == i23')); |
|
104 |
|
105 %% test/octave.test/matrix/eye-2.m |
5751
|
106 %!error <Invalid call to eye.*> eye (1, 2, 3); |
5590
|
107 |
|
108 %% test/octave.test/matrix/ones-1.m |
|
109 %!test |
|
110 %! x33 = [1, 1, 1; 1, 1, 1; 1, 1, 1]; |
|
111 %! x23 = [1, 1, 1; 1, 1, 1]; |
|
112 %! assert((ones (3) == x33 && ones (size (x33)) == x33 && ones (3, 3) == x33 |
|
113 %! && ones (2, 3) == x23 && ones (3, 2) == x23')); |
|
114 |
|
115 %% test/octave.test/matrix/ones-2.m |
|
116 %!assert(all (size (ones (3, 4, 5)) == [3, 4, 5])); |
|
117 |
|
118 %% test/octave.test/matrix/zeros-1.m |
|
119 %!test |
|
120 %! x33 = [0, 0, 0; 0, 0, 0; 0, 0, 0]; |
|
121 %! x23 = [0, 0, 0; 0, 0, 0]; |
|
122 %! assert((zeros (3) == x33 && zeros (size (x33)) == x33 && zeros (3, 3) == x33 |
|
123 %! && zeros (2, 3) == x23 && zeros (3, 2) == x23')); |
|
124 |
|
125 %% test/octave.test/matrix/zeros-2.m |
|
126 %!assert(all (size (zeros (3, 4, 5)) == [3, 4, 5])); |
|
127 |
|
128 %% test/octave.test/matrix/rand-1.m |
|
129 %!test |
|
130 %! rand ("seed", 0.5); |
|
131 %! r1 = rand (100); |
|
132 %! rand ("seed", 0.5); |
|
133 %! r2 = rand (100); |
|
134 %! assert(rand (100) < 1 && rand (100) > 0 && r1 == r2); |
|
135 |
|
136 %% test/octave.test/matrix/rand-2.m |
|
137 %!assert(all (size (rand (1, 2, 3)) == [1, 2, 3])); |
|
138 |
|
139 %% test/octave.test/matrix/randn-1.m |
|
140 %!test |
|
141 %! randn ("seed", 0.5); |
|
142 %! r1 = randn (100); |
|
143 %! randn ("seed", 0.5); |
|
144 %! r2 = randn (100); |
|
145 %! assert(all (all (r1 == r2))); |
|
146 |
|
147 %% test/octave.test/matrix/randn-2.m |
|
148 %!assert(all (size (randn (1, 2, 3)) == [1, 2, 3])); |
|
149 |
|
150 %% test/octave.test/matrix/diag-1.m |
|
151 %!test |
|
152 %! d = [1; 2; 3]; |
|
153 %! |
|
154 %! d0 = [1, 0, 0; |
|
155 %! 0, 2, 0; |
|
156 %! 0, 0, 3]; |
|
157 %! |
|
158 %! d1 = [0, 1, 0, 0; |
|
159 %! 0, 0, 2, 0; |
|
160 %! 0, 0, 0, 3; |
|
161 %! 0, 0, 0, 0]; |
|
162 %! |
|
163 %! d2 = [0, 0, 1, 0, 0; |
|
164 %! 0, 0, 0, 2, 0; |
|
165 %! 0, 0, 0, 0, 3; |
|
166 %! 0, 0, 0, 0, 0; |
|
167 %! 0, 0, 0, 0, 0]; |
|
168 %! |
|
169 %! dm1 = [0, 0, 0, 0; |
|
170 %! 1, 0, 0, 0; |
|
171 %! 0, 2, 0, 0; |
|
172 %! 0, 0, 3, 0]; |
|
173 %! |
|
174 %! dm2 = [0, 0, 0, 0, 0; |
|
175 %! 0, 0, 0, 0, 0; |
|
176 %! 1, 0, 0, 0, 0; |
|
177 %! 0, 2, 0, 0, 0; |
|
178 %! 0, 0, 3, 0, 0]; |
|
179 %! |
|
180 %! assert((diag (d) == d0 && diag (d, 1) == d1 && diag (d, 2) == d2 |
|
181 %! && diag (d, -1) == dm1 && diag (d, -2) == dm2 |
|
182 %! && diag (d0) == d && diag (d1, 1) == d && diag (dm1, -1) == d)); |
|
183 |
|
184 %% test/octave.test/matrix/diag-2.m |
5751
|
185 %!error <Invalid call to diag.*> diag (); |
5590
|
186 |
|
187 %% test/octave.test/matrix/diag-3.m |
5751
|
188 %!error <Invalid call to diag.*> diag (1, 2, 3); |
5590
|
189 |
|
190 %% test/octave.test/matrix/linspace-1.m |
|
191 %!test |
|
192 %! x1 = linspace (1, 2); |
|
193 %! x2 = linspace (1, 2, 10); |
|
194 %! x3 = linspace (1, -2, 10); |
|
195 %! assert((size (x1) == [1, 100] && x1(1) == 1 && x1(100) == 2 |
|
196 %! && size (x2) == [1, 10] && x2(1) == 1 && x2(10) == 2 |
|
197 %! && size (x3) == [1, 10] && x3(1) == 1 && x3(10) == -2)); |
|
198 |
|
199 %% test/octave.test/matrix/linspace-2.m |
|
200 %!test |
|
201 %! warn_fortran_indexing = 0; |
|
202 %! assert(all (linspace ([1, 2; 3, 4], 5, 6) == linspace (1, 5, 6))); |
|
203 |
|
204 %% test/octave.test/matrix/linspace-3.m |
5751
|
205 %!error <Invalid call to linspace.*> linspace (); |
5590
|
206 |
|
207 %% test/octave.test/matrix/linspace-4.m |
5751
|
208 %!error <Invalid call to linspace.*> linspace (1, 2, 3, 4); |
5590
|
209 |
|
210 %% test/octave.test/matrix/linspace-5.m |
|
211 %!test |
|
212 %! warn_fortran_indexing = 1; |
|
213 %! fail("linspace ([1, 2; 3, 4], 5, 6)","warning"); |
|
214 |