diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-05-04 09:51:10 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-05-04 09:51:10 +0000 |
commit | 54bc9378e016049dc0349409ed1e6e76fd14048f (patch) | |
tree | e5797bc7b1d4e9e2453ae38fb74fa155abf548ad | |
parent | 97f6ad335859f1ec2beab89ba5812da105713857 (diff) | |
download | mpfr-54bc9378e016049dc0349409ed1e6e76fd14048f.tar.gz |
Add functions mpfr_sech, mpfr_coth and mpfr_csch.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3526 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | coth.c | 37 | ||||
-rw-r--r-- | csch.c | 38 | ||||
-rw-r--r-- | mpfr.h | 4 | ||||
-rw-r--r-- | mpfr.texi | 7 | ||||
-rw-r--r-- | sech.c | 34 | ||||
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/tcot.c | 3 | ||||
-rw-r--r-- | tests/tcoth.c | 92 | ||||
-rw-r--r-- | tests/tcsch.c | 92 | ||||
-rw-r--r-- | tests/tsec.c | 2 | ||||
-rw-r--r-- | tests/tsech.c | 92 |
14 files changed, 402 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am index 716bb015c..4037737b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,13 +1,13 @@ AUTOMAKE_OPTIONS = gnu no-dependencies ansi2knr SUBDIRS = tests -EXTRA_DIST = BUGS FAQ.html VERSION generic.c round_raw_generic.c +EXTRA_DIST = BUGS FAQ.html VERSION generic.c round_raw_generic.c gen_inverse.h include_HEADERS = mpfr.h mpf2mpfr.h lib_LTLIBRARIES = libmpfr.la -libmpfr_la_SOURCES = mpfr.h mpf2mpfr.h mpfr-gmp.h mpfr-impl.h mpfr-longlong.h mpfr-test.h log_b2.h exceptions.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_si.c cmp_ui.c comparisons.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp10.c exp2.c exp3.c exp.c frac.c get_d.c get_exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c next.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c round_prec.c set.c setmax.c setmin.c set_d.c set_dfl_prec.c set_exp.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c powerof2.c gamma.c set_ld.c get_ld.c cbrt.c volatile.c fits_s.h fits_sshort.c fits_sint.c fits_slong.c fits_u.h fits_ushort.c fits_uint.c fits_ulong.c fits_uintmax.c fits_intmax.c get_si.c get_ui.c zeta.c cmp_d.c erf.c inits.c inits2.c clears.c sgn.c check.c sub1sp.c version.c mpn_exp.c mpfr-gmp.c mp_clz_tab.c sum.c add1sp.c free_cache.c si_op.c cmp_ld.c set_ui_2exp.c set_si_2exp.c set_uj.c set_sj.c get_sj.c get_uj.c get_z.c iszero.c cache.c sqr.c int_ceil_log2.c isqrt.c strtofr.c pow_z.c logging.c mulders.c get_f.c round_p.c erfc.c atan2.c subnormal.c const_catalan.c root.c gen_inverse.h sec.c csc.c cot.c eint.c +libmpfr_la_SOURCES = mpfr.h mpf2mpfr.h mpfr-gmp.h mpfr-impl.h mpfr-longlong.h mpfr-test.h log_b2.h exceptions.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_si.c cmp_ui.c comparisons.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp10.c exp2.c exp3.c exp.c frac.c get_d.c get_exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c next.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c round_prec.c set.c setmax.c setmin.c set_d.c set_dfl_prec.c set_exp.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c powerof2.c gamma.c set_ld.c get_ld.c cbrt.c volatile.c fits_s.h fits_sshort.c fits_sint.c fits_slong.c fits_u.h fits_ushort.c fits_uint.c fits_ulong.c fits_uintmax.c fits_intmax.c get_si.c get_ui.c zeta.c cmp_d.c erf.c inits.c inits2.c clears.c sgn.c check.c sub1sp.c version.c mpn_exp.c mpfr-gmp.c mp_clz_tab.c sum.c add1sp.c free_cache.c si_op.c cmp_ld.c set_ui_2exp.c set_si_2exp.c set_uj.c set_sj.c get_sj.c get_uj.c get_z.c iszero.c cache.c sqr.c int_ceil_log2.c isqrt.c strtofr.c pow_z.c logging.c mulders.c get_f.c round_p.c erfc.c atan2.c subnormal.c const_catalan.c root.c gen_inverse.h sec.c csc.c cot.c eint.c sech.c csch.c coth.c libmpfr_la_LIBADD = @LIBOBJS@ @@ -25,7 +25,7 @@ Changes from version 2.1.1 to version 2.2.0: - new functions mpfr_set_overflow, mpfr_set_underflow, mpfr_set_inexflag, mpfr_set_erangeflag, mpfr_set_nanflag, mpfr_erfc, mpfr_atan2, mpfr_pow_z, mpfr_subnormalize, mpfr_const_catalan, mpfr_sec, mpfr_csc, mpfr_cot, - mpfr_root, mpfr_eint, mpfr_get_f, + mpfr_root, mpfr_eint, mpfr_get_f, mpfr_sech, mpfr_csch, mpfr_coth, - new macro: MPFR_VERSION_STRING - Remove the exported MPFR variables from mpfr.h to mpfr-impl.h. (They were undocumented, so programs which respect the API still work). @@ -69,7 +69,6 @@ New functions to implement: - modf (to extract integer and fractional parts), suggested by Dmitry Antipov <dmitry.antipov@mail.ru> Thu, 13 Jun 2002 -- those from LIA: missing secant, cosecant, cotangent (trigo/hyperbolic) - mpfr_fmod (mpfr_t, mpfr_srcptr, mpfr_srcptr, mp_rnd_t) [suggested by Tomas Zahradnicky <tomas@24uSoftware.com>, 29 Nov 2003] Kevin: Might want to be called mpfr_mod, to match mpz_mod. @@ -0,0 +1,37 @@ +/* mpfr_coth - Hyperbolic cotangent function. + +Copyright 2005 Free Software Foundation, Inc. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +/* the hyperbolic cotangent is defined by coth(x) = 1/tanh(x) + coth (NaN) = NaN. + coth (+Inf) = 1 + coth (-Inf) = -1 + coth (+0) = +0. + coth (-0) = -0. +*/ + +#define FUNCTION mpfr_coth +#define INVERSE mpfr_tan +#define ACTION_NAN(y) do { MPFR_SET_NAN(y); MPFR_RET_NAN; } while (1) +#define ACTION_INF(y) return mpfr_set_si (y, MPFR_IS_POS(x) ? 1 : -1, GMP_RNDN) +#define ACTION_ZERO(y,x) do { MPFR_SET_SAME_SIGN(y,x); MPFR_SET_ZERO(y); \ + MPFR_RET(0); } while (1) + +#include "gen_inverse.h" @@ -0,0 +1,38 @@ +/* mpfr_csch - Hyperbolic cosecant function. + +Copyright 2005 Free Software Foundation, Inc. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +/* the hyperbolic cosecant is defined by csch(x) = 1/sinh(x). + csc (NaN) = NaN. + csc (+Inf) = 0+. + csc (-Inf) = 0-. + csc (+0) = +Inf. + csc (-0) = -Inf. +*/ + +#define FUNCTION mpfr_csch +#define INVERSE mpfr_sinh +#define ACTION_NAN(y) do { MPFR_SET_NAN(y); MPFR_RET_NAN; } while (1) +#define ACTION_INF(y) do { MPFR_SET_SAME_SIGN(y,x); MPFR_SET_ZERO (y); \ + MPFR_RET(0); } while (1) +#define ACTION_ZERO(y,x) do { MPFR_SET_SAME_SIGN(y,x); MPFR_SET_INF(y); \ + MPFR_RET(0); } while (1) + +#include "gen_inverse.h" @@ -476,6 +476,10 @@ __MPFR_DECLSPEC int mpfr_cosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t)); __MPFR_DECLSPEC int mpfr_sinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t)); __MPFR_DECLSPEC int mpfr_tanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t)); +__MPFR_DECLSPEC int mpfr_sech _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t)); +__MPFR_DECLSPEC int mpfr_csch _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t)); +__MPFR_DECLSPEC int mpfr_coth _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t)); + __MPFR_DECLSPEC int mpfr_acos _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t)); __MPFR_DECLSPEC int mpfr_asin _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t)); __MPFR_DECLSPEC int mpfr_atan _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t)); @@ -1297,6 +1297,13 @@ Set @var{rop} to the hyperbolic cosine, sine or tangent of @var{op}, rounded in the direction @var{rnd}. @end deftypefun +@deftypefun int mpfr_sech (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd}) +@deftypefunx int mpfr_csch (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd}) +@deftypefunx int mpfr_coth (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd}) +Set @var{rop} to the hyperbolic secant of @var{op}, cosecant of @var{op}, +cotangent of @var{op}, rounded in the direction @var{rnd}. +@end deftypefun + @deftypefun int mpfr_acosh (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd}) @deftypefunx int mpfr_asinh (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd}) @deftypefunx int mpfr_atanh (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd}) @@ -0,0 +1,34 @@ +/* mpfr_sech - Hyperbolic secant function = 1/cosh. + +Copyright 2005 Free Software Foundation, Inc. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +/* The hyperbolic secant function is defined by sech(x)=1/cosh(x): + csc (NaN) = NaN. + csc (+Inf) = csc (-Inf) = 0+. + csc (+0) = csc (-0) = 1. + */ + +#define FUNCTION mpfr_sech +#define INVERSE mpfr_cosh +#define ACTION_NAN(y) do { MPFR_SET_NAN(y); MPFR_RET_NAN; } while (1) +#define ACTION_INF(y) return mpfr_set_ui (y, 0, GMP_RNDN) +#define ACTION_ZERO(y,x) return mpfr_set_ui (y, 1, GMP_RNDN) + +#include "gen_inverse.h" diff --git a/tests/Makefile.am b/tests/Makefile.am index b95200bf1..6d481bd46 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr -check_PROGRAMS = tversion tinits tsgn tcheck tisnan texceptions tset_exp tset tabs tset_d tset_f tset_q tset_si tset_str tset_z tset_ld tset_sj tswap tcopysign tcmp tcmp2 tcmpabs tcmp_d tcmp_ld tcomparisons teq tadd tsub tmul tdiv tsub1sp tadd1sp tadd_ui tsub_ui tcmp_ui tdiv_ui tmul_ui tsqrt_ui tui_div tui_sub tgmpop tsi_op tmul_2exp tfma tsum tdim tminmax tnext tfits tget_d tget_d_2exp tget_z tget_str tget_sj tout_str tinp_str toutimpl tcan_round tround_prec tsqrt tconst_log2 tconst_pi tconst_euler trandom ttrunc trint tfrac texp texp2 texpm1 tlog tlog2 tlog10 tlog1p tpow tui_pow tpow3 tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic tasin tacos tcos tatan tsin ttan tsin_cos tagm thypot tfactorial tgamma terf tcbrt tzeta mpf_compat mpfr_compat reuse tsqr tstrtofr tpow_z tget_f tconst_catalan troot tsec tcsc tcot teint +check_PROGRAMS = tversion tinits tsgn tcheck tisnan texceptions tset_exp tset tabs tset_d tset_f tset_q tset_si tset_str tset_z tset_ld tset_sj tswap tcopysign tcmp tcmp2 tcmpabs tcmp_d tcmp_ld tcomparisons teq tadd tsub tmul tdiv tsub1sp tadd1sp tadd_ui tsub_ui tcmp_ui tdiv_ui tmul_ui tsqrt_ui tui_div tui_sub tgmpop tsi_op tmul_2exp tfma tsum tdim tminmax tnext tfits tget_d tget_d_2exp tget_z tget_str tget_sj tout_str tinp_str toutimpl tcan_round tround_prec tsqrt tconst_log2 tconst_pi tconst_euler trandom ttrunc trint tfrac texp texp2 texpm1 tlog tlog2 tlog10 tlog1p tpow tui_pow tpow3 tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic tasin tacos tcos tatan tsin ttan tsin_cos tagm thypot tfactorial tgamma terf tcbrt tzeta mpf_compat mpfr_compat reuse tsqr tstrtofr tpow_z tget_f tconst_catalan troot tsec tcsc tcot teint tcoth tcsch tsech EXTRA_DIST = tgeneric.c tgeneric_ui.c mpf_compat.h inp_str.data diff --git a/tests/tcot.c b/tests/tcot.c index 3c113480b..ebc208011 100644 --- a/tests/tcot.c +++ b/tests/tcot.c @@ -85,8 +85,7 @@ main (int argc, char *argv[]) tests_start_mpfr (); check_specials (); - - test_generic (2, 100, 100); + test_generic (2, 200, 10); tests_end_mpfr (); return 0; diff --git a/tests/tcoth.c b/tests/tcoth.c new file mode 100644 index 000000000..a3a619128 --- /dev/null +++ b/tests/tcoth.c @@ -0,0 +1,92 @@ +/* Test file for mpfr_coth. + +Copyright 2005 Free Software Foundation, Inc. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "mpfr-test.h" + +#define TEST_FUNCTION mpfr_coth +#include "tgeneric.c" + +static void +check_specials (void) +{ + mpfr_t x, y; + + mpfr_init2 (x, 123L); + mpfr_init2 (y, 123L); + + mpfr_set_nan (x); + mpfr_coth (y, x, GMP_RNDN); + if (! mpfr_nan_p (y)) + { + printf ("Error: coth(NaN) != NaN\n"); + exit (1); + } + + mpfr_set_inf (x, 1); + mpfr_coth (y, x, GMP_RNDN); + if (mpfr_cmp_ui (y, 1)) + { + printf ("Error: coth(Inf) != 1\n"); + exit (1); + } + + mpfr_set_inf (x, -1); + mpfr_coth (y, x, GMP_RNDN); + if (mpfr_cmp_si (y, -1)) + { + printf ("Error: coth(-Inf) != -1\n"); + exit (1); + } + + /* cot(+/-0) = +/-0 */ + mpfr_set_ui (x, 0, GMP_RNDN); + mpfr_coth (y, x, GMP_RNDN); + if (! (mpfr_zero_p (y) && MPFR_SIGN (y) > 0)) + { + printf ("Error: coth(+0) != +0\n"); + exit (1); + } + mpfr_neg (x, x, GMP_RNDN); + mpfr_coth (y, x, GMP_RNDN); + if (! (mpfr_zero_p (y) && MPFR_SIGN (y) < 0)) + { + printf ("Error: coth(-0) != -0\n"); + exit (1); + } + + mpfr_clear (x); + mpfr_clear (y); +} + +int +main (int argc, char *argv[]) +{ + tests_start_mpfr (); + + check_specials (); + test_generic (2, 200, 10); + + tests_end_mpfr (); + return 0; +} diff --git a/tests/tcsch.c b/tests/tcsch.c new file mode 100644 index 000000000..49e10668c --- /dev/null +++ b/tests/tcsch.c @@ -0,0 +1,92 @@ +/* Test file for mpfr_csch. + +Copyright 2005 Free Software Foundation, Inc. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "mpfr-test.h" + +#define TEST_FUNCTION mpfr_csch +#include "tgeneric.c" + +static void +check_specials (void) +{ + mpfr_t x, y; + + mpfr_init2 (x, 123L); + mpfr_init2 (y, 123L); + + mpfr_set_nan (x); + mpfr_csch (y, x, GMP_RNDN); + if (! mpfr_nan_p (y)) + { + printf ("Error: csch(NaN) != NaN\n"); + exit (1); + } + + mpfr_set_inf (x, 1); + mpfr_csch (y, x, GMP_RNDN); + if (! (mpfr_zero_p (y) && MPFR_SIGN (y) >0)) + { + printf ("Error: csch(+Inf) != +0\n"); + exit (1); + } + + mpfr_set_inf (x, -1); + mpfr_csch (y, x, GMP_RNDN); + if (! (mpfr_zero_p (y) && MPFR_SIGN (y) <0)) + { + printf ("Error: csch(-0) != -0\n"); + exit (1); + } + + /* csc(+/-0) = +/-Inf */ + mpfr_set_ui (x, 0, GMP_RNDN); + mpfr_csch (y, x, GMP_RNDN); + if (! (mpfr_inf_p (y) && mpfr_sgn (y) > 0)) + { + printf ("Error: csch(+0) != +Inf\n"); + exit (1); + } + mpfr_neg (x, x, GMP_RNDN); + mpfr_csch (y, x, GMP_RNDN); + if (! (mpfr_inf_p (y) && mpfr_sgn (y) < 0)) + { + printf ("Error: csch(-0) != -Inf\n"); + exit (1); + } + + mpfr_clear (x); + mpfr_clear (y); +} + +int +main (int argc, char *argv[]) +{ + tests_start_mpfr (); + + check_specials (); + test_generic (2, 200, 10); + + tests_end_mpfr (); + return 0; +} diff --git a/tests/tsec.c b/tests/tsec.c index 02eb0d0c1..dab474944 100644 --- a/tests/tsec.c +++ b/tests/tsec.c @@ -86,7 +86,7 @@ main (int argc, char *argv[]) check_specials (); - test_generic (2, 100, 100); + test_generic (2, 200, 10); tests_end_mpfr (); return 0; diff --git a/tests/tsech.c b/tests/tsech.c new file mode 100644 index 000000000..3182b53fd --- /dev/null +++ b/tests/tsech.c @@ -0,0 +1,92 @@ +/* Test file for mpfr_sech. + +Copyright 2005 Free Software Foundation, Inc. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdio.h> +#include <stdlib.h> + +#include "mpfr-test.h" + +#define TEST_FUNCTION mpfr_sech +#include "tgeneric.c" + +static void +check_specials (void) +{ + mpfr_t x, y; + + mpfr_init2 (x, 123L); + mpfr_init2 (y, 123L); + + mpfr_set_nan (x); + mpfr_sech (y, x, GMP_RNDN); + if (! mpfr_nan_p (y)) + { + printf ("Error: sech(NaN) != NaN\n"); + exit (1); + } + + mpfr_set_inf (x, 1); + mpfr_sech (y, x, GMP_RNDN); + if (! (MPFR_IS_ZERO (y) && MPFR_SIGN (y) > 0)) + { + printf ("Error: sech(+Inf) != +0\n"); + exit (1); + } + + mpfr_set_inf (x, -1); + mpfr_sech (y, x, GMP_RNDN); + if (! (MPFR_IS_ZERO (y) && MPFR_SIGN (y) > 0)) + { + printf ("Error: sech(-Inf) != +0\n"); + exit (1); + } + + /* sec(+/-0) = 1 */ + mpfr_set_ui (x, 0, GMP_RNDN); + mpfr_sech (y, x, GMP_RNDN); + if (mpfr_cmp_ui (y, 1)) + { + printf ("Error: sech(+0) != 1\n"); + exit (1); + } + mpfr_neg (x, x, GMP_RNDN); + mpfr_sech (y, x, GMP_RNDN); + if (mpfr_cmp_ui (y, 1)) + { + printf ("Error: sech(-0) != 1\n"); + exit (1); + } + + mpfr_clear (x); + mpfr_clear (y); +} + +int +main (int argc, char *argv[]) +{ + tests_start_mpfr (); + + check_specials (); + test_generic (2, 200, 10); + + tests_end_mpfr (); + return 0; +} |