7016
|
1 ## Copyright (C) 2007 John W. Eaton |
|
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/arith/beta-1.m |
|
22 %!test |
|
23 %! a=[1, 1.5, 2, 3]; |
|
24 %! b=[4, 3, 2, 1]; |
|
25 %! v1=beta(a,b); |
|
26 %! v2=beta(b,a); |
|
27 %! v3=gamma(a).*gamma(b)./gamma(a+b); |
|
28 %! assert(all(abs(v1-v2)<sqrt(eps)) && all(abs(v2-v3)<sqrt(eps))); |
|
29 |
|
30 %% test/octave.test/arith/beta-2.m |
|
31 %!error beta(); |
|
32 |
|
33 %% test/octave.test/arith/beta-3.m |
|
34 %!error beta(1); |
|
35 |
|
36 %% test/octave.test/arith/betainc-1.m |
|
37 %!test |
|
38 %! a=[1, 1.5, 2, 3]; |
|
39 %! b=[4, 3, 2, 1]; |
|
40 %! v1=betainc(1,a,b); |
|
41 %! v2=[1,1,1,1]; |
|
42 %! x = [.2, .4, .6, .8]; |
|
43 %! v3=betainc(x, a, b); |
|
44 %! v4 = 1-betainc(1.-x, b, a); |
|
45 %! assert(all(abs(v1-v2)<sqrt(eps)) && all(abs(v3-v4)<sqrt(eps))); |
|
46 |
|
47 %% test/octave.test/arith/betainc-2.m |
5751
|
48 %!error <Invalid call to betainc.*> betainc(); |
5590
|
49 |
|
50 %% test/octave.test/arith/betainc-3.m |
5751
|
51 %!error <Invalid call to betainc.*> betainc(1); |
5590
|
52 |
|
53 %% test/octave.test/arith/betainc-4.m |
5751
|
54 %!error <Invalid call to betainc.*> betainc(1,2); |
5590
|
55 |
|
56 %% test/octave.test/arith/ceil-1.m |
|
57 %!assert(all (ceil ([2, 1.1, -1.1, -1]) == [2, 2, -1, -1])); |
|
58 |
|
59 %% test/octave.test/arith/ceil-2.m |
|
60 %!assert(all (ceil ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i]) == [2+2i, 2+2i, -1-i, -1-i])); |
|
61 |
|
62 %% test/octave.test/arith/ceil-3.m |
|
63 %!error ceil (); |
|
64 |
|
65 %% test/octave.test/arith/ceil-4.m |
|
66 %!error ceil (1, 2); |
|
67 |
|
68 %% test/octave.test/arith/erf-1.m |
|
69 %!test |
|
70 %! x=[0,.5,1]; |
|
71 %! v=[0, .520499877813047, .842700792949715]; |
|
72 %! assert(all(abs(erf(x)-v)<1.e-10) && all(abs(erf(-x)+v)<1.e-10) && all(abs(erfc(x)+v-1)<1.e-10) && all(abs(erfinv(v)-x)<1.e-10)); |
|
73 |
|
74 %% test/octave.test/arith/erf-2.m |
|
75 %!error erf(); |
|
76 |
|
77 %% test/octave.test/arith/erf-3.m |
|
78 %!error erf(1,2); |
|
79 |
|
80 %% test/octave.test/arith/exp-1.m |
|
81 %!assert(all (abs (exp ([0, 1, -1, -1000]) - [1, e, 1/e, 0]) < sqrt (eps))); |
|
82 |
|
83 %% test/octave.test/arith/exp-2.m |
|
84 %!assert(abs (exp (1+i) - e * (cos (1) + sin (1) * i)) < sqrt (eps)); |
|
85 |
|
86 %% test/octave.test/arith/exp-3.m |
|
87 %!error exp (); |
|
88 |
|
89 %% test/octave.test/arith/exp-4.m |
|
90 %!error exp (1, 2); |
|
91 |
|
92 %% test/octave.test/arith/exp-5.m |
|
93 %!assert(exp (Inf) == Inf && exp (-Inf) == 0 && isnan (exp (NaN))); |
|
94 |
|
95 %% test/octave.test/arith/fix-1.m |
|
96 %!assert(all (fix ([1.1, 1, -1.1, -1]) == [1, 1, -1, -1])); |
|
97 |
|
98 %% test/octave.test/arith/fix-2.m |
|
99 %!assert(all (fix ([1.1+1.1i, 1+i, -1.1-1.1i, -1-i]) == [1+i, 1+i, -1-i, -1-i])); |
|
100 |
|
101 %% test/octave.test/arith/fix-3.m |
|
102 %!error fix (); |
|
103 |
|
104 %% test/octave.test/arith/fix-4.m |
|
105 %!error fix (1, 2); |
|
106 |
|
107 %% test/octave.test/arith/floor-1.m |
|
108 %!assert(all (floor ([2, 1.1, -1.1, -1]) == [2, 1, -2, -1])); |
|
109 |
|
110 %% test/octave.test/arith/floor-2.m |
|
111 %!assert(all (floor ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i]) == [2+2i, 1+i, -2-2i, -1-i])); |
|
112 |
|
113 %% test/octave.test/arith/floor-3.m |
|
114 %!error floor (); |
|
115 |
|
116 %% test/octave.test/arith/floor-4.m |
|
117 %!error floor (1, 2); |
|
118 |
|
119 %% test/octave.test/arith/gamma-1.m |
|
120 %!test |
|
121 %! x = [.5, 1, 1.5, 2, 3, 4, 5]; |
|
122 %! v = [sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]; |
|
123 %! assert(all(abs(gamma(x) - v) < sqrt(eps)) && all(abs(lgamma(x) - log(v)) < sqrt(eps)) |
|
124 %! ); |
|
125 |
|
126 %% test/octave.test/arith/gamma-2.m |
|
127 %!error gamma(); |
|
128 |
|
129 %% test/octave.test/arith/gamma-3.m |
|
130 %!error gamma(1,2); |
|
131 |
|
132 %% test/octave.test/arith/gammainc-1.m |
|
133 %!test |
|
134 %! a = [.5 .5 .5 .5 .5]; |
|
135 %! x = [0 1 2 3 4]; |
|
136 %! v1 = sqrt(pi)*erf(x)./gamma(a); |
|
137 %! v3 = gammainc(x.*x,a); |
|
138 %! assert(all (abs(v1 - v3) < sqrt(eps))); |
|
139 |
|
140 %% test/octave.test/arith/gcd-1.m |
|
141 %!assert((gcd (200, 300, 50, 35) == gcd ([200, 300, 50, 35]) |
|
142 %! && gcd ([200, 300, 50, 35]) == 5)); |
|
143 |
|
144 %% test/octave.test/arith/gcd-2.m |
5751
|
145 %!error <Invalid call to gcd.*> gcd (); |
5590
|
146 |
|
147 %% test/octave.test/arith/gcd-3.m |
|
148 %!test |
|
149 %! s.a = 1; |
|
150 %! fail("gcd (s)"); |
|
151 |
|
152 %% test/octave.test/arith/lcm-1.m |
|
153 %!assert(lcm (3, 5, 7, 15) == lcm ([3, 5, 7, 15]) && lcm ([3, 5, 7,15]) == 105); |
|
154 |
|
155 %% test/octave.test/arith/lcm-2.m |
|
156 %!error lcm (); |
|
157 |
|
158 %% test/octave.test/arith/lcm-3.m |
|
159 %!test |
|
160 %! s.a = 1; |
|
161 %! fail("lcm (s)"); |
|
162 |
|
163 %% test/octave.test/arith/max-1.m |
5955
|
164 %!assert (max ([1, 4, 2, 3]) == 4); |
|
165 %!assert (max ([1; -10; 5; -2]) == 5); |
5590
|
166 |
|
167 %% test/octave.test/arith/max-2.m |
|
168 %!assert(all (max ([4, i 4.999; -2, 2, 3+4i]) == [4, 2, 3+4i])); |
|
169 |
|
170 %% test/octave.test/arith/max-3.m |
5751
|
171 %!error <Invalid call to max.*> max (); |
5590
|
172 |
|
173 %% test/octave.test/arith/max-4.m |
5751
|
174 %!error <Invalid call to max.*> max (1, 2, 3, 4); |
5590
|
175 |
|
176 %% test/octave.test/arith/min-1.m |
5955
|
177 %!assert (min ([1, 4, 2, 3]) == 1); |
|
178 %!assert (min ([1; -10; 5; -2]) == -10); |
5590
|
179 |
|
180 %% test/octave.test/arith/min-2.m |
|
181 %!assert(all (min ([4, i; -2, 2]) == [-2, i])); |
|
182 |
|
183 %% test/octave.test/arith/min-3.m |
5751
|
184 %!error <Invalid call to min.*> min (); |
5590
|
185 |
|
186 %% test/octave.test/arith/min-4.m |
5751
|
187 %!error <Invalid call to min.*> min (1, 2, 3, 4); |
5590
|
188 |
|
189 %% test/octave.test/arith/pow2-1.m |
|
190 %!test |
|
191 %! x = [3, 0, -3]; |
|
192 %! v = [8, 1, .125]; |
|
193 %! assert(all (abs (pow2 (x) - v) < sqrt (eps))); |
|
194 |
|
195 %% test/octave.test/arith/pow2-2.m |
|
196 %!test |
|
197 %! x = [3, 0, -3, 4, 0, -4, 5, 0, -5]; |
|
198 %! y = [-2, -2, -2, 1, 1, 1, 3, 3, 3]; |
|
199 %! z = x .* (2 .^ y); |
|
200 %! assert(all (abs (pow2 (x,y) - z) < sqrt (eps)) |
|
201 %! ); |
|
202 |
|
203 %% test/octave.test/arith/pow2-3.m |
|
204 %!error pow2(); |
|
205 |
|
206 %% test/octave.test/arith/rem-1.m |
|
207 %!assert(all (all (rem ([1, 2, 3; -1, -2, -3], 2) == [1, 0, 1; -1, 0, -1]))); |
|
208 |
|
209 %% test/octave.test/arith/rem-2.m |
|
210 %!assert(all (all (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3)) |
|
211 %! == [1, 0, 1; -1, 0, -1]))); |
|
212 |
|
213 %% test/octave.test/arith/rem-3.m |
|
214 %!error rem (); |
|
215 |
|
216 %% test/octave.test/arith/rem-4.m |
|
217 %!error rem (1, 2, 3); |
|
218 |
|
219 %% test/octave.test/arith/rem-5.m |
|
220 %!error rem ([1, 2], [3, 4, 5]); |
|
221 |
|
222 %% test/octave.test/arith/rem-6.m |
|
223 %!error rem (i, 1); |
|
224 |
|
225 %% test/octave.test/arith/round-1.m |
|
226 %!assert((round (1) == 1 && round (1.1) == 1 && round (5.5) == 6 |
|
227 %! && round (i) == i && round (2.5+3.5i) == 3+4i && round (-2.6) == -3)); |
|
228 |
|
229 %% test/octave.test/arith/round-2.m |
|
230 %!assert(all (all (round ([1.1, -2.4; -3.7, 7.1]) == [1, -2; -4, 7]))); |
|
231 |
|
232 %% test/octave.test/arith/round-3.m |
|
233 %!error round (); |
|
234 |
|
235 %% test/octave.test/arith/round-4.m |
|
236 %!error round (1, 2); |
|
237 |
|
238 %% test/octave.test/arith/sign-1.m |
|
239 %!assert(sign (-2) == -1 && sign (3) == 1 && sign (0) == 0); |
|
240 |
|
241 %% test/octave.test/arith/sign-2.m |
|
242 %!assert(all (all (sign ([1, -pi; e, 0]) == [1, -1; 1, 0]))); |
|
243 |
|
244 %% test/octave.test/arith/sign-3.m |
|
245 %!error sign (); |
|
246 |
|
247 %% test/octave.test/arith/sign-4.m |
|
248 %!error sign (1, 2); |
|
249 |
|
250 %% test/octave.test/arith/sqrt-1.m |
|
251 %!assert((sqrt (4) == 2 && sqrt (-1) == i |
|
252 %! && abs (sqrt (1+i) - exp (0.5 * log (1+i))) < sqrt (eps))); |
|
253 |
|
254 %% test/octave.test/arith/sqrt-2.m |
|
255 %!test |
|
256 %! t1 = exp (0.5 * log (i)); |
|
257 %! t2 = exp (0.5 * log (1-i)); |
|
258 %! assert(all (all (abs (sqrt ([4, -4; i, 1-i]) - [2, 2i; t1, t2]) < sqrt (eps)))); |
|
259 |
|
260 %% test/octave.test/arith/sqrt-3.m |
|
261 %!error sqrt (); |
|
262 |
|
263 %% test/octave.test/arith/sqrt-4.m |
|
264 %!error sqrt (1, 2); |
|
265 |
|
266 %% test/octave.test/arith/abs-1.m |
|
267 %!assert(abs (1) == 1 && abs (-3.5) == 3.5 && abs (3+4i) == 5 && abs (3-4i) == 5); |
|
268 |
|
269 %% test/octave.test/arith/abs-2.m |
|
270 %!assert(all (all (abs ([1.1, 3i; 3+4i, -3-4i]) == [1.1, 3; 5, 5]))); |
|
271 |
|
272 %% test/octave.test/arith/abs-3.m |
|
273 %!error abs (); |
|
274 |
|
275 %% test/octave.test/arith/abs-4.m |
|
276 %!error abs (1, 2); |
|
277 |
|
278 %% test/octave.test/arith/xor-1.m |
|
279 %!assert((xor ([1, 1, 0, 0], [0, 1, 0, 1]) == [1, 0, 0, 1] |
|
280 %! && xor ([i, i, 0, 0], [1, 0, 1, 0]) == [0, 1, 1, 0])); |
|
281 |
|
282 %% test/octave.test/arith/xor-2.m |
|
283 %!assert(all (all (xor (eye (2), fliplr (eye (2))) == ones (2)))); |
|
284 |
|
285 %% test/octave.test/arith/xor-3.m |
|
286 %!error xor (); |
|
287 |
|
288 %% test/octave.test/arith/xor-4.m |
|
289 %!error xor (1, 2, 3); |
|
290 |
|
291 %% test/octave.test/arith/arg-1.m |
|
292 %!assert(arg (1) == 0 && arg (i) == pi/2 && arg (-1) == pi && arg (-i) == -pi/2); |
|
293 |
|
294 %% test/octave.test/arith/arg-2.m |
|
295 %!assert(all (all (arg ([1, i; -1, -i]) == [0, pi/2; pi, -pi/2]))); |
|
296 |
|
297 %% test/octave.test/arith/arg-3.m |
|
298 %!error arg (); |
|
299 |
|
300 %% test/octave.test/arith/arg-4.m |
|
301 %!error arg (1, 2); |
|
302 |
|
303 %% test/octave.test/arith/conj-1.m |
|
304 %!assert(conj (1) == 1 && conj (i) == -i && conj (1+i) == 1-i && conj (1-i) == 1+i); |
|
305 |
|
306 %% test/octave.test/arith/conj-2.m |
|
307 %!assert(all (all (conj ([-1, -i; -1+i, -1-i]) == [-1, i; -1-i, -1+i]))); |
|
308 |
|
309 %% test/octave.test/arith/conj-3.m |
|
310 %!error conj (); |
|
311 |
|
312 %% test/octave.test/arith/conj-4.m |
|
313 %!error conj (1, 2); |
|
314 |
|
315 %% test/octave.test/arith/imag-1.m |
|
316 %!assert(imag (1) == 0 && imag (i) == 1 && imag (1+i) == 1); |
|
317 |
|
318 %% test/octave.test/arith/imag-2.m |
|
319 %!assert(all (all (imag ([i, 1; 1, i]) == eye (2)))); |
|
320 |
|
321 %% test/octave.test/arith/imag-3.m |
|
322 %!error imag (); |
|
323 |
|
324 %% test/octave.test/arith/imag-4.m |
|
325 %!error imag (1, 2); |
|
326 |
|
327 %% test/octave.test/arith/real-1.m |
|
328 %!assert(real (1) == 1 && real (i) == 0 && real (1+i) == 1); |
|
329 |
|
330 %% test/octave.test/arith/real-2.m |
|
331 %!assert(all (all (real ([1, i; i, 1]) == eye (2)))); |
|
332 |
|
333 %% test/octave.test/arith/real-3.m |
|
334 %!error real (); |
|
335 |
|
336 %% test/octave.test/arith/real-4.m |
|
337 %!error real (1, 2); |
|
338 |
|
339 %% test/octave.test/arith/log-1.m |
|
340 %!assert(all (abs (log ([1, e, e^2]) - [0, 1, 2]) < sqrt (eps))); |
|
341 |
|
342 %% test/octave.test/arith/log-2.m |
|
343 %!error log (); |
|
344 |
|
345 %% test/octave.test/arith/log-3.m |
|
346 %!error log (1, 2); |
|
347 |
|
348 %% test/octave.test/arith/log10-1.m |
|
349 %!assert(all (abs (log10 ([0.01, 0.1, 1, 10, 100]) - [-2, -1, 0, 1, 2]) < sqrt (eps))); |
|
350 |
|
351 %% test/octave.test/arith/log10-2.m |
|
352 %!error log10 (); |
|
353 |
|
354 %% test/octave.test/arith/log10-3.m |
|
355 %!error log10 (1, 2); |
|
356 |
|
357 %% test/octave.test/arith/log2-1.m |
|
358 %!assert(all (abs (log2 ([1/4, 1/2, 1, 2, 4]) - [-2, -1, 0, 1, 2]) < sqrt (eps))); |
|
359 |
|
360 %% test/octave.test/arith/log2-2.m |
|
361 %!error log2 (); |
|
362 |
|
363 %% test/octave.test/arith/log2-3.m |
|
364 %!error log2 (1, 2); |
|
365 |
|
366 %% test/octave.test/arith/sin-1.m |
|
367 %!test |
|
368 %! rt2 = sqrt (2); |
|
369 %! rt3 = sqrt (3); |
|
370 %! x = [0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
|
371 %! v = [0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0]; |
|
372 %! assert(all (abs (sin (x) - v) < sqrt (eps))); |
|
373 |
|
374 %% test/octave.test/arith/sin-2.m |
|
375 %!error sin (); |
|
376 |
|
377 %% test/octave.test/arith/sin-3.m |
|
378 %!error sin (1, 2); |
|
379 |
|
380 %% test/octave.test/arith/cos-1.m |
|
381 %!test |
|
382 %! rt2 = sqrt (2); |
|
383 %! rt3 = sqrt (3); |
|
384 %! x = [0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
|
385 %! v = [1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]; |
|
386 %! assert(all (abs (cos (x) - v) < sqrt (eps))); |
|
387 |
|
388 %% test/octave.test/arith/cos-2.m |
|
389 %!error cos (); |
|
390 |
|
391 %% test/octave.test/arith/cos-3.m |
|
392 %!error cos (1, 2); |
|
393 |
|
394 %% test/octave.test/arith/tan-1.m |
|
395 %!test |
|
396 %! rt2 = sqrt (2); |
|
397 %! rt3 = sqrt (3); |
|
398 %! x = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
|
399 %! v = [0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]; |
|
400 %! assert(all (abs (tan (x) - v) < sqrt (eps))); |
|
401 |
|
402 %% test/octave.test/arith/tan-2.m |
|
403 %!error tan (); |
|
404 |
|
405 %% test/octave.test/arith/tan-3.m |
|
406 %!error tan (1, 2); |
|
407 |
|
408 %% test/octave.test/arith/sec-1.m |
|
409 %!test |
|
410 %! rt2 = sqrt (2); |
|
411 %! rt3 = sqrt (3); |
|
412 %! x = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
|
413 %! v = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1]; |
|
414 %! assert(all (abs (sec (x) - v) < sqrt (eps))); |
|
415 |
|
416 %% test/octave.test/arith/sec-2.m |
|
417 %!error sec (); |
|
418 |
|
419 %% test/octave.test/arith/sec-3.m |
|
420 %!error sec (1, 2); |
|
421 |
|
422 %% test/octave.test/arith/csc-1.m |
|
423 %!test |
|
424 %! rt2 = sqrt (2); |
|
425 %! rt3 = sqrt (3); |
|
426 %! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6]; |
|
427 %! v = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2]; |
|
428 %! assert(all (abs (csc (x) - v) < sqrt (eps))); |
|
429 |
|
430 %% test/octave.test/arith/csc-2.m |
|
431 %!error csc (); |
|
432 |
|
433 %% test/octave.test/arith/csc-3.m |
|
434 %!error csc (1, 2); |
|
435 |
|
436 %% test/octave.test/arith/cot-1.m |
|
437 %!test |
|
438 %! rt2 = sqrt (2); |
|
439 %! rt3 = sqrt (3); |
|
440 %! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6]; |
|
441 %! v = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3]; |
|
442 %! assert(all (abs (cot (x) - v) < sqrt (eps))); |
|
443 |
|
444 %% test/octave.test/arith/cot-2.m |
|
445 %!error cot (); |
|
446 |
|
447 %% test/octave.test/arith/cot-3.m |
|
448 %!error cot (1, 2); |
|
449 |
|
450 %% test/octave.test/arith/asin-1.m |
|
451 %!test |
|
452 %! rt2 = sqrt (2); |
|
453 %! rt3 = sqrt (3); |
|
454 %! v = [0, pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6, 0]; |
|
455 %! x = [0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0]; |
|
456 %! assert(all (abs (asin (x) - v) < sqrt (eps)) |
|
457 %! |
|
458 %! ); |
|
459 |
|
460 %% test/octave.test/arith/asin-2.m |
|
461 %!error asin (); |
|
462 |
|
463 %% test/octave.test/arith/asin-3.m |
|
464 %!error asin (1, 2); |
|
465 |
|
466 %% test/octave.test/arith/acos-1.m |
|
467 %!test |
|
468 %! rt2 = sqrt (2); |
|
469 %! rt3 = sqrt (3); |
|
470 %! v = [0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
|
471 %! x = [1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]; |
|
472 %! assert(all (abs (acos (x) - v) < sqrt (eps)) |
|
473 %! |
|
474 %! ); |
|
475 |
|
476 %% test/octave.test/arith/acos-2.m |
|
477 %!error acos (); |
|
478 |
|
479 %% test/octave.test/arith/acos-3.m |
|
480 %!error acos (1, 2); |
|
481 |
|
482 %% test/octave.test/arith/atan-1.m |
|
483 %!test |
|
484 %! rt2 = sqrt (2); |
|
485 %! rt3 = sqrt (3); |
|
486 %! v = [0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]; |
|
487 %! x = [0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]; |
|
488 %! assert(all (abs (atan (x) - v) < sqrt (eps)) |
|
489 %! |
|
490 %! ); |
|
491 |
|
492 %% test/octave.test/arith/atan-2.m |
|
493 %!error atan (); |
|
494 |
|
495 %% test/octave.test/arith/atan-3.m |
|
496 %!error atan (1, 2); |
|
497 |
|
498 %% test/octave.test/arith/asec-1.m |
|
499 %!test |
|
500 %! rt2 = sqrt (2); |
|
501 %! rt3 = sqrt (3); |
|
502 %! v = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
|
503 %! x = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1]; |
|
504 %! assert(all (abs (asec (x) - v) < sqrt (eps)) |
|
505 %! |
|
506 %! ); |
|
507 |
|
508 %% test/octave.test/arith/asec-2.m |
|
509 %!error asec (); |
|
510 |
|
511 %% test/octave.test/arith/asec-3.m |
|
512 %!error asec (1, 2); |
|
513 |
|
514 %% test/octave.test/arith/acsc-1.m |
|
515 %!test |
|
516 %! rt2 = sqrt (2); |
|
517 %! rt3 = sqrt (3); |
|
518 %! v = [pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6]; |
|
519 %! x = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2]; |
|
520 %! assert(all (abs (acsc (x) - v) < sqrt (eps)) |
|
521 %! ); |
|
522 |
|
523 %% test/octave.test/arith/acsc-2.m |
|
524 %!error acsc (); |
|
525 |
|
526 %% test/octave.test/arith/acsc-3.m |
|
527 %!error acsc (1, 2); |
|
528 |
|
529 %% test/octave.test/arith/acot-1.m |
|
530 %!test |
|
531 %! rt2 = sqrt (2); |
|
532 %! rt3 = sqrt (3); |
|
533 %! x = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3]; |
|
534 %! v = [pi/6, pi/4, pi/3, pi/2, -pi/3, -pi/4, -pi/6]; |
|
535 %! assert(all (abs (acot (x) - v) < sqrt (eps)) |
|
536 %! |
|
537 %! ); |
|
538 |
|
539 %% test/octave.test/arith/acot-2.m |
|
540 %!error acot (); |
|
541 |
|
542 %% test/octave.test/arith/acot-3.m |
|
543 %!error acot (1, 2); |
|
544 |
|
545 %% test/octave.test/arith/sinh-1.m |
|
546 %!test |
|
547 %! x = [0, pi/2*i, pi*i, 3*pi/2*i]; |
|
548 %! v = [0, i, 0, -i]; |
|
549 %! assert(all (abs (sinh (x) - v) < sqrt (eps))); |
|
550 |
|
551 %% test/octave.test/arith/sinh-2.m |
|
552 %!error sinh (); |
|
553 |
|
554 %% test/octave.test/arith/sinh-3.m |
|
555 %!error sinh (1, 2); |
|
556 |
|
557 %% test/octave.test/arith/cosh-1.m |
|
558 %!test |
|
559 %! x = [0, pi/2*i, pi*i, 3*pi/2*i]; |
|
560 %! v = [1, 0, -1, 0]; |
|
561 %! assert(all (abs (cosh (x) - v) < sqrt (eps))); |
|
562 |
|
563 %% test/octave.test/arith/cosh-2.m |
|
564 %!error cosh (); |
|
565 |
|
566 %% test/octave.test/arith/cosh-3.m |
|
567 %!error cosh (1, 2); |
|
568 |
|
569 %% test/octave.test/arith/tanh-1.m |
|
570 %!test |
|
571 %! x = [0, pi*i]; |
|
572 %! v = [0, 0]; |
|
573 %! assert(all (abs (tanh (x) - v) < sqrt (eps))); |
|
574 |
|
575 %% test/octave.test/arith/tanh-2.m |
|
576 %!error tanh (); |
|
577 |
|
578 %% test/octave.test/arith/tanh-3.m |
|
579 %!error tanh (1, 2); |
|
580 |
|
581 %% test/octave.test/arith/sech-1.m |
|
582 %!test |
|
583 %! x = [0, pi*i]; |
|
584 %! v = [1, -1]; |
|
585 %! assert(all (abs (sech (x) - v) < sqrt (eps))); |
|
586 |
|
587 %% test/octave.test/arith/sech-2.m |
|
588 %!error sech (); |
|
589 |
|
590 %% test/octave.test/arith/sech-3.m |
|
591 %!error sech (1, 2); |
|
592 |
|
593 %% test/octave.test/arith/csch-1.m |
|
594 %!test |
|
595 %! x = [pi/2*i, 3*pi/2*i]; |
|
596 %! v = [-i, i]; |
|
597 %! assert(all (abs (csch (x) - v) < sqrt (eps))); |
|
598 |
|
599 %% test/octave.test/arith/csch-2.m |
|
600 %!error csch (); |
|
601 |
|
602 %% test/octave.test/arith/csch-3.m |
|
603 %!error csch (1, 2); |
|
604 |
|
605 %% test/octave.test/arith/coth-1.m |
|
606 %!test |
|
607 %! x = [pi/2*i, 3*pi/2*i]; |
|
608 %! v = [0, 0]; |
|
609 %! assert(all (abs (coth (x) - v) < sqrt (eps))); |
|
610 |
|
611 %% test/octave.test/arith/coth-2.m |
|
612 %!error coth (); |
|
613 |
|
614 %% test/octave.test/arith/coth-3.m |
|
615 %!error coth (1, 2); |
|
616 |
|
617 %% test/octave.test/arith/asinh-1.m |
|
618 %!test |
|
619 %! v = [0, pi/2*i, 0, -pi/2*i]; |
|
620 %! x = [0, i, 0, -i]; |
|
621 %! assert(all (abs (asinh (x) - v) < sqrt (eps)) |
|
622 %! ); |
|
623 |
|
624 %% test/octave.test/arith/asinh-2.m |
|
625 %!error asinh (); |
|
626 |
|
627 %% test/octave.test/arith/asinh-3.m |
|
628 %!error asinh (1, 2); |
|
629 |
|
630 %% test/octave.test/arith/acosh-1.m |
|
631 %!test |
|
632 %! v = [0, pi/2*i, pi*i, pi/2*i]; |
|
633 %! x = [1, 0, -1, 0]; |
|
634 %! assert(all (abs (acosh (x) - v) < sqrt (eps)) |
|
635 %! ); |
|
636 |
|
637 %% test/octave.test/arith/acosh-2.m |
|
638 %!error acosh (); |
|
639 |
|
640 %% test/octave.test/arith/acosh-3.m |
|
641 %!error acosh (1, 2); |
|
642 |
|
643 %% test/octave.test/arith/atanh-1.m |
|
644 %!test |
|
645 %! v = [0, 0]; |
|
646 %! x = [0, 0]; |
|
647 %! assert(all (abs (atanh (x) - v) < sqrt (eps)) |
|
648 %! ); |
|
649 |
|
650 %% test/octave.test/arith/atanh-2.m |
|
651 %!error atanh (); |
|
652 |
|
653 %% test/octave.test/arith/atanh-3.m |
|
654 %!error atanh (1, 2); |
|
655 |
|
656 %% test/octave.test/arith/asech-1.m |
|
657 %!test |
|
658 %! v = [0, pi*i]; |
|
659 %! x = [1, -1]; |
|
660 %! assert(all (abs (asech (x) - v) < sqrt (eps)) |
|
661 %! ); |
|
662 |
|
663 %% test/octave.test/arith/asech-2.m |
|
664 %!error asech (); |
|
665 |
|
666 %% test/octave.test/arith/asech-3.m |
|
667 %!error asech (1, 2); |
|
668 |
|
669 %% test/octave.test/arith/acsch-1.m |
|
670 %!test |
|
671 %! v = [pi/2*i, -pi/2*i]; |
|
672 %! x = [-i, i]; |
|
673 %! assert(all (abs (acsch (x) - v) < sqrt (eps)) |
|
674 %! ); |
|
675 |
|
676 %% test/octave.test/arith/acsch-2.m |
|
677 %!error acsch (); |
|
678 |
|
679 %% test/octave.test/arith/acsch-3.m |
|
680 %!error acsch (1, 2); |
|
681 |
|
682 %% test/octave.test/arith/acoth-1.m |
|
683 %!test |
|
684 %! rt2 = sqrt (2); |
|
685 %! rt3 = sqrt (3); |
|
686 %! v = -i*[pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6]; |
|
687 %! x = i*[rt3, 1, rt3/3, -rt3/3, -1, -rt3]; |
|
688 %! assert(all (abs (acoth (x) - v) < sqrt (eps))); |
|
689 |
|
690 %% test/octave.test/arith/acoth-2.m |
|
691 %!error acoth (); |
|
692 |
|
693 %% test/octave.test/arith/acoth-3.m |
|
694 %!error acoth (1, 2); |
|
695 |
|
696 %% test/octave.test/arith/atan2-1.m |
|
697 %!test |
|
698 %! rt2 = sqrt (2); |
|
699 %! rt3 = sqrt (3); |
|
700 %! v = [0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]; |
|
701 %! y = [0, rt3, 1, rt3, -rt3, -1, -rt3, 0]; |
|
702 %! x = [1, 3, 1, 1, 1, 1, 3, 1]; |
|
703 %! assert(all (abs (atan2 (y, x) - v) < sqrt (eps)) |
|
704 %! ); |
|
705 |
|
706 %% test/octave.test/arith/atan2-2.m |
5751
|
707 %!error <Invalid call to atan2.*> atan2 (); |
5590
|
708 |
|
709 %% test/octave.test/arith/atan2-3.m |
5751
|
710 %!error <Invalid call to atan2.*> atan2 (1, 2, 3); |
5590
|
711 |
|
712 %% test/octave.test/arith/sum-1.m |
|
713 %!assert((sum ([1, 2, 3]) == 6 && sum ([-1; -2; -3]) == -6 |
|
714 %! && sum ([i, 2+i, -3+2i, 4]) == 3+4i)); |
|
715 |
|
716 %% test/octave.test/arith/sum-2.m |
|
717 %!assert(all (all (sum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]) == [2+2i, 4+4i, 6+6i]))); |
|
718 |
|
719 %% test/octave.test/arith/sum-3.m |
5751
|
720 %!error <Invalid call to sum.*> sum (); |
5590
|
721 |
|
722 %% test/octave.test/arith/sum-4.m |
5955
|
723 %!assert (all (sum ([1, 2; 3, 4], 1) == [4, 6])); |
|
724 %!assert (all (sum ([1, 2; 3, 4], 2) == [3; 7])); |
|
725 %!assert (sum (zeros (1, 0)) == 0); |
|
726 %!assert (all (size (sum (zeros (1, 0), 1)) == [1, 0])); |
|
727 %!assert (sum (zeros (1, 0), 2) == 0); |
|
728 %!assert (sum (zeros (0, 1)) == 0); |
|
729 %!assert (sum (zeros (0, 1), 1) == 0); |
|
730 %!assert (all (size (sum (zeros (0, 1), 2)) == [0, 1])); |
|
731 %!assert (all (size (sum (zeros (2, 0))) == [1, 0])); |
|
732 %!assert (all (size (sum (zeros (2, 0), 1)) == [1, 0])); |
|
733 %!assert (all (sum (zeros (2, 0), 2) == [0; 0])); |
|
734 %!assert (all (sum (zeros (0, 2)) == [0, 0])); |
|
735 %!assert (all (sum (zeros (0, 2), 1) == [0, 0])); |
|
736 %!assert (all (size (sum (zeros (0, 2), 2)) == [0, 1])); |
|
737 %!assert (all (size (sum (zeros (2, 2, 0, 3))) == [1, 2, 0, 3])); |
|
738 %!assert (all (size (sum (zeros (2, 2, 0, 3), 2)) == [2, 1, 0, 3])); |
|
739 %!assert (all (size (sum (zeros (2, 2, 0, 3), 3)) == [2, 2, 1, 3])); |
|
740 %!assert (all (size (sum (zeros (2, 2, 0, 3), 4)) == [2, 2, 0])); |
|
741 %!assert (all (size (sum (zeros (2, 2, 0, 3), 7)) == [2, 2, 0, 3])); |
5590
|
742 |
|
743 %% test/octave.test/arith/prod-1.m |
5955
|
744 %!assert (prod ([1, 2, 3]) == 6 && prod ([-1; -2; -3]) == -6); |
|
745 %!assert (prod ([i, 2+i, -3+2i, 4]) == -4-32i); |
5590
|
746 |
|
747 %% test/octave.test/arith/prod-2.m |
|
748 %!assert(all (all (prod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]) |
|
749 %! == [-1+i, -8+8i, -27+27i]))); |
|
750 |
|
751 %% test/octave.test/arith/prod-3.m |
5751
|
752 %!error <Invalid call to prod.*> prod (); |
5590
|
753 |
|
754 %% test/octave.test/arith/prod-4.m |
5955
|
755 %!assert (all (prod ([1, 2; 3, 4], 1) == [3, 8])); |
|
756 %!assert (all (prod ([1, 2; 3, 4], 2) == [2; 12])); |
|
757 %!assert (prod (zeros (1, 0)) == 1); |
|
758 %!assert (all (size (prod (zeros (1, 0), 1)) == [1, 0])); |
|
759 %!assert (prod (zeros (1, 0), 2) == 1); |
|
760 %!assert (prod (zeros (0, 1)) == 1); |
|
761 %!assert (prod (zeros (0, 1), 1) == 1); |
|
762 %!assert (all (size (prod (zeros (0, 1), 2)) == [0, 1])); |
|
763 %!assert (all (size (prod (zeros (2, 0))) == [1, 0])); |
|
764 %!assert (all (size (prod (zeros (2, 0), 1)) == [1, 0])); |
|
765 %!assert (all (prod (zeros (2, 0), 2) == [1; 1])); |
|
766 %!assert (all (prod (zeros (0, 2)) == [1, 1])); |
|
767 %!assert (all (prod (zeros (0, 2), 1) == [1, 1])); |
|
768 %!assert (all (size (prod (zeros (0, 2), 2)) == [0, 1])); |
5590
|
769 |
|
770 %% test/octave.test/arith/cumsum-1.m |
5955
|
771 %!assert (cumsum ([1, 2, 3]) == [1, 3, 6]); |
|
772 %!assert (cumsum ([-1; -2; -3]) == [-1; -3; -6]); |
|
773 %!assert (cumsum ([i, 2+i, -3+2i, 4]) == [i, 2+2i, -1+4i, 3+4i]); |
5590
|
774 |
|
775 %% test/octave.test/arith/cumsum-2.m |
|
776 %!assert(all (all (cumsum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]) |
|
777 %! == [1, 2, 3; 1+i, 2+2i, 3+3i; 2+2i, 4+4i, 6+6i]))); |
|
778 |
|
779 %% test/octave.test/arith/cumsum-3.m |
5751
|
780 %!error <Invalid call to cumsum.*> cumsum (); |
5590
|
781 |
|
782 %% test/octave.test/arith/cumsum-4.m |
5955
|
783 %!assert (all (cumsum ([1, 2; 3, 4], 1) == [1, 2; 4, 6])); |
|
784 %!assert (all (cumsum ([1, 2; 3, 4], 2) == [1, 3; 3, 7])); |
5590
|
785 |
|
786 %% test/octave.test/arith/cumprod-1.m |
5955
|
787 %!assert (cumprod ([1, 2, 3]) == [1, 2, 6]); |
|
788 %!assert (cumprod ([-1; -2; -3]) == [-1; 2; -6]); |
|
789 %!assert (cumprod ([i, 2+i, -3+2i, 4]) == [i, -1+2i, -1-8i, -4-32i]); |
5590
|
790 |
|
791 %% test/octave.test/arith/cumprod-2.m |
|
792 %!assert(all (all (cumprod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]) |
|
793 %! == [1, 2, 3; i, 4i, 9i; -1+i, -8+8i, -27+27i]))); |
|
794 |
|
795 %% test/octave.test/arith/cumprod-3.m |
5751
|
796 %!error <Invalid call to cumprod.*> cumprod (); |
5590
|
797 |
|
798 %% test/octave.test/arith/cumprod-4.m |
5955
|
799 %!assert (all (cumprod ([2, 3; 4, 5], 1) == [2, 3; 8, 15])); |
|
800 %!assert (all (cumprod ([2, 3; 4, 5], 2) == [2, 6; 4, 20])); |
5590
|
801 |
|
802 %% test/octave.test/arith/sumsq-1.m |
|
803 %!assert(sumsq ([1, 2, 3]) == 14 && sumsq ([-1; -2; 4i]) == 21); |
|
804 |
|
805 %% test/octave.test/arith/sumsq-2.m |
|
806 %!assert(all (all (sumsq ([1, 2, 3; 2, 3, 4; 4i, 6i, 2]) == [21, 49, 29]))); |
|
807 |
|
808 %% test/octave.test/arith/sumsq-3.m |
5751
|
809 %!error <Invalid call to sumsq.*> sumsq (); |
5590
|
810 |
|
811 %% test/octave.test/arith/sumsq-4.m |
5955
|
812 %!assert (all (sumsq ([1, 2; 3, 4], 1) == [10, 20])); |
|
813 %!assert (all (sumsq ([1, 2; 3, 4], 2) == [5; 25])); |
5590
|
814 |
|
815 %% test/octave.test/arith/bincoeff-1.m |
|
816 %!assert(bincoeff (5, 2) == 10 && bincoeff (50, 6) == 15890700); |
|
817 |
|
818 %% test/octave.test/arith/bincoeff-2.m |
|
819 %!error bincoeff (); |
|
820 |
|
821 %% test/octave.test/arith/bincoeff-3.m |
|
822 %!error bincoeff (1, 2, 3); |
|
823 |