Skip to main content

Module numerics_host

Module numerics_host 

Source
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π), matching INV_SQRT_2PI in the kernel source bit-for-bit.
INV_SQRT_PI
1/√π, matching inv_sqrt_pi in the kernel source bit-for-bit.
SQRT_2
√2, matching SQRT_2 in the kernel source bit-for-bit.
SQRT_2_OVER_PI
√(2/π), matching sqrt_2_over_pi in 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) for x ≥ 0, the host oracle for the device erfcx_nonnegative. Returns 1.0 for x ≤ 0, 0.0 at +∞, +∞ at −∞. For 0 < x < 26 evaluates the direct exp(min(x², 700))·erfc(x) form; beyond that (where exp(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 device log_ndtr. For x < 0 uses the erfcx representation log Φ(x) = −u² + log(½·erfcx(u)), u = −x/√2, keeping digits into the deep left tail; for x ≥ 0 uses log(½·erfc(−x/√2)) with the same clamps as the kernel. Propagates ±∞/NaN exactly as the device path does.
log_ndtr_and_mills
Joint (log Φ(x), Mills ratio φ(x)/Φ(x)), the host oracle for the device log_ndtr_and_mills. The x < 0 branch computes the Mills ratio as √(2/π)/erfcx(u), which stays finite even when Φ(x) underflows; the x ≥ 0 branch forms pdf/cdf directly. Boundary values mirror the kernel: (+0, +0) at +∞, (−∞, +∞) at −∞, (NaN, NaN) at NaN.