diff options
author | Keith Packard via Newlib <newlib@sourceware.org> | 2020-09-04 09:25:27 -0700 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2020-09-04 21:27:11 +0200 |
commit | 1f8e5847dff27e504949cd21bfeadb987d36ad19 (patch) | |
tree | adbbd24f728478115a1953c57c8dfb35f60ae74f /newlib/libm/math/er_gamma.c | |
parent | a0d7982ff486292540078c0121a435013c5ee1ea (diff) | |
download | newlib-1f8e5847dff27e504949cd21bfeadb987d36ad19.zip newlib-1f8e5847dff27e504949cd21bfeadb987d36ad19.tar.gz newlib-1f8e5847dff27e504949cd21bfeadb987d36ad19.tar.bz2 |
libm: Fix 'gamma' and 'gammaf' functions. Clean up other gamma code. [v2]
The current gamma, gamma_r, gammaf and gammaf_r functions return
|gamma(x)| instead of ln(|gamma(x)|) due to a change made back in 2002
to the __ieee754_gamma_r implementation. This patch fixes that, making
all of these functions map too their lgamma equivalents.
To fix the underlying bug, the __ieee754_gamma functions have been
changed to return gamma(x), removing the _r variants as those are no
longer necessary. Their names have been changed to __ieee754_tgamma to
avoid potential confusion from users.
Now that the __ieee754_tgamma functions return the correctly signed
value, the tgamma functions have been modified to use them.
libm.a now exposes the following gamma functions:
ln(|gamma(x)|):
__ieee754_lgamma_r
__ieee754_lgammaf_r
lgamma
lgamma_r
gamma
gamma_r
lgammaf
lgammaf_r
gammaf
gammaf_r
lgammal (on machines where long double is double)
gamma(x):
__ieee754_tgamma
__ieee754_tgammaf
tgamma
tgammaf
tgammal (on machines where long double is double)
Additional aliases for any of the above functions can be added if
necessary; in particular, I'm not sure if we need to include
__ieee754_gamma*_r functions (which would return ln(|(gamma(x)|).
Signed-off-by: Keith Packard <keithp@keithp.com>
----
v2:
Switch commit message to ASCII
Diffstat (limited to 'newlib/libm/math/er_gamma.c')
-rw-r--r-- | newlib/libm/math/er_gamma.c | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/newlib/libm/math/er_gamma.c b/newlib/libm/math/er_gamma.c deleted file mode 100644 index 3c0e241..0000000 --- a/newlib/libm/math/er_gamma.c +++ /dev/null @@ -1,32 +0,0 @@ - -/* @(#)er_gamma.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* __ieee754_gamma_r(x, signgamp) - * Reentrant version of the logarithm of the Gamma function - * with user provide pointer for the sign of Gamma(x). - * - * Method: See __ieee754_lgamma_r - */ - -#include "fdlibm.h" - -#ifdef __STDC__ - double __ieee754_gamma_r(double x, int *signgamp) -#else - double __ieee754_gamma_r(x,signgamp) - double x; int *signgamp; -#endif -{ - return __ieee754_exp (__ieee754_lgamma_r(x,signgamp)); -} |