17 #define PI 3.14159265358979324 18 #define LOG_2PI 1.83787706640934548 19 #define LOG_PI 1.14472988584940017 23 #define B1 (-1.0 / 2.0) 24 #define B2 ( 1.0 / 6.0) 25 #define B4 (-1.0 / 30.0) 26 #define B6 ( 1.0 / 42.0) 27 #define B8 (-1.0 / 30.0) 28 #define B10 ( 5.0 / 66.0) 29 #define B12 (-691.0 / 2730.0) 30 #define B14 ( 7.0 / 6.0) 31 #define B16 (-3617.0 / 510.0) 38 if (x == 1.0 || x == 2.0)
return 0.0;
41 while (x <
N) { v *= x; x++; }
43 return ((((((((
B16 / (16 * 15)) * w + (
B14 / (14 * 13))) * w
44 + (
B12 / (12 * 11))) * w + (
B10 / (10 * 9))) * w
45 + (
B8 / ( 8 * 7))) * w + (
B6 / ( 6 * 5))) * w
46 + (
B4 / ( 4 * 3))) * w + (
B2 / ( 2 * 1))) / x
47 + 0.5 *
LOG_2PI - log(v) - x + (x - 0.5) * log(x);
51 #ifdef __MINGW_ATTRIB_PURE 53 #define modf(_X, _Y) __extension__ ({\ 54 double intpart_modf_bug = intpart_modf_bug;\ 55 double result_modf_bug = modf((_X), &intpart_modf_bug);\ 56 *(_Y) = intpart_modf_bug;\ 73 *signp = (fmod(i, 2.0) != 0.0) ? 1 : -1;
76 return LOG_PI - log(s) - loggamma(1 - x);
double lgamma_r(double x, int *signp)
RUBY_EXTERN int signbit(double x)