12 #include "ruby/config.h" 19 # if !defined __MINGW32__ || defined __NO_ISOCEXT 21 # define isnan(x) _isnan(x) 24 # define isinf(x) (!_finite(x) && !_isnan(x)) 27 # define finite(x) _finite(x) 35 #define PI 3.14159265358979324 36 #define LOG_2PI 1.83787706640934548 40 #define B1 (-1.0 / 2.0) 41 #define B2 ( 1.0 / 6.0) 42 #define B4 (-1.0 / 30.0) 43 #define B6 ( 1.0 / 42.0) 44 #define B8 (-1.0 / 30.0) 45 #define B10 ( 5.0 / 66.0) 46 #define B12 (-691.0 / 2730.0) 47 #define B14 ( 7.0 / 6.0) 48 #define B16 (-3617.0 / 510.0) 56 while (x <
N) { v *= x; x++; }
58 return ((((((((
B16 / (16 * 15)) * w + (
B14 / (14 * 13))) * w
59 + (
B12 / (12 * 11))) * w + (
B10 / (10 * 9))) * w
60 + (
B8 / ( 8 * 7))) * w + (
B6 / ( 6 * 5))) * w
61 + (
B4 / ( 4 * 3))) * w + (
B2 / ( 2 * 1))) / x
62 + 0.5 *
LOG_2PI - log(v) - x + (x - 0.5) * log(x);
71 return 1/x < 0 ? -HUGE_VAL : HUGE_VAL;
78 static double zero = 0.0;
87 sign = (fmod(i, 2.0) != 0.0) ? 1 : -1;
88 return sign *
PI / (sin(
PI * f) * exp(loggamma(1 - x)));
92 return exp(loggamma(x));
RUBY_EXTERN double lgamma_r(double, int *)
RUBY_EXTERN int isinf(double)
#define domain_error(msg)