diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-10-15 14:15:27 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-10-15 14:15:27 +0000 |
commit | 9c7cd58e47f4deed76f68556a5244f81b773d456 (patch) | |
tree | 111f331065acc80f6d95b076d6af27c48b6259e2 /tests/ttan.c | |
parent | fff9b94f431903cff5c5af5811317588fde315d5 (diff) | |
download | mpfr-9c7cd58e47f4deed76f68556a5244f81b773d456.tar.gz |
now use tgeneric.c
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1259 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/ttan.c')
-rw-r--r-- | tests/ttan.c | 59 |
1 files changed, 7 insertions, 52 deletions
diff --git a/tests/ttan.c b/tests/ttan.c index fc03a1eb0..daa7d2071 100644 --- a/tests/ttan.c +++ b/tests/ttan.c @@ -45,22 +45,19 @@ void check53 (double x, double tan_x, mp_rnd_t rnd_mode) mpfr_clear (s); } +#define TEST_FUNCTION mpfr_tan +#include "tgeneric.c" + int main(int argc, char *argv[]) { - unsigned int prec, err, yprec, n, p0 = 1, p1 = 100, N = 100; - mp_rnd_t rnd; - mpfr_t x, y, z, t; - - mpfr_init (x); - mpfr_init (y); - mpfr_init (z); - mpfr_init (t); + mpfr_t x; check53(0.0/0.0, 0.0/0.0, GMP_RNDN); check53(1.0/0.0, 0.0/0.0, GMP_RNDN); check53(-1.0/0.0, 0.0/0.0, GMP_RNDN); + mpfr_init (x); mpfr_set_prec (x, 1); mpfr_set_d (x, 0.5, GMP_RNDN); mpfr_tan (x, x, GMP_RNDD); @@ -69,51 +66,9 @@ main(int argc, char *argv[]) fprintf (stderr, "mpfr_tan(0.5, GMP_RNDD) failed\n"); exit (1); } - - /* generic test */ - for (prec = p0; prec <= p1; prec++) - { - mpfr_set_prec (x, prec); - mpfr_set_prec (z, prec); - mpfr_set_prec (t, prec); - yprec = prec + 10; - - for (n=0; n<N; n++) - { - mpfr_random (x); - rnd = random () % 4; - mpfr_set_prec (y, yprec); - mpfr_tan (y, x, rnd); - err = (rnd == GMP_RNDN) ? yprec + 1 : yprec; - if (mpfr_can_round (y, err, rnd, rnd, prec)) - { - mpfr_set (t, y, rnd); - mpfr_tan (z, x, rnd); - if (mpfr_cmp (t, z)) - { - printf ("results differ for x="); - mpfr_out_str (stdout, 2, prec, x, GMP_RNDN); - printf (" prec=%u rnd_mode=%s\n", prec, - mpfr_print_rnd_mode (rnd)); - printf (" got "); - mpfr_out_str (stdout, 2, prec, z, GMP_RNDN); - putchar ('\n'); - printf (" expected "); - mpfr_out_str (stdout, 2, prec, t, GMP_RNDN); - putchar ('\n'); - printf (" approximation was "); - mpfr_print_raw (y); - putchar ('\n'); - exit (1); - } - } - } - } - mpfr_clear (x); - mpfr_clear (y); - mpfr_clear (z); - mpfr_clear (t); + + test_generic (1, 100, 100); return 0; } |