pub fn lgamma(value: f64) -> Result<(f64, i32), DomainError>
Expand description
Calculates the logarithmic gamma of value and the sign of gamma of value.
lgamma
is same as:
[Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
but avoids overflow of gamma
for large values.
§Examples
use spinoso_math as math;
assert_eq!(math::lgamma(0.0), Ok((f64::INFINITY, 1)));
assert!(math::lgamma(f64::NEG_INFINITY).is_err());
§Errors
If the given value is negative infinity, an error is returned.