5590
|
1 %% Automatically generated from DejaGNU files |
|
2 |
|
3 %% test/octave.test/matrix/all-1.m |
|
4 %!test |
|
5 %! x = ones (3); |
|
6 %! x(1,1) = 0; |
|
7 %! assert((all (all (rand (3) + 1) == [1, 1, 1]) == 1 |
|
8 %! && all (all (x) == [0, 1, 1]) == 1 |
|
9 %! && all (x, 1) == [0, 1, 1] |
|
10 %! && all (x, 2) == [0; 1; 1])); |
|
11 |
|
12 %% test/octave.test/matrix/all-2.m |
|
13 %!error <... all:.*> all (); |
|
14 |
|
15 %% test/octave.test/matrix/all-3.m |
|
16 %!error <... all:.*> all (1, 2, 3); |
|
17 |
|
18 %% test/octave.test/matrix/any-1.m |
|
19 %!test |
|
20 %! x = zeros (3); |
|
21 %! x(3,3) = 1; |
|
22 %! assert((all (any (x) == [0, 0, 1]) == 1 |
|
23 %! && all (any (ones (3)) == [1, 1, 1]) == 1 |
|
24 %! && any (x, 1) == [0, 0, 1] |
|
25 %! && any (x, 2) == [0; 0; 1])); |
|
26 |
|
27 %% test/octave.test/matrix/any-2.m |
|
28 %!error <... any:.*> any (); |
|
29 |
|
30 %% test/octave.test/matrix/any-3.m |
|
31 %!error <... any:.*> any (1, 2, 3); |
|
32 |
|
33 %% test/octave.test/matrix/diff-1.m |
|
34 %!assert((diff ([1, 2, 3, 4]) == [1, 1, 1] |
|
35 %! && diff ([1, 3, 7, 19], 2) == [2, 8] |
|
36 %! && diff ([1, 2; 5, 4; 8, 7; 9, 6; 3, 1]) == [4, 2; 3, 3; 1, -1; -6, -5] |
|
37 %! && diff ([1, 2; 5, 4; 8, 7; 9, 6; 3, 1], 3) == [-1, -5; -5, 0] |
|
38 %! && isempty (diff (1)))); |
|
39 |
|
40 %% test/octave.test/matrix/diff-2.m |
|
41 %!error diff ([1, 2; 3, 4], -1); |
|
42 |
|
43 %% test/octave.test/matrix/diff-3.m |
|
44 %!error diff ("foo"); |
|
45 |
|
46 %% test/octave.test/matrix/diff-4.m |
|
47 %!error diff (); |
|
48 |
|
49 %% test/octave.test/matrix/diff-5.m |
|
50 %!error diff (1, 2, 3, 4); |
|
51 |
|
52 %% test/octave.test/matrix/find-1.m |
|
53 %!assert((find ([1, 0, 1, 0, 1]) == [1, 3, 5] |
|
54 %! && find ([1; 0; 3; 0; 1]) == [1; 3; 5] |
|
55 %! && find ([0, 0, 2; 0, 3, 0; -1, 0, 0]) == [3; 5; 7])); |
|
56 |
|
57 %% test/octave.test/matrix/find-2.m |
|
58 %!test |
|
59 %! [i, j, v] = find ([0, 0, 2; 0, 3, 0; -1, 0, 0]); |
|
60 %! |
|
61 %! assert(i == [3; 2; 1] && j == [1; 2; 3] && v == [-1; 3; 2]); |
|
62 |
|
63 %% test/octave.test/matrix/find-3.m |
|
64 %!error <... find:.*> find (); |
|
65 |
|
66 %% test/octave.test/matrix/find-4.m |
|
67 %!error <... find:.*> find (1, 2); |
|
68 |
|
69 %% test/octave.test/matrix/fliplr-1.m |
|
70 %!assert((fliplr ([1, 2; 3, 4]) == [2, 1; 4, 3] |
|
71 %! && fliplr ([1, 2; 3, 4; 5, 6]) == [2, 1; 4, 3; 6, 5] |
|
72 %! && fliplr ([1, 2, 3; 4, 5, 6]) == [3, 2, 1; 6, 5, 4])); |
|
73 |
|
74 %% test/octave.test/matrix/fliplr-2.m |
|
75 %!error <usage.*fliplr> fliplr(); |
|
76 |
|
77 %% test/octave.test/matrix/fliplr-3.m |
|
78 %!error fliplr (1, 2); |
|
79 |
|
80 %% test/octave.test/matrix/flipud-1.m |
|
81 %!assert((flipud ([1, 2; 3, 4]) == [3, 4; 1, 2] |
|
82 %! && flipud ([1, 2; 3, 4; 5, 6]) == [5, 6; 3, 4; 1, 2] |
|
83 %! && flipud ([1, 2, 3; 4, 5, 6]) == [4, 5, 6; 1, 2, 3])); |
|
84 |
|
85 %% test/octave.test/matrix/flipud-2.m |
|
86 %!error flipud (); |
|
87 |
|
88 %% test/octave.test/matrix/flipud-3.m |
|
89 %!error flipud (1, 2); |
|
90 |
|
91 %% test/octave.test/matrix/rot90-1.m |
|
92 %!test |
|
93 %! x1 = [1, 2; |
|
94 %! 3, 4]; |
|
95 %! x2 = [2, 4; |
|
96 %! 1, 3]; |
|
97 %! x3 = [4, 3; |
|
98 %! 2, 1]; |
|
99 %! x4 = [3, 1; |
|
100 %! 4, 2]; |
|
101 %! |
|
102 %! assert((rot90 (x1)== x2 && rot90 (x1, 2) == x3 && rot90 (x1, 3) == x4 |
|
103 %! && rot90 (x1, 4) == x1 && rot90 (x1, 5) == x2 && rot90 (x1, -1) == x4)); |
|
104 |
|
105 %% test/octave.test/matrix/rot90-2.m |
|
106 %!error rot90 (); |
|
107 |
|
108 %% test/octave.test/matrix/rot90-3.m |
|
109 %!error rot90 (1, 2, 3); |
|
110 |
|
111 %% test/octave.test/matrix/reshape-1.m |
|
112 %!assert((size (reshape (rand (4, 4), 2, 8)) == [2, 8] |
|
113 %! && size (reshape (rand (4, 4), 8, 2)) == [8, 2] |
|
114 %! && size (reshape (rand (15, 4), 1, 60)) == [1, 60] |
|
115 %! && size (reshape (rand (15, 4), 60, 1)) == [60, 1])); |
|
116 |
|
117 %% test/octave.test/matrix/reshape-2.m |
|
118 %!test |
|
119 %! s.a = 1; |
|
120 %! fail("reshape (s, 2, 3)"); |
|
121 |
|
122 %% test/octave.test/matrix/reshape-3.m |
|
123 %!error <... reshape:.*> reshape (); |
|
124 |
|
125 %% test/octave.test/matrix/reshape-4.m |
|
126 %!error reshape (1, 2, 3, 4); |
|
127 |
|
128 %% test/octave.test/matrix/shift-1.m |
|
129 %!test |
|
130 %! a = [1, 2, 3]; |
|
131 %! b = [4, 5, 6]; |
|
132 %! c = [7, 8, 9]; |
|
133 %! |
|
134 %! r = [a, b, c]; |
|
135 %! m = [a; b; c]; |
|
136 %! |
|
137 %! assert((shift (r, 3) == [c, a, b] |
|
138 %! && shift (r, -6) == [c, a, b] |
|
139 %! && shift (r, -3) == [b, c, a] |
|
140 %! && shift (m, 1) == [c; a; b] |
|
141 %! && shift (m, -2) == [c; a; b])); |
|
142 |
|
143 %% test/octave.test/matrix/shift-2.m |
|
144 %!error shift (); |
|
145 |
|
146 %% test/octave.test/matrix/shift-3.m |
|
147 %!error shift (1, 2, 3, 4); |
|
148 |
|
149 %% test/octave.test/matrix/sort-1.m |
|
150 %!test |
|
151 %! a = [1, 2; 2, 3; 3, 1]; |
|
152 %! s = [1, 1; 2, 2; 3, 3]; |
|
153 %! i = [1, 3; 2, 1; 3, 2]; |
|
154 %! [xs, xi] = sort (a); |
|
155 %! assert(sort (a) == s && xs == s && xi == i); |
|
156 |
|
157 %% test/octave.test/matrix/sort-2.m |
|
158 %!error <... sort:.*> sort (); |
|
159 |
|
160 %% test/octave.test/matrix/sort-3.m |
|
161 %!error <... sort:.*> sort (1, 2, 3, 4); |
|
162 |
|
163 %% test/octave.test/matrix/tril-1.m |
|
164 %!test |
|
165 %! a = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; |
|
166 %! |
|
167 %! l0 = [1, 0, 0; 4, 5, 0; 7, 8, 9; 10, 11, 12]; |
|
168 %! l1 = [1, 2, 0; 4, 5, 6; 7, 8, 9; 10, 11, 12]; |
|
169 %! l2 = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; |
|
170 %! lm1 = [0, 0, 0; 4, 0, 0; 7, 8, 0; 10, 11, 12]; |
|
171 %! lm2 = [0, 0, 0; 0, 0, 0; 7, 0, 0; 10, 11, 0]; |
|
172 %! lm3 = [0, 0, 0; 0, 0, 0; 0, 0, 0; 10, 0, 0]; |
|
173 %! lm4 = [0, 0, 0; 0, 0, 0; 0, 0, 0; 0, 0, 0]; |
|
174 %! |
|
175 %! assert((tril (a, -4) == lm4 && tril (a, -3) == lm3 |
|
176 %! && tril (a, -2) == lm2 && tril (a, -1) == lm1 |
|
177 %! && tril (a) == l0 && tril (a, 1) == l1 && tril (a, 2) == l2)); |
|
178 |
|
179 %% test/octave.test/matrix/tril-2.m |
|
180 %!error tril (); |
|
181 |
|
182 %% test/octave.test/matrix/tril-3.m |
|
183 %!error tril (1, 2, 3); |
|
184 |
|
185 %% test/octave.test/matrix/triu-1.m |
|
186 %!test |
|
187 %! a = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; |
|
188 %! |
|
189 %! u0 = [1, 2, 3; 0, 5, 6; 0, 0, 9; 0, 0, 0]; |
|
190 %! u1 = [0, 2, 3; 0, 0, 6; 0, 0, 0; 0, 0, 0]; |
|
191 %! u2 = [0, 0, 3; 0, 0, 0; 0, 0, 0; 0, 0, 0]; |
|
192 %! u3 = [0, 0, 0; 0, 0, 0; 0, 0, 0; 0, 0, 0]; |
|
193 %! um1 = [1, 2, 3; 4, 5, 6; 0, 8, 9; 0, 0, 12]; |
|
194 %! um2 = [1, 2, 3; 4, 5, 6; 7, 8, 9; 0, 11, 12]; |
|
195 %! um3 = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; |
|
196 %! |
|
197 %! assert((triu (a, -3) == um3 && triu (a, -2) == um2 |
|
198 %! && triu (a, -1) == um1 && triu (a) == u0 && triu (a, 1) == u1 |
|
199 %! && triu (a, 2) == u2 && triu (a, 3) == u3)); |
|
200 |
|
201 %% test/octave.test/matrix/triu-2.m |
|
202 %!error triu (); |
|
203 |
|
204 %% test/octave.test/matrix/triu-3.m |
|
205 %!error triu (1, 2, 3); |
|
206 |
|
207 %% test/octave.test/matrix/vec-1.m |
|
208 %!assert(vec ([1, 2; 3, 4]) == [1; 3; 2; 4] && vec ([1, 3, 2, 4]) == [1; 3; 2; 4]); |
|
209 |
|
210 %% test/octave.test/matrix/vec-2.m |
|
211 %!error vec (); |
|
212 |
|
213 %% test/octave.test/matrix/vec-3.m |
|
214 %!error vec (1, 2); |
|
215 |
|
216 %% test/octave.test/matrix/vech-1.m |
|
217 %!assert(all (vech ([1, 2, 3; 4, 5, 6; 7, 8, 9]) == [1; 4; 7; 5; 8; 9])); |
|
218 |
|
219 %% test/octave.test/matrix/vech-2.m |
|
220 %!error vech (); |
|
221 |
|
222 %% test/octave.test/matrix/vech-3.m |
|
223 %!error vech (1, 2); |
|
224 |
|
225 %% test/octave.test/matrix/eye-1.m |
|
226 %!test |
|
227 %! i33 = [1, 0, 0; 0, 1, 0; 0, 0, 1]; |
|
228 %! i23 = [1, 0, 0; 0, 1, 0]; |
|
229 %! assert((eye (3) == i33 && eye (size (i33)) == i33 && eye (3, 3) == i33 |
|
230 %! && eye (2, 3) == i23 && eye (3, 2) == i23')); |
|
231 |
|
232 %% test/octave.test/matrix/eye-2.m |
|
233 %!error <... eye:.*> eye (1, 2, 3); |
|
234 |
|
235 %% test/octave.test/matrix/ones-1.m |
|
236 %!test |
|
237 %! x33 = [1, 1, 1; 1, 1, 1; 1, 1, 1]; |
|
238 %! x23 = [1, 1, 1; 1, 1, 1]; |
|
239 %! assert((ones (3) == x33 && ones (size (x33)) == x33 && ones (3, 3) == x33 |
|
240 %! && ones (2, 3) == x23 && ones (3, 2) == x23')); |
|
241 |
|
242 %% test/octave.test/matrix/ones-2.m |
|
243 %!assert(all (size (ones (3, 4, 5)) == [3, 4, 5])); |
|
244 |
|
245 %% test/octave.test/matrix/zeros-1.m |
|
246 %!test |
|
247 %! x33 = [0, 0, 0; 0, 0, 0; 0, 0, 0]; |
|
248 %! x23 = [0, 0, 0; 0, 0, 0]; |
|
249 %! assert((zeros (3) == x33 && zeros (size (x33)) == x33 && zeros (3, 3) == x33 |
|
250 %! && zeros (2, 3) == x23 && zeros (3, 2) == x23')); |
|
251 |
|
252 %% test/octave.test/matrix/zeros-2.m |
|
253 %!assert(all (size (zeros (3, 4, 5)) == [3, 4, 5])); |
|
254 |
|
255 %% test/octave.test/matrix/rand-1.m |
|
256 %!test |
|
257 %! rand ("seed", 0.5); |
|
258 %! r1 = rand (100); |
|
259 %! rand ("seed", 0.5); |
|
260 %! r2 = rand (100); |
|
261 %! assert(rand (100) < 1 && rand (100) > 0 && r1 == r2); |
|
262 |
|
263 %% test/octave.test/matrix/rand-2.m |
|
264 %!assert(all (size (rand (1, 2, 3)) == [1, 2, 3])); |
|
265 |
|
266 %% test/octave.test/matrix/randn-1.m |
|
267 %!test |
|
268 %! randn ("seed", 0.5); |
|
269 %! r1 = randn (100); |
|
270 %! randn ("seed", 0.5); |
|
271 %! r2 = randn (100); |
|
272 %! assert(all (all (r1 == r2))); |
|
273 |
|
274 %% test/octave.test/matrix/randn-2.m |
|
275 %!assert(all (size (randn (1, 2, 3)) == [1, 2, 3])); |
|
276 |
|
277 %% test/octave.test/matrix/diag-1.m |
|
278 %!test |
|
279 %! d = [1; 2; 3]; |
|
280 %! |
|
281 %! d0 = [1, 0, 0; |
|
282 %! 0, 2, 0; |
|
283 %! 0, 0, 3]; |
|
284 %! |
|
285 %! d1 = [0, 1, 0, 0; |
|
286 %! 0, 0, 2, 0; |
|
287 %! 0, 0, 0, 3; |
|
288 %! 0, 0, 0, 0]; |
|
289 %! |
|
290 %! d2 = [0, 0, 1, 0, 0; |
|
291 %! 0, 0, 0, 2, 0; |
|
292 %! 0, 0, 0, 0, 3; |
|
293 %! 0, 0, 0, 0, 0; |
|
294 %! 0, 0, 0, 0, 0]; |
|
295 %! |
|
296 %! dm1 = [0, 0, 0, 0; |
|
297 %! 1, 0, 0, 0; |
|
298 %! 0, 2, 0, 0; |
|
299 %! 0, 0, 3, 0]; |
|
300 %! |
|
301 %! dm2 = [0, 0, 0, 0, 0; |
|
302 %! 0, 0, 0, 0, 0; |
|
303 %! 1, 0, 0, 0, 0; |
|
304 %! 0, 2, 0, 0, 0; |
|
305 %! 0, 0, 3, 0, 0]; |
|
306 %! |
|
307 %! assert((diag (d) == d0 && diag (d, 1) == d1 && diag (d, 2) == d2 |
|
308 %! && diag (d, -1) == dm1 && diag (d, -2) == dm2 |
|
309 %! && diag (d0) == d && diag (d1, 1) == d && diag (dm1, -1) == d)); |
|
310 |
|
311 %% test/octave.test/matrix/diag-2.m |
|
312 %!error <... diag:.*> diag (); |
|
313 |
|
314 %% test/octave.test/matrix/diag-3.m |
|
315 %!error <... diag:.*> diag (1, 2, 3); |
|
316 |
|
317 %% test/octave.test/matrix/linspace-1.m |
|
318 %!test |
|
319 %! x1 = linspace (1, 2); |
|
320 %! x2 = linspace (1, 2, 10); |
|
321 %! x3 = linspace (1, -2, 10); |
|
322 %! assert((size (x1) == [1, 100] && x1(1) == 1 && x1(100) == 2 |
|
323 %! && size (x2) == [1, 10] && x2(1) == 1 && x2(10) == 2 |
|
324 %! && size (x3) == [1, 10] && x3(1) == 1 && x3(10) == -2)); |
|
325 |
|
326 %% test/octave.test/matrix/linspace-2.m |
|
327 %!test |
|
328 %! warn_fortran_indexing = 0; |
|
329 %! assert(all (linspace ([1, 2; 3, 4], 5, 6) == linspace (1, 5, 6))); |
|
330 |
|
331 %% test/octave.test/matrix/linspace-3.m |
|
332 %!error <... linspace:.*> linspace (); |
|
333 |
|
334 %% test/octave.test/matrix/linspace-4.m |
|
335 %!error <... linspace:.*> linspace (1, 2, 3, 4); |
|
336 |
|
337 %% test/octave.test/matrix/linspace-5.m |
|
338 %!test |
|
339 %! warn_fortran_indexing = 1; |
|
340 %! fail("linspace ([1, 2; 3, 4], 5, 6)","warning"); |
|
341 |
|
342 %% test/octave.test/matrix/logspace-1.m |
|
343 %!test |
|
344 %! x1 = logspace (1, 2); |
|
345 %! x2 = logspace (1, 2, 10); |
|
346 %! x3 = logspace (1, -2, 10); |
|
347 %! x4 = logspace (1, pi, 10); |
|
348 %! assert((size (x1) == [1, 50] && x1(1) == 10 && x1(50) == 100 |
|
349 %! && size (x2) == [1, 10] && x2(1) == 10 && x2(10) == 100 |
|
350 %! && size (x3) == [1, 10] && x3(1) == 10 && x3(10) == 0.01 |
|
351 %! && size (x4) == [1, 10] && x4(1) == 10 && abs (x4(10) - pi) < sqrt (eps))); |
|
352 |
|
353 %% test/octave.test/matrix/logspace-2.m |
|
354 %!error logspace ([1, 2; 3, 4], 5, 6); |
|
355 |
|
356 %% test/octave.test/matrix/logspace-3.m |
|
357 %!error logspace (); |
|
358 |
|
359 %% test/octave.test/matrix/logspace-4.m |
|
360 %!error logspace (1, 2, 3, 4); |
|
361 |
|
362 %% test/octave.test/matrix/sylvester_matrix-1.m |
|
363 %!assert((sylvester_matrix (1) == [1, 1; 1, -1] |
|
364 %! && (sylvester_matrix (2) |
|
365 %! == [1, 1, 1, 1; 1, -1, 1, -1; 1, 1, -1, -1; 1, -1, -1, 1]))); |
|
366 |
|
367 %% test/octave.test/matrix/sylvester_matrix-2.m |
|
368 %!error sylvester_matrix ([1, 2; 3, 4]); |
|
369 |
|
370 %% test/octave.test/matrix/sylvester_matrix-3.m |
|
371 %!error sylvester_matrix (); |
|
372 |
|
373 %% test/octave.test/matrix/sylvester_matrix-4.m |
|
374 %!error sylvester_matrix (1, 2); |
|
375 |
|
376 %% test/octave.test/matrix/hankel-1.m |
|
377 %!assert((hankel (1) == 1 && hankel ([1, 2]) == [1, 2; 2, 0] |
|
378 %! && hankel ([1, 2], [2; -1; -3]) == [1, 2, -1; 2, -1, -3])); |
|
379 |
|
380 %% test/octave.test/matrix/hankel-2.m |
|
381 %!error hankel ([1, 2; 3, 4], [1, 2; 3, 4]); |
|
382 |
|
383 %% test/octave.test/matrix/hankel-3.m |
|
384 %!error hankel (); |
|
385 |
|
386 %% test/octave.test/matrix/hankel-4.m |
|
387 %!error hankel (1, 2, 3); |
|
388 |
|
389 %% test/octave.test/matrix/hilb-1.m |
|
390 %!assert((hilb (2) == [1, 1/2; 1/2, 1/3] |
|
391 %! && hilb (3) == [1, 1/2, 1/3; 1/2, 1/3, 1/4; 1/3, 1/4, 1/5])); |
|
392 |
|
393 %% test/octave.test/matrix/hilb-2.m |
|
394 %!error hilb (); |
|
395 |
|
396 %% test/octave.test/matrix/hilb-3.m |
|
397 %!error hilb (1, 2); |
|
398 |
|
399 %% test/octave.test/matrix/invhilb-1.m |
|
400 %!test |
|
401 %! result4 = [16, -120, 240, -140; |
|
402 %! -120, 1200, -2700, 1680; |
|
403 %! 240, -2700, 6480, -4200; |
|
404 %! -140, 1680, -4200, 2800]; |
|
405 %! |
|
406 %! assert((invhilb (1) == 1 && invhilb (2) == [4, -6; -6, 12] |
|
407 %! && invhilb (4) == result4 |
|
408 %! && abs (invhilb (7) * hilb (7) - eye (7)) < sqrt (eps))); |
|
409 |
|
410 %% test/octave.test/matrix/invhilb-2.m |
|
411 %!error invhilb ([1, 2]); |
|
412 |
|
413 %% test/octave.test/matrix/invhilb-3.m |
|
414 %!error invhilb (); |
|
415 |
|
416 %% test/octave.test/matrix/invhilb-4.m |
|
417 %!error invhilb (1, 2); |
|
418 |
|
419 %% test/octave.test/matrix/toeplitz-1.m |
|
420 %!assert((toeplitz (1) == 1 |
|
421 %! && toeplitz ([1, 2, 3], [1; -3; -5]) == [1, -3, -5; 2, 1, -3; 3, 2, 1] |
|
422 %! && toeplitz ([1, 2, 3], [1; -3i; -5i]) == [1, -3i, -5i; 2, 1, -3i; 3, 2, 1])); |
|
423 |
|
424 %% test/octave.test/matrix/toeplitz-2.m |
|
425 %!error toeplitz ([1, 2; 3, 4], 1); |
|
426 |
|
427 %% test/octave.test/matrix/toeplitz-3.m |
|
428 %!error toeplitz (); |
|
429 |
|
430 %% test/octave.test/matrix/toeplitz-4.m |
|
431 %!error toeplitz (1, 2, 3); |
|
432 |
|
433 %% test/octave.test/matrix/vander-1.m |
|
434 %!assert((vander (1) == 1 && vander ([1, 2, 3]) == vander ([1; 2; 3]) |
|
435 %! && vander ([1, 2, 3]) == [1, 1, 1; 4, 2, 1; 9, 3, 1] |
|
436 %! && vander ([1, 2, 3]*i) == [-1, i, 1; -4, 2i, 1; -9, 3i, 1])); |
|
437 |
|
438 %% test/octave.test/matrix/vander-2.m |
|
439 %!error vander ([1, 2; 3, 4]); |
|
440 |
|
441 %% test/octave.test/matrix/vander-3.m |
|
442 %!error vander (); |
|
443 |
|
444 %% test/octave.test/matrix/vander-4.m |
|
445 %!error vander (1, 2); |
|
446 |