1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! The error function pair behind the `Erf` and `ErfDerivative` map
//! operations.
//!
//! `erf` delegates to the pure-Rust `libm` crate (the Sun/FDLIBM
//! implementation, accurate to about one ulp and bit-identical on
//! every platform), like the rest of the transcendental vocabulary;
//! Rust's standard library has no `erf`, and the platform's C library
//! would need `unsafe` and vary by target. A crate-owned three-piece
//! series implementation preceded the delegation and lives in the
//! history should the dependency ever need replacing.
//!
//! The derivative is computed here: `libm` has no scaled Gaussian,
//! and the composed `exp(-x*x)` would let the rounding of `x*x` grow
//! through the exponential. Splitting the argument into an exactly
//! squared sixteenth-step head and a small tail keeps the rounding a
//! few epsilon at every magnitude. This module is also where the
//! pair's transcendental constant lives: a concrete `f64` is in
//! scope, so the kernel states the correctly rounded `2/sqrt(pi)` in
//! its own precision — the same standing as the constants inside
//! `libm` itself.
/// Computes the error function of `x`.
///
/// It is odd, saturates to `+-1`, keeps the sign of zero, and
/// propagates NaN.
pub
/// Computes the derivative of the error function of `x`:
/// `(2/sqrt(pi)) * e^(-x^2)`, the scaled Gaussian.
///
/// It is even, underflows to zero past `|x| ~ 27`, and propagates
/// NaN.
pub