diff options
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/const_pi.c')
-rw-r--r-- | Build/source/libs/mpfr/mpfr-src/src/const_pi.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/const_pi.c b/Build/source/libs/mpfr/mpfr-src/src/const_pi.c index ba9fced04f5..77d8df01e33 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/const_pi.c +++ b/Build/source/libs/mpfr/mpfr-src/src/const_pi.c @@ -44,6 +44,7 @@ mpfr_const_pi_internal (mpfr_ptr x, mpfr_rnd_t rnd_mode) { mpfr_t a, A, B, D, S; mpfr_prec_t px, p, cancel, k, kmax; + MPFR_GROUP_DECL (group); MPFR_ZIV_DECL (loop); int inex; @@ -58,11 +59,7 @@ mpfr_const_pi_internal (mpfr_ptr x, mpfr_rnd_t rnd_mode) p = px + 3 * kmax + 14; /* guarantees no recomputation for px <= 10000 */ - mpfr_init2 (a, p); - mpfr_init2 (A, p); - mpfr_init2 (B, p); - mpfr_init2 (D, p); - mpfr_init2 (S, p); + MPFR_GROUP_INIT_5 (group, p, a, A, B, D, S); MPFR_ZIV_INIT (loop, p); for (;;) { @@ -87,13 +84,13 @@ mpfr_const_pi_internal (mpfr_ptr x, mpfr_rnd_t rnd_mode) mpfr_sub (Bp, Ap, S, MPFR_RNDN); /* -1/4 <= Bp <= 3/4 */ mpfr_mul_2ui (Bp, Bp, 1, MPFR_RNDN); /* -1/2 <= Bp <= 3/2 */ mpfr_sub (S, Ap, Bp, MPFR_RNDN); - MPFR_ASSERTN (mpfr_cmp_ui (S, 1) < 0); - cancel = mpfr_cmp_ui (S, 0) ? (mpfr_uexp_t) -mpfr_get_exp(S) : p; + MPFR_ASSERTD (mpfr_cmp_ui (S, 1) < 0); + cancel = MPFR_NOTZERO (S) ? (mpfr_uexp_t) -mpfr_get_exp(S) : p; /* MPFR_ASSERTN (cancel >= px || cancel >= 9 * (1 << k) - 4); */ mpfr_mul_2ui (S, S, k, MPFR_RNDN); mpfr_sub (D, D, S, MPFR_RNDN); /* stop when |A_k - B_k| <= 2^(k-p) i.e. cancel >= p-k */ - if (cancel + k >= p) + if (cancel >= p - k) break; } #undef b @@ -109,20 +106,12 @@ mpfr_const_pi_internal (mpfr_ptr x, mpfr_rnd_t rnd_mode) p += kmax; MPFR_ZIV_NEXT (loop, p); - mpfr_set_prec (a, p); - mpfr_set_prec (A, p); - mpfr_set_prec (B, p); - mpfr_set_prec (D, p); - mpfr_set_prec (S, p); + MPFR_GROUP_REPREC_5 (group, p, a, A, B, D, S); } MPFR_ZIV_FREE (loop); inex = mpfr_set (x, A, rnd_mode); - mpfr_clear (a); - mpfr_clear (A); - mpfr_clear (B); - mpfr_clear (D); - mpfr_clear (S); + MPFR_GROUP_CLEAR (group); return inex; } |