Skip to main content

Module special

Module special 

Source
Available on crate feature special only.
Expand description

Special functions for Complex (special feature).

Implements thermite_special’s SpecializedSpecialMath, giving complex vectors the SpecialMath API.

thermite-special splits its families along the line this crate needs: Special is documented as valid for real and complex vectors alike, while RealSpecial (erfinv, probit, gelu, swish, algebraic_sigmoid, lgamma_r, …) and RealPrimal (the _d forms) are real-only. Complex implements the first and not the others, as it implements CoreMath but not RealMath.

erf and erfc are implemented over the whole plane. The holomorphic defaults (hermite, hermitev, chebyshev, jacobi, legendre, gaussian) are complex polynomial recurrences and are inherited as they are. logistic_sigmoid and softplus must be overridden: their defaults are stabilized for the real axis with |x| and max(x, 0).

§Element-specific functions

Anything carrying a coefficient table goes through SpecializedComplexSpecialMath, which is implemented per element type the way thermite-special’s own ps.rs/pd.rs are. trigamma and lambert_w are implemented there; beta is a default written on tgamma. So is the Faddeeva function, whose own module is faddeeva.

The whole Gamma family is implemented, on the tables thermite-special exports from [thermite_special::tables]. Only part of each table survives the crossing: the Lanczos sums and the digamma p_large are analytic approximations that hold off the real axis, while the digamma [1, 2] rational and the trigamma regions are minimax fits to real intervals and are unusable here - so digamma and trigamma lean on a recurrence where the real versions reach for a rational.

expint is inherited whole and simply runs in complex arithmetic; what changes is ExpIntDetails, all three methods of it. use_series picks the regime by norm_sqr rather than the lexicographic cmp_lt, and additionally claims the whole left half-plane, where the Stieltjes continued fraction degrades toward the cut but the series stops alternating and converges cleanly. invalid drops the real version’s x < 0 hole, since the principal branch covers the cut plane; the cut itself needs no handling, as all of the multivaluedness is the -ln z term and the principal ln already carries it. cf_tiny backs the Lentz sentinel off MIN_POSITIVE, which a complex reciprocal squares into zero.

E_1 holds machine precision over the cut plane. Higher orders come off the order recurrence and lose roughly |z|^(N-1)/(N-1)!, matching what the real path considers reliable - but the asymptotic series that path swaps in past its threshold has no complex counterpart yet, so very large |z| at high N is not covered.

§Not implemented

bessel_j is disabled crate-wide until orders beyond J_0 exist upstream.

Complex<Compensated<..>> gets the element-agnostic functions but todo!()s the table-driven ones; Complex<Dual<..>> has all of them, and differentiates through them, since the shared bodies are generic over RealValue.

Modules§

faddeeva
The Faddeeva function $w(z) = e^{-z^2}\operatorname{erfc}(-iz)$.

Traits§

ComplexSpecialMath
ComplexSpecial math functions using the default policy. Complex special functions that carry an element-specific coefficient table.
ComplexSpecialMathWithPolicy
ComplexSpecial math functions with customizable policies. Complex special functions that carry an element-specific coefficient table.
SpecializedComplexSpecialMath
The complex special functions whose algorithms carry element-specific coefficient tables.