Class BoostGamma.Lanczos
- java.lang.Object
-
- org.apache.commons.numbers.gamma.BoostGamma.Lanczos
-
- Enclosing class:
- BoostGamma
static final class BoostGamma.Lanczos extends java.lang.Object
53-bit precision implementation of the Lanczos approximation.This implementation is in partial fraction form with the leading constant of \( \sqrt{2\pi} \) absorbed into the sum.
It is related to the Gamma function by the following equation \[ \Gamma(z) = \frac{(z + g - 0.5)^{z - 0.5}}{e^{z + g - 0.5}} \mathrm{lanczos}(z) \] where \( g \) is the Lanczos constant.
Warning
This is not a substitute for
LanczosApproximation
. The approximation is written in partial fraction form with the leading constants absorbed by the coefficients in the sum.- See Also:
- Boost Lanczos Approximation
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Lanczos()
Private constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static double
evaluateRational(double[] a, int[] b, double x)
Evaluate the rational number as two polynomials.(package private) static double
lanczosSum(double z)
Computes the Lanczos approximation.(package private) static double
lanczosSumExpGScaled(double z)
Computes the Lanczos approximation scaled byexp(g)
.
-
-
-
Field Detail
-
G
static final double G
Lanczos constant G.- See Also:
- Constant Field Values
-
GMH
static final double GMH
Lanczos constant G - half.Note: The form
(g - 0.5)
is used when computing the gamma function.- See Also:
- Constant Field Values
-
DENOM
private static final int[] DENOM
Common denominator used for the rational evaluation.
-
-
Method Detail
-
lanczosSum
static double lanczosSum(double z)
Computes the Lanczos approximation.- Parameters:
z
- Argument.- Returns:
- the Lanczos approximation.
-
lanczosSumExpGScaled
static double lanczosSumExpGScaled(double z)
Computes the Lanczos approximation scaled byexp(g)
.- Parameters:
z
- Argument.- Returns:
- the scaled Lanczos approximation.
-
evaluateRational
private static double evaluateRational(double[] a, int[] b, double x)
Evaluate the rational number as two polynomials.Adapted from
boost/math/tools/detail/rational_horner3_13.hpp
. Note: There are 3 variations of the unrolled rational evaluation. These methods change the order based on the sign of x. This should be used for the Lanczos code as this comment inboost/math/tools/rational.hpp
notes:However, there are some tricks we can use to prevent overflow that might otherwise occur in polynomial evaluation, if z is large. This is important in our Lanczos code for example.
- Parameters:
a
- Coefficients of the numerator polynomialb
- Coefficients of the denominator polynomialx
- Value- Returns:
- the rational number
-
-