diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-02-28 09:10:28 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-02-28 09:10:28 +0000 |
commit | 8cc8fb658820edacf8c1c0684d81c85cea8597e0 (patch) | |
tree | cbf6ed9c36f8a3ebc7452d9e01c49ead2bd6d47e /src/beta.c | |
parent | b4bc3781c7d0aff4dc292231f0c7e39d91b1b029 (diff) | |
download | mpfr-8cc8fb658820edacf8c1c0684d81c85cea8597e0.tar.gz |
[src/beta.c] Added comments and some corrections (incomplete) for the
case "z or w is 0".
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11372 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/beta.c')
-rw-r--r-- | src/beta.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/beta.c b/src/beta.c index b2f4154bc..2ab00c16e 100644 --- a/src/beta.c +++ b/src/beta.c @@ -121,21 +121,38 @@ mpfr_beta (mpfr_ptr r, mpfr_srcptr z, mpfr_srcptr w, mpfr_rnd_t rnd_mode) } else /* z or w is 0 */ { - if (mpfr_cmp_ui (z, 0) != 0) /* then w = +0 or -0 */ + /* If x is not a nonpositive integer, Gamma(x) is regular, so that + when y -> 0 with either y >= 0 or y <= 0, + Beta(x,y) ~ Gamma(y) / Gamma(x) + Gamma(y) tends to an infinity of the same sign as y. + Thus Beta(x,y) should be an infinity whose sign is the product + of the signs of y and Gamma(x). */ + if (mpfr_cmp_ui (z, 0) != 0) /* then w is +0 or -0 and z > 0 */ { - /* beta(z,+0) = +Inf, beta(z,-0) = -Inf */ + /* beta(z,+0) = +Inf, beta(z,-0) = -Inf (see above) */ MPFR_SET_INF(r); MPFR_SET_SAME_SIGN(r,w); MPFR_SET_DIVBY0 (); MPFR_RET(0); } - else if (mpfr_cmp_ui (w, 0) != 0) + else if (mpfr_cmp_ui (w, 0) != 0) /* then z is +0 or -0 and w < 0 */ { - /* beta(+0,w) = +Inf, beta(-0,w) = -Inf */ - MPFR_SET_INF(r); - MPFR_SET_SAME_SIGN(r,z); - MPFR_SET_DIVBY0 (); - MPFR_RET(0); + if (mpfr_integer_p (w)) + { + /* When y -> w, |Gamma(y)| -> +Inf but Gamma(y) takes + opposite signs for y < w and y > w, so that the + result is NaN. */ + MPFR_SET_NAN(r); + MPFR_RET_NAN; + } + else + { + /* FIXME concerning the sign (see above) */ + MPFR_SET_INF(r); + MPFR_SET_SAME_SIGN(r,z); + MPFR_SET_DIVBY0 (); + MPFR_RET(0); + } } else /* w = z = 0: beta(+0,+0) = +Inf |