Expand description
SIMD-accelerated mathematical operations
This module provides mathematical functions with an architecture-specific
fast path for a subset of operations. Key operations (sqrt, abs, floor, ceil,
round) use NEON hardware instructions directly on aarch64. Transcendental
functions (exp, log, sin, cos, …) currently call the standard library’s
scalar libm implementation (e.g. f32::exp, f32::ln) on every target,
including aarch64 — there is no SIMD polynomial approximation implemented
for transcendentals today.
§Architecture Support
- aarch64: NEON intrinsics for sqrt (vsqrtq_f32), abs (vabsq_f32), and floor/ceil/round (vrndmq_f32/vrndpq_f32/vrndaq_f32). Transcendental functions (exp, ln, log2, log10, sin, cos, …) fall back to scalar libm calls even on this target.
- All other targets (including x86-64): Scalar fallback with auto-vectorization hints for every operation; there is no hand-written SSE2/SSE4.1/AVX2 path in this module today.
§Supported Operations
- Power/Root: sqrt, cbrt, pow, exp, exp2
- Logarithms: log, log2, log10
- Trigonometric: sin, cos, tan, asin, acos, atan, atan2
- Hyperbolic: sinh, cosh, tanh
- Special: abs, signum, floor, ceil, round, fract
§Performance
Expected speedup over scalar: 3-6x for most operations
§Example
use oxigeo_algorithms::simd::math::{sqrt_f32, exp_f32};
let data = vec![1.0, 4.0, 9.0, 16.0];
let mut result = vec![0.0; 4];
sqrt_f32(&data, &mut result)?;
assert_eq!(result, vec![1.0, 2.0, 3.0, 4.0]);Functions§
- abs_f32
- Compute absolute value element-wise using hardware SIMD
- acos_
f32 - Compute arccosine element-wise
- asin_
f32 - Compute arcsine element-wise
- atan2_
f32 - Compute two-argument arctangent element-wise: atan2(y, x)
- atan_
f32 - Compute arctangent element-wise
- ceil_
f32 - Compute ceiling element-wise using hardware SIMD
- cos_f32
- Compute cosine element-wise
- cosh_
f32 - Compute hyperbolic cosine element-wise
- exp2_
f32 - Compute 2^x element-wise
- exp_f32
- Compute exponential (e^x) element-wise
- floor_
f32 - Compute floor element-wise using hardware SIMD
- fract_
f32 - Compute fractional part element-wise: fract(x) = x - floor(x)
- ln_f32
- Compute natural logarithm (ln) element-wise
- log2_
f32 - Compute base-2 logarithm element-wise
- log10_
f32 - Compute base-10 logarithm element-wise
- pow_f32
- Compute power (base^exponent) element-wise
- round_
f32 - Compute round (nearest integer) element-wise using hardware SIMD
- sin_f32
- Compute sine element-wise
- sinh_
f32 - Compute hyperbolic sine element-wise
- sqrt_
f32 - Compute square root element-wise using hardware SIMD
- tan_f32
- Compute tangent element-wise
- tanh_
f32 - Compute hyperbolic tangent element-wise