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/texp.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/texp.c')
-rw-r--r-- | tests/texp.c | 84 |
1 files changed, 29 insertions, 55 deletions
diff --git a/tests/texp.c b/tests/texp.c index 8450f30..9e824a1 100644 --- a/tests/texp.c +++ b/tests/texp.c @@ -25,27 +25,25 @@ MA 02111-1307, USA. */ #include "mpfr.h" #include "mpc.h" +#define TEST_FUNCTION mpc_exp +#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 f, 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 (f); + 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); @@ -56,49 +54,25 @@ main() mpc_exp (z, x, MPC_RNDNN); mpfr_sin_cos (f, g, MPC_IM(x), GMP_RNDN); if (mpfr_cmp (g, MPC_RE(z)) || mpfr_cmp (f, MPC_IM(z))) - { - fprintf (stderr, "Error in mpc_exp: exp(I*x) <> cos(x)+I*sin(x)\n" - "got "); - mpc_out_str (stderr, 10, 0, z, MPC_RNDNN); - fprintf (stderr, "\nexpected "); - mpfr_set (MPC_RE(z), g, GMP_RNDN); - mpfr_set (MPC_IM(z), f, GMP_RNDN); - mpc_out_str (stderr, 10, 0, z, MPC_RNDNN); - fprintf (stderr, "\n"); - exit (1); - } - } - - - /* 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_exp (z, x, MPC_RNDNN); - mpc_exp (t, x, MPC_RNDNN); - mpc_set (u, t, MPC_RNDNN); - - if (mpc_cmp (z, t)) - { - fprintf (stderr, "rounding in exp might be incorrect for\nx="); - mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); - fprintf (stderr, "\nmpc_exp gives "); - mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); - fprintf (stderr, "\nmpc_exp 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); + { + fprintf (stderr, "Error in mpc_exp: exp(I*x) <> cos(x)+I*sin(x)\n" + "got "); + mpc_out_str (stderr, 10, 0, z, MPC_RNDNN); + fprintf (stderr, "\nexpected "); + mpfr_set (MPC_RE(z), g, GMP_RNDN); + mpfr_set (MPC_IM(z), f, GMP_RNDN); + mpc_out_str (stderr, 10, 0, z, 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); + tgeneric (); + + mpc_clear (x); + mpc_clear (z); + mpfr_clear (f); + mpfr_clear (g); - return 0; + return 0; } |