diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-10-28 16:31:13 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-10-28 16:31:13 +0000 |
commit | 117edf14c822a22cdd9c25689aeadc904a1a30d1 (patch) | |
tree | e39bd61cefc24cc6cfbc5b2b956e4fb36015d111 /acosh.c | |
parent | 734c0a144b04e2cae4e67b394010e3f6e3cadecc (diff) | |
download | mpfr-117edf14c822a22cdd9c25689aeadc904a1a30d1.tar.gz |
Use of MPFR_UNLIKELY and MPFR_IS_SINGULAR for fast detection of special values (Nan, Inf or Zero).
Start to encapsulate the sign to be independant of the reprensation (Must be 1 or -1).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2525 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'acosh.c')
-rw-r--r-- | acosh.c | 36 |
1 files changed, 21 insertions, 15 deletions
@@ -36,29 +36,35 @@ mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode) int inexact = 0; int comp; - if (MPFR_IS_NAN(x) || (comp = mpfr_cmp_ui (x, 1)) < 0) + /* Deal with special cases */ + if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(x) )) + { + /* Nan, or zero or -Inf */ + if (MPFR_IS_NAN(x) || MPFR_IS_ZERO(x) || MPFR_IS_NEG(x) ) + { + MPFR_SET_NAN(y); + MPFR_RET_NAN; + } + else if (MPFR_IS_INF(x)) + { + MPFR_SET_INF(y); + MPFR_SET_POS(y); + MPFR_RET(0); + } + MPFR_ASSERTN(1); + } + else if (MPFR_UNLIKELY( (comp = mpfr_cmp_ui (x, 1)) < 0)) { MPFR_SET_NAN(y); MPFR_RET_NAN; - } - - MPFR_CLEAR_NAN(y); - - if (comp == 0) + } + MPFR_CLEAR_FLAGS(y); + if (MPFR_UNLIKELY( comp == 0 )) { MPFR_SET_ZERO(y); /* acosh(1) = 0 */ MPFR_SET_POS(y); MPFR_RET(0); } - - if (MPFR_IS_INF(x)) - { - MPFR_SET_INF(y); - MPFR_SET_POS(y); - MPFR_RET(0); - } - - MPFR_CLEAR_INF(y); /* General case */ { |