diff options
author | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-05-20 14:37:01 +0000 |
---|---|---|
committer | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-05-20 14:37:01 +0000 |
commit | f25a5b6185d196fd47ef3668d5ce1cb4211e4043 (patch) | |
tree | c76a7c4b6c7bf1d81589c56e4e8836efa71ca4a8 /tests/ttanh.c | |
parent | a45ae524c8e221c394e97ff949385c53ae1161cf (diff) | |
download | mpc-f25a5b6185d196fd47ef3668d5ce1cb4211e4043.tar.gz |
Add mpc_tanh function.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@133 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/ttanh.c')
-rw-r--r-- | tests/ttanh.c | 617 |
1 files changed, 617 insertions, 0 deletions
diff --git a/tests/ttanh.c b/tests/ttanh.c new file mode 100644 index 0000000..be859b5 --- /dev/null +++ b/tests/ttanh.c @@ -0,0 +1,617 @@ +/* test file for mpc_tanh. + +Copyright (C) 2008 Philippe Th\'eveny + +This file is part of the MPC Library. + +The MPC 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 MPC 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 MPC 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 "gmp.h" +#include "mpfr.h" +#include "mpc.h" + +#define TEST_FUNCTION mpc_tanh +#include "tgeneric.c" + +static void +test_failed (mpc_t op, mpc_t get, mpc_t expected) +{ + printf ("mpc_tanh(op) failed\n with "); + OUT (op); + printf (" "); + OUT (get); + OUT (expected); + exit (1); +} + +/* check special values as defined in C99 standard */ +static void +special () +{ + mpc_t z; + mpc_t t; + + mpc_init (z); + mpc_init (t); + + /* tanh(NaN +i*NaN) = NaN +i*NaN */ + mpfr_set_nan (MPC_RE (z)); + mpfr_set_nan (MPC_IM (z)); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + test_failed (z, t, z); + + /* tanh(NaN -i*Inf) = NaN +i*NaN */ + mpfr_set_inf (MPC_IM (z), -1); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + + /* tanh(NaN +i*Inf) = NaN +i*NaN */ + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + + /* tanh(NaN +i*y) = NaN +i*NaN when |y|>0 */ + mpfr_set_si (MPC_IM (z), -1, GMP_RNDN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + + /* tanh(x +i*NaN) = NaN +i*NaN when x is a finite number */ + mpfr_set_si (MPC_RE (z), -1, GMP_RNDN); + mpfr_set_nan (MPC_IM (z)); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpfr_set_ui (MPC_RE (z), 0, GMP_RNDN); + mpfr_set_nan (MPC_IM (z)); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + + /* tanh(x +i*+/-Inf) = NaN +i*NaN when x is a finite number */ + mpfr_set_si (MPC_RE (z), -1, GMP_RNDN); + mpfr_set_inf (MPC_IM (z), +1); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpfr_set_ui (MPC_RE (z), 0, GMP_RNDN); + mpfr_set_inf (MPC_IM (z), +1); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpfr_set_nan (MPC_RE (c99)); + mpfr_set_nan (MPC_IM (c99)); + test_failed (z, t, c99); + } + + /* tanh(+Inf +i*NaN) = 1 +i*+/-0 */ + mpfr_set_inf (MPC_RE (z), +1); + mpfr_set_nan (MPC_IM (z)); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), +1) != 0 || !mpfr_zero_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(-Inf +i*NaN) = -1 +i*-/+0 */ + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), -1) != 0 || !mpfr_zero_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_si_si (c99, -1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(-Inf +i*Inf) = -1 +i*+/-0 */ + mpfr_set_inf (MPC_IM (z), +1); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), -1) != 0 || !mpfr_zero_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_si_si (c99, -1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(-Inf -i*Inf) = -1 +i*-/+0 */ + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), -1) != 0 || !mpfr_zero_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_si_si (c99, -1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(+Inf +i*Inf) = +1 +i*+/-0 */ + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), +1) != 0 || !mpfr_zero_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_si_si (c99, 1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(+Inf -i*Inf) = +1 +i*-/+0 */ + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), +1) != 0 || !mpfr_zero_p (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_si_si (c99, 1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(NaN +i*0) = NaN +i*0 */ + mpfr_set_nan (MPC_RE (z)); + mpfr_set_ui (MPC_IM (z), 0, GMP_RNDN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) + || !mpfr_zero_p (MPC_IM (t)) || mpfr_signbit (MPC_IM (t))) + test_failed (z, t, z); + + /* tanh(NaN -i*0) = NaN -i*0 */ + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (!mpfr_nan_p (MPC_RE (t)) + || !mpfr_zero_p (MPC_IM (t)) || !mpfr_signbit (MPC_IM (t))) + test_failed (z, t, z); + + /* tanh(+Inf +i*0) = +1 +i*0 */ + mpfr_set_inf (MPC_RE (z), +1); + mpfr_set_ui (MPC_IM (z), 0, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), +1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_si_si (c99, +1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(-Inf -i*0) = -1 -i*0 */ + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), -1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || !mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + mpc_neg (c99, c99, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(-Inf +i*0) = -1 +i*0 */ + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), -1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_si_si (c99, -1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(+Inf -i*0) = +1 -i*0 */ + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), +1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || !mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + mpc_conj (c99, c99, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(+Inf +i*y) = 1 +i*0*sin 2y */ + mpfr_set_inf (MPC_RE (z), +1); + mpfr_set_ui (MPC_IM (z), +1, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), 1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), 1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || !mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + mpc_conj (c99, c99, MPC_RNDNN); + test_failed (z, t, c99); + } + mpfr_set_ui (MPC_IM (z), +2, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), 1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || !mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + mpc_conj (c99, c99, MPC_RNDNN); + test_failed (z, t, c99); + } + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), 1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(-Inf +i*y) = -1 +i*0*sin 2y */ + mpfr_set_inf (MPC_RE (z), -1); + mpfr_set_ui (MPC_IM (z), +1, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), -1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), -1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || !mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + mpc_conj (c99, c99, MPC_RNDNN); + test_failed (z, t, c99); + } + mpfr_set_ui (MPC_IM (z), +2, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), -1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || !mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + mpc_conj (c99, c99, MPC_RNDNN); + test_failed (z, t, c99); + } + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpfr_cmp_si (MPC_RE (t), -1) != 0 + || !mpfr_zero_p (MPC_IM (t)) || mpfr_signbit (MPC_IM (t))) + { + mpc_t c99; + mpc_init (c99); + mpc_set_ui_ui (c99, 1, 0, MPC_RNDNN); + test_failed (z, t, c99); + } + + /* tanh(+0 +i*0) = +0 +i*0 */ + mpc_set_ui_ui (z, 0, 0, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpc_cmp (t, z) != 0 ) + test_failed (z, t, z); + + /* tanh(+0 -i*0) = +0 -i*0 */ + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpc_cmp (t, z) != 0 ) + test_failed (z, t, z); + + /* tanh(-0 +i*0) = -0 +i*0 */ + mpc_neg (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpc_cmp (t, z) != 0 ) + test_failed (z, t, z); + + /* tanh(-0 -i*0) = -0 -i*0 */ + mpc_conj (z, z, MPC_RNDNN); + mpc_tanh (t, z, MPC_RNDNN); + if (mpc_cmp (t, z) != 0 ) + test_failed (z, t, z); + + mpc_clear (t); + mpc_clear (z); +} + +static void +pure_real_argument () +{ + /* cosh(x -i*0) = cosh(x) +i*0 if x<0 */ + /* cosh(x -i*0) = cosh(x) -i*0 if x>0 */ + /* cosh(x +i*0) = cosh(x) -i*0 if x<0 */ + /* cosh(x -i*0) = cosh(x) +i*0 if x>0 */ + mpc_t u; + mpc_t z; + mpc_t cosh_z; + + return; + + mpc_init (u); + mpc_init (z); + mpc_init (cosh_z); + + /* cosh(1 +i*0) = cosh(1) +i*0 */ + mpc_set_ui_ui (z, 1, 0, MPC_RNDNN); + mpfr_cosh (MPC_RE (u), MPC_RE (z), GMP_RNDN); + mpfr_set_ui (MPC_IM (u), 0, GMP_RNDN); + mpc_cosh (cosh_z, z, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0) + test_failed (z, cosh_z, u); + + /* cosh(1 -i*0) = cosh(1) -i*0 */ + mpc_conj (z, z, MPC_RNDNN); + mpc_conj (u, u, MPC_RNDNN); + mpc_cosh (cosh_z, z, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0) + test_failed (z, cosh_z, u); + + /* cosh(-1 +i*0) = cosh(1) -i*0 */ + mpc_neg (z, z, MPC_RNDNN); + mpc_cosh (cosh_z, z, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0) + test_failed (z, cosh_z, u); + + /* cosh(-1 -i*0) = cosh(1) +i*0 */ + mpc_conj (z, z, MPC_RNDNN); + mpc_conj (u, u, MPC_RNDNN); + mpc_cosh (cosh_z, z, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0) + test_failed (z, cosh_z, u); + + mpc_clear (cosh_z); + mpc_clear (z); + mpc_clear (u); +} + +static void +pure_imaginary_argument () +{ + /* cosh(+0 +i*y) = cos y +i*0*sin y */ + /* cosh(-0 +i*y) = cos y -i*0*sin y */ + mpc_t u; + mpc_t z; + mpc_t cosh_z; + + return; + + mpc_init (u); + mpc_init (z); + mpc_init (cosh_z); + + /* cosh(+0 +i) = cos(1) +i*0 */ + mpc_set_ui_ui (z, 0, 1, MPC_RNDNN); + mpfr_cos (MPC_RE (u), MPC_IM (z), GMP_RNDN); + mpfr_set_ui (MPC_IM (u), 0, GMP_RNDN); + if (mpc_cmp (cosh_z, u) != 0) + test_failed (z, cosh_z, u); + + /* cosh(+0 -i) = cos(1) -i*0 */ + mpc_conj (z, z, MPC_RNDNN); + mpc_conj (u, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0) + test_failed (z, cosh_z, u); + + /* cosh(-0 +i) = cos(1) -i*0 */ + mpc_neg (z, z, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0) + test_failed (z, cosh_z, u); + + /* cosh(-0 -i) = cos(1) +i*0 */ + mpc_conj (z, z, MPC_RNDNN); + mpc_conj (u, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0) + test_failed (z, cosh_z, u); + + mpc_clear (cosh_z); + mpc_clear (z); + mpc_clear (u); +} + +static void +check_53() +{ + mpc_t z; + mpc_t tanh_z; + mpc_t t; + + return; + + mpc_init2 (z, 53); + mpc_init2 (tanh_z, 53); + mpc_init2 (t, 53); + + /* cosh(z) is near (1+2^(-53)) *(0.5+i) */ + mpfr_set_str (MPC_RE (z), "1DA2E1BD2C9EBCp-53", 16, GMP_RNDN); + mpfr_set_str (MPC_IM (z), "138AADEA15829Fp-52", 16, GMP_RNDN); + mpfr_set_str (MPC_RE (t), "10000000000001p-53", 16, GMP_RNDN); + mpfr_set_str (MPC_IM (t), "10000000000001p-52", 16, GMP_RNDN); + mpc_tanh (tanh_z, z, MPC_RNDNN); + if (mpc_cmp (tanh_z, t) != 0) + test_failed (z, tanh_z, t); + + mpc_clear (t); + mpc_clear (tanh_z); + mpc_clear (z); +} + +int +main() +{ + special (); + pure_real_argument (); + pure_imaginary_argument (); + + tgeneric (); + + check_53 (); + + return 0; +} |