12 #include "ruby/config.h" 24 return 1/x < 0 ? -HUGE_VAL : HUGE_VAL;
27 static double zero = 0.0;
42 #define PI 3.14159265358979324 43 #define LOG_2PI 1.83787706640934548 47 #define B1 (-1.0 / 2.0) 48 #define B2 ( 1.0 / 6.0) 49 #define B4 (-1.0 / 30.0) 50 #define B6 ( 1.0 / 42.0) 51 #define B8 (-1.0 / 30.0) 52 #define B10 ( 5.0 / 66.0) 53 #define B12 (-691.0 / 2730.0) 54 #define B14 ( 7.0 / 6.0) 55 #define B16 (-3617.0 / 510.0) 63 while (x <
N) { v *= x; x++; }
65 return ((((((((
B16 / (16 * 15)) * w + (
B14 / (14 * 13))) * w
66 + (
B12 / (12 * 11))) * w + (
B10 / (10 * 9))) * w
67 + (
B8 / ( 8 * 7))) * w + (
B6 / ( 6 * 5))) * w
68 + (
B4 / ( 4 * 3))) * w + (
B2 / ( 2 * 1))) / x
69 + 0.5 *
LOG_2PI - log(v) - x + (x - 0.5) * log(x);
76 return 1/x < 0 ? -HUGE_VAL : HUGE_VAL;
80 static double zero = 0.0;
87 sign = (fmod(i, 2.0) != 0.0) ? 1 : -1;
static double loggamma(double x)
RUBY_EXTERN double lgamma_r(double, int *)