lgamma(p1)
public
Calculates the logarithmic gamma of x
and the sign of gamma of x.
Math.lgamma(x) is same as
- Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1
-
but avoid overflow by Math.gamma(x) for large x.
static VALUE
math_lgamma(VALUE obj, VALUE x)
{
double d0, d;
int sign;
VALUE v;
Need_Float(x);
errno = 0;
d0 = RFLOAT_VALUE(x);
d = lgamma_r(d0, &sign);
domain_check(d0, d, "lgamma");
v = DBL2NUM(d);
return rb_assoc_new(v, INT2FIX(sign));
}