Mercurial > hg > octave-max
changeset 14220:5a13a75c2457
Use Octave spacing conventions for scripts in elfun/ directory.
* acosd.m, acot.m, acotd.m, acoth.m, acsc.m, acscd.m, acsch.m, asec.m, asecd.m,
asech.m, asind.m, atand.m, cosd.m, cot.m, cotd.m, coth.m, csc.m, cscd.m,
csch.m, sec.m, secd.m, sech.m, sind.m, tand.m: Use Octave spacing conventions.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 18 Jan 2012 21:17:14 -0800 |
parents | addec4a8a787 |
children | b03b15d507d4 |
files | scripts/elfun/acosd.m scripts/elfun/acot.m scripts/elfun/acotd.m scripts/elfun/acoth.m scripts/elfun/acsc.m scripts/elfun/acscd.m scripts/elfun/acsch.m scripts/elfun/asec.m scripts/elfun/asecd.m scripts/elfun/asech.m scripts/elfun/asind.m scripts/elfun/atand.m scripts/elfun/cosd.m scripts/elfun/cot.m scripts/elfun/cotd.m scripts/elfun/coth.m scripts/elfun/csc.m scripts/elfun/cscd.m scripts/elfun/csch.m scripts/elfun/sec.m scripts/elfun/secd.m scripts/elfun/sech.m scripts/elfun/sind.m scripts/elfun/tand.m |
diffstat | 24 files changed, 166 insertions(+), 107 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/elfun/acosd.m +++ b/scripts/elfun/acosd.m @@ -25,12 +25,17 @@ ## Author: David Bateman <dbateman@free.fr> function y = acosd (x) + if (nargin != 1) print_usage (); endif - y = acos(x) .* 180 ./ pi; + + y = acos (x) .* 180 ./ pi; + endfunction -%!error(acosd()) -%!error(acosd(1,2)) -%!assert(acosd(0:0.1:1),180/pi*acos(0:0.1:1),-10*eps) + +%!assert (acosd (0:0.1:1), 180/pi*acos (0:0.1:1), -10*eps) + +%!error acosd () +%!error acosd (1, 2)
--- a/scripts/elfun/acot.m +++ b/scripts/elfun/acot.m @@ -30,18 +30,18 @@ print_usage (); endif - y = atan (1./x); + y = atan (1 ./ x); 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))); +%! assert (all (abs (acot (x) - v) < sqrt (eps))); -%!error acot (); +%!error acot () +%!error acot (1, 2) -%!error acot (1, 2); -
--- a/scripts/elfun/acotd.m +++ b/scripts/elfun/acotd.m @@ -25,12 +25,17 @@ ## Author: David Bateman <dbateman@free.fr> function y = acotd (x) + if (nargin != 1) print_usage (); endif + y = atand (1 ./ x); + endfunction -%!error(acotd()) -%!error(acotd(1,2)) -%!assert(acotd(0:10:90),180./pi.*acot(0:10:90),-10*eps) + +%!assert (acotd (0:10:90), 180./pi.*acot (0:10:90), -10*eps) + +%!error acotd () +%!error acotd (1, 2)
--- a/scripts/elfun/acoth.m +++ b/scripts/elfun/acoth.m @@ -34,14 +34,14 @@ 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))); +%! assert (all (abs (acoth (x) - v) < sqrt (eps))); -%!error acoth (); +%!error acoth () +%!error acoth (1, 2) -%!error acoth (1, 2); -
--- a/scripts/elfun/acsc.m +++ b/scripts/elfun/acsc.m @@ -34,14 +34,14 @@ 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))); +%! assert (all (abs (acsc (x) - v) < sqrt (eps))); -%!error acsc (); +%!error acsc () +%!error acsc (1, 2) -%!error acsc (1, 2); -
--- a/scripts/elfun/acscd.m +++ b/scripts/elfun/acscd.m @@ -25,12 +25,17 @@ ## Author: David Bateman <dbateman@free.fr> function y = acscd (x) + if (nargin != 1) print_usage (); endif - y = acsc(x) .* 180 ./ pi; + + y = acsc (x) .* 180 ./ pi; + endfunction -%!error(acscd()) -%!error(acscd(1,2)) -%!assert(acscd(0:10:90),180/pi*acsc(0:10:90),-10*eps) + +%!assert (acscd (0:10:90), 180/pi*acsc (0:10:90), -10*eps) + +%!error acscd () +%!error acscd (1, 2)
--- a/scripts/elfun/acsch.m +++ b/scripts/elfun/acsch.m @@ -34,12 +34,12 @@ endfunction + %!test %! v = [pi/2*i, -pi/2*i]; %! x = [-i, i]; -%! assert(all (abs (acsch (x) - v) < sqrt (eps))); +%! assert (all (abs (acsch (x) - v) < sqrt (eps))); -%!error acsch (); +%!error acsch () +%!error acsch (1, 2) -%!error acsch (1, 2); -
--- a/scripts/elfun/asec.m +++ b/scripts/elfun/asec.m @@ -34,13 +34,13 @@ 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))); +%! assert (all (abs (asec (x) - v) < sqrt (eps))); -%!error asec (); - -%!error asec (1, 2); +%!error asec () +%!error asec (1, 2)
--- a/scripts/elfun/asecd.m +++ b/scripts/elfun/asecd.m @@ -25,12 +25,17 @@ ## Author: David Bateman <dbateman@free.fr> function y = asecd (x) + if (nargin != 1) print_usage (); endif + y = asec (x) .* 180 ./ pi; -endfunction; + +endfunction -%!error(asecd()) -%!error(asecd(1,2)) -%!assert(asecd(0:10:90),180./pi.*asec(0:10:90),-10*eps) + +%!assert (asecd (0:10:90), 180./pi.*asec (0:10:90), -10*eps) + +%!error asecd () +%!error asecd (1, 2)
--- a/scripts/elfun/asech.m +++ b/scripts/elfun/asech.m @@ -34,12 +34,12 @@ endfunction + %!test %! v = [0, pi*i]; %! x = [1, -1]; -%! assert(all (abs (asech (x) - v) < sqrt (eps))); +%! assert (all (abs (asech (x) - v) < sqrt (eps))); -%!error asech (); +%!error asech () +%!error asech (1, 2) -%!error asech (1, 2); -
--- a/scripts/elfun/asind.m +++ b/scripts/elfun/asind.m @@ -25,12 +25,17 @@ ## Author: David Bateman <dbateman@free.fr> function y = asind (x) + if (nargin != 1) print_usage (); endif - y = asin(x) .* 180 ./ pi; + + y = asin (x) .* 180 ./ pi; + endfunction -%!error(asind()) -%!error(asind(1,2)) -%!assert(asind(0:0.1:1),180/pi*asin(0:0.1:1),-10*eps) + +%!assert (asind (0:0.1:1), 180/pi*asin (0:0.1:1), -10*eps) + +%!error asind () +%!error asind (1, 2)
--- a/scripts/elfun/atand.m +++ b/scripts/elfun/atand.m @@ -25,12 +25,17 @@ ## Author: David Bateman <dbateman@free.fr> function y = atand (x) + if (nargin != 1) print_usage (); endif + y = 180 ./ pi .* atan (x); + endfunction -%!error(atand()) -%!error(atand(1,2)) -%!assert(atand(0:10:90),180./pi.*atan(0:10:90),-10*eps) + +%!assert (atand (0:10:90), 180./pi.*atan (0:10:90), -10*eps) + +%!error atand () +%!error atand (1, 2)
--- a/scripts/elfun/cosd.m +++ b/scripts/elfun/cosd.m @@ -26,17 +26,22 @@ ## Author: David Bateman <dbateman@free.fr> function y = cosd (x) + if (nargin != 1) print_usage (); endif + I = x / 180; y = cos (I .* pi); I = I + 0.5; y(I == fix (I) & finite (I)) = 0; + endfunction -%!error(cosd()) -%!error(cosd(1,2)) -%!assert(cosd(0:10:80),cos(pi*[0:10:80]/180),-10*eps) -%!assert(cosd([0,180,360]) != 0) -%!assert(cosd([90,270]) == 0) + +%!assert (cosd (0:10:80), cos (pi*[0:10:80]/180), -10*eps) +%!assert (cosd ([0, 180, 360]) != 0) +%!assert (cosd ([90, 270]) == 0) + +%!error cosd () +%!error cosd (1, 2)
--- a/scripts/elfun/cot.m +++ b/scripts/elfun/cot.m @@ -30,18 +30,18 @@ print_usage (); endif - y = 1 ./ tan(x); + y = 1 ./ tan (x); 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))); +%! assert (all (abs (cot (x) - v) < sqrt (eps))); -%!error cot (); +%!error cot () +%!error cot (1, 2) -%!error cot (1, 2); -
--- a/scripts/elfun/cotd.m +++ b/scripts/elfun/cotd.m @@ -25,14 +25,19 @@ ## Author: David Bateman <dbateman@free.fr> function y = cotd (x) + if (nargin != 1) print_usage (); endif + y = 1 ./ tand (x); + endfunction -%!error(cotd()) -%!error(cotd(1,2)) -%!assert(cotd(10:10:80),cot(pi*[10:10:80]/180),-10*eps) -%!assert(cotd([0,180,360]) == Inf) -%!assert(cotd([90,270]) == 0) + +%!assert (cotd (10:10:80), cot (pi*[10:10:80]/180), -10*eps) +%!assert (cotd ([0, 180, 360]) == Inf) +%!assert (cotd ([90, 270]) == 0) + +%!error cotd () +%!error cotd (1, 2)
--- a/scripts/elfun/coth.m +++ b/scripts/elfun/coth.m @@ -34,12 +34,12 @@ endfunction + %!test %! x = [pi/2*i, 3*pi/2*i]; %! v = [0, 0]; -%! assert(all (abs (coth (x) - v) < sqrt (eps))); +%! assert (all (abs (coth (x) - v) < sqrt (eps))); -%!error coth (); +%!error coth () +%!error coth (1, 2) -%!error coth (1, 2); -
--- a/scripts/elfun/csc.m +++ b/scripts/elfun/csc.m @@ -30,18 +30,18 @@ print_usage (); endif - y = 1 ./ sin(x); + y = 1 ./ sin (x); 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))); +%! assert (all (abs (csc (x) - v) < sqrt (eps))); -%!error csc (); +%!error csc () +%!error csc (1, 2) -%!error csc (1, 2); -
--- a/scripts/elfun/cscd.m +++ b/scripts/elfun/cscd.m @@ -25,15 +25,19 @@ ## Author: David Bateman <dbateman@free.fr> function y = cscd (x) + if (nargin != 1) print_usage (); endif + y = 1 ./ sind (x); + endfunction -%!error(cscd()) -%!error(cscd(1,2)) -%!assert(cscd(10:10:90),csc(pi*[10:10:90]/180),-10*eps) -%!assert(cscd([0,180,360]) == Inf) -%!assert(cscd([90,270]) != Inf) +%!assert (cscd (10:10:90), csc (pi*[10:10:90]/180), -10*eps) +%!assert (cscd ([0, 180, 360]) == Inf) +%!assert (cscd ([90, 270]) != Inf) + +%!error cscd () +%!error cscd (1, 2)
--- a/scripts/elfun/csch.m +++ b/scripts/elfun/csch.m @@ -30,16 +30,16 @@ print_usage (); endif - y = 1 ./ sinh(x); + y = 1 ./ sinh (x); endfunction + %!test %! x = [pi/2*i, 3*pi/2*i]; %! v = [-i, i]; -%! assert(all (abs (csch (x) - v) < sqrt (eps))); +%! assert (all (abs (csch (x) - v) < sqrt (eps))); -%!error csch (); +%!error csch () +%!error csch (1, 2) -%!error csch (1, 2); -
--- a/scripts/elfun/sec.m +++ b/scripts/elfun/sec.m @@ -30,18 +30,18 @@ print_usage (); endif - y = 1 ./ cos(x); + y = 1 ./ cos (x); 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))); +%! assert (all (abs (sec (x) - v) < sqrt (eps))); -%!error sec (); +%!error sec () +%!error sec (1, 2) -%!error sec (1, 2); -
--- a/scripts/elfun/secd.m +++ b/scripts/elfun/secd.m @@ -25,14 +25,19 @@ ## Author: David Bateman <dbateman@free.fr> function y = secd (x) + if (nargin != 1) print_usage (); endif + y = 1 ./ cosd (x); + endfunction -%!error(secd()) -%!error(secd(1,2)) -%!assert(secd(0:10:80),sec(pi*[0:10:80]/180),-10*eps) -%!assert(secd([0,180,360]) != Inf) -%!assert(secd([90,270]) == Inf) + +%!assert (secd (0:10:80), sec (pi*[0:10:80]/180), -10*eps) +%!assert (secd ([0, 180, 360]) != Inf) +%!assert (secd ([90, 270]) == Inf) + +%!error secd () +%!error secd (1, 2)
--- a/scripts/elfun/sech.m +++ b/scripts/elfun/sech.m @@ -30,16 +30,16 @@ print_usage (); endif - y = 1 ./ cosh(x); + y = 1 ./ cosh (x); endfunction + %!test %! x = [0, pi*i]; %! v = [1, -1]; -%! assert(all (abs (sech (x) - v) < sqrt (eps))); +%! assert (all (abs (sech (x) - v) < sqrt (eps))); -%!error sech (); +%!error sech () +%!error sech (1, 2) -%!error sech (1, 2); -
--- a/scripts/elfun/sind.m +++ b/scripts/elfun/sind.m @@ -26,16 +26,21 @@ ## Author: David Bateman <dbateman@free.fr> function y = sind (x) + if (nargin != 1) print_usage (); endif + I = x / 180; y = sin (I .* pi); y(I == fix (I) & finite (I)) = 0; + endfunction -%!error(sind()) -%!error(sind(1,2)) -%!assert(sind(10:10:90),sin(pi*[10:10:90]/180),-10*eps) -%!assert(sind([0,180,360]) == 0) -%!assert(sind([90,270]) != 0) + +%!assert (sind (10:10:90), sin (pi*[10:10:90]/180), -10*eps) +%!assert (sind ([0, 180, 360]) == 0) +%!assert (sind ([90, 270]) != 0) + +%!error sind () +%!error sind (1, 2)
--- a/scripts/elfun/tand.m +++ b/scripts/elfun/tand.m @@ -27,18 +27,23 @@ ## Author: David Bateman <dbateman@free.fr> function y = tand (x) + if (nargin != 1) print_usage (); endif + I0 = x / 180; I90 = (x-90) / 180; y = tan (I0 .* pi); y(I0 == fix (I0) & finite (I0)) = 0; y(I90 == fix (I90) & finite (I90)) = Inf; -endfunction; + +endfunction + -%!error(tand()) -%!error(tand(1,2)) -%!assert(tand(10:10:80),tan(pi*[10:10:80]/180),-10*eps) -%!assert(tand([0,180,360]) == 0) -%!assert(tand([90,270]) == Inf) +%!assert (tand (10:10:80), tan (pi*[10:10:80]/180), -10*eps) +%!assert (tand ([0, 180, 360]) == 0) +%!assert (tand ([90, 270]) == Inf) + +%!error tand () +%!error tand (1, 2)