diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-07-02 00:47:18 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-07-02 00:47:18 +0000 |
commit | f62e3e6cbd88ea00b17bd9496aeaaaac7858adc5 (patch) | |
tree | 716a3b80b053a30e5bdee09fe69b5be1283ab237 /src | |
parent | 4b54c30ab8914451bc2aa4018629061ff7818f63 (diff) | |
download | mpfr-f62e3e6cbd88ea00b17bd9496aeaaaac7858adc5.tar.gz |
[doc/mpfr.texi] Completed specification:
* on special numbers (±0, ±Inf);
* of mpfr_lngamma and mpfr_lgamma on 1 and 2 (result is +0);
* general rules for special values and on mpfr_lngamma.
[src/lngamma.c] Fixed mpfr_lngamma behavior on nonpositive integers
and -Inf.
[tests/tlngamma.c] Update. Test the flags for some special values.
See <https://sympa.inria.fr/sympa/arc/mpfr/2013-08/msg00008.html> about
the behavior of mpfr_lngamma on zero and general rule for such limits.
(merged changesets r8629,8632-8633,8841,8847 from the trunk)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@9605 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src')
-rw-r--r-- | src/lngamma.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lngamma.c b/src/lngamma.c index cd43df615..1a760192b 100644 --- a/src/lngamma.c +++ b/src/lngamma.c @@ -603,16 +603,17 @@ mpfr_lngamma (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) mpfr_get_prec (y), mpfr_log_prec, y, inex)); /* special cases */ - if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) + if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x) || + (MPFR_IS_NEG (x) && mpfr_integer_p (x)))) { - if (MPFR_IS_NAN (x) || MPFR_IS_NEG (x)) + if (MPFR_IS_NAN (x)) { MPFR_SET_NAN (y); MPFR_RET_NAN; } - else /* lngamma(+Inf) = lngamma(+0) = +Inf */ + else /* lngamma(+/-Inf) = lngamma(nonpositive integer) = +Inf */ { - if (MPFR_IS_ZERO (x)) + if (!MPFR_IS_INF (x)) mpfr_set_divby0 (); MPFR_SET_INF (y); MPFR_SET_POS (y); @@ -620,8 +621,8 @@ mpfr_lngamma (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) } } - /* if x < 0 and -2k-1 <= x <= -2k, then lngamma(x) = NaN */ - if (MPFR_IS_NEG (x) && (unit_bit (x) == 0 || mpfr_integer_p (x))) + /* if -2k-1 < x < -2k <= 0, then lngamma(x) = NaN */ + if (MPFR_IS_NEG (x) && unit_bit (x) == 0) { MPFR_SET_NAN (y); MPFR_RET_NAN; |