Skip to main content

Module elliptic

Module elliptic 

Source
Expand description

Elliptic integrals.

The complete integrals K and E use the arithmetic-geometric mean (AGM), which is branchless and needs only one sqrt per iteration - far cheaper for SIMD than the Carlson duplication algorithm used for the incomplete forms (see carlson_rf etc.).

The algorithms are classical (Gauss/Legendre AGM; Carlson’s symmetric forms); this is an original SIMD implementation, not a port of any particular source.

Structs§

CarlsonRc
Carlson R_C(x, y) = R_F(x, y, y) - degenerate first kind. See CarlsonKind.
CarlsonRd
Carlson R_D(x, y, z) = R_J(x, y, z, z) - degenerate third kind; z is the repeated argument. See CarlsonKind.
CarlsonRf
Carlson R_F(x, y, z) - symmetric integral of the first kind. See CarlsonKind.
CarlsonRg
Carlson R_G(x, y, z) - symmetric integral of the second kind. See CarlsonKind.
CarlsonRj
Carlson R_J(x, y, z, p) - symmetric integral of the third kind; p is the parameter (a Cauchy principal value when p < 0). See CarlsonKind.
EllintD
Complete D(k) = (K - E) / k^2.
EllintDInc
Incomplete D(phi, k).
EllintE
Complete elliptic integral of the second kind, E(k).
EllintEInc
Incomplete elliptic integral of the second kind, E(phi, k).
EllintF
Incomplete elliptic integral of the first kind, F(phi, k).
EllintK
Complete elliptic integral of the first kind, K(k).
EllintPi
Complete elliptic integral of the third kind, Pi(n, k).
EllintPiInc
Incomplete elliptic integral of the third kind, Pi(n, phi, k).
HeumanLambda
Heuman’s lambda Lambda_0(phi, k), the complementary-modulus companion to the complete integral of the third kind. See heuman_lambda.
JacobiZeta
Jacobi zeta Z(phi, k): the oscillating part of E(phi, k). See jacobi_zeta.

Constants§

KIND_D
KIND_E
KIND_F
Legendre integral kinds for ellint_impl’s KIND const parameter.
KIND_PI

Traits§

CarlsonKind
A Carlson symmetric elliptic integral request. The implementors are small structs that carry the integral’s arguments as named fields (CarlsonRf, CarlsonRc, CarlsonRd, CarlsonRj, CarlsonRg), so each kind has exactly its own arguments - no dummy slots, and the special roles (R_J’s parameter p, R_D’s repeated z) are named at the call site.
EllipticConsts
Compile-time per-element constants for the elliptic routines, so values that are otherwise a few runtime ops (e.g. the Carlson convergence threshold, three sequential sqrts) become a constant splat. Declared for f32/f64; add more element types as needed.
EllipticKind
Legendre elliptic integral request, dual to CarlsonKind (see it for the named-field rationale). The implementors are EllintK/EllintF (1st kind, complete/incomplete), EllintE/EllintEInc (2nd kind), EllintD/EllintDInc, and EllintPi/EllintPiInc (3rd kind). Completeness is encoded by the fields: a complete integral has no phi.
WrapTo
The wider (vector) form of a scalar request struct - the inverse of [Unwrap] for these structs. Unwrap only maps vector -> scalar (type Unwrapped), and Rust cannot invert an associated type, so this names the forward (scalar -> vector) direction. It is what lets the Scalar* math-trait layer take a scalar request (CarlsonRf<f64>), wrap it into a width-1 vector request (CarlsonRf<Vector<f64>>), evaluate on the (vector-only) backend, then unwrap the scalar result - without implementing the backend twice. Implemented only for scalar-element request structs.

Functions§

agm
The arithmetic-geometric mean $\mathrm{AGM}(a, b)$ of two non-negative arguments.
agm_complete_ke
Complete elliptic integrals of the first and second kind, (K(k), E(k)), evaluated together from a single AGM pass (they share the iteration).
carlson_rc
Carlson degenerate integral R_C(x, y) = R_F(x, y, y), closed form. Assumes y > 0 (the only cases that arise inside R_J and the third-kind reductions); the y < 0 Cauchy-principal-value branch is not handled here.
carlson_rd
Carlson symmetric integral R_D(x, y, z) = R_J(x, y, z, z) (degenerate third kind, used for the second-kind incomplete integral). Same duplication scheme as carlson_rf, plus an accumulated sum term.
carlson_rf
Carlson symmetric integral of the first kind, R_F(x, y, z), via the duplication algorithm. All Boost special cases are omitted: the duplication converges for any valid input (e.g. a single zero argument becomes positive after one step), so the loop runs uniformly across lanes and stops once every lane has converged.
carlson_rg
Carlson symmetric integral of the second kind, R_G(x, y, z), as a combination of carlson_rf and carlson_rd (Carlson 2015):
carlson_rj
Carlson symmetric integral of the third kind, R_J(x, y, z, p), via duplication. Handles p < 0 (a Cauchy principal value) through Carlson’s transform to a positive parameter. Each step accumulates an R_C term, so this is the most expensive Carlson primitive.
ellint_impl
Legendre elliptic integral, const-generic over kind and completeness.
heuman_lambda
Heuman’s lambda function $\Lambda_0(\varphi, k)$.
jacobi_zeta
The Jacobi zeta function $Z(\varphi, k)$.
Last built: 2026-09-08 21:35:55 UTC