diff -r 20e2ceceaa7a scripts/elfun/acot.m --- a/scripts/elfun/acot.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/acot.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,17 @@ function w = acot (z) w = atan (1./z); endfunction + +%!test +%! rt2 = sqrt (2); +%! rt3 = sqrt (3); +%! x = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3]; +%! v = [pi/6, pi/4, pi/3, pi/2, -pi/3, -pi/4, -pi/6]; +%! assert(all (abs (acot (x) - v) < sqrt (eps)) +%! +%! ); + +%!error acot (); + +%!error acot (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/acoth.m --- a/scripts/elfun/acoth.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/acoth.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,15 @@ function w = acoth (z) w = atanh (1 ./ z); endfunction + +%!test +%! rt2 = sqrt (2); +%! rt3 = sqrt (3); +%! v = -i*[pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6]; +%! x = i*[rt3, 1, rt3/3, -rt3/3, -1, -rt3]; +%! assert(all (abs (acoth (x) - v) < sqrt (eps))); + +%!error acoth (); + +%!error acoth (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/acsc.m --- a/scripts/elfun/acsc.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/acsc.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,16 @@ function w = acsc (z) w = asin (1 ./ z); endfunction + +%!test +%! rt2 = sqrt (2); +%! rt3 = sqrt (3); +%! v = [pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6]; +%! x = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2]; +%! assert(all (abs (acsc (x) - v) < sqrt (eps)) +%! ); + +%!error acsc (); + +%!error acsc (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/acsch.m --- a/scripts/elfun/acsch.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/acsch.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,14 @@ function w = acsch (z) w = asinh (1 ./ z); endfunction + +%!test +%! v = [pi/2*i, -pi/2*i]; +%! x = [-i, i]; +%! assert(all (abs (acsch (x) - v) < sqrt (eps)) +%! ); + +%!error acsch (); + +%!error acsch (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/asec.m --- a/scripts/elfun/asec.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/asec.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,17 @@ function w = asec (z) w = acos (1 ./ z); endfunction + +%!test +%! rt2 = sqrt (2); +%! rt3 = sqrt (3); +%! v = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; +%! x = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1]; +%! assert(all (abs (asec (x) - v) < sqrt (eps)) +%! +%! ); + +%!error asec (); + +%!error asec (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/asech.m --- a/scripts/elfun/asech.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/asech.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,14 @@ function w = asech (z) w = acosh (1 ./ z); endfunction + +%!test +%! v = [0, pi*i]; +%! x = [1, -1]; +%! assert(all (abs (asech (x) - v) < sqrt (eps)) +%! ); + +%!error asech (); + +%!error asech (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/cot.m --- a/scripts/elfun/cot.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/cot.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,15 @@ function w = cot (z) w = 1 ./ tan(z); endfunction + +%!test +%! rt2 = sqrt (2); +%! rt3 = sqrt (3); +%! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6]; +%! v = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3]; +%! assert(all (abs (cot (x) - v) < sqrt (eps))); + +%!error cot (); + +%!error cot (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/coth.m --- a/scripts/elfun/coth.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/coth.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,13 @@ function w = coth (z) w = 1 ./ tanh (z); endfunction + +%!test +%! x = [pi/2*i, 3*pi/2*i]; +%! v = [0, 0]; +%! assert(all (abs (coth (x) - v) < sqrt (eps))); + +%!error coth (); + +%!error coth (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/csc.m --- a/scripts/elfun/csc.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/csc.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,15 @@ function w = csc (z) w = 1 ./ sin(z); endfunction + +%!test +%! rt2 = sqrt (2); +%! rt3 = sqrt (3); +%! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6]; +%! v = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2]; +%! assert(all (abs (csc (x) - v) < sqrt (eps))); + +%!error csc (); + +%!error csc (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/csch.m --- a/scripts/elfun/csch.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/csch.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,13 @@ function w = csch (z) w = 1 ./ sinh(z); endfunction + +%!test +%! x = [pi/2*i, 3*pi/2*i]; +%! v = [-i, i]; +%! assert(all (abs (csch (x) - v) < sqrt (eps))); + +%!error csch (); + +%!error csch (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/lcm.m --- a/scripts/elfun/lcm.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/lcm.m Tue Jan 15 21:11:54 2008 +0100 @@ -93,3 +93,12 @@ function l = lcm (varargin) endif endfunction + +%!assert(lcm (3, 5, 7, 15) == lcm ([3, 5, 7, 15]) && lcm ([3, 5, 7,15]) == 105); + +%!error lcm (); + +%!test +%! s.a = 1; +%! fail("lcm (s)"); + diff -r 20e2ceceaa7a scripts/elfun/sec.m --- a/scripts/elfun/sec.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/sec.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,15 @@ function w = sec (z) w = 1 ./ cos(z); endfunction + +%!test +%! rt2 = sqrt (2); +%! rt3 = sqrt (3); +%! x = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; +%! v = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1]; +%! assert(all (abs (sec (x) - v) < sqrt (eps))); + +%!error sec (); + +%!error sec (1, 2); + diff -r 20e2ceceaa7a scripts/elfun/sech.m --- a/scripts/elfun/sech.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/elfun/sech.m Tue Jan 15 21:11:54 2008 +0100 @@ -33,3 +33,13 @@ if (nargin != 1) w = 1 ./ cosh(z); endfunction + +%!test +%! x = [0, pi*i]; +%! v = [1, -1]; +%! assert(all (abs (sech (x) - v) < sqrt (eps))); + +%!error sech (); + +%!error sech (1, 2); + diff -r 20e2ceceaa7a scripts/general/rem.m --- a/scripts/general/rem.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/general/rem.m Tue Jan 15 21:11:54 2008 +0100 @@ -53,3 +53,17 @@ function r = rem (x, y) endif endfunction + +%!assert(all (all (rem ([1, 2, 3; -1, -2, -3], 2) == [1, 0, 1; -1, 0, -1]))); + +%!assert(all (all (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3)) +%! == [1, 0, 1; -1, 0, -1]))); + +%!error rem (); + +%!error rem (1, 2, 3); + +%!error rem ([1, 2], [3, 4, 5]); + +%!error rem (i, 1); + diff -r 20e2ceceaa7a scripts/miscellaneous/bincoeff.m --- a/scripts/miscellaneous/bincoeff.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/miscellaneous/bincoeff.m Tue Jan 15 21:11:54 2008 +0100 @@ -102,3 +102,10 @@ endfunction %!assert(bincoeff(4,2), 6) %!assert(bincoeff(2,4), 0) %!assert(bincoeff(0.4,2), -.12, 8*eps) + +%!assert(bincoeff (5, 2) == 10 && bincoeff (50, 6) == 15890700); + +%!error bincoeff (); + +%!error bincoeff (1, 2, 3); + diff -r 20e2ceceaa7a scripts/miscellaneous/xor.m --- a/scripts/miscellaneous/xor.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/miscellaneous/xor.m Tue Jan 15 21:11:54 2008 +0100 @@ -42,3 +42,13 @@ function z = xor (x, y) endif endfunction + +%!assert((xor ([1, 1, 0, 0], [0, 1, 0, 1]) == [1, 0, 0, 1] +%! && xor ([i, i, 0, 0], [1, 0, 1, 0]) == [0, 1, 1, 0])); + +%!assert(all (all (xor (eye (2), fliplr (eye (2))) == ones (2)))); + +%!error xor (); + +%!error xor (1, 2, 3); + diff -r 20e2ceceaa7a scripts/specfun/beta.m --- a/scripts/specfun/beta.m Tue Jan 15 20:38:04 2008 +0100 +++ b/scripts/specfun/beta.m Tue Jan 15 21:11:54 2008 +0100 @@ -48,3 +48,16 @@ function retval = beta (a, b) retval = exp (gammaln (a) + gammaln (b) - gammaln (a+b)); endfunction + +%!test +%! a=[1, 1.5, 2, 3]; +%! b=[4, 3, 2, 1]; +%! v1=beta(a,b); +%! v2=beta(b,a); +%! v3=gamma(a).*gamma(b)./gamma(a+b); +%! assert(all(abs(v1-v2) min (1, 2, 3, 4); - -%% test/octave.test/arith/pow2-1.m -%!test -%! x = [3, 0, -3]; -%! v = [8, 1, .125]; -%! assert(all (abs (pow2 (x) - v) < sqrt (eps))); - -%% test/octave.test/arith/pow2-2.m -%!test -%! x = [3, 0, -3, 4, 0, -4, 5, 0, -5]; -%! y = [-2, -2, -2, 1, 1, 1, 3, 3, 3]; -%! z = x .* (2 .^ y); -%! assert(all (abs (pow2 (x,y) - z) < sqrt (eps)) -%! ); - -%% test/octave.test/arith/pow2-3.m -%!error pow2(); - -%% test/octave.test/arith/rem-1.m -%!assert(all (all (rem ([1, 2, 3; -1, -2, -3], 2) == [1, 0, 1; -1, 0, -1]))); - -%% test/octave.test/arith/rem-2.m -%!assert(all (all (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3)) -%! == [1, 0, 1; -1, 0, -1]))); - -%% test/octave.test/arith/rem-3.m -%!error rem (); - -%% test/octave.test/arith/rem-4.m -%!error rem (1, 2, 3); - -%% test/octave.test/arith/rem-5.m -%!error rem ([1, 2], [3, 4, 5]); - -%% test/octave.test/arith/rem-6.m -%!error rem (i, 1); %% test/octave.test/arith/round-1.m %!assert((round (1) == 1 && round (1.1) == 1 && round (5.5) == 6 @@ -274,19 +213,6 @@ %% test/octave.test/arith/abs-4.m %!error abs (1, 2); - -%% test/octave.test/arith/xor-1.m -%!assert((xor ([1, 1, 0, 0], [0, 1, 0, 1]) == [1, 0, 0, 1] -%! && xor ([i, i, 0, 0], [1, 0, 1, 0]) == [0, 1, 1, 0])); - -%% test/octave.test/arith/xor-2.m -%!assert(all (all (xor (eye (2), fliplr (eye (2))) == ones (2)))); - -%% test/octave.test/arith/xor-3.m -%!error xor (); - -%% test/octave.test/arith/xor-4.m -%!error xor (1, 2, 3); %% test/octave.test/arith/arg-1.m %!assert(arg (1) == 0 && arg (i) == pi/2 && arg (-1) == pi && arg (-i) == -pi/2); @@ -354,15 +280,6 @@ %% test/octave.test/arith/log10-3.m %!error log10 (1, 2); -%% test/octave.test/arith/log2-1.m -%!assert(all (abs (log2 ([1/4, 1/2, 1, 2, 4]) - [-2, -1, 0, 1, 2]) < sqrt (eps))); - -%% test/octave.test/arith/log2-2.m -%!error log2 (); - -%% test/octave.test/arith/log2-3.m -%!error log2 (1, 2); - %% test/octave.test/arith/sin-1.m %!test %! rt2 = sqrt (2); @@ -404,48 +321,6 @@ %% test/octave.test/arith/tan-3.m %!error tan (1, 2); - -%% test/octave.test/arith/sec-1.m -%!test -%! rt2 = sqrt (2); -%! rt3 = sqrt (3); -%! x = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; -%! v = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1]; -%! assert(all (abs (sec (x) - v) < sqrt (eps))); - -%% test/octave.test/arith/sec-2.m -%!error sec (); - -%% test/octave.test/arith/sec-3.m -%!error sec (1, 2); - -%% test/octave.test/arith/csc-1.m -%!test -%! rt2 = sqrt (2); -%! rt3 = sqrt (3); -%! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6]; -%! v = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2]; -%! assert(all (abs (csc (x) - v) < sqrt (eps))); - -%% test/octave.test/arith/csc-2.m -%!error csc (); - -%% test/octave.test/arith/csc-3.m -%!error csc (1, 2); - -%% test/octave.test/arith/cot-1.m -%!test -%! rt2 = sqrt (2); -%! rt3 = sqrt (3); -%! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6]; -%! v = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3]; -%! assert(all (abs (cot (x) - v) < sqrt (eps))); - -%% test/octave.test/arith/cot-2.m -%!error cot (); - -%% test/octave.test/arith/cot-3.m -%!error cot (1, 2); %% test/octave.test/arith/asin-1.m %!test @@ -495,53 +370,6 @@ %% test/octave.test/arith/atan-3.m %!error atan (1, 2); -%% test/octave.test/arith/asec-1.m -%!test -%! rt2 = sqrt (2); -%! rt3 = sqrt (3); -%! v = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; -%! x = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1]; -%! assert(all (abs (asec (x) - v) < sqrt (eps)) -%! -%! ); - -%% test/octave.test/arith/asec-2.m -%!error asec (); - -%% test/octave.test/arith/asec-3.m -%!error asec (1, 2); - -%% test/octave.test/arith/acsc-1.m -%!test -%! rt2 = sqrt (2); -%! rt3 = sqrt (3); -%! v = [pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6]; -%! x = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2]; -%! assert(all (abs (acsc (x) - v) < sqrt (eps)) -%! ); - -%% test/octave.test/arith/acsc-2.m -%!error acsc (); - -%% test/octave.test/arith/acsc-3.m -%!error acsc (1, 2); - -%% test/octave.test/arith/acot-1.m -%!test -%! rt2 = sqrt (2); -%! rt3 = sqrt (3); -%! x = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3]; -%! v = [pi/6, pi/4, pi/3, pi/2, -pi/3, -pi/4, -pi/6]; -%! assert(all (abs (acot (x) - v) < sqrt (eps)) -%! -%! ); - -%% test/octave.test/arith/acot-2.m -%!error acot (); - -%% test/octave.test/arith/acot-3.m -%!error acot (1, 2); - %% test/octave.test/arith/sinh-1.m %!test %! x = [0, pi/2*i, pi*i, 3*pi/2*i]; @@ -577,42 +405,6 @@ %% test/octave.test/arith/tanh-3.m %!error tanh (1, 2); - -%% test/octave.test/arith/sech-1.m -%!test -%! x = [0, pi*i]; -%! v = [1, -1]; -%! assert(all (abs (sech (x) - v) < sqrt (eps))); - -%% test/octave.test/arith/sech-2.m -%!error sech (); - -%% test/octave.test/arith/sech-3.m -%!error sech (1, 2); - -%% test/octave.test/arith/csch-1.m -%!test -%! x = [pi/2*i, 3*pi/2*i]; -%! v = [-i, i]; -%! assert(all (abs (csch (x) - v) < sqrt (eps))); - -%% test/octave.test/arith/csch-2.m -%!error csch (); - -%% test/octave.test/arith/csch-3.m -%!error csch (1, 2); - -%% test/octave.test/arith/coth-1.m -%!test -%! x = [pi/2*i, 3*pi/2*i]; -%! v = [0, 0]; -%! assert(all (abs (coth (x) - v) < sqrt (eps))); - -%% test/octave.test/arith/coth-2.m -%!error coth (); - -%% test/octave.test/arith/coth-3.m -%!error coth (1, 2); %% test/octave.test/arith/asinh-1.m %!test @@ -652,46 +444,6 @@ %% test/octave.test/arith/atanh-3.m %!error atanh (1, 2); - -%% test/octave.test/arith/asech-1.m -%!test -%! v = [0, pi*i]; -%! x = [1, -1]; -%! assert(all (abs (asech (x) - v) < sqrt (eps)) -%! ); - -%% test/octave.test/arith/asech-2.m -%!error asech (); - -%% test/octave.test/arith/asech-3.m -%!error asech (1, 2); - -%% test/octave.test/arith/acsch-1.m -%!test -%! v = [pi/2*i, -pi/2*i]; -%! x = [-i, i]; -%! assert(all (abs (acsch (x) - v) < sqrt (eps)) -%! ); - -%% test/octave.test/arith/acsch-2.m -%!error acsch (); - -%% test/octave.test/arith/acsch-3.m -%!error acsch (1, 2); - -%% test/octave.test/arith/acoth-1.m -%!test -%! rt2 = sqrt (2); -%! rt3 = sqrt (3); -%! v = -i*[pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6]; -%! x = i*[rt3, 1, rt3/3, -rt3/3, -1, -rt3]; -%! assert(all (abs (acoth (x) - v) < sqrt (eps))); - -%% test/octave.test/arith/acoth-2.m -%!error acoth (); - -%% test/octave.test/arith/acoth-3.m -%!error acoth (1, 2); %% test/octave.test/arith/atan2-1.m %!test @@ -812,12 +564,4 @@ %!assert (all (sumsq ([1, 2; 3, 4], 1) == [10, 20])); %!assert (all (sumsq ([1, 2; 3, 4], 2) == [5; 25])); -%% test/octave.test/arith/bincoeff-1.m -%!assert(bincoeff (5, 2) == 10 && bincoeff (50, 6) == 15890700); -%% test/octave.test/arith/bincoeff-2.m -%!error bincoeff (); - -%% test/octave.test/arith/bincoeff-3.m -%!error bincoeff (1, 2, 3); -