diff options
author | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-04-09 14:53:04 +0000 |
---|---|---|
committer | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2008-04-09 14:53:04 +0000 |
commit | 71403d4e1586541af943388ae8f744d794e396f2 (patch) | |
tree | a13c0895665fb25872a0ed4174bd0f2fb62fd9bd /tests/tsin.c | |
parent | f57b10c211176832a201aa5bd7ddedf65ef5b595 (diff) | |
download | mpc-71403d4e1586541af943388ae8f744d794e396f2.tar.gz |
Replace rounding tests by the new tgeneric functions.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@87 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/tsin.c')
-rw-r--r-- | tests/tsin.c | 81 |
1 files changed, 26 insertions, 55 deletions
diff --git a/tests/tsin.c b/tests/tsin.c index 8fc0899..ff3ce84 100644 --- a/tests/tsin.c +++ b/tests/tsin.c @@ -25,28 +25,24 @@ MA 02111-1307, USA. */ #include "mpfr.h" #include "mpc.h" +#define TEST_FUNCTION mpc_sin +#include "tgeneric.c" int main() { - mpc_t x, z, t, u; - mpfr_t f, g; - mp_prec_t prec; + mpc_t x, z; + mpfr_t g; + mp_prec_t prec; - mpc_init (x); - mpc_init (z); - mpc_init (t); - mpc_init (u); - mpfr_init (f); - mpfr_init (g); + mpc_init (x); + mpc_init (z); + mpfr_init (g); - for (prec = 2; prec <= 1000; prec++) - { + for (prec = 2; prec <= 1000; prec++) + { mpc_set_prec (x, prec); mpc_set_prec (z, prec); - mpc_set_prec (t, prec); - mpc_set_prec (u, 4*prec); - mpfr_set_prec (f, prec); mpfr_set_prec (g, prec); /* check that sin(I*b) = I*sinh(b) */ @@ -56,49 +52,24 @@ main() mpc_sin (z, x, MPC_RNDNN); mpfr_sinh (g, MPC_IM(x), GMP_RNDN); if (mpfr_cmp_ui (MPC_RE(z), 0) || mpfr_cmp (g, MPC_IM(z))) - { - fprintf (stderr, "Error in mpc_sin: sin(I*x) <> I*sinh(x)\n" - "got "); - mpc_out_str (stderr, 10, 0, z, MPC_RNDNN); - fprintf (stderr, "\nexpected "); - mpfr_set_ui (MPC_RE(z), 0, GMP_RNDN); - mpfr_set (MPC_IM(z), g, GMP_RNDN); - mpc_out_str (stderr, 10, 0, z, MPC_RNDNN); - fprintf (stderr, "\n"); - exit (1); - } + { + fprintf (stderr, "Error in mpc_sin: sin(I*x) <> I*sinh(x)\n" + "got "); + mpc_out_str (stderr, 10, 0, z, MPC_RNDNN); + fprintf (stderr, "\nexpected "); + mpfr_set_ui (MPC_RE(z), 0, GMP_RNDN); + mpfr_set (MPC_IM(z), g, GMP_RNDN); + mpc_out_str (stderr, 10, 0, z, MPC_RNDNN); + fprintf (stderr, "\n"); + exit (1); + } } + tgeneric (); - /* We also compute the result with four times the precision and check */ - /* whether the rounding is correct. Error reports in this part of the */ - /* algorithm might still be wrong, though, since there are two */ - /* consecutive roundings. */ - mpc_random (x); - mpc_sin (z, x, MPC_RNDNN); - mpc_sin (u, x, MPC_RNDNN); - mpc_set (t, u, MPC_RNDNN); - - if (mpc_cmp (z, t)) - { - fprintf (stderr, "rounding in sin might be incorrect for\nx="); - mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); - fprintf (stderr, "\nmpc_sin gives "); - mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); - fprintf (stderr, "\nmpc_sin quadruple precision gives "); - mpc_out_str (stderr, 2, 0, u, MPC_RNDNN); - fprintf (stderr, "\nand is rounded to "); - mpc_out_str (stderr, 2, 0, t, MPC_RNDNN); - fprintf (stderr, "\n"); - exit (1); - } - - mpc_clear (x); - mpc_clear (z); - mpc_clear (t); - mpc_clear (u); - mpfr_clear (f); - mpfr_clear (g); + mpc_clear (x); + mpc_clear (z); + mpfr_clear (g); - return 0; + return 0; } |