diff options
-rw-r--r-- | acos.c | 4 | ||||
-rw-r--r-- | acosh.c | 3 | ||||
-rw-r--r-- | agm.c | 3 | ||||
-rw-r--r-- | asin.c | 4 | ||||
-rw-r--r-- | asinh.c | 3 | ||||
-rw-r--r-- | atan.c | 4 | ||||
-rw-r--r-- | atanh.c | 3 | ||||
-rw-r--r-- | const_euler.c | 3 | ||||
-rw-r--r-- | const_pi.c | 3 | ||||
-rw-r--r-- | cos.c | 3 | ||||
-rw-r--r-- | cosh.c | 5 | ||||
-rw-r--r-- | erf.c | 3 | ||||
-rw-r--r-- | exp2.c | 3 | ||||
-rw-r--r-- | exp_2.c | 3 | ||||
-rw-r--r-- | expm1.c | 3 | ||||
-rw-r--r-- | gmp_op.c | 6 | ||||
-rw-r--r-- | hypot.c | 3 | ||||
-rw-r--r-- | log.c | 3 | ||||
-rw-r--r-- | log10.c | 3 | ||||
-rw-r--r-- | log1p.c | 3 | ||||
-rw-r--r-- | log2.c | 3 | ||||
-rw-r--r-- | mul.c | 6 | ||||
-rw-r--r-- | pow.c | 3 | ||||
-rw-r--r-- | pow_si.c | 3 | ||||
-rw-r--r-- | pow_ui.c | 3 | ||||
-rw-r--r-- | pow_z.c | 6 | ||||
-rw-r--r-- | sinh.c | 3 | ||||
-rw-r--r-- | tan.c | 3 | ||||
-rw-r--r-- | tanh.c | 3 | ||||
-rw-r--r-- | ui_pow_ui.c | 3 | ||||
-rw-r--r-- | zeta.c | 10 |
31 files changed, 41 insertions, 73 deletions
@@ -110,8 +110,8 @@ mpfr_acos (mpfr_ptr acos, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_div_2ui (tmp, tmp, 1, GMP_RNDN); mpfr_sub (arcc, tmp, arcc, GMP_RNDN); - if (mpfr_can_round (arcc, prec-supplement, GMP_RNDN, GMP_RNDZ, - MPFR_PREC (acos) + (rnd_mode == GMP_RNDN))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (arcc, prec-supplement, + MPFR_PREC (acos), rnd_mode))) break; MPFR_ZIV_NEXT (loop, prec); mpfr_set_prec (tmp, prec); @@ -101,8 +101,7 @@ mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) err = Nt - (-1 + 2 * MAX (2 + MAX (2 - MPFR_GET_EXP (t), 1 + exp_te - exp_ti - MPFR_GET_EXP (t)), 0)); - if (MPFR_LIKELY (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* reactualisation of the precision */ @@ -146,8 +146,7 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode) mpfr_swap (v, tmp); } /* Roundability of the result */ - if (MPFR_LIKELY (mpfr_can_round (v, p - 4 - 3, GMP_RNDN, GMP_RNDZ, - q + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (v, p - 4 - 3, q, rnd_mode))) break; /* Stop the loop */ /* Next iteration */ @@ -106,8 +106,8 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_sqrt (xp, xp, GMP_RNDN); mpfr_div (xp, x, xp, GMP_RNDN); mpfr_atan (xp, xp, GMP_RNDN); - if (mpfr_can_round (xp, prec - xp_exp, GMP_RNDN, GMP_RNDZ, - MPFR_PREC (asin) + (rnd_mode == GMP_RNDN))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (xp, prec - xp_exp, + MPFR_PREC (asin), rnd_mode))) break; MPFR_ZIV_NEXT (loop, prec); } @@ -95,8 +95,7 @@ mpfr_asinh (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) err = Nt - (MAX (3 - MPFR_GET_EXP (t), 0) + 1); if (MPFR_LIKELY (MPFR_IS_ZERO (t) - || mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + || MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* actualisation of the precision */ @@ -350,8 +350,8 @@ mpfr_atan (mpfr_ptr atan, mpfr_srcptr x, mp_rnd_t rnd_mode) } MPFR_SET_POS (arctgt); - if (mpfr_can_round (arctgt, realprec, GMP_RNDN, GMP_RNDZ, - MPFR_PREC (atan) + (rnd_mode == GMP_RNDN))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (arctgt, realprec, MPFR_PREC (atan), + rnd_mode))) break; MPFR_ZIV_NEXT (loop, realprec); } @@ -103,8 +103,7 @@ mpfr_atanh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) err = Nt - (MAX (4 - MPFR_GET_EXP (t), 0) + 1); if (MPFR_LIKELY (MPFR_IS_ZERO (t) - || mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + || MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* reactualisation of the precision */ diff --git a/const_euler.c b/const_euler.c index d96e42627..2b9666cfc 100644 --- a/const_euler.c +++ b/const_euler.c @@ -64,8 +64,7 @@ mpfr_const_euler_internal (mpfr_t x, mp_rnd_t rnd) mpfr_set_prec (z, m - log2m); mpfr_const_euler_R (z, n); mpfr_sub (y, y, z, GMP_RNDN); - if (MPFR_LIKELY (mpfr_can_round (y, m - 3, GMP_RNDN, GMP_RNDZ, - prec + (rnd == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (y, m - 3, prec, rnd))) break; MPFR_ZIV_NEXT (loop, m); mpfr_set_prec (y, m); diff --git a/const_pi.c b/const_pi.c index c2ae870ed..4e3237de6 100644 --- a/const_pi.c +++ b/const_pi.c @@ -93,8 +93,7 @@ mpfr_const_pi_internal (mpfr_ptr x, mp_rnd_t rnd_mode) mpfr_div (A, B, D, GMP_RNDN); /* MPFR_ASSERTN(p >= 2 * k + 8); */ - if (MPFR_LIKELY (mpfr_can_round (A, p - 2 * k - 8, GMP_RNDN, GMP_RNDZ, - px + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (A, p - 2 * k - 8, px, rnd_mode))) break; p += kmax; @@ -135,8 +135,7 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) /* now the error is bounded by 2^(k-m) = 2^(EXP(s)-err) */ exps = MPFR_GET_EXP(s); - if (MPFR_LIKELY(mpfr_can_round (s, exps + m - k, GMP_RNDN, GMP_RNDZ, - precy + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (s, exps + m - k, precy, rnd_mode))) break; if (MPFR_UNLIKELY (exps == 1)) @@ -94,9 +94,8 @@ mpfr_cosh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) err = Nt - 3; /* Check if we can round */ - if (MPFR_UNLIKELY(MPFR_IS_INF(t)) || - mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN))) + if (MPFR_UNLIKELY (MPFR_IS_INF (t)) + || MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* Actualisation of the precision */ @@ -172,8 +172,7 @@ mpfr_erf_0 (mpfr_ptr res, mpfr_srcptr x, double xf2, mp_rnd_t rnd_mode) tauk = 4.0 * tauk + 11.0; /* final ulp-error on s */ log2tauk = __gmpfr_ceil_log2 (tauk); - if (MPFR_LIKELY (mpfr_can_round (s, m - log2tauk, GMP_RNDN, GMP_RNDZ, - n + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (s, m - log2tauk, n, rnd_mode))) break; /* Actualisation of the precision */ @@ -116,8 +116,7 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) err = Nt - (MPFR_GET_EXP (t) + 2); /* Estimate of the error */ mpfr_exp (t, t, GMP_RNDN); /* exp(x*ln(2))*/ - if (MPFR_LIKELY (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* Actualisation of the precision */ @@ -184,8 +184,7 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) MPFR_LOG_VAR (s); MPFR_LOG_MSG (("err=%d bits\n", K)); - if (mpfr_can_round (s, q - K, GMP_RNDN, GMP_RNDZ, - precy + (rnd_mode == GMP_RNDN)) ) + if (MPFR_LIKELY (MPFR_CAN_ROUND (s, q-K, precy, rnd_mode))) break; MPFR_ZIV_NEXT (loop, q); mpfr_set_prec (r, q); @@ -93,8 +93,7 @@ mpfr_expm1 (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) /*err=Nt-(__gmpfr_ceil_log2(1+pow(2,MPFR_EXP(te)-MPFR_EXP(t))));*/ err = Nt - (MAX (exp_te - MPFR_GET_EXP (t), 0) + 1); - if (MPFR_LIKELY (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* actualisation of the precision */ @@ -196,8 +196,7 @@ mpfr_add_q (mpfr_ptr y, mpfr_srcptr x, mpq_srcptr z, mp_rnd_t rnd_mode) if (MPFR_LIKELY (!MPFR_IS_ZERO (t))) { err = (mp_exp_t) p - 1 - MAX (MPFR_GET_EXP(q)-MPFR_GET_EXP(t), 0); - if (MPFR_LIKELY (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - MPFR_PREC(y) + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, MPFR_PREC (y), rnd_mode))) { res = mpfr_set (y, t, rnd_mode); break; @@ -275,8 +274,7 @@ mpfr_sub_q (mpfr_ptr y, mpfr_srcptr x, mpq_srcptr z,mp_rnd_t rnd_mode) if (MPFR_LIKELY (!MPFR_IS_ZERO (t))) { err = (mp_exp_t) p - 1 - MAX (MPFR_GET_EXP(q)-MPFR_GET_EXP(t), 0); - res = mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - MPFR_PREC(y) + (rnd_mode == GMP_RNDN) ); + res = MPFR_CAN_ROUND (t, err, MPFR_PREC (y), rnd_mode); if (MPFR_LIKELY (res != 0)) /* We can round! */ { res = mpfr_set (y, t, rnd_mode); @@ -130,8 +130,7 @@ mpfr_hypot (mpfr_ptr z, mpfr_srcptr x , mpfr_srcptr y , mp_rnd_t rnd_mode) exact |= mpfr_sqrt (t, t, GMP_RNDZ); /* sqrt(x^2+y^2)*/ if (MPFR_LIKELY (exact == 0 - || mpfr_can_round (t, Nt - 2, GMP_RNDN, GMP_RNDZ, - Nz + (rnd_mode == GMP_RNDN)))) + || MPFR_CAN_ROUND (t, Nt-2, Nz, rnd_mode))) break; /* reactualization of the precision */ @@ -148,8 +148,7 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode) /* we have 7 ulps of error from the above roundings, 4 ulps from the 4/s^2 second order term, plus the canceled bits */ - if (MPFR_LIKELY (mpfr_can_round (tmp1, p - cancel - 4, GMP_RNDN, - GMP_RNDZ, q + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (tmp1, p-cancel-4, q, rnd_mode))) break; p += cancel; MPFR_ZIV_NEXT (loop, p); @@ -113,8 +113,7 @@ mpfr_log10 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode) /* estimation of the error */ err = Nt - 4; - if (MPFR_LIKELY (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* log10(10^n) is exact: @@ -110,8 +110,7 @@ mpfr_log1p (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) /*err=Nt-(__gmpfr_ceil_log2(1+pow(2,1-MPFR_GET_EXP(t))));*/ err = Nt - (MAX (1 - MPFR_GET_EXP (t), 0) + 1); - if (MPFR_LIKELY (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* actualisation of the precision */ @@ -116,8 +116,7 @@ mpfr_log2 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode) /* estimation of the error */ err = Nt-3; - if (MPFR_LIKELY (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* actualisation of the precision */ @@ -198,8 +198,6 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) /****** END OF CHECK *******/ - - /* Multiply 2 mpfr_t */ int @@ -394,8 +392,8 @@ mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) mpn_lshift (tmp, tmp, tn, 1); MPFR_ASSERTD (MPFR_LIMB_MSB (tmp[tn-1]) != 0); - if (MPFR_UNLIKELY (!mpfr_can_round_raw (tmp, tn, sign, p + b1 - 1, - GMP_RNDN, GMP_RNDZ, MPFR_PREC(a)+(rnd_mode==GMP_RNDN)))) + if (MPFR_UNLIKELY (!mpfr_round_p (tmp, tn, p+b1-1, + MPFR_PREC(a)+(rnd_mode==GMP_RNDN)))) { tmp -= k-tn; /* tmp may have changed, FIX IT!!!!! */ goto full_multiply; @@ -378,8 +378,7 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mp_rnd_t rnd_mode) /* estimate of the error -- see pow function in algorithms.ps */ err = Nt - (exp_te + 3); - if (MPFR_LIKELY (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Nz + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Nz, rnd_mode))) break; /* check exact power */ @@ -120,8 +120,7 @@ mpfr_pow_si (mpfr_ptr y, mpfr_srcptr x, long int n, mp_rnd_t rnd_mode) /* error estimate -- see pow function in algorithms.ps */ err = Nt - 3; if (MPFR_LIKELY (inexact != 0 - || mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + || MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* actualisation of the precision */ @@ -115,8 +115,7 @@ mpfr_pow_ui (mpfr_ptr x, mpfr_srcptr y, unsigned long int n, mp_rnd_t rnd) } if (MPFR_LIKELY (inexact == 0 || mpfr_overflow_p () || mpfr_underflow_p () - || mpfr_can_round (res, err, GMP_RNDN, GMP_RNDZ, - MPFR_PREC(x) + (rnd == GMP_RNDN)))) + || MPFR_CAN_ROUND (res, err, MPFR_PREC (x), rnd))) break; /* Actualisation of the precision */ MPFR_ZIV_NEXT (loop, prec); @@ -68,8 +68,7 @@ mpfr_pow_pos_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z, mp_rnd_t rnd) if (MPFR_LIKELY (inexact == 0 || mpfr_overflow_p () || mpfr_underflow_p () - || mpfr_can_round (res, err, GMP_RNDN, GMP_RNDZ, - MPFR_PREC (y) + (rnd == GMP_RNDN)))) + || MPFR_CAN_ROUND (res, err, MPFR_PREC (y), rnd))) break; /* Actualisation of the precision */ @@ -219,8 +218,7 @@ mpfr_pow_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z, mp_rnd_t rnd) inexact = inexact || MPFR_IS_ZERO (t) || MPFR_IS_INF (t); if (MPFR_LIKELY (inexact != 0 - || mpfr_can_round (t, Nt - 3, GMP_RNDN, GMP_RNDZ, - MPFR_PREC (y) + (rnd == GMP_RNDN)))) + || MPFR_CAN_ROUND (t, Nt-3, MPFR_PREC (y), rnd))) break; /* actualisation of the precision */ MPFR_ZIV_NEXT (loop, Nt); @@ -105,8 +105,7 @@ mpfr_sinh (mpfr_ptr y, mpfr_srcptr xt, mp_rnd_t rnd_mode) /* err = Nt-(__gmpfr_ceil_log2(1+pow(2,d)));*/ err = Nt - (MAX (d, 0) + 1); - if (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - MPFR_PREC (y) + (rnd_mode == GMP_RNDN))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, MPFR_PREC (y), rnd_mode))) break; } /* actualisation of the precision */ @@ -72,8 +72,7 @@ mpfr_tan (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_sin_cos (s, c, x, GMP_RNDN); /* err <= 1/2 ulp on s and c */ mpfr_div (c, s, c, GMP_RNDN); /* err <= 2 ulps */ MPFR_ASSERTD (!MPFR_IS_SINGULAR (c)); - if (MPFR_LIKELY (mpfr_can_round (c, m - 1, GMP_RNDN, GMP_RNDZ, - precy + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (c, m-1, precy, rnd_mode))) break; MPFR_ZIV_NEXT (loop, m); mpfr_set_prec (s, m); @@ -96,8 +96,7 @@ mpfr_tanh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) d = d - MPFR_GET_EXP (t); err = Nt - (MAX(d + 1, 3) + 1); - if (MPFR_LIKELY (mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, - Ny + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (t, err, Ny, rnd_mode))) break; /* if t=1, we still can round */ diff --git a/ui_pow_ui.c b/ui_pow_ui.c index 1303a1884..678801580 100644 --- a/ui_pow_ui.c +++ b/ui_pow_ui.c @@ -70,8 +70,7 @@ mpfr_ui_pow_ui (mpfr_ptr x, unsigned long int y, unsigned long int n, err = prec - err; if (MPFR_LIKELY (inexact == 0 - || mpfr_can_round (res, err, GMP_RNDN, GMP_RNDZ, - MPFR_PREC(x) + (rnd == GMP_RNDN)))) + || MPFR_CAN_ROUND (res, err, MPFR_PREC (x), rnd))) break; /* Actualisation of the precision */ @@ -174,7 +174,7 @@ mpfr_zeta_pos (mpfr_t z, mpfr_srcptr s, mp_rnd_t rnd_mode) for (;;) { /* Principal loop: we compute, in z_pre, - an approximation of Zeta(s), that we send to mpfr_can_round */ + an approximation of Zeta(s), that we send to can_round */ mpfr_sub_ui (s1, s, 1, GMP_RNDN); MPFR_ASSERTN (MPFR_IS_FP (s1)); @@ -265,8 +265,7 @@ mpfr_zeta_pos (mpfr_t z, mpfr_srcptr s, mp_rnd_t rnd_mode) } MPFR_TRACE (MPFR_DUMP (z_pre)); - if (MPFR_LIKELY (mpfr_can_round (z_pre, d - 3, GMP_RNDN, GMP_RNDZ, - precz + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (z_pre, d-3, precz, rnd_mode))) break; MPFR_ZIV_NEXT (loop, d); } @@ -389,9 +388,8 @@ mpfr_zeta (mpfr_t z, mpfr_srcptr s, mp_rnd_t rnd_mode) mpfr_mul (z_pre, z_pre, y, GMP_RNDN); mpfr_mul_2ui (z_pre, z_pre, 1, GMP_RNDN); - if (MPFR_LIKELY (mpfr_can_round (z_pre, prec1 - add, GMP_RNDN, - GMP_RNDZ, - precz + (rnd_mode == GMP_RNDN)))) + if (MPFR_LIKELY (MPFR_CAN_ROUND (z_pre, prec1 - add, precz, + rnd_mode))) break; /* Actualisation of the precision */ |