diff options
author | tege <tege@gmplib.org> | 2000-06-29 17:59:44 +0200 |
---|---|---|
committer | tege <tege@gmplib.org> | 2000-06-29 17:59:44 +0200 |
commit | ef0f7391964d47fd032ce46c6cd52441a6b2b39e (patch) | |
tree | dd427664f256f9f12fdcdfa67435fbc31ba9290b /mpf | |
parent | abf2eb435d6e530a953a0fc096f2a85e67126267 (diff) | |
download | gmp-ef0f7391964d47fd032ce46c6cd52441a6b2b39e.tar.gz |
Set u randomly in loop. Perform more mpf_mul_2exp testing.
Diffstat (limited to 'mpf')
-rw-r--r-- | mpf/tests/t-dm2exp.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/mpf/tests/t-dm2exp.c b/mpf/tests/t-dm2exp.c index 48503c80b..2be9c3527 100644 --- a/mpf/tests/t-dm2exp.c +++ b/mpf/tests/t-dm2exp.c @@ -34,9 +34,11 @@ main (argc, argv) { int reps = 500000; int i; - mpf_t u, v, w1, w2; + mpf_t u, v, w1, w2, w3; mp_size_t bprec = 100; mpf_t rerr, limit_rerr; + mp_size_t un; + mp_exp_t ue; if (argc > 1) { @@ -54,6 +56,7 @@ main (argc, argv) mpf_init (v); mpf_init (w1); mpf_init (w2); + mpf_init (w3); for (i = 0; i < reps; i++) { @@ -63,6 +66,7 @@ main (argc, argv) res_prec = urandom () % (bprec + 100); mpf_set_prec (w1, res_prec); mpf_set_prec (w2, res_prec); + mpf_set_prec (w3, res_prec); mpf_set_ui (limit_rerr, 1); mpf_div_2exp (limit_rerr, limit_rerr, res_prec); @@ -71,6 +75,10 @@ main (argc, argv) mpf_set_ui (v, 1); mpf_mul_2exp (v, v, pow2); + un = urandom () % (2 * SIZE) - SIZE; + ue = urandom () % SIZE; + mpf_random2 (u, un, ue); + mpf_div_2exp (w1, u, pow2); mpf_div (w2, u, v); mpf_reldiff (rerr, w1, w2); @@ -83,6 +91,17 @@ main (argc, argv) printf (" w2 = "); mpf_dump (w2); abort (); } + mpf_mul_2exp (w3, w1, pow2); + mpf_reldiff (rerr, u, w3); + if (mpf_cmp (rerr, limit_rerr) > 0) + { + printf ("ERROR in mpf_mul_2exp after %d tests\n", i); + printf (" u = "); mpf_dump (u); + printf (" v = "); mpf_dump (v); + printf (" w1 = "); mpf_dump (w1); + printf (" w3 = "); mpf_dump (w3); + abort (); + } } exit (0); |