[Bug 1837] New: tgamma() is incorrectly implemented
bugzilla at busybox.net
bugzilla at busybox.net
Tue May 25 22:18:15 UTC 2010
https://bugs.busybox.net/show_bug.cgi?id=1837
Summary: tgamma() is incorrectly implemented
Product: uClibc
Version: 0.9.32
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P5
Component: Standard Compliance
AssignedTo: unassigned at uclibc.org
ReportedBy: r.c.poss at uva.nl
CC: uclibc-cvs at uclibc.org
Estimated Hours: 0.0
As per the ISO standard, tgamma(x) should compute Gamma(x), while lgamma(x)
computes ln(Gamma(x)). The current implementation aliases tgamma and lgamma,
which is incorrect.
This was identified in Sept 2009, as per the comment in e_lgamma_r.c:
"""
/* FIXME! Looks like someone just used __ieee754_gamma_r,
* believing it's a "true" gamma function, but it was not!
* Our tgamma is WRONG.
*/
"""
(Denis Vlasenko, 2009-09-18)
The function tgamma() thus needs to be replaced entirely.
A "quick and dirty" fix is to rewrite as follows:
"""
double y;
int local_signgam;
y = __ieee754_lgamma_r(x, &local_signgam);
return local_signgam * exp(y);
"""
This provides relatively accurate results for small inputs, but diverges for
large inputs.
An alternate implementation can be found in FreeBSD's source, in
/scratch/usr/src/lib/msun/bsdsrc/b_tgamma.c.
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the uClibc-cvs
mailing list