Expand description
Host-side scalar special functions shared by the CPU parity references of the GPU backends.
The CUDA kernels emit their own NVRTC-visible numerics (see
crate::numerics_device); this module is the matching host side
used by the CPU parity oracles (bms_flex_row’s test oracle) and the
CPU reference path (pirls_row’s probit CDF). Keeping a single definition
here means the host erfc cannot drift between backends.
Constants§
- INV_
SQRT_ 2PI 1/√(2π), matchingINV_SQRT_2PIin the kernel source bit-for-bit.- INV_
SQRT_ PI 1/√π, matchinginv_sqrt_piin the kernel source bit-for-bit.- SQRT_2
√2, matchingSQRT_2in the kernel source bit-for-bit.- SQRT_
2_ OVER_ PI √(2/π), matchingsqrt_2_over_piin the kernel source bit-for-bit.
Functions§
- erfc
- Complementary error function
erfc(x) = 1 − erf(x)evaluated on the host. - erfcx_
nonnegative - Scaled complementary error function
erfcx(x) = exp(x²)·erfc(x)forx ≥ 0, the host oracle for the deviceerfcx_nonnegative. Returns1.0forx ≤ 0,0.0at+∞,+∞at−∞. For0 < x < 26evaluates the directexp(min(x², 700))·erfc(x)form; beyond that (whereexp(x²)would overflow) it switches to the same 4-term asymptotic expansion as the kernel. - log_
ndtr log Φ(x)for the standard normal CDF, the host oracle for the devicelog_ndtr. Forx < 0uses theerfcxrepresentationlog Φ(x) = −u² + log(½·erfcx(u)),u = −x/√2, keeping digits into the deep left tail; forx ≥ 0useslog(½·erfc(−x/√2))with the same clamps as the kernel. Propagates±∞/NaNexactly as the device path does.- log_
ndtr_ and_ mills - Joint
(log Φ(x), Mills ratio φ(x)/Φ(x)), the host oracle for the devicelog_ndtr_and_mills. Thex < 0branch computes the Mills ratio as√(2/π)/erfcx(u), which stays finite even whenΦ(x)underflows; thex ≥ 0branch formspdf/cdfdirectly. Boundary values mirror the kernel:(+0, +0)at+∞,(−∞, +∞)at−∞,(NaN, NaN)atNaN.