foresight_gammafun
gnuplot 6.0.0's error, gamma, incomplete gamma, incomplete beta and normal distribution functions.
Ported from gnuplot 6.0.0 specfun.c (Cephes ndtri, incbet, igamc, the inverse functions) and complexfun.c (Igamma, lnGamma), with gnuplot's coefficients, branch points and operation order, so that the values match the installed gnuplot (Linux, glibc 2.39) to the last digit.
Every entry point gp_<name> takes gnuplot's arguments in gnuplot's order and returns r and status: 0 the value is in r; 1 gnuplot's undefined value ("undefined value", a gap in a plot); 2 a gnuplot error, which no function of this family ever raises. gnuplot flags a result undefined when a libm call leaves errno at EDOM or ERANGE (eval.c evaluate_at), even when the value is meaningful (igamma(1, 800)): that errno is tracked here. All results are real (gnuplot prints 1.0, not 1). A NaN in r with status 0 is gnuplot's printed NaN (its overflowing continued fractions and Halley steps end there). Where gnuplot's result is infinite (huge or tiny arguments, see each docstring) status is 1 instead. Every operation that could overflow, divide by zero or be invalid is guarded, so no finite argument raises an IEEE exception other than underflow and inexact.
gnuplot calls glibc's erf, erfc, tgamma, lgamma, exp, log, pow, sin, cos: the Fortran intrinsics, which are glibc's under gfortran. glibc's complex clog and cexp are emulated (clog uses log1p for moduli in [0.5, 2), ported from glibc's FMA build, the one this machine's glibc dispatches).
Source: src/lib/foresight_gammafun.F90
Dependencies
Contents
- gp_erf
- gp_erfc
- gp_gamma
- gp_lgamma
- gp_norm
- gp_invnorm
- gp_inverf
- gp_igamma
- gp_uigamma
- gp_invigamma
- gp_ibeta
- gp_invibeta
- cexp_
- pow_
- pow_inf
- exp_
- lgamma_
- mul_
- add_
- div_
- ratio_
- lngamma_lanczos
- igamma_core
- igamma_gl
- igamma_negative_z
- igamma_re
- igamc
- inverse_incomplete_gamma
- halley_step
- incbet
- incbcf
- incbd
- pseries
- inverse_incomplete_beta
- nan
- fma_
- inv_overflows
- high_word
- with_high_word
- log1p_glibc
- clog_re
- quotient_or_inf
- polevl
- p1evl
- ndtri
- inverse_error_func
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
DBL_MAX | real(kind=R8P) | parameter | C DBL_MAX. |
DBL_MIN | real(kind=R8P) | parameter | C DBL_MIN. |
MACHEP | real(kind=R8P) | parameter | Cephes MACHEP = DBL_EPSILON. |
MAXLOG | real(kind=R8P) | parameter | Cephes MAXLOG, log(2**1022). |
MINLOG | real(kind=R8P) | parameter | Cephes MINLOG. |
MAXGAM | real(kind=R8P) | parameter | Cephes MAXGAM. |
BIG | real(kind=R8P) | parameter | Cephes incbet big. |
BIGINV | real(kind=R8P) | parameter | Cephes incbet biginv. |
IGAMMA_PRECISION | real(kind=R8P) | parameter | gnuplot IGAMMA_PRECISION. |
FLT_MAX | real(kind=R8P) | parameter | C FLT_MAX (IGAMMA_OVERFLOW). |
VERYLARGE | real(kind=R8P) | parameter | gnuplot VERYLARGE, DBL_MAX/2-1. |
PI | real(kind=R8P) | parameter | gnuplot PI and M_PI. |
SQRT_TWO | real(kind=R8P) | parameter | gnuplot SQRT_TWO. |
LN2 | real(kind=R8P) | parameter | glibc M_LN2. |
ZERO_TOL | real(kind=R8P) | parameter | gnuplot set zero: plotted if |imag| <= it. |
EXP_ZERO | real(kind=R8P) | parameter | glibc exp(x) is 0 (and ERANGE) iff x <= it. |
EXP_INF | real(kind=R8P) | parameter | glibc exp(x) overflows (ERANGE) iff x > it. |
TGAMMA_MAX | real(kind=R8P) | parameter | glibc tgamma(x) overflows iff x > it. |
INV_TINY_BITS | integer(kind=I8P) | parameter | Bits of the least x with 1/x finite, 5.56e-309: also glibc tgamma's overflow threshold near 0. |
LGAMMA_MAX | real(kind=R8P) | parameter | glibc lgamma(x) overflows iff x > it. |
ERFC_ZERO | real(kind=R8P) | parameter | glibc erfc(x) is 0 (and ERANGE) iff x >= it. |
LOG_HALF_DENORM | real(kind=R8P) | parameter | log(2**-1075): tgamma rounds to 0 below it. |
S2PI | real(kind=R8P) | parameter | ndtri's sqrt(2pi). |
LANCZOS_SQRT2PI | real(kind=R8P) | parameter | complexfun.c lnGamma sqrt2pi. |
LANCZOS_G | real(kind=R8P) | parameter | complexfun.c lnGamma g. |
LANCZOS | real(kind=R8P) | parameter | complexfun.c lnGamma 14 term Lanczos coef. |
GL_Y | real(kind=R8P) | parameter | Igamma_GL Gauss-Legendre abscissae. |
GL_W | real(kind=R8P) | parameter | Igamma_GL Gauss-Legendre weights. |
NDTRI_P0 | real(kind=R8P) | parameter | ndtri P0, 0 <= |y - 0.5| <= 3/8. |
NDTRI_Q0 | real(kind=R8P) | parameter | ndtri Q0 (leading 1 omitted). |
NDTRI_P1 | real(kind=R8P) | parameter | ndtri P1, z = sqrt(-2 log y) in [2, 8]. |
NDTRI_Q1 | real(kind=R8P) | parameter | ndtri Q1 (leading 1 omitted). |
NDTRI_P2 | real(kind=R8P) | parameter | ndtri P2, z = sqrt(-2 log y) in [8, 64]. |
NDTRI_Q2 | real(kind=R8P) | parameter | ndtri Q2 (leading 1 omitted). |
INVERF_A | real(kind=R8P) | parameter | inverse_error_func a[]. |
INVERF_B | real(kind=R8P) | parameter | inverse_error_func b[]. |
INVERF_C | real(kind=R8P) | parameter | inverse_error_func c[]. |
INVERF_D | real(kind=R8P) | parameter | inverse_error_func d[]. |
L1P_LN2_HI | real(kind=R8P) | parameter | glibc log1p ln2_hi. |
L1P_LN2_LO | real(kind=R8P) | parameter | glibc log1p ln2_lo. |
L1P_LP | real(kind=R8P) | parameter | glibc log1p Lp1..Lp7. |
Subroutines
gp_erf
gnuplot erf(x) (specfun.c f_erf): libm erf. Real result, always defined.
Attributes: pure
subroutine gp_erf(x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument. | |
r | real(kind=R8P) | out | erf(x). | |
status | integer(kind=I4P) | out | 0 (always defined). |
Call graph
gp_erfc
gnuplot erfc(x) (specfun.c f_erfc): libm erfc. Real result; undefined when glibc's erfc underflows to 0 (x >= 27.2263641357421875), since glibc then sets ERANGE.
Attributes: pure
subroutine gp_erfc(x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument. | |
r | real(kind=R8P) | out | erfc(x). | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
gp_gamma
gnuplot gamma(x) (specfun.c f_gamma): libm tgamma. Real result; undefined where glibc's tgamma sets errno: at 0 and the negative integers, on overflow (x > 171.62437695630271, |x| < 5.56e-309) and when the result underflows to 0 (x < -184 or so, judged by lgamma so that a flush-to-zero build agrees).
Attributes: pure
subroutine gp_gamma(x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument. | |
r | real(kind=R8P) | out | Gamma(x). | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
gp_lgamma
gnuplot lgamma(x) (specfun.c f_lgamma): libm lgamma, ln|Gamma(x)| (no sign: lgamma(-0.5) = 1.2655 > 0 while Gamma(-0.5) < 0). Real result; undefined at 0 and the negative integers (poles) and for x > 2.5599833278516383e305 (overflow), where glibc sets ERANGE.
Attributes: pure
subroutine gp_lgamma(x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument. | |
r | real(kind=R8P) | out | ln|Gamma(x)|. | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
gp_norm
gnuplot norm(x) (specfun.c f_normal): 0.5 erfc(-x/sqrt(2)) for x > -38, else 0. Real result, always defined.
Attributes: pure
subroutine gp_norm(x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument. | |
r | real(kind=R8P) | out | Normal cumulative distribution at x. | |
status | integer(kind=I4P) | out | 0 (always defined). |
Call graph
gp_invnorm
gnuplot invnorm(x) (specfun.c f_inverse_normal, Cephes ndtri). Real result; undefined for x <= 0 or x >= 1.
Attributes: pure
subroutine gp_invnorm(x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Probability. | |
r | real(kind=R8P) | out | Normal quantile. | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
gp_inverf
gnuplot inverf(x) (specfun.c f_inverse_erf, inverse_error_func: NIST rational guess and 4 Newton steps, with gnuplot's b[3] * z + b[3] typo kept). Real result; undefined for |x| >= 1.
Attributes: pure
subroutine gp_inverf(x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument in (-1, 1). | |
r | real(kind=R8P) | out | Inverse error function. | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
gp_igamma
gnuplot igamma(a, x), the regularized lower incomplete gamma P(a, x): gnuplot 6.0 built with complex functions evaluates complexfun.c Igamma (AS239 series and continued fraction, Gauss-Legendre for large a, A&S 6.5.29 for x < 0), not specfun.c's real igamma. Real result for x >= 0; for x < 0 gnuplot returns a complex value: r is its real part, ri its imaginary part (for gnuplot's sampled x, imaginary part +0), and status is 1 when |imag| > 1e-8, as gnuplot's plot (set zero). a <= 0, or no convergence / overflow of the continued fraction (gnuplot warns "Igamma: overflow" or "Igamma: no convergence after %d iterations residual %g"): NaN, status 0, unless errno is set. Undefined (status 1) when glibc's cexp underflows to 0 in the continued fraction or the Gauss-Legendre sum (e.g. igamma(1, 800), igamma(1e6, 1.1e6)), and where gnuplot's result is infinite (x < 0 with |x| beyond a few hundred, a beyond 1e300).
Attributes: pure
subroutine gp_igamma(a, x, r, status, ri)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape, a > 0. | |
x | real(kind=R8P) | in | Upper limit. | |
r | real(kind=R8P) | out | P(a, x), real part. | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. | |
ri | real(kind=R8P) | out | optional | Imaginary part (nonzero only for x < 0). |
Call graph
gp_uigamma
gnuplot uigamma(a, x), the regularized upper incomplete gamma Q(a, x) (specfun.c f_uigamma, Cephes igamc: for x < 1 or x < a 1 - igamma(a, x) with complexfun.c's igamma, so 2 when that fails). Real result; undefined for x < 0 or a <= 0 and when errno is set (as in igamma, or glibc's lgamma(a) overflowing, a > 2.56e305); NaN (status 0) where gnuplot's continued fraction overflows (a, x beyond about 1e154).
Attributes: pure
subroutine gp_uigamma(a, x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape, a > 0. | |
x | real(kind=R8P) | in | Lower limit, x >= 0. | |
r | real(kind=R8P) | out | Q(a, x). | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
gp_invigamma
gnuplot invigamma(a, p) (specfun.c f_inverse_igamma, inverse_incomplete_gamma: A&S or NR initial guess, 12 Halley steps on complexfun.c's igamma). Real result: 0 for p = 0, max(100, a + 100 sqrt(a)) for p = 1. Undefined for a <= 0 (gnuplot warns "invigamma: a<=0 invalid"), p < 0 or p > 1 ("invigamma: p invalid"), and when errno is set during the iteration (gnuplot warns inverse_incomplete_gamma: <strerror>... and gives NaN). NaN (status 0) when a Halley step overflows (huge a).
Attributes: pure
subroutine gp_invigamma(a, p, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape, a > 0. | |
p | real(kind=R8P) | in | Probability in [0, 1]. | |
r | real(kind=R8P) | out | x such that igamma(a, x) = p. | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
gp_ibeta
gnuplot ibeta(a, b, x), the regularized incomplete beta I_x(a, b) (specfun.c f_ibeta with Cephes incbet: power series or one of two continued fractions). Real result; undefined for a <= 0, b <= 0, x outside [0, 1], when glibc's tgamma or lgamma overflow (a or b below 5.56e-309, a + b above 2.56e305) and where gnuplot's power series returns inf (a below 5.56e-309 with a + b >= 171.6); NaN (status 0) where gnuplot's continued fractions overflow (a, b beyond about 1e150).
Attributes: pure
subroutine gp_ibeta(a, b, x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape a > 0. | |
b | real(kind=R8P) | in | Shape b > 0. | |
x | real(kind=R8P) | in | Upper limit in [0, 1]. | |
r | real(kind=R8P) | out | I_x(a, b). | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
gp_invibeta
gnuplot invibeta(a, b, p) (specfun.c f_inverse_ibeta, inverse_incomplete_beta: A&S 26.5.22 or NR 6.4.8 initial guess, 12 Halley steps on incbet). Real result: NaN for a <= 0 or b <= 0 (status 0, gnuplot prints NaN), 0 for p <= 0, 1 for |1 - p| < 1e-14; p outside [0, 1] is only warned ("f_inverse_ibeta: p %g not in domain") and computed. Undefined when errno is set: gnuplot's guess takes sqrt(z) of a negative normal deviate, so for a >= 1 and b >= 1 every p < 0.5 is undefined (invibeta(2, 2, 0.1)), as in gnuplot 6.0.0. NaN (status 0) when a Halley step overflows.
Attributes: pure
subroutine gp_invibeta(a, b, p, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape a > 0. | |
b | real(kind=R8P) | in | Shape b > 0. | |
p | real(kind=R8P) | in | Probability. | |
r | real(kind=R8P) | out | x such that ibeta(a, b, x) = p. | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
cexp_
glibc's cexp(u + i w) for finite u, w: exp(u) (cos w, sin w), scaled by exp(709) above 709; errno when exp(u) underflows to 0; ovf when the result overflows (gnuplot then holds infinities).
Attributes: pure
subroutine cexp_(u, w, cr, ci, errno, ovf)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
u | real(kind=R8P) | in | Real and imaginary parts of the argument. | |
w | real(kind=R8P) | in | Real and imaginary parts of the argument. | |
cr | real(kind=R8P) | out | Result. | |
ci | real(kind=R8P) | out | Result. | |
errno | logical | inout | errno. | |
ovf | logical | out | Overflow. |
Call graph
pow_
glibc's pow(x, y): negative x only for integer y (else NaN and EDOM), errno on overflow and on underflow to 0.
Attributes: pure
subroutine pow_(x, y, r, errno, ovf)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | value | Base and exponent (by value: r may be one of them). | |
y | real(kind=R8P) | value | Base and exponent (by value: r may be one of them). | |
r | real(kind=R8P) | inout | x**y (inout: see mul_). | |
errno | logical | inout | errno. | |
ovf | logical | out | Overflow (r is then +-huge). |
Call graph
pow_inf
glibc's pow(x, +inf): 0 for |x| < 1, 1 for |x| = 1, +inf (ovf) above, without errno.
Attributes: pure
subroutine pow_inf(x, r, ovf)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | value | Base (by value: r may be it). | |
r | real(kind=R8P) | inout | pow(x, +inf) (inout: see mul_). | |
ovf | logical | out | +inf result. |
Call graph
exp_
glibc's exp(x): errno on overflow and on underflow to 0.
Attributes: pure
subroutine exp_(x, r, errno, ovf)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument. | |
r | real(kind=R8P) | out | exp(x). | |
errno | logical | inout | errno. | |
ovf | logical | out | Overflow (r is then huge). |
Call graph
lgamma_
glibc's lgamma(x) for x > 0: ERANGE (and a huge value) on overflow.
Attributes: pure
subroutine lgamma_(x, r, errno)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument, positive. | |
r | real(kind=R8P) | out | ln Gamma(x). | |
errno | logical | inout | errno. |
Call graph
mul_
r = a * b; bad set (and r = 0) when the product overflows.
Attributes: pure
subroutine mul_(a, b, r, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | value | Factors (by value: r may be one of them). | |
b | real(kind=R8P) | value | Factors (by value: r may be one of them). | |
r | real(kind=R8P) | inout | a * b (inout, not out: gfortran clobbers an intent(out) actual that is also a value actual of the same call before reading it). | |
bad | logical | inout | Overflow flag. |
Call graph
add_
r = a + b; bad set (and r = 0) when the sum overflows.
Attributes: pure
subroutine add_(a, b, r, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | value | Addends (by value: r may be one of them). | |
b | real(kind=R8P) | value | Addends (by value: r may be one of them). | |
r | real(kind=R8P) | inout | a + b (inout: see mul_). | |
bad | logical | inout | Overflow flag. |
Call graph
div_
r = a / b; bad set (and r = 0) when b is 0 or the quotient overflows.
Attributes: pure
subroutine div_(a, b, r, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | value | Dividend and divisor (by value: r may be one of them). | |
b | real(kind=R8P) | value | Dividend and divisor (by value: r may be one of them). | |
r | real(kind=R8P) | inout | a / b (inout: see mul_). | |
bad | logical | inout | Overflow flag. |
Call graph
ratio_
r = (a b) / (c d) as C evaluates it: 0 when only c d overflows (finite / inf), bad when a b overflows.
Attributes: pure
subroutine ratio_(a, b, c, d, r, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Operands. | |
b | real(kind=R8P) | in | Operands. | |
c | real(kind=R8P) | in | Operands. | |
d | real(kind=R8P) | in | Operands. | |
r | real(kind=R8P) | out | (a b) / (c d). | |
bad | logical | inout | Overflow flag. |
Call graph
lngamma_lanczos
complexfun.c lnGamma for real z > 0 (14 term Lanczos, glibc clog); ok false when gnuplot gets +inf.
Attributes: pure
subroutine lngamma_lanczos(z, f, ok)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
z | real(kind=R8P) | in | Argument, positive. | |
f | real(kind=R8P) | out | ln Gamma(z). | |
ok | logical | out | Finite result. |
Call graph
igamma_core
complexfun.c Igamma(a, z) for real a > 0 and real z /= 0 (imaginary parts +0). Outcomes: a value in re, im; fail, Igamma's -1 (overflow or no convergence); nanres, a NaN; bad, an infinite value.
Attributes: pure
subroutine igamma_core(a, z, re, im, fail, nanres, errno, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape, positive. | |
z | real(kind=R8P) | in | Argument, nonzero. | |
re | real(kind=R8P) | out | Result. | |
im | real(kind=R8P) | out | Result. | |
fail | logical | out | Igamma returned -1 (overflow or no convergence). | |
nanres | logical | out | Igamma returned NaN. | |
errno | logical | inout | errno (cleared on entry, as Igamma does). | |
bad | logical | out | Igamma returned an infinity. |
Call graph
igamma_gl
complexfun.c Igamma_GL, 18 point Gauss-Legendre quadrature, for real a > 100 and real z > 0.
Attributes: pure
subroutine igamma_gl(a, z, re, nanres, errno, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape. | |
z | real(kind=R8P) | in | Argument. | |
re | real(kind=R8P) | out | Result. | |
nanres | logical | out | NaN result. | |
errno | logical | inout | errno. | |
bad | logical | out | Infinite result. |
Call graph
igamma_negative_z
complexfun.c Igamma_negative_z (A&S 6.5.29), for real 0 < a < 75 and real z < 0 (imaginary part +0).
Attributes: pure
subroutine igamma_negative_z(a, z, re, im, fail, errno, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape. | |
z | real(kind=R8P) | in | Argument, negative. | |
re | real(kind=R8P) | out | Result. | |
im | real(kind=R8P) | out | Result. | |
fail | logical | out | Overflow (gnuplot returns -1). | |
errno | logical | inout | errno. | |
bad | logical | out | gnuplot's result is not finite. |
Call graph
igamma_re
complexfun.c igamma(a, z) wrapper, creal(Igamma(a, z)), for real a > 0 and z >= 0 (-1 when Igamma fails).
Attributes: pure
subroutine igamma_re(a, z, re, fail, nanres, errno, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape. | |
z | real(kind=R8P) | in | Argument. | |
re | real(kind=R8P) | out | Real part. | |
fail | logical | out | Igamma returned -1 (re is -1). | |
nanres | logical | out | Igamma returned NaN. | |
errno | logical | inout | errno. | |
bad | logical | out | Igamma returned an infinity. |
Call graph
igamc
specfun.c igamc (Cephes), the complemented incomplete gamma, for a > 0 and x >= 0.
Attributes: pure
subroutine igamc(a, x, r, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape. | |
x | real(kind=R8P) | in | Argument. | |
r | real(kind=R8P) | out | Q(a, x). | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
inverse_incomplete_gamma
specfun.c inverse_incomplete_gamma, Halley's method on igamma, for a > 0 and 0 < p < 1.
Attributes: pure
subroutine inverse_incomplete_gamma(a, p, z, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shape. | |
p | real(kind=R8P) | in | Probability. | |
z | real(kind=R8P) | out | Root. | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
halley_step
gnuplot's Halley step tn = u / (1 - 0.5 min(1, u q)), u = err / t, with C's infinities: t is +inf for tcls 1, q is +-inf for qcls +-1 and NaN for qcls 2. nonfinite when tn is not finite (gnuplot's z then turns NaN).
Attributes: pure
subroutine halley_step(err, t, tcls, q, qcls, tn, nonfinite)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
err | real(kind=R8P) | in | Residual. | |
t | real(kind=R8P) | in | Derivative, >= 0. | |
tcls | integer(kind=I4P) | in | Class of t: 0 finite, 1 +inf. | |
q | real(kind=R8P) | in | Second order factor. | |
qcls | integer(kind=I4P) | in | Class of q: 0 finite, +-1 +-inf, 2 NaN. | |
tn | real(kind=R8P) | out | Step. | |
nonfinite | logical | out | Step not finite. |
Call graph
incbet
specfun.c incbet (Cephes): -1 for aa <= 0, bb <= 0 or xx outside [0, 1]; bad when gnuplot's result is infinite, nanres when it is NaN (a continued fraction overflowing).
Attributes: pure
subroutine incbet(aa, bb, xx, t, errno, bad, nanres)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
aa | real(kind=R8P) | in | Shapes and argument. | |
bb | real(kind=R8P) | in | Shapes and argument. | |
xx | real(kind=R8P) | in | Shapes and argument. | |
t | real(kind=R8P) | out | I_xx(aa, bb). | |
errno | logical | inout | errno. | |
bad | logical | out | Infinite result. | |
nanres | logical | out | NaN result. |
Call graph
incbcf
specfun.c incbcf, continued fraction expansion #1 for the incomplete beta integral.
Attributes: pure
subroutine incbcf(a, b, x, ans, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shapes and argument. | |
b | real(kind=R8P) | in | Shapes and argument. | |
x | real(kind=R8P) | in | Shapes and argument. | |
ans | real(kind=R8P) | out | Continued fraction. | |
bad | logical | inout | Overflow flag. |
Call graph
incbd
specfun.c incbd, continued fraction expansion #2 for the incomplete beta integral.
Attributes: pure
subroutine incbd(a, b, x, ans, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shapes and argument. | |
b | real(kind=R8P) | in | Shapes and argument. | |
x | real(kind=R8P) | in | Shapes and argument. | |
ans | real(kind=R8P) | out | Continued fraction. | |
bad | logical | inout | Overflow flag. |
Call graph
pseries
specfun.c pseries, power series for the incomplete beta integral (b x small, x not near 1).
Attributes: pure
subroutine pseries(a, b, x, s, errno, bad)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shapes and argument. | |
b | real(kind=R8P) | in | Shapes and argument. | |
x | real(kind=R8P) | in | Shapes and argument. | |
s | real(kind=R8P) | out | Series value. | |
errno | logical | inout | errno. | |
bad | logical | out | gnuplot's result is not finite. |
Call graph
inverse_incomplete_beta
specfun.c inverse_incomplete_beta, Halley's method on incbet, for a > 0, b > 0, p > 0, |1 - p| >= 1e-14.
Attributes: pure
subroutine inverse_incomplete_beta(a, b, p, z, status)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Shapes and probability. | |
b | real(kind=R8P) | in | Shapes and probability. | |
p | real(kind=R8P) | in | Shapes and probability. | |
z | real(kind=R8P) | out | Root. | |
status | integer(kind=I4P) | out | 0 defined, 1 undefined. |
Call graph
Functions
nan
Quiet NaN, without raising an exception.
Attributes: pure
Returns: real(kind=R8P)
function nan() result(r)Call graph
fma_
a * b + c rounded once (glibc's FMA build); nvfortran has no ieee_fma, -Mnofma leaves a * b + c unfused there.
Attributes: pure
Returns: real(kind=R8P)
function fma_(a, b, c) result(r)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Operands. | |
b | real(kind=R8P) | in | Operands. | |
c | real(kind=R8P) | in | Operands. |
Call graph
inv_overflows
1/x overflows (x >= 0): x below 5.5626846462680084e-309, compared on the bits so that flush-to-zero builds (and their denormals-are-zero comparisons) agree.
Attributes: pure
Returns: logical
function inv_overflows(x) result(ovf)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Non negative value. |
Call graph
high_word
High 32 bits of the IEEE representation of x, as glibc's GET_HIGH_WORD.
Attributes: pure
Returns: integer(kind=I4P)
function high_word(x) result(h)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Value. |
Call graph
with_high_word
x with its high 32 bits replaced by h, as glibc's SET_HIGH_WORD.
Attributes: pure
Returns: real(kind=R8P)
function with_high_word(x, h) result(y)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Value. | |
h | integer(kind=I4P) | in | New high word (non negative). |
Call graph
log1p_glibc
glibc 2.39 __log1p_fma (fdlibm s_log1p.c built with FMA contraction), for x > -1.
Attributes: pure
Returns: real(kind=R8P)
function log1p_glibc(x) result(r)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument. |
Call graph
clog_re
Real part of glibc's clog(x + 0i), x /= 0: log|x|, through log1p for |x| in [0.5, 2) as glibc does.
Attributes: pure
Returns: real(kind=R8P)
function clog_re(x) result(r)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument, nonzero. |
Call graph
quotient_or_inf
|a / b| for b /= 0, huge where C gets inf (the continued fractions' relative change test goes on).
Attributes: pure
Returns: real(kind=R8P)
function quotient_or_inf(a, b) result(r)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Dividend and nonzero divisor. | |
b | real(kind=R8P) | in | Dividend and nonzero divisor. |
Call graph
polevl
Cephes polevl: coef(0) x**n + ... + coef(n).
Attributes: pure
Returns: real(kind=R8P)
function polevl(x, coef, n) result(ans)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument. | |
coef | real(kind=R8P) | in | Coefficients, highest degree first. | |
n | integer(kind=I4P) | in | Degree. |
Call graph
p1evl
Cephes p1evl: xn + coef(0) x(n-1) + ... + coef(n-1).
Attributes: pure
Returns: real(kind=R8P)
function p1evl(x, coef, n) result(ans)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Argument. | |
coef | real(kind=R8P) | in | Coefficients, leading 1 omitted. | |
n | integer(kind=I4P) | in | Degree. |
Call graph
ndtri
specfun.c inverse_normal_func (Cephes ndtri), for 0 < y0 < 1.
Attributes: pure
Returns: real(kind=R8P)
function ndtri(y0) result(x)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
y0 | real(kind=R8P) | in | Probability. |
Call graph
inverse_error_func
specfun.c inverse_error_func, for |y| < 1.
Attributes: pure
Returns: real(kind=R8P)
function inverse_error_func(y) result(x)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
y | real(kind=R8P) | in | Argument. |
Call graph