* Returns the base e (2.718...) logarithm of the absolute
* value of the gamma function of the argument.
* The sign (+1 or -1) of the gamma function is returned in a
- * global (extern) variable named sgngam.
+ * global (extern) variable named signgam.
*
* The positive domain is partitioned into numerous segments for approximation.
* For x > 10,
#include "quadmath-imp.h"
+#ifdef HAVE_MATH_H_SIGNGAM
+#include <math.h> /* For POSIX's extern int signgam. */
+#endif
+
static const __float128 PIQ = 3.1415926535897932384626433832795028841972E0Q;
static const __float128 MAXLGM = 1.0485738685148938358098967157129705071571E4928Q;
static const __float128 one = 1.0Q;
lgammaq (__float128 x)
{
__float128 p, q, w, z, nx;
- int i, nn, sign;
+ int i, nn;
+#ifndef HAVE_MATH_H_SIGNGAM
+ int signgam;
+#endif
- sign = 1;
+ signgam = 1;
if (! finiteq (x))
return x * x;
if (x == 0.0Q)
{
if (signbitq (x))
- sign = -1;
+ signgam = -1;
}
if (x < 0.0Q)
return (one / (p - p));
i = p;
if ((i & 1) == 0)
- sign = -1;
+ signgam = -1;
else
- sign = 1;
+ signgam = 1;
z = q - p;
if (z > 0.5Q)
{
}
z = q * sinq (PIQ * z);
if (z == 0.0Q)
- return (sign * huge * huge);
+ return (signgam * huge * huge);
w = lgammaq (q);
z = logq (PIQ / z) - w;
return (z);
{
z = x - 0.75Q;
p = z * neval (z, RN1r75, NRN1r75)
- / deval (z, RD1r75, NRD1r75);
+ / deval (z, RD1r75, NRD1r75);
p += lgam1r75b;
p += lgam1r75a;
}
}
if (x > MAXLGM)
- return (sign * huge * huge);
+ return (signgam * huge * huge);
q = ls2pi - x;
q = (x - 0.5Q) * logq (x) + q;