diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2013-08-23 11:12:37 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2013-08-23 11:12:37 +0000 |
commit | 26cf555e4e8b7f3f3a957a14199feb3c8971b29d (patch) | |
tree | 464536251cda02061ca21fcf7be85b0cb8f7cdd0 /src/ai.c | |
parent | a80a670c8a7341ea3185f55e0821d9a4ecc7540f (diff) | |
download | mpfr-26cf555e4e8b7f3f3a957a14199feb3c8971b29d.tar.gz |
[src/ai.c] Moved the handling of the special cases NaN and ±Inf to
the main function mpfr_ai.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8667 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/ai.c')
-rw-r--r-- | src/ai.c | 43 |
1 files changed, 16 insertions, 27 deletions
@@ -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,19 +73,6 @@ 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); @@ -315,7 +303,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) { @@ -343,18 +332,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); @@ -640,6 +617,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); |