changeset 6239:82185e38eea8

[project @ 2007-01-10 22:53:58 by jwe]
author jwe
date Wed, 10 Jan 2007 22:53:59 +0000
parents 3ecd8d2c5654
children 3e5a3b5fd40e
files scripts/ChangeLog scripts/elfun/acosd.m scripts/elfun/acotd.m scripts/elfun/acscd.m scripts/elfun/asecd.m scripts/elfun/asind.m scripts/elfun/atand.m scripts/elfun/cosd.m scripts/elfun/cotd.m scripts/elfun/cscd.m scripts/elfun/secd.m scripts/elfun/sind.m scripts/elfun/tand.m
diffstat 13 files changed, 417 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Wed Jan 10 21:13:22 2007 +0000
+++ b/scripts/ChangeLog	Wed Jan 10 22:53:59 2007 +0000
@@ -1,3 +1,10 @@
+2007-01-10  David Bateman  <dbateman@free.fr>
+
+	* elfun/acosd.m, elfun/acotd.m, elfun/acscd.m, elfun/asecd.m,
+	elfun/asind.m, elfun/atand.m, elfun/cosd.m, elfun/cotd.m,
+	elfun/cscd.m, elfun/secd.m, elfun/sind.m, elfun/tand.m:
+	New files.
+
 2007-01-09  Søren Hauberg  <hauberg@gmail.com>
 
          * pkg/pkg.m: Allow filenames to contain glob patterns.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/acosd.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,32 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} acosd (@var{x})
+## Compute the inverse cosine of an angle in degrees.
+## @seealso{acos, cosd, asecd}
+## @end deftypefn
+
+function y = acosd (x)
+  if (nargin != 1)
+    print_usage ();
+  endif
+  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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/acotd.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,32 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} acotd (@var{x})
+## Compute the inverse cotangent of an angle in degrees.
+## @seealso{atan, tand}
+## @end deftypefn
+
+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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/acscd.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,32 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} acscd (@var{x})
+## Compute the inverse cosecant of an angle in degrees.
+## @seealso{acsc, cscd, asecd}
+## @end deftypefn
+
+function y = acscd (x)
+  if (nargin != 1)
+    print_usage ();
+  endif
+  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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/asecd.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,32 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} asecd (@var{x})
+## Compute inverse secant in degrees.
+## @seealso{asec, secd, acscd}
+## @end deftypefn
+
+function y = asecd (x)
+  if (nargin != 1)
+    print_usage ();
+  endif
+  y = asec (x) .* 180 ./ pi;
+endfunction;
+
+%!error(asecd())
+%!error(asecd(1,2))
+%!assert(asecd(0:10:90),180./pi.*asec(0:10:90),-10*eps)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/asind.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,32 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} asind (@var{x})
+## Compute the inverse sine of an angle in degrees.
+## @seealso{asin, sind, acosd}
+## @end deftypefn
+
+function y = asind (x)
+  if (nargin != 1)
+    print_usage ();
+  endif
+  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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/atand.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,32 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} atand (@var{x})
+## Compute the inverse tangent of an angle in degrees.
+## @seealso{acot, tand}
+## @end deftypefn
+
+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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/cosd.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,38 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} cosd (@var{x})
+## Compute the cosine of an angle in degrees.  Returns zero in elements
+## for which @code{(@var{x}-90)/180} is an integer.
+## @seealso{cos, sind, tand, acosd, asind, atand}
+## @end deftypefn
+
+function y = cosd (x)
+  if (nargin != 1)
+    print_usage ();
+  endif
+  I = x / 180;
+  y = cos (I .* pi);
+  I = I + 0.5;
+  y(I == round (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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/cotd.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,34 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} cotd (@var{x})
+## Compute the cotangent of an angle in degrees.
+## @seealso{cot, tand}
+## @end deftypefn
+
+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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/cscd.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,35 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} cscd (@var{x})
+## Compute the cosecant of an angle in degrees.
+## @seealso{csc, secd, sind, cosd}
+## @end deftypefn
+
+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)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/secd.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,34 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} secd (@var{x})
+## Compute the secant of an angle in degrees.
+## @seealso{sec, cscd, sind, cosd}
+## @end deftypefn
+
+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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/sind.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,37 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} sind (@var{x})
+## Compute the sine of each element of @var{x}.  Returns zero in elements
+## for which @code{@var{x}/180} is an integer.
+## @seealso{sin, cosd, tand, acosd, asind, atand}
+## @end deftypefn
+
+function y = sind (x)
+  if (nargin != 1)
+    print_usage ();
+  endif
+  I = x / 180;
+  y = sin (I .* pi);
+  y(I == round (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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/elfun/tand.m	Wed Jan 10 22:53:59 2007 +0000
@@ -0,0 +1,40 @@
+## Copyright (C) 2006 David Bateman <dbateman@free.fr>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} tand (@var{x})
+## Compute the tangent of an angle in degrees.  Returns zero for elements
+## of for which @code{@var{x}/180} is an integer and @code{Inf} for elements
+## where @code{(@var{x}-90}/180} is an integer.
+## @seealso{tan, cosd, sind, acosd, asind, atand}
+## @end deftypefn
+
+function y = tand (x)
+  if (nargin != 1)
+    print_usage ();
+  endif
+  I0 = x / 180;
+  I90 = (x-90) / 180;
+  y = tan (I0 .* pi);
+  y(I0 == round (I0) & finite (I0)) = 0;
+  y(I90 == round (I90) & finite (I90)) = Inf;
+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)