diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-12-26 11:50:03 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-12-26 11:50:03 +0000 |
commit | 6ddc203e5368cf1d4108e64c18b0bf6c7d53d176 (patch) | |
tree | dda1d9b65325699c60418cfcd02fa5d800cde1f8 /Build/source/libs/mpfr/mpfr-src/src/ai.c | |
parent | bbfe0bab9260ac7a06a69f710b053dcc73cecad2 (diff) |
mpfr-4.0.0
git-svn-id: svn://tug.org/texlive/trunk@46140 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/ai.c')
-rw-r--r-- | Build/source/libs/mpfr/mpfr-src/src/ai.c | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/ai.c b/Build/source/libs/mpfr/mpfr-src/src/ai.c index ba65851e3a5..f24e4a4933a 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/ai.c +++ b/Build/source/libs/mpfr/mpfr-src/src/ai.c @@ -45,7 +45,8 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., */ -/* Airy function Ai evaluated by the most naive algorithm */ +/* Airy function Ai evaluated by the most naive algorithm. + Assume that x is a finite number. */ static int mpfr_ai1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) { @@ -72,26 +73,13 @@ mpfr_ai1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y) ); - /* Special cases */ - if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) - { - if (MPFR_IS_NAN (x)) - { - MPFR_SET_NAN (y); - MPFR_RET_NAN; - } - else if (MPFR_IS_INF (x)) - return mpfr_set_ui (y, 0, rnd); - } - - /* Save current exponents range */ MPFR_SAVE_EXPO_MARK (expo); if (MPFR_UNLIKELY (MPFR_IS_ZERO (x))) { mpfr_t y1, y2; - prec = MPFR_PREC (y) + 3; + prec = MPFR_ADD_PREC (MPFR_PREC (y), 3); mpfr_init2 (y1, prec); mpfr_init2 (y2, prec); MPFR_ZIV_INIT (loop, prec); @@ -133,7 +121,7 @@ mpfr_ai1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) /* if x<=0, ????? */ /* We begin with 11 guard bits */ - prec = MPFR_PREC (y)+11; + prec = MPFR_ADD_PREC (MPFR_PREC (y), 11); MPFR_ZIV_INIT (loop, prec); /* The working precision is heuristically chosen in order to obtain */ @@ -178,7 +166,11 @@ mpfr_ai1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) assumed_exponent = 10; } - wprec = prec + MPFR_INT_CEIL_LOG2 (prec) + 5 + cond + assumed_exponent; + { + mpfr_prec_t incr = + MPFR_INT_CEIL_LOG2 (prec) + 5 + cond + assumed_exponent; + wprec = MPFR_ADD_PREC (prec, incr); + } mpfr_init (ti); mpfr_init (tip1); @@ -276,8 +268,9 @@ mpfr_ai1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) { if (correct_bits < prec) { /* The precision was badly chosen */ - MPFR_LOG_MSG (("Bad assumption on the exponent of Ai(x)", 0)); - MPFR_LOG_MSG ((" (E=%ld)\n", (long) MPFR_GET_EXP (s))); + MPFR_LOG_MSG (("Bad assumption on the exponent of Ai(x)" + " (E=%" MPFR_EXP_FSPEC "d)\n", + (mpfr_eexp_t) MPFR_GET_EXP (s))); wprec = prec + err + 1; } else @@ -311,7 +304,8 @@ mpfr_ai1 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) } -/* Airy function Ai evaluated by Smith algorithm */ +/* Airy function Ai evaluated by Smith algorithm. + Assume that x is a finite number. */ static int mpfr_ai2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) { @@ -339,18 +333,6 @@ mpfr_ai2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) ("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); - /* Special cases */ - if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) - { - if (MPFR_IS_NAN (x)) - { - MPFR_SET_NAN (y); - MPFR_RET_NAN; - } - else if (MPFR_IS_INF (x)) - return mpfr_set_ui (y, 0, rnd); - } - /* Save current exponents range */ MPFR_SAVE_EXPO_MARK (expo); @@ -407,7 +389,7 @@ mpfr_ai2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) L = __gmpfr_isqrt (prec); MPFR_LOG_MSG (("size of blocks L = %lu\n", L)); - z = (mpfr_t *) (*__gmp_allocate_func) ( (L + 1) * sizeof (mpfr_t) ); + z = (mpfr_t *) mpfr_allocate_func ( (L + 1) * sizeof (mpfr_t) ); MPFR_ASSERTN (z != NULL); for (j=0; j<=L; j++) mpfr_init (z[j]); @@ -557,10 +539,10 @@ mpfr_ai2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) for (j=0; j<=L; j++) mpfr_clear (z[j]); - (*__gmp_free_func) (z, (L + 1) * sizeof (mpfr_t)); + mpfr_free_func (z, (L + 1) * sizeof (mpfr_t)); L = __gmpfr_isqrt (t); MPFR_LOG_MSG (("size of blocks L = %lu\n", L)); - z = (mpfr_t *) (*__gmp_allocate_func) ( (L + 1) * sizeof (mpfr_t)); + z = (mpfr_t *) mpfr_allocate_func ( (L + 1) * sizeof (mpfr_t)); MPFR_ASSERTN (z != NULL); for (j=0; j<=L; j++) mpfr_init (z[j]); @@ -576,8 +558,9 @@ mpfr_ai2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) { if (correctBits < prec) { /* The precision was badly chosen */ - MPFR_LOG_MSG (("Bad assumption on the exponent of Ai (x)", 0)); - MPFR_LOG_MSG ((" (E=%ld)\n", (long) (MPFR_GET_EXP (result)))); + MPFR_LOG_MSG (("Bad assumption on the exponent of Ai(x)" + " (E=%" MPFR_EXP_FSPEC "d)\n", + (mpfr_eexp_t) MPFR_GET_EXP (result))); wprec = prec + err + 1; } else @@ -601,7 +584,7 @@ mpfr_ai2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) mpfr_clear (tmp2_sp); for (j=0; j<=L; j++) mpfr_clear (z[j]); - (*__gmp_free_func) (z, (L + 1) * sizeof (mpfr_t)); + mpfr_free_func (z, (L + 1) * sizeof (mpfr_t)); mpfr_clear (s); mpfr_clear (u0); mpfr_clear (u1); @@ -636,6 +619,18 @@ mpfr_ai (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) int use_ai2; MPFR_SAVE_EXPO_DECL (expo); + /* Special cases */ + if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) + { + if (MPFR_IS_NAN (x)) + { + MPFR_SET_NAN (y); + MPFR_RET_NAN; + } + else if (MPFR_IS_INF (x)) + return mpfr_set_ui (y, 0, rnd); + } + /* The exponent range must be large enough for the computation of temp1. */ MPFR_SAVE_EXPO_MARK (expo); |