Skip to content

bpo-26121: Revert to using the own implementations of lgamma and gamm… #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ Library
- bpo-28692: Using non-integer value for selecting a plural form in gettext is
now deprecated.

- bpo-26121: Use C library implementation for math functions:
tgamma(), lgamma(), erf() and erfc().
- bpo-26121: Use C library implementation for math functions erf() and erfc().

- bpo-29619: os.stat() and os.DirEntry.inode() now convert inode (st_ino) using
unsigned integers.
Expand Down
31 changes: 0 additions & 31 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,6 @@ static const double pi = 3.141592653589793238462643383279502884197;
static const double sqrtpi = 1.772453850905516027298167483341145182798;
static const double logpi = 1.144729885849400174143427351353058711647;

#ifndef __APPLE__
# ifdef HAVE_TGAMMA
# define USE_TGAMMA
# endif
# ifdef HAVE_LGAMMA
# define USE_LGAMMA
# endif
#endif

#if !defined(USE_TGAMMA) || !defined(USE_LGAMMA)

static double
sinpi(double x)
{
Expand Down Expand Up @@ -241,7 +230,6 @@ lanczos_sum(double x)
}
return num/den;
}
#endif /* !defined(USE_TGAMMA) || !defined(USE_LGAMMA) */

/* Constant for +infinity, generated in the same way as float('inf'). */

Expand Down Expand Up @@ -275,14 +263,6 @@ m_nan(void)
static double
m_tgamma(double x)
{
#ifdef USE_TGAMMA
if (x == 0.0) {
errno = EDOM;
/* tgamma(+-0.0) = +-inf, divide-by-zero */
return copysign(Py_HUGE_VAL, x);
}
return tgamma(x);
#else
double absx, r, y, z, sqrtpow;

/* special cases */
Expand Down Expand Up @@ -374,7 +354,6 @@ m_tgamma(double x)
if (Py_IS_INFINITY(r))
errno = ERANGE;
return r;
#endif
}

/*
Expand All @@ -386,15 +365,6 @@ static double
m_lgamma(double x)
{
double r;

#ifdef USE_LGAMMA
r = lgamma(x);
if (errno == ERANGE && x == floor(x) && x <= 0.0) {
errno = EDOM; /* lgamma(n) = inf, divide-by-zero for */
return Py_HUGE_VAL; /* integers n <= 0 */
}
return r;
#else
double absx;

/* special cases */
Expand Down Expand Up @@ -433,7 +403,6 @@ m_lgamma(double x)
if (Py_IS_INFINITY(r))
errno = ERANGE;
return r;
#endif
}

#if !defined(HAVE_ERF) || !defined(HAVE_ERFC)
Expand Down