diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-06 13:27:05 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-02-06 13:27:05 +0000 |
commit | 19767e6f6f9089ef12f81e9f3b64f5c71ff71c84 (patch) | |
tree | 388f8324eb4f2595b607ac0b1afa7352ca4c9c5d /tests | |
parent | 6e0b309b6faf9353e1732c77a95099a5aa5d86c0 (diff) | |
download | mpfr-19767e6f6f9089ef12f81e9f3b64f5c71ff71c84.tar.gz |
+ Better support of non IEEE doubles.
+ You can compile MPFR without gmp internal files (ie gmp-impl.h, gmp-mparam.h, and config.h). You only need gmp.h and libgmp.a. But you can still compile with GMP internal files (configure detects them).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2665 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/memory.c | 3 | ||||
-rw-r--r-- | tests/tacos.c | 4 | ||||
-rw-r--r-- | tests/tadd.c | 4 | ||||
-rw-r--r-- | tests/tasin.c | 4 | ||||
-rw-r--r-- | tests/tatan.c | 4 | ||||
-rw-r--r-- | tests/tcan_round.c | 4 | ||||
-rw-r--r-- | tests/tconst_log2.c | 2 | ||||
-rw-r--r-- | tests/tdiv.c | 2 | ||||
-rw-r--r-- | tests/tests.c | 2 | ||||
-rw-r--r-- | tests/texceptions.c | 6 | ||||
-rw-r--r-- | tests/texp.c | 2 | ||||
-rw-r--r-- | tests/tfma.c | 2 | ||||
-rw-r--r-- | tests/tfrac.c | 2 | ||||
-rw-r--r-- | tests/tgeneric.c | 2 | ||||
-rw-r--r-- | tests/tget_d_2exp.c | 2 | ||||
-rw-r--r-- | tests/tget_str.c | 2 | ||||
-rw-r--r-- | tests/tgmpop.c | 4 | ||||
-rw-r--r-- | tests/thypot.c | 2 | ||||
-rw-r--r-- | tests/tmul.c | 2 | ||||
-rw-r--r-- | tests/tout_str.c | 2 | ||||
-rw-r--r-- | tests/tpow3.c | 2 | ||||
-rw-r--r-- | tests/trint.c | 6 | ||||
-rw-r--r-- | tests/tset_f.c | 4 | ||||
-rw-r--r-- | tests/tset_q.c | 6 | ||||
-rw-r--r-- | tests/tset_si.c | 4 | ||||
-rw-r--r-- | tests/tset_str.c | 3 | ||||
-rw-r--r-- | tests/tset_z.c | 6 | ||||
-rw-r--r-- | tests/tsqrt.c | 2 | ||||
-rw-r--r-- | tests/tsub.c | 11 | ||||
-rw-r--r-- | tests/tsub1sp.c | 4 | ||||
-rw-r--r-- | tests/tui_pow.c | 2 |
31 files changed, 54 insertions, 53 deletions
diff --git a/tests/memory.c b/tests/memory.c index a145e0328..8a2877e3d 100644 --- a/tests/memory.c +++ b/tests/memory.c @@ -26,8 +26,7 @@ MA 02111-1307, USA. */ #include <stdlib.h> /* for abort */ #include <limits.h> -#include "gmp.h" -#include "gmp-impl.h" + #include "mpfr-test.h" /* Each block allocated is a separate malloc, for the benefit of a redzoning diff --git a/tests/tacos.c b/tests/tacos.c index aaa3a1f1a..f566de22d 100644 --- a/tests/tacos.c +++ b/tests/tacos.c @@ -106,7 +106,7 @@ main (void) } /* acos (0) = Pi/2 */ - for (r = 0; r < 4; r++) + for (r = 0; r < GMP_RND_MAX; r++) { mpfr_set_ui (x, 0, GMP_RNDN); /* exact */ mpfr_acos (y, x, r); @@ -121,7 +121,7 @@ main (void) } /* acos (-1) = Pi */ - for (r = 0; r < 4; r++) + for (r = 0; r < GMP_RND_MAX; r++) { mpfr_set_si (x, -1, GMP_RNDN); /* exact */ mpfr_acos (y, x, r); diff --git a/tests/tadd.c b/tests/tadd.c index 8a4e956e8..ae4c980ab 100644 --- a/tests/tadd.c +++ b/tests/tadd.c @@ -492,7 +492,7 @@ check_inexact (void) abs(EXP(x)-EXP(u)) + max(prec(x), prec(u)) + 1 */ pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u)) + 1; mpfr_set_prec (z, pz); - rnd = randlimb () % 4; + rnd = RND_RAND(); if (mpfr_add (z, x, u, rnd)) { printf ("z <- x + u should be exact\n"); @@ -502,7 +502,7 @@ check_inexact (void) exit (1); } { - rnd = randlimb () % 4; + rnd = RND_RAND(); inexact = mpfr_add (y, x, u, rnd); cmp = mpfr_cmp (y, z); if (((inexact == 0) && (cmp != 0)) || diff --git a/tests/tasin.c b/tests/tasin.c index e3694d9c9..12f5037d8 100644 --- a/tests/tasin.c +++ b/tests/tasin.c @@ -95,7 +95,7 @@ special (void) } /* asin(1) = Pi/2 */ - for (r = 0; r < 4; r++) + for (r = 0; r < GMP_RND_MAX; r++) { mpfr_set_ui (x, 1, GMP_RNDN); /* exact */ mpfr_asin (y, x, r); @@ -110,7 +110,7 @@ special (void) } /* asin(-1) = -Pi/2 */ - for (r = 0; r < 4; r++) + for (r = 0; r < GMP_RND_MAX; r++) { mpfr_set_si (x, -1, GMP_RNDN); /* exact */ mpfr_asin (y, x, r); diff --git a/tests/tatan.c b/tests/tatan.c index 52e7a8b50..4967205f5 100644 --- a/tests/tatan.c +++ b/tests/tatan.c @@ -52,7 +52,7 @@ special (void) } /* atan(+Inf) = Pi/2 */ - for (r = 0; r < 4; r++) + for (r = 0; r < GMP_RND_MAX ; r++) { mpfr_set_inf (x, 1); mpfr_atan (y, x, r); @@ -66,7 +66,7 @@ special (void) } /* atan(-Inf) = - Pi/2 */ - for (r = 0; r < 4; r++) + for (r = 0; r < GMP_RND_MAX ; r++) { mpfr_set_inf (x, -1); mpfr_atan (y, x, r); diff --git a/tests/tcan_round.c b/tests/tcan_round.c index f9c2b4a40..e0b1d0119 100644 --- a/tests/tcan_round.c +++ b/tests/tcan_round.c @@ -63,8 +63,8 @@ main (void) for (j = 30; j < 99; j++) { mp_rnd_t r1, r2; - for (r1 = 0; r1 < 4; r1++) - for (r2 = 0; r2 < 4; r2++) + for (r1 = 0; r1 < GMP_RND_MAX ; r1++) + for (r2 = 0; r2 < GMP_RND_MAX ; r2++) mpfr_can_round (x, i, r1, r2, j); /* test for assertions */ } diff --git a/tests/tconst_log2.c b/tests/tconst_log2.c index c458cdb88..df5b7c1e8 100644 --- a/tests/tconst_log2.c +++ b/tests/tconst_log2.c @@ -43,7 +43,7 @@ check (mp_prec_t p0, mp_prec_t p1) mpfr_set_prec (x, p0); mpfr_set_prec (y, p0); { - rnd = randlimb () % 4; + rnd = RND_RAND (); mpfr_const_log2 (x, rnd); mpfr_set (y, z, rnd); if (mpfr_cmp (x, y) && mpfr_can_round (z, mpfr_get_prec(z), GMP_RNDN, diff --git a/tests/tdiv.c b/tests/tdiv.c index b565a2bbc..0093d5e95 100644 --- a/tests/tdiv.c +++ b/tests/tdiv.c @@ -427,7 +427,7 @@ check_inexact (void) mpfr_set_prec (y, py); mpfr_set_prec (z, py + pu); { - rnd = randlimb () % 4; + rnd = RND_RAND (); inexact = mpfr_div (y, x, u, rnd); if (mpfr_mul (z, y, u, rnd)) { diff --git a/tests/tests.c b/tests/tests.c index f71f6dbd5..b39506f6d 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -193,7 +193,7 @@ randlimb (void) { mp_limb_t limb; - _gmp_rand (&limb, RANDS, GMP_NUMB_BITS); + _gmp_rand (&limb, RANDS, BITS_PER_MP_LIMB); return limb; } diff --git a/tests/texceptions.c b/tests/texceptions.c index cf13f5a44..55fb5d8b6 100644 --- a/tests/texceptions.c +++ b/tests/texceptions.c @@ -29,7 +29,7 @@ static void check_default_rnd(void) { mp_rnd_t r, t; - for(r = 0 ; r < 4 ; r++) + for(r = 0 ; r < GMP_RND_MAX ; r++) { mpfr_set_default_rounding_mode (r); t = mpfr_get_default_rounding_mode(); @@ -92,7 +92,7 @@ test_set_underflow (void) r[1] = r[3] = zero; for (s = 1; s > 0; s = -1) { - for (i = 0; i < 4; i++) + for (i = 0; i < GMP_RND_MAX ; i++) { int j; int inex; @@ -135,7 +135,7 @@ test_set_overflow (void) r[1] = r[3] = max; for (s = 1; s > 0; s = -1) { - for (i = 0; i < 4; i++) + for (i = 0; i < GMP_RND_MAX ; i++) { int j; int inex; diff --git a/tests/texp.c b/tests/texp.c index 3765ff550..ba2f9c193 100644 --- a/tests/texp.c +++ b/tests/texp.c @@ -170,7 +170,7 @@ compare_exp2_exp3 (int n) mpfr_set_prec (y, prec); mpfr_set_prec (z, prec); mpfr_random (x); - rnd = randlimb () % 4; + rnd = RND_RAND() ; mpfr_exp_2 (y, x, rnd); mpfr_exp3 (z, x, rnd); if (mpfr_cmp (y,z)) diff --git a/tests/tfma.c b/tests/tfma.c index e1f3cc543..051d90e00 100644 --- a/tests/tfma.c +++ b/tests/tfma.c @@ -273,7 +273,7 @@ main (int argc, char *argv[]) if (randlimb () % 2) mpfr_neg (z, z, GMP_RNDN); - rnd = randlimb () % 4; + rnd = RND_RAND (); mpfr_set_prec (slong, 2 * prec); if (mpfr_mul (slong, x, y, rnd)) { diff --git a/tests/tfrac.c b/tests/tfrac.c index 7f51133c6..67f2c7128 100644 --- a/tests/tfrac.c +++ b/tests/tfrac.c @@ -115,7 +115,7 @@ check1 (mpfr_ptr ip, mpfr_ptr fp) { mp_rnd_t rnd; - for (rnd = 0; rnd < 4; rnd++) + for (rnd = 0; rnd < GMP_RND_MAX ; rnd++) { check0 (ip, fp, PMAX, rnd); check0 (ip, fp, 70, rnd); diff --git a/tests/tgeneric.c b/tests/tgeneric.c index f1fc39f9e..b55cb8e1c 100644 --- a/tests/tgeneric.c +++ b/tests/tgeneric.c @@ -48,7 +48,7 @@ test_generic (mp_prec_t p0, mp_prec_t p1, unsigned int N) #else mpfr_random (x); #endif - rnd = randlimb () % 4; + rnd = RND_RAND (); mpfr_set_prec (y, yprec); compare = TEST_FUNCTION (y, x, rnd); if (mpfr_can_round (y, yprec, rnd, rnd, prec)) diff --git a/tests/tget_d_2exp.c b/tests/tget_d_2exp.c index 989f990a0..c8646c61b 100644 --- a/tests/tget_d_2exp.c +++ b/tests/tget_d_2exp.c @@ -39,7 +39,7 @@ check_round (void) mpfr_init2 (f, 1024L); - for (rnd_mode = 0; rnd_mode < 4; rnd_mode++) + for (rnd_mode = 0; rnd_mode < GMP_RND_MAX ; rnd_mode++) { for (i = 0; i < (int) numberof (data); i++) { diff --git a/tests/tget_str.c b/tests/tget_str.c index 8fbbdf0f1..081ae2d92 100644 --- a/tests/tget_str.c +++ b/tests/tget_str.c @@ -524,7 +524,7 @@ main (int argc, char *argv[]) mpfr_set_exp (x, (e == -10) ? mpfr_get_emin () : ((e == 10) ? mpfr_get_emax () : e)); b = 2 + (randlimb () % 35); - r = randlimb () % 4; + r = RND_RAND(); mpfr_get_str (s, &f, b, m, x, r); } mpfr_clear (x); diff --git a/tests/tgmpop.c b/tests/tgmpop.c index 299184b29..eecd02fe0 100644 --- a/tests/tgmpop.c +++ b/tests/tgmpop.c @@ -98,7 +98,7 @@ test_genericz (mp_prec_t p0, mp_prec_t p1, unsigned int N, { mpfr_urandomb (arg1, RANDS); mpz_urandomb (arg2, RANDS, 1024); - rnd = randlimb () % 4; + rnd = RND_RAND (); mpfr_set_prec (dst_big, 2*prec); compare = func(dst_big, arg1, arg2, rnd); if (mpfr_can_round (dst_big, 2*prec, rnd, rnd, prec)) @@ -175,7 +175,7 @@ test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N, { mpfr_urandomb (arg1, RANDS); mpq_set_ui (arg2, randlimb (), randlimb() ); - rnd = randlimb () % 4; + rnd = RND_RAND (); mpfr_set_prec (dst_big, prec+10); compare = func(dst_big, arg1, arg2, rnd); if (mpfr_can_round (dst_big, prec+10, rnd, rnd, prec)) diff --git a/tests/thypot.c b/tests/thypot.c index b17e8c7a7..a93247331 100644 --- a/tests/thypot.c +++ b/tests/thypot.c @@ -122,7 +122,7 @@ main (int argc, char *argv[]) mpfr_neg (x1, x1, GMP_RNDN); if (randlimb () % 2) mpfr_neg (x2, x2, GMP_RNDN); - rnd = randlimb () % 4; + rnd = RND_RAND (); mpfr_set_prec (y, yprec); compare =TEST_FUNCTION (y, x1,x2, rnd); diff --git a/tests/tmul.c b/tests/tmul.c index aeff45690..9cd2ce08c 100644 --- a/tests/tmul.c +++ b/tests/tmul.c @@ -217,7 +217,7 @@ check_exact (void) { mpfr_random (a); mpfr_random (b); - rnd = randlimb () % 4; + rnd = RND_RAND (); inexact = mpfr_mul (c, a, b, rnd); if (mpfr_mul (d, a, b, rnd)) /* should be always exact */ { diff --git a/tests/tout_str.c b/tests/tout_str.c index 82362390f..12d222339 100644 --- a/tests/tout_str.c +++ b/tests/tout_str.c @@ -147,7 +147,7 @@ main (int argc, char *argv[]) #else while (ABS(d) < DBL_MIN); #endif - r = randlimb () % 4; + r = RND_RAND (); p = 2 + randlimb () % 35; check (d, r, p); } diff --git a/tests/tpow3.c b/tests/tpow3.c index 02010ec69..0626d51dc 100644 --- a/tests/tpow3.c +++ b/tests/tpow3.c @@ -65,7 +65,7 @@ main (int argc, char *argv[]) mpfr_random (s); if (randlimb () % 2) mpfr_neg (s, s, GMP_RNDN); - rnd = randlimb () % 4; + rnd = RND_RAND (); mpfr_set_prec (y, yprec); compare = mpfr_pow (y, x, s, rnd); err = (rnd == GMP_RNDN) ? yprec + 1 : yprec; diff --git a/tests/trint.c b/tests/trint.c index 5275a170d..a773f195c 100644 --- a/tests/trint.c +++ b/tests/trint.c @@ -80,13 +80,13 @@ test_fct (double (*f)(double), int (*g)(), char *s, mp_rnd_t r) static void test_against_libc (void) { - int r = 0; + mp_rnd_t r; TEST_FCT (round); TEST_FCT (trunc); TEST_FCT (floor); TEST_FCT (ceil); - for (r = 0; r < 4; r++) + for (r = 0; r < GMP_RND_MAX ; r++) if (mpfr_set_machine_rnd_mode (r) == 0) test_fct (&nearbyint, &mpfr_rint, "rint", r); } @@ -151,7 +151,7 @@ main (int argc, char *argv[]) int trint; mpfr_set_prec (y, p); mpfr_set_prec (v, p); - for (r = 0; r < 4; r++) + for (r = 0; r < GMP_RND_MAX ; r++) for (trint = 0; trint < 2; trint++) { if (trint) diff --git a/tests/tset_f.c b/tests/tset_f.c index 8f1666061..37c80485c 100644 --- a/tests/tset_f.c +++ b/tests/tset_f.c @@ -46,7 +46,7 @@ main (void) mpfr_set_f (x, y, GMP_RNDN); mpf_random2(y, 10, 0); - mpfr_set_f(x, y, randlimb () & 3); + mpfr_set_f(x, y, RND_RAND() ); /* bug found by Jean-Pierre Merlet */ mpfr_set_prec(x, 256); @@ -86,7 +86,7 @@ main (void) mpfr_set_prec(x, 53); mpf_set_prec(y, 53); mpf_set_ui(y, 0); - for(r = 0 ; r < 4 ; r++) + for(r = 0 ; r < GMP_RND_MAX ; r++) { inexact = mpfr_set_f(x, y, r); if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact) diff --git a/tests/tset_q.c b/tests/tset_q.c index 732b25443..02853c5e6 100644 --- a/tests/tset_q.c +++ b/tests/tset_q.c @@ -74,12 +74,14 @@ static void check0(void) { mpq_t y; mpfr_t x; - int inexact, r; + int inexact; + mp_rnd_t r; + /* Check for +0 */ mpfr_init(x); mpq_init(y); mpq_set_si(y, 0, 1); - for(r = 0 ; r < 4 ; r++) + for(r = 0 ; r < GMP_RND_MAX ; r++) { inexact = mpfr_set_q(x, y, r); if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact) diff --git a/tests/tset_si.c b/tests/tset_si.c index f6fdfc22a..bd234a955 100644 --- a/tests/tset_si.c +++ b/tests/tset_si.c @@ -36,7 +36,7 @@ main (int argc, char *argv[]) long k, z, d, N; unsigned long zl, dl; int inex; - int r; + mp_rnd_t r; tests_start_mpfr (); @@ -130,7 +130,7 @@ main (int argc, char *argv[]) exit (1); } - for(r = 0 ; r < 4 ; r++) + for(r = 0 ; r < GMP_RND_MAX ; r++) { mpfr_set_si (x, -1, r); mpfr_set_ui (x, 0, r); diff --git a/tests/tset_str.c b/tests/tset_str.c index be36a1a33..b0c62c7fa 100644 --- a/tests/tset_str.c +++ b/tests/tset_str.c @@ -149,7 +149,7 @@ main (int argc, char *argv[]) for (i=0;i<N;i++) { mpfr_random (x); - k = randlimb () % 4; + k = RND_RAND (); logbase = (randlimb () % 5) + 1; base = 1 << logbase; /* Warning: the number of bits needed to print exactly a number of @@ -422,6 +422,7 @@ main (int argc, char *argv[]) printf ("return : "); mpfr_print_binary (y); puts (""); + exit (1); } } diff --git a/tests/tset_z.c b/tests/tset_z.c index bf72f0e71..630b6e950 100644 --- a/tests/tset_z.c +++ b/tests/tset_z.c @@ -35,7 +35,7 @@ static void check0(void) mpfr_init(x); mpz_init(y); mpz_set_si(y, 0); - for(r = 0 ; r < 4 ; r++) + for(r = 0 ; r < GMP_RND_MAX ; r++) { inexact = mpfr_set_z(x, y, r); if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact) @@ -54,7 +54,7 @@ static void check0(void) mpfr_get_si is a rather indirect test of a low level routine. */ static void -check (long i, unsigned char rnd) +check (long i, mp_rnd_t rnd) { mpfr_t f; mpz_t z; @@ -104,7 +104,7 @@ main (int argc, char *argv[]) check_large (); check (0, 0); for (j = 0; j < 200000; j++) - check (randlimb () & LONG_MAX, randlimb () % 4); + check (randlimb () & LONG_MAX, RND_RAND () ); check0(); tests_end_mpfr (); diff --git a/tests/tsqrt.c b/tests/tsqrt.c index afad39df9..3acc7749f 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -242,7 +242,7 @@ check_inexact (mp_prec_t p) mpfr_init2 (y, p); mpfr_init2 (z, 2*p); mpfr_random (x); - rnd = randlimb () % 4; + rnd = RND_RAND(); inexact = mpfr_sqrt (y, x, rnd); if (mpfr_mul (z, y, y, rnd)) /* exact since prec(z) = 2*prec(y) */ { diff --git a/tests/tsub.c b/tests/tsub.c index d94d77a7b..806b7316e 100644 --- a/tests/tsub.c +++ b/tests/tsub.c @@ -307,11 +307,10 @@ check_two_sum (mp_prec_t p) mpfr_random (y); if (mpfr_cmpabs (x, y) < 0) mpfr_swap (x, y); - rnd = randlimb () % 4; rnd = GMP_RNDN; - inexact = mpfr_sub (u, x, y, GMP_RNDN); - mpfr_sub (v, u, x, GMP_RNDN); - mpfr_add (w, v, y, GMP_RNDN); + inexact = mpfr_sub (u, x, y, rnd); + mpfr_sub (v, u, x, rnd); + mpfr_add (w, v, y, rnd); /* as u = (x-y) - w, we should have inexact and w of opposite signs */ if (((inexact == 0) && mpfr_cmp_ui (w, 0)) || ((inexact > 0) && (mpfr_cmp_ui (w, 0) <= 0)) || @@ -386,14 +385,14 @@ check_inexact (void) : MPFR_EXP(u) - MPFR_EXP(x); pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u)); mpfr_set_prec (z, pz); - rnd = randlimb () % 4; + rnd = RND_RAND(); if (mpfr_sub (z, x, u, rnd)) { printf ("z <- x - u should be exact\n"); exit (1); } { - rnd = randlimb () % 4; + rnd = RND_RAND (); inexact = mpfr_sub (y, x, u, rnd); cmp = mpfr_cmp (y, z); if (((inexact == 0) && (cmp != 0)) || diff --git a/tests/tsub1sp.c b/tests/tsub1sp.c index 4cbf8ca0a..64250eda2 100644 --- a/tests/tsub1sp.c +++ b/tests/tsub1sp.c @@ -81,7 +81,7 @@ void check_random(mpfr_prec_t p) mpfr_urandomb(y, state); mpfr_urandomb(z, state); if (MPFR_IS_PURE_FP(y) && MPFR_IS_PURE_FP(z)) - for(r = 0 ; r < 4 ; r++) + for(r = 0 ; r < GMP_RND_MAX ; r++) { inexact1 = mpfr_sub1(x2, y, z, r); inexact2 = mpfr_sub1sp(x, y, z, r); @@ -105,7 +105,7 @@ void check_special(void) mpfr_inits(x,y,z,x2,NULL); - for(r = 0 ; r < 4 ; r++) + for(r = 0 ; r < GMP_RND_MAX ; r++) { p = 53; mpfr_set_prec(x, 53); diff --git a/tests/tui_pow.c b/tests/tui_pow.c index 249a020e5..4da7010cf 100644 --- a/tests/tui_pow.c +++ b/tests/tui_pow.c @@ -218,7 +218,7 @@ main (int argc, char *argv[]) int nt; nt = randlimb () & INT_MAX; mpfr_random (x); - rnd = randlimb () % 4; + rnd = RND_RAND (); check1 (x, prec, nt, rnd); } } |