This class provides various constants and methods to compute numerical quantities such as factorials, combinations, gamma functions, and so on. More...
Static Public Member Functions | |
| static int | gcd (int x, int y) |
| Returns the greatest common divisor (gcd) of \(x\) and \(y\). | |
| static long | gcd (long x, long y) |
| Returns the greatest common divisor (gcd) of \(x\) and \(y\). | |
| static double | combination (int n, int s) |
| Returns the value of \(\binom{n}{s}\), the number of different combinations of \(s\) objects amongst. | |
| static double | lnCombination (int n, int s) |
| Returns the natural logarithm of. | |
| static double | factorial (int n) |
| Returns the value of \(n!\). | |
| static double | lnFactorial (int n) |
| Returns the value of \(\ln(n!)\), the natural logarithm of factorial \(n\). | |
| static double | lnFactorial (long n) |
| Returns the value of \(\ln(n!)\), the natural logarithm of factorial \(n\). | |
| static double | factoPow (int n) |
| Returns the value of \(n!/n^n\). | |
| static double[][] | calcMatStirling (int m, int n) |
| Computes and returns the Stirling numbers of the second kind. | |
| static double | log2 (double x) |
| Returns \(\log_2 (\)x \()\). | |
| static double | lnGamma (double x) |
| Returns the natural logarithm of the gamma function \(\Gamma(x)\) evaluated at x. | |
| static double | lnBeta (double lam, double nu) |
| Computes the natural logarithm of the Beta function \(B(\lambda, \nu)\). | |
| static double | digamma (double x) |
| Returns the value of the logarithmic derivative of the Gamma function \(\psi(x) = \Gamma’(x) / \Gamma(x)\). | |
| static double | trigamma (double x) |
| Returns the value of the trigamma function \(d\psi(x)/dx\), the derivative of the digamma function, evaluated at \(x\). | |
| static double | tetragamma (double x) |
| Returns the value of the tetragamma function \(d^2\psi(x)/d^2x\), the second derivative of the digamma function, evaluated at \(x\). | |
| static double | gammaRatioHalf (double x) |
| Returns the value of the ratio \(\Gamma(x+1/2)/\Gamma(x)\) of two gamma functions. | |
| static double | sumKahan (double[] A, int n) |
| Implementation of the Kahan summation algorithm. | |
| static double | harmonic (long n) |
| Computes the \(n\)-th harmonic number \(H_n = \sum_{j=1}^n 1/j\). | |
| static double | harmonic2 (long n) |
| Computes the sum. | |
| static double | volumeSphere (double p, int t) |
| Returns the volume \(V\) of a sphere of radius 1 in \(t\) dimensions using the norm \(L_p\). | |
| static double | bernoulliPoly (int n, double x) |
| Evaluates the Bernoulli polynomial \(B_n(x)\) of degree \(n\) at. | |
| static double | evalCheby (double a[], int n, double x) |
| Evaluates a series of Chebyshev polynomials \(T_j\) at \(x\) over the basic interval \([-1, \;1]\), using the method of Clenshaw [34] , i.e., computes and returns. | |
| static double | evalChebyStar (double a[], int n, double x) |
| Evaluates a series of shifted Chebyshev polynomials \(T_j^*\) at. | |
| static double | besselK025 (double x) |
| Returns the value of \(K_{1/4}(x)\), where. | |
| static double | expBesselK1 (double x, double y) |
| Returns the value of \(e^x K_1(y)\), where \( K_1\) is the modified Bessel function of the second kind of order 1. | |
| static double | erf (double x) |
| Returns the value of erf( \(x\)), the error function. | |
| static double | erfc (double x) |
| Returns the value of erfc( \(x\)), the complementary error function. | |
| static double | erfInv (double u) |
| Returns the value of erf \({}^{-1}(u)\), the inverse of the error function. | |
| static double | erfcInv (double u) |
| Returns the value of erfc \({}^{-1}(u)\), the inverse of the complementary error function. | |
Static Public Attributes | |
Constants @{ | |
| static final double | DBL_EPSILON = 2.2204460492503131e-16 |
| Difference between 1.0 and the smallest double greater than 1.0. | |
| static final int | DBL_MAX_EXP = 1024 |
| Largest int \(x\) such that \(2^{x-1}\) is representable (approximately) as a double. | |
| static final int | DBL_MIN_EXP = -1021 |
| Smallest int \(x\) such that \(2^{x-1}\) is representable (approximately) as a normalised double. | |
| static final int | DBL_MAX_10_EXP = 308 |
| Largest int \(x\) such that \(10^x\) is representable (approximately) as a double. | |
| static final double | DBL_MIN = 2.2250738585072014e-308 |
| Smallest normalized positive floating-point double. | |
| static final double | LN_DBL_MIN = -708.3964185322641 |
| Natural logarithm of DBL_MIN. | |
| static final int | DBL_DIG = 15 |
| Number of decimal digits of precision in a double. | |
| static final double | EBASE = 2.7182818284590452354 |
| The constant \(e\). | |
| static final double | EULER = 0.57721566490153286 |
| The Euler-Mascheroni constant. | |
| static final double | RAC2 = 1.41421356237309504880 |
| The value of \(\sqrt{2}\). | |
| static final double | IRAC2 = 0.70710678118654752440 |
| The value of \(1/\sqrt{2}\). | |
| static final double | LN2 = 0.69314718055994530941 |
| The values of \(\ln2\). | |
| static final double | ILN2 = 1.44269504088896340737 |
| The values of \(1/\ln2\). | |
| static final double | MAXINTDOUBLE = 9007199254740992.0 |
| Largest integer \(n_0 = 2^{53}\) such that any integer \(n \le n_0\) is represented exactly as a double. | |
| static final double | MAXTWOEXP = 64 |
| Powers of 2 up to MAXTWOEXP are stored exactly in the array TWOEXP. | |
| static final double | TWOEXP [] |
| Contains the precomputed positive powers of 2. | |
| static final double | TEN_NEG_POW [] |
| Contains the precomputed negative powers of 10. | |
This class provides various constants and methods to compute numerical quantities such as factorials, combinations, gamma functions, and so on.
|
static |
Evaluates the Bernoulli polynomial \(B_n(x)\) of degree \(n\) at.
\(x\). Only degrees \(n\le8\) are programmed for now. The first Bernoulli polynomials of even degree are:
\begin{align} B_0(x) & = 1 \nonumber \\ B_2(x) & = x^2-x+1/6 \nonumber \\ B_4(x) & = x^4-2x^3+x^2-1/30 \tag{bernoulli} \\ B_6(x) & = x^6-3x^5+5x^4/2-x^2/2+1/42 \nonumber \\ B_8(x) & = x^8-4x^7+14x^6/3 - 7x^4/3 +2x^2/3-1/30. \nonumber \end{align}
|
static |
Returns the value of \(K_{1/4}(x)\), where.
\(K_{\nu}\) is the modified Bessel’s function of the second kind. The relative error on the returned value is less than \(0.5\times10^{-6}\) for \(x > 10^{-300}\).
| x | value at which the function is calculated |
|
static |
Computes and returns the Stirling numbers of the second kind.
\[ M[i,j] = \left\{\begin{matrix} j \\ i \end{matrix}\right\} \quad\mbox{ for $0\le i\le m$ and $0\le i\le j\le n$}. \tag{Stirling2} \]
See [107] (Section 1.2.6). The matrix \(M\) is the transpose of Knuth’s (1973).
| m | number of rows of the allocated matrix |
| n | number of columns of the allocated matrix |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Evaluates a series of Chebyshev polynomials \(T_j\) at \(x\) over the basic interval \([-1, \;1]\), using the method of Clenshaw [34] , i.e., computes and returns.
\[ y = \frac{a_0}{2} + \sum_{j=1}^n a_j T_j (x). \]
| a | coefficients of the polynomials |
| n | largest degree of polynomials |
| x | the parameter of the \(T_j\) functions |
|
static |
Evaluates a series of shifted Chebyshev polynomials \(T_j^*\) at.
\(x\) over the basic interval \( [0, \;1]\), using the method of Clenshaw [34] , i.e., computes and returns
\[ y = \frac{a_0}{2} + \sum_{j=1}^n a_j T_j^* (x). \]
| a | coefficients of the polynomials |
| n | largest degree of polynomials |
| x | the parameter of the \(T_j^*\) functions |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Returns the natural logarithm of the gamma function \(\Gamma(x)\) evaluated at x.
Gives 16 decimals of precision, but is implemented only for \(x>0\).
| x | the value for which the lnGamma function must be computed |
|
static |
|
static |
Implementation of the Kahan summation algorithm.
Sums the first
\(n\) elements of \(A\) and returns the sum. This algorithm is more precise than the naive algorithm. See http://en.wikipedia.org/wiki/Kahan_summation_algorithm.
|
static |
|
static |
|
static |
Returns the volume \(V\) of a sphere of radius 1 in \(t\) dimensions using the norm \(L_p\).
It is given by the formula
\[ V = \frac{\left[2 \Gamma(1 + 1/p)\right]^t}{\Gamma\left(1 + t/p\right)}, \qquad p > 0, \]
where \(\Gamma\) is the gamma function. The case of the sup norm
\(L_{\infty}\) is obtained by choosing \(p=0\). Restrictions: \(p\ge0\) and \(t\ge1\).
| p | index of the used norm |
| t | number of dimensions |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Contains the precomputed negative powers of 10.
One has TEN_NEG_POW[j] \( = 10^{-j}\), for \(j=0,…,16\).
|
static |
Contains the precomputed positive powers of 2.
One has TWOEXP[j] \(= 2^j\), for \(j=0,…,64\).