Class BoostGamma.Lanczos
- Enclosing class:
BoostGamma
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:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate 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 Details
-
G
static final double GLanczos constant G.- See Also:
-
GMH
static final double GMHLanczos constant G - half.Note: The form
(g - 0.5)
is used when computing the gamma function.- See Also:
-
DENOM
private static final int[] DENOMCommon denominator used for the rational evaluation.
-
-
Constructor Details
-
Lanczos
private Lanczos()Private constructor.
-
-
Method Details
-
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
-