elem_simd_math/lib.rs
1//! `elem-simd-math` — vectorized elementwise math for `f64`.
2//!
3//! This crate is a port of [SLEEF] as expressed by the [sleef-rs] crate, rewritten against the
4//! stable-Rust SIMD abstraction of [`fearless_simd`] so that it builds on stable Rust with
5//! runtime CPU feature detection. See `NOTICE` and `THIRD-PARTY-LICENSES` for the provenance and
6//! licensing of the derived portions.
7//!
8//! [SLEEF]: https://sleef.org/
9//! [sleef-rs]: https://github.com/burrbull/sleef-rs
10//!
11//! # Layers
12//!
13//! * [`f64x`] exposes the ported kernels as functions generic over a
14//! [`fearless_simd::Simd`] token, operating on native-width vectors. Use these when you
15//! already own the SIMD loop.
16//! * [`ElementwiseMath`] exposes slice entry points that pick the best available SIMD level at
17//! runtime, with a scalar fallback.
18//!
19//! # Accuracy
20//!
21//! Kernels come from SLEEF's four accuracy tiers and each function documents its tier's error
22//! bound (`u05` = 0.5 ULP, `u10` = 1.0 ULP, `u15` = 1.5 ULP, `u35` = 3.5 ULP). Those bounds are
23//! asserted by the ported upstream test suites against MPFR. They bound the vector body; the
24//! value produced for inputs outside a kernel's tested domain is documented per function.
25
26#![forbid(unsafe_code)]
27#![warn(missing_docs)]
28// The ported coefficients are written out to upstream's full decimal expansion. Shortening them
29// to the shortest round-tripping form would change the constants, and several are deliberately
30// not the nearest `f64` to a mathematical constant (they are the range-reduction splits).
31#![allow(clippy::excessive_precision)]
32#![allow(clippy::approx_constant)]
33
34pub mod bessel;
35pub mod common;
36pub mod constants;
37pub mod doubled;
38pub mod f32x;
39pub mod f64x;
40pub(crate) mod tables;
41
42mod dispatch;
43
44pub use dispatch::{ElementwiseMath, LengthMismatch};
45
46/// The `f32` slice entry points are also available as free functions here.
47pub mod f32 {
48 pub use crate::dispatch::f32::*;
49}
50
51/// The `f64` slice entry points are also available as free functions here.
52pub mod f64 {
53 pub use crate::dispatch::f64::*;
54}