summaryrefslogtreecommitdiff
path: root/gamma.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-28 16:31:13 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-28 16:31:13 +0000
commit117edf14c822a22cdd9c25689aeadc904a1a30d1 (patch)
treee39bd61cefc24cc6cfbc5b2b956e4fb36015d111 /gamma.c
parent734c0a144b04e2cae4e67b394010e3f6e3cadecc (diff)
downloadmpfr-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 'gamma.c')
-rw-r--r--gamma.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/gamma.c b/gamma.c
index 5da283b02..b0613d471 100644
--- a/gamma.c
+++ b/gamma.c
@@ -60,34 +60,36 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mp_rnd_t rnd_mode)
int inex;
/* Trivial cases */
- if (MPFR_IS_NAN(x))
+ if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(x) ))
{
- MPFR_SET_NAN(gamma);
- MPFR_RET_NAN;
- }
-
- if (MPFR_IS_INF(x))
- {
- if (MPFR_SIGN(x) < 0)
- {
- MPFR_SET_NAN(gamma);
- MPFR_RET_NAN;
- }
- else
- {
- MPFR_CLEAR_NAN(gamma);
- MPFR_SET_INF(gamma);
- MPFR_SET_POS(gamma);
- return 0; /* exact */
- }
- }
-
- if (MPFR_IS_ZERO(x))
- {
- MPFR_CLEAR_NAN(gamma);
- MPFR_SET_INF(gamma);
- MPFR_SET_SAME_SIGN(gamma, x);
- return 0; /* exact */
+ if (MPFR_IS_NAN(x))
+ {
+ MPFR_SET_NAN(gamma);
+ MPFR_RET_NAN;
+ }
+ if (MPFR_IS_INF(x))
+ {
+ if (MPFR_IS_NEG(x))
+ {
+ MPFR_SET_NAN(gamma);
+ MPFR_RET_NAN;
+ }
+ else
+ {
+ MPFR_CLEAR_NAN(gamma);
+ MPFR_SET_INF(gamma);
+ MPFR_SET_POS(gamma);
+ return 0; /* exact */
+ }
+ }
+ if (MPFR_IS_ZERO(x))
+ {
+ MPFR_CLEAR_NAN(gamma);
+ MPFR_SET_INF(gamma);
+ MPFR_SET_SAME_SIGN(gamma, x);
+ return 0; /* exact */
+ }
+ MPFR_ASSERTN(1);
}
/* Set x_p=x if x> 1 else set x_p=2-x */