diff options
Diffstat (limited to 'tests/tpow_all.c')
-rw-r--r-- | tests/tpow_all.c | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/tests/tpow_all.c b/tests/tpow_all.c index db1ceeb49..cf66e95aa 100644 --- a/tests/tpow_all.c +++ b/tests/tpow_all.c @@ -58,7 +58,7 @@ err (const char *s, int i, int j, int rnd, mpfr_srcptr z, int inex) printf ("x = %s, y = %s, %s\n", val[i], val[j], mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf ("z = "); - mpfr_out_str (stdout, 10, 0, z, GMP_RNDN); + mpfr_out_str (stdout, 10, 0, z, MPFR_RNDN); printf ("\ninex = %d\n", inex); exit (1); } @@ -104,7 +104,7 @@ cmpres (int spx, const void *px, const char *sy, mp_rnd_t rnd, printf ("%s, ", (char *) px); else { - mpfr_out_str (stdout, 16, 0, (mpfr_ptr) px, GMP_RNDN); + mpfr_out_str (stdout, 16, 0, (mpfr_ptr) px, MPFR_RNDN); puts (","); } printf ("y = %s, %s\n", sy, mpfr_print_rnd_mode (rnd)); @@ -115,11 +115,11 @@ cmpres (int spx, const void *px, const char *sy, mp_rnd_t rnd, } else { - mpfr_out_str (stdout, 16, 0, z1, GMP_RNDN); + mpfr_out_str (stdout, 16, 0, z1, MPFR_RNDN); printf (", inex = %d, flags = %u\n", SIGN (inex1), flags1); } printf ("Got "); - mpfr_out_str (stdout, 16, 0, z2, GMP_RNDN); + mpfr_out_str (stdout, 16, 0, z2, MPFR_RNDN); printf (", inex = %d, flags = %u\n", SIGN (inex2), flags2); if (all_cmpres_errors != 0) all_cmpres_errors = -1; @@ -131,8 +131,8 @@ static int is_odd (mpfr_srcptr x) { /* works only with the values from val[] */ - return mpfr_integer_p (x) && mpfr_fits_slong_p (x, GMP_RNDN) && - (mpfr_get_si (x, GMP_RNDN) & 1); + return mpfr_integer_p (x) && mpfr_fits_slong_p (x, MPFR_RNDN) && + (mpfr_get_si (x, MPFR_RNDN) & 1); } /* Compare the result (z1,inex1) of mpfr_pow with all flags cleared @@ -163,9 +163,9 @@ test_others (const void *sx, const char *sy, mp_rnd_t rnd, /* If y is an integer that fits in an unsigned long and is not -0, we can test mpfr_pow_ui. */ if (MPFR_IS_POS (y) && mpfr_integer_p (y) && - mpfr_fits_ulong_p (y, GMP_RNDN)) + mpfr_fits_ulong_p (y, MPFR_RNDN)) { - unsigned long yy = mpfr_get_ui (y, GMP_RNDN); + unsigned long yy = mpfr_get_ui (y, MPFR_RNDN); mpfr_clear_flags (); inex2 = mpfr_pow_ui (z2, x, yy, rnd); @@ -179,9 +179,9 @@ test_others (const void *sx, const char *sy, mp_rnd_t rnd, /* If x is an integer that fits in an unsigned long and is not -0, we can also test mpfr_ui_pow_ui. */ if (MPFR_IS_POS (x) && mpfr_integer_p (x) && - mpfr_fits_ulong_p (x, GMP_RNDN)) + mpfr_fits_ulong_p (x, MPFR_RNDN)) { - unsigned long xx = mpfr_get_ui (x, GMP_RNDN); + unsigned long xx = mpfr_get_ui (x, MPFR_RNDN); mpfr_clear_flags (); inex2 = mpfr_ui_pow_ui (z2, xx, yy, rnd); @@ -202,9 +202,9 @@ test_others (const void *sx, const char *sy, mp_rnd_t rnd, mpz_t yyy; /* If y fits in a long, we can test mpfr_pow_si. */ - if (mpfr_fits_slong_p (y, GMP_RNDN)) + if (mpfr_fits_slong_p (y, MPFR_RNDN)) { - long yy = mpfr_get_si (y, GMP_RNDN); + long yy = mpfr_get_si (y, MPFR_RNDN); mpfr_clear_flags (); inex2 = mpfr_pow_si (z2, x, yy, rnd); @@ -244,7 +244,7 @@ test_others (const void *sx, const char *sy, mp_rnd_t rnd, /* Test mpfr_pow_z. */ mpz_init (yyy); - mpfr_get_z (yyy, y, GMP_RNDN); + mpfr_get_z (yyy, y, MPFR_RNDN); mpfr_clear_flags (); inex2 = mpfr_pow_z (z2, x, yyy, rnd); cmpres (spx, sx, sy, rnd, z1, inex1, z2, inex2, flags, @@ -291,9 +291,9 @@ test_others (const void *sx, const char *sy, mp_rnd_t rnd, /* If x is an integer that fits in an unsigned long and is not -0, we can test mpfr_ui_pow. */ if (MPFR_IS_POS (x) && mpfr_integer_p (x) && - mpfr_fits_ulong_p (x, GMP_RNDN)) + mpfr_fits_ulong_p (x, MPFR_RNDN)) { - unsigned long xx = mpfr_get_ui (x, GMP_RNDN); + unsigned long xx = mpfr_get_ui (x, MPFR_RNDN); mpfr_clear_flags (); inex2 = mpfr_ui_pow (z2, xx, y, rnd); @@ -356,7 +356,7 @@ my_setstr (mpfr_ptr t, const char *s) MPFR_SET_POS (t); return 0; } - return mpfr_set_str (t, s, 10, GMP_RNDN); + return mpfr_set_str (t, s, 10, MPFR_RNDN); } static void @@ -401,7 +401,7 @@ tst (void) if (mpfr_overflow_p ()) err ("got overflow", i, j, rnd, z, inex); exact = MPFR_IS_SINGULAR (z) || - (mpfr_mul_2ui (tmp, z, 16, GMP_RNDN), mpfr_integer_p (tmp)); + (mpfr_mul_2ui (tmp, z, 16, MPFR_RNDN), mpfr_integer_p (tmp)); if (exact && inex != 0) err ("got exact value with ternary flag different from 0", i, j, rnd, z, inex); @@ -478,19 +478,19 @@ underflow_up1 (void) return; mpfr_init2 (delta, 2); - inex = mpfr_set_ui_2exp (delta, 1, -2, GMP_RNDN); + inex = mpfr_set_ui_2exp (delta, 1, -2, MPFR_RNDN); MPFR_ASSERTN (inex == 0); mpfr_init2 (x, 8); - inex = mpfr_set_ui (x, 2, GMP_RNDN); + inex = mpfr_set_ui (x, 2, MPFR_RNDN); MPFR_ASSERTN (inex == 0); mpfr_init2 (y, sizeof (long) * CHAR_BIT + 4); - inex = mpfr_set_si (y, n, GMP_RNDN); + inex = mpfr_set_si (y, n, MPFR_RNDN); MPFR_ASSERTN (inex == 0); mpfr_init2 (z0, 2); - mpfr_set_ui (z0, 0, GMP_RNDN); + mpfr_set_ui (z0, 0, MPFR_RNDN); mpfr_init2 (z, 32); @@ -501,7 +501,7 @@ underflow_up1 (void) /* Test 2^(emin - i/4). * --> Underflow iff i > 4. - * --> Zero in GMP_RNDN iff i >= 8. + * --> Zero in MPFR_RNDN iff i >= 8. */ if (i != 0 && i != 4) @@ -515,8 +515,8 @@ underflow_up1 (void) { int zero; - zero = (i > 4 && (rnd == GMP_RNDZ || rnd == GMP_RNDD)) || - (i >= 8 && rnd == GMP_RNDN); + zero = (i > 4 && (rnd == MPFR_RNDZ || rnd == MPFR_RNDD)) || + (i >= 8 && rnd == MPFR_RNDN); mpfr_clear_flags (); inex = mpfr_pow (z, x, y, (mp_rnd_t) rnd); @@ -526,7 +526,7 @@ underflow_up1 (void) "underflow_up1"); } - inex = mpfr_sub (y, y, delta, GMP_RNDN); + inex = mpfr_sub (y, y, delta, MPFR_RNDN); MPFR_ASSERTN (inex == 0); } @@ -537,7 +537,7 @@ underflow_up1 (void) * due to a double-rounding problem when rescaling the result: * Error with underflow_up2 and extended exponent range * x = 7.fffffffffffffff0@-1, - * y = 4611686018427387904, GMP_RNDN + * y = 4611686018427387904, MPFR_RNDN * Expected 1.0000000000000000@-1152921504606846976, inex = 1, flags = 9 * Got 0, inex = -1, flags = 9 * With pow_ui.c r5423, the following test fails on a 64-bit Linux machine @@ -545,7 +545,7 @@ underflow_up1 (void) * error is ignored): * Error with mpfr_pow_ui, flags cleared * x = 7.fffffffffffffff0@-1, - * y = 4611686018427387904, GMP_RNDN + * y = 4611686018427387904, MPFR_RNDN * Expected 1.0000000000000000@-1152921504606846976, inex = 1, flags = 9 * Got 0, inex = -1, flags = 9 */ @@ -563,17 +563,17 @@ underflow_up2 (void) return; mpfr_init2 (eps, 2); - mpfr_set_ui_2exp (eps, 1, -1, GMP_RNDN); /* 1/2 */ - mpfr_div_ui (eps, eps, n, GMP_RNDZ); /* 1/(2n) rounded toward zero */ + mpfr_set_ui_2exp (eps, 1, -1, MPFR_RNDN); /* 1/2 */ + mpfr_div_ui (eps, eps, n, MPFR_RNDZ); /* 1/(2n) rounded toward zero */ mpfr_init2 (x, sizeof (unsigned long) * CHAR_BIT + 1); - inex = mpfr_ui_sub (x, 1, eps, GMP_RNDN); + inex = mpfr_ui_sub (x, 1, eps, MPFR_RNDN); MPFR_ASSERTN (inex == 0); /* since n < 2^(size_of_long_in_bits) */ - inex = mpfr_div_2ui (x, x, 1, GMP_RNDN); /* 1/2 - eps/2 exactly */ + inex = mpfr_div_2ui (x, x, 1, MPFR_RNDN); /* 1/2 - eps/2 exactly */ MPFR_ASSERTN (inex == 0); mpfr_init2 (y, sizeof (unsigned long) * CHAR_BIT); - inex = mpfr_set_ui (y, n, GMP_RNDN); + inex = mpfr_set_ui (y, n, MPFR_RNDN); MPFR_ASSERTN (inex == 0); /* 0 < eps < 1 / (2n), thus (1 - eps)^n > 1/2, @@ -585,8 +585,8 @@ underflow_up2 (void) int expected_inex; char sy[256]; - mpfr_set_ui (z0, 0, GMP_RNDN); - expected_inex = rnd == GMP_RNDN || rnd == GMP_RNDU || rnd == GMP_RNDA ? + mpfr_set_ui (z0, 0, MPFR_RNDN); + expected_inex = rnd == MPFR_RNDN || rnd == MPFR_RNDU || rnd == MPFR_RNDA ? (mpfr_nextabove (z0), 1) : -1; sprintf (sy, "%lu", (unsigned long) n); @@ -614,7 +614,7 @@ underflow_up3 (void) mpfr_init2 (z, 32); mpfr_init2 (z0, 2); - inex = mpfr_set_exp_t (y, mpfr_get_emin () - 2, GMP_RNDN); + inex = mpfr_set_exp_t (y, mpfr_get_emin () - 2, MPFR_RNDN); MPFR_ASSERTN (inex == 0); for (i = -1; i <= 1; i++) RND_LOOP (rnd) @@ -622,17 +622,17 @@ underflow_up3 (void) unsigned int ufinex = MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT; int expected_inex; - mpfr_set_ui (x, 2, GMP_RNDN); + mpfr_set_ui (x, 2, MPFR_RNDN); if (i < 0) mpfr_nextbelow (x); if (i > 0) mpfr_nextabove (x); /* x = 2 + i * eps, y = emin - 2, x^y ~= 2^(emin - 2) */ - expected_inex = rnd == GMP_RNDU || rnd == GMP_RNDA - || (rnd == GMP_RNDN && i < 0) ? 1 : -1; + expected_inex = rnd == MPFR_RNDU || rnd == MPFR_RNDA + || (rnd == MPFR_RNDN && i < 0) ? 1 : -1; - mpfr_set_ui (z0, 0, GMP_RNDN); + mpfr_set_ui (z0, 0, MPFR_RNDN); if (expected_inex > 0) mpfr_nextabove (z0); @@ -667,7 +667,7 @@ overflow_inv (void) mpfr_init2 (y, 2); mpfr_init2 (z, 8); - mpfr_set_si (y, -1, GMP_RNDN); + mpfr_set_si (y, -1, MPFR_RNDN); for (precx = 10; precx <= 100; precx += 90) { const char *sp = precx == 10 ? @@ -676,7 +676,7 @@ overflow_inv (void) mpfr_init2 (x, precx); for (s = -1; s <= 1; s += 2) { - inex = mpfr_set_si_2exp (x, s, - mpfr_get_emax (), GMP_RNDN); + inex = mpfr_set_si_2exp (x, s, - mpfr_get_emax (), MPFR_RNDN); MPFR_ASSERTN (inex == 0); for (t = 0; t <= 5; t++) { @@ -685,31 +685,31 @@ overflow_inv (void) * 1/x = s * 2^emax * (1 - t * 2^(-9) + eps) with eps > 0. * Values of (1/x) / 2^emax and overflow condition for x > 0: * t = 0: 1 o: always - * t = 1: 0.11111111 100000000011... o: GMP_RNDN and GMP_RNDU - * t = 2: 0.11111111 000000001111... o: GMP_RNDU + * t = 1: 0.11111111 100000000011... o: MPFR_RNDN and MPFR_RNDU + * t = 2: 0.11111111 000000001111... o: MPFR_RNDU * t = 3: 0.11111110 100000100011... o: never * * If precx = 100: * t = 0: always overflow - * t > 0: overflow for GMP_RNDN and GMP_RNDU. + * t > 0: overflow for MPFR_RNDN and MPFR_RNDU. */ RND_LOOP (rnd) { int inf, overflow; mp_rnd_t rnd2; - if (rnd == GMP_RNDA) - rnd2 = s < 0 ? GMP_RNDD : GMP_RNDU; + if (rnd == MPFR_RNDA) + rnd2 = s < 0 ? MPFR_RNDD : MPFR_RNDU; else rnd2 = rnd; overflow = t == 0 || - ((mp_rnd_t) rnd == GMP_RNDN && (precx > 10 || t == 1)) || - ((mp_rnd_t) rnd2 == (s < 0 ? GMP_RNDD : GMP_RNDU) && + ((mp_rnd_t) rnd == MPFR_RNDN && (precx > 10 || t == 1)) || + ((mp_rnd_t) rnd2 == (s < 0 ? MPFR_RNDD : MPFR_RNDU) && (precx > 10 || t <= 2)); inf = overflow && - ((mp_rnd_t) rnd == GMP_RNDN || - (mp_rnd_t) rnd2 == (s < 0 ? GMP_RNDD : GMP_RNDU)); + ((mp_rnd_t) rnd == MPFR_RNDN || + (mp_rnd_t) rnd2 == (s < 0 ? MPFR_RNDD : MPFR_RNDU)); mpfr_clear_flags (); inex = mpfr_pow (z, x, y, (mp_rnd_t) rnd); if (overflow ^ !! mpfr_overflow_p ()) @@ -726,7 +726,7 @@ overflow_inv (void) "s = %d, t = %d, %s\nGot ", sp, ext ? ", extended exponent range" : "", s, t, mpfr_print_rnd_mode ((mp_rnd_t) rnd)); - mpfr_out_str (stdout, 16, 0, z, GMP_RNDN); + mpfr_out_str (stdout, 16, 0, z, MPFR_RNDN); printf (" instead of %s value.\n", inf ? "infinite" : "finite"); exit (1); |