diff --git a/src/math/f64/binary_misc.rs b/src/math/f64/binary_misc.rs new file mode 100644 index 0000000..f6d0d26 --- /dev/null +++ b/src/math/f64/binary_misc.rs @@ -0,0 +1,34 @@ +use crate::math::{map, scalar}; +use crate::SimdFloat64; + +#[inline(always)] +pub(crate) fn log10_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::log10_u35_f64) +} + +#[inline(always)] +pub(crate) fn atan2_u35(y: V, x: V) -> V +where + V: SimdFloat64, +{ + map::binary_f64(y, x, scalar::atan2_u35_f64) +} + +#[inline(always)] +pub(crate) fn hypot_u35(x: V, y: V) -> V +where + V: SimdFloat64, +{ + map::binary_f64(x, y, scalar::hypot_u35_f64) +} + +#[inline(always)] +pub(crate) fn fmod(x: V, y: V) -> V +where + V: SimdFloat64, +{ + map::binary_f64(x, y, scalar::fmod_f64) +} diff --git a/src/math/f64/core.rs b/src/math/f64/core.rs new file mode 100644 index 0000000..318fd58 --- /dev/null +++ b/src/math/f64/core.rs @@ -0,0 +1,58 @@ +use crate::math::{map, scalar}; +use crate::SimdFloat64; + +#[inline(always)] +pub(crate) fn log2_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::log2_u35_f64) +} + +#[inline(always)] +pub(crate) fn exp2_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::exp2_u35_f64) +} + +#[inline(always)] +pub(crate) fn ln_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::ln_u35_f64) +} + +#[inline(always)] +pub(crate) fn exp_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::exp_u35_f64) +} + +#[inline(always)] +pub(crate) fn sin_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::sin_u35_f64) +} + +#[inline(always)] +pub(crate) fn cos_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::cos_u35_f64) +} + +#[inline(always)] +pub(crate) fn tan_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::tan_u35_f64) +} diff --git a/src/math/f64/hyperbolic.rs b/src/math/f64/hyperbolic.rs new file mode 100644 index 0000000..111aa78 --- /dev/null +++ b/src/math/f64/hyperbolic.rs @@ -0,0 +1,26 @@ +use crate::math::{map, scalar}; +use crate::SimdFloat64; + +#[inline(always)] +pub(crate) fn sinh_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::sinh_u35_f64) +} + +#[inline(always)] +pub(crate) fn cosh_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::cosh_u35_f64) +} + +#[inline(always)] +pub(crate) fn tanh_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::tanh_u35_f64) +} diff --git a/src/math/f64/inverse_hyperbolic.rs b/src/math/f64/inverse_hyperbolic.rs new file mode 100644 index 0000000..503988c --- /dev/null +++ b/src/math/f64/inverse_hyperbolic.rs @@ -0,0 +1,26 @@ +use crate::math::{map, scalar}; +use crate::SimdFloat64; + +#[inline(always)] +pub(crate) fn asinh_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::asinh_u35_f64) +} + +#[inline(always)] +pub(crate) fn acosh_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::acosh_u35_f64) +} + +#[inline(always)] +pub(crate) fn atanh_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::atanh_u35_f64) +} diff --git a/src/math/f64/inverse_trig.rs b/src/math/f64/inverse_trig.rs new file mode 100644 index 0000000..288cd49 --- /dev/null +++ b/src/math/f64/inverse_trig.rs @@ -0,0 +1,26 @@ +use crate::math::{map, scalar}; +use crate::SimdFloat64; + +#[inline(always)] +pub(crate) fn asin_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::asin_u35_f64) +} + +#[inline(always)] +pub(crate) fn acos_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::acos_u35_f64) +} + +#[inline(always)] +pub(crate) fn atan_u35(input: V) -> V +where + V: SimdFloat64, +{ + map::unary_f64(input, scalar::atan_u35_f64) +} diff --git a/src/math/f64/mod.rs b/src/math/f64/mod.rs new file mode 100644 index 0000000..18e5923 --- /dev/null +++ b/src/math/f64/mod.rs @@ -0,0 +1,16 @@ +//! f64 SIMD math dispatch layering: +//! - family-local modules own the public internal routing points for each math family. +//! - current implementations remain scalar-mapped through `map` + `scalar`. +//! - follow-up optimization PRs can replace one family module at a time. + +mod binary_misc; +mod core; +mod hyperbolic; +mod inverse_hyperbolic; +mod inverse_trig; + +pub(crate) use binary_misc::{atan2_u35, fmod, hypot_u35, log10_u35}; +pub(crate) use core::{cos_u35, exp2_u35, exp_u35, ln_u35, log2_u35, sin_u35, tan_u35}; +pub(crate) use hyperbolic::{cosh_u35, sinh_u35, tanh_u35}; +pub(crate) use inverse_hyperbolic::{acosh_u35, asinh_u35, atanh_u35}; +pub(crate) use inverse_trig::{acos_u35, asin_u35, atan_u35}; diff --git a/src/math/families/binary_misc/mod.rs b/src/math/families/binary_misc/mod.rs index d946786..e50ea1e 100644 --- a/src/math/families/binary_misc/mod.rs +++ b/src/math/families/binary_misc/mod.rs @@ -1,6 +1,6 @@ mod portable_f32; -use crate::math::{map, scalar}; +use crate::math::{f64, map, scalar}; use crate::{Simd, SimdFloat32, SimdFloat64}; pub trait SimdMathF32BinaryMisc: SimdFloat32 { @@ -40,23 +40,23 @@ impl SimdMathF32BinaryMisc for T {} pub trait SimdMathF64BinaryMisc: SimdFloat64 { #[inline(always)] fn log10_u35(self) -> Self { - map::unary_f64(self, scalar::log10_u35_f64) + f64::log10_u35(self) } #[inline(always)] fn atan2_u35(self, x: Self) -> Self { - map::binary_f64(self, x, scalar::atan2_u35_f64) + f64::atan2_u35(self, x) } #[inline(always)] fn hypot_u35(self, y: Self) -> Self { - map::binary_f64(self, y, scalar::hypot_u35_f64) + f64::hypot_u35(self, y) } /// Floating-point remainder with C/libm `fmod` semantics (sign follows dividend). #[inline(always)] fn fmod(self, y: Self) -> Self { - map::binary_f64(self, y, scalar::fmod_f64) + f64::fmod(self, y) } } diff --git a/src/math/families/core.rs b/src/math/families/core.rs index 1b2eaa0..94ac53d 100644 --- a/src/math/families/core.rs +++ b/src/math/families/core.rs @@ -1,4 +1,4 @@ -use crate::math::{f32, map, scalar}; +use crate::math::{f32, f64, map, scalar}; use crate::{Simd, SimdFloat32, SimdFloat64}; pub trait SimdMathF32Core: SimdFloat32 { @@ -58,37 +58,37 @@ impl SimdMathF32Core for T {} pub trait SimdMathF64Core: SimdFloat64 { #[inline(always)] fn log2_u35(self) -> Self { - map::unary_f64(self, scalar::log2_u35_f64) + f64::log2_u35(self) } #[inline(always)] fn exp2_u35(self) -> Self { - map::unary_f64(self, scalar::exp2_u35_f64) + f64::exp2_u35(self) } #[inline(always)] fn ln_u35(self) -> Self { - map::unary_f64(self, scalar::ln_u35_f64) + f64::ln_u35(self) } #[inline(always)] fn exp_u35(self) -> Self { - map::unary_f64(self, scalar::exp_u35_f64) + f64::exp_u35(self) } #[inline(always)] fn sin_u35(self) -> Self { - map::unary_f64(self, scalar::sin_u35_f64) + f64::sin_u35(self) } #[inline(always)] fn cos_u35(self) -> Self { - map::unary_f64(self, scalar::cos_u35_f64) + f64::cos_u35(self) } #[inline(always)] fn tan_u35(self) -> Self { - map::unary_f64(self, scalar::tan_u35_f64) + f64::tan_u35(self) } } diff --git a/src/math/families/hyperbolic.rs b/src/math/families/hyperbolic.rs index 91fbd45..676bca4 100644 --- a/src/math/families/hyperbolic.rs +++ b/src/math/families/hyperbolic.rs @@ -1,4 +1,4 @@ -use crate::math::{f32, map, scalar}; +use crate::math::{f32, f64}; use crate::{Simd, SimdFloat32, SimdFloat64}; pub trait SimdMathF32Hyperbolic: SimdFloat32 { @@ -32,17 +32,17 @@ impl SimdMathF32Hyperbolic for T {} pub trait SimdMathF64Hyperbolic: SimdFloat64 { #[inline(always)] fn sinh_u35(self) -> Self { - map::unary_f64(self, scalar::sinh_u35_f64) + f64::sinh_u35(self) } #[inline(always)] fn cosh_u35(self) -> Self { - map::unary_f64(self, scalar::cosh_u35_f64) + f64::cosh_u35(self) } #[inline(always)] fn tanh_u35(self) -> Self { - map::unary_f64(self, scalar::tanh_u35_f64) + f64::tanh_u35(self) } } diff --git a/src/math/families/inverse_hyperbolic.rs b/src/math/families/inverse_hyperbolic.rs index c0a9cfe..18d6f75 100644 --- a/src/math/families/inverse_hyperbolic.rs +++ b/src/math/families/inverse_hyperbolic.rs @@ -1,4 +1,4 @@ -use crate::math::{f32, map, scalar}; +use crate::math::{f32, f64}; use crate::{Simd, SimdFloat32, SimdFloat64}; pub trait SimdMathF32InverseHyperbolic: SimdFloat32 { @@ -32,17 +32,17 @@ impl SimdMathF32InverseHyperbolic for T {} pub trait SimdMathF64InverseHyperbolic: SimdFloat64 { #[inline(always)] fn asinh_u35(self) -> Self { - map::unary_f64(self, scalar::asinh_u35_f64) + f64::asinh_u35(self) } #[inline(always)] fn acosh_u35(self) -> Self { - map::unary_f64(self, scalar::acosh_u35_f64) + f64::acosh_u35(self) } #[inline(always)] fn atanh_u35(self) -> Self { - map::unary_f64(self, scalar::atanh_u35_f64) + f64::atanh_u35(self) } } diff --git a/src/math/families/inverse_trig/mod.rs b/src/math/families/inverse_trig/mod.rs index 1ac141f..a5de564 100644 --- a/src/math/families/inverse_trig/mod.rs +++ b/src/math/families/inverse_trig/mod.rs @@ -1,6 +1,6 @@ mod portable_f32; -use crate::math::{map, scalar}; +use crate::math::f64; use crate::{Simd, SimdFloat32, SimdFloat64}; pub trait SimdMathF32InverseTrig: SimdFloat32 { @@ -34,17 +34,17 @@ impl SimdMathF32InverseTrig for T {} pub trait SimdMathF64InverseTrig: SimdFloat64 { #[inline(always)] fn asin_u35(self) -> Self { - map::unary_f64(self, scalar::asin_u35_f64) + f64::asin_u35(self) } #[inline(always)] fn acos_u35(self) -> Self { - map::unary_f64(self, scalar::acos_u35_f64) + f64::acos_u35(self) } #[inline(always)] fn atan_u35(self) -> Self { - map::unary_f64(self, scalar::atan_u35_f64) + f64::atan_u35(self) } } diff --git a/src/math/mod.rs b/src/math/mod.rs index 35f7230..9b36bb2 100644 --- a/src/math/mod.rs +++ b/src/math/mod.rs @@ -17,11 +17,14 @@ //! Structure notes: //! - `families/` owns public extension traits grouped by math family. //! - `scalar/` owns scalar fallback helpers using the same family boundaries. +//! - `f64/` mirrors the family split for future backend work while preserving +//! the current scalar-mapped behavior. //! - `contracts.rs` and `map.rs` stay stable so follow-up optimization PRs can //! target a single family file with minimal overlap. pub mod contracts; mod f32; +mod f64; mod families; mod map; mod scalar;