pub struct SimdOps;Expand description
Safe SIMD-accelerated operations for performance-critical paths
Uses the wide crate for portable, safe SIMD operations
This struct provides vectorized math operations for numerical processing without any unsafe code. It automatically uses SIMD when beneficial and falls back to scalar operations for small arrays.
§Performance considerations
- Uses safe
widef64x4 operations for parallel processing - Portable across all platforms (not limited to
x86_64) - NaN-safe operations with hardware NaN propagation
- Avoids heap allocations for small to medium-sized arrays
- Handles edge cases like empty arrays and single-element arrays efficiently
Implementations§
Source§impl SimdOps
impl SimdOps
Sourcepub fn sum_f64(values: &[f64]) -> f64
pub fn sum_f64(values: &[f64]) -> f64
Apply safe SIMD-accelerated sum to an array of f64 values Uses wide f64x4 operations for maximum performance and safety Optimized with different strategies based on array size
Sourcepub fn decimal_to_f64(values: &[Decimal]) -> Vec<f64>
pub fn decimal_to_f64(values: &[Decimal]) -> Vec<f64>
Convert an array of decimal values to f64 for SIMD operations
Sourcepub fn sum_decimal(values: &[Decimal]) -> Decimal
pub fn sum_decimal(values: &[Decimal]) -> Decimal
Sum an array of Decimal values using safe SIMD acceleration
Sourcepub fn sum_price_level_sizes<T>(
levels: &[T],
extract_size: impl Fn(&T) -> Decimal,
) -> Decimal
pub fn sum_price_level_sizes<T>( levels: &[T], extract_size: impl Fn(&T) -> Decimal, ) -> Decimal
Sum the size values from an array of PriceLevel structs using SIMD acceleration
This avoids creating a temporary Vec
Sourcepub fn min_f64(values: &[f64]) -> f64
pub fn min_f64(values: &[f64]) -> f64
Apply safe SIMD-accelerated min to an array of f64 values Uses wide f64x4 operations with NaN-safe comparisons
Sourcepub fn max_f64(values: &[f64]) -> f64
pub fn max_f64(values: &[f64]) -> f64
Apply safe SIMD-accelerated max to an array of f64 values Uses wide f64x4 operations with NaN-safe comparisons
Sourcepub fn min_decimal(values: &[Decimal]) -> Decimal
pub fn min_decimal(values: &[Decimal]) -> Decimal
Calculate the min value of an array of Decimal values using SIMD acceleration
Sourcepub fn max_decimal(values: &[Decimal]) -> Decimal
pub fn max_decimal(values: &[Decimal]) -> Decimal
Calculate the max value of an array of Decimal values using SIMD acceleration
Sourcepub fn dot_product_f64(a: &[f64], b: &[f64]) -> f64
pub fn dot_product_f64(a: &[f64], b: &[f64]) -> f64
Calculate the dot product of two f64 arrays using safe SIMD acceleration
Sourcepub fn mean_f64(values: &[f64]) -> f64
pub fn mean_f64(values: &[f64]) -> f64
Calculate the mean (average) of an array of f64 values using SIMD acceleration
Sourcepub fn mean_decimal(values: &[Decimal]) -> Decimal
pub fn mean_decimal(values: &[Decimal]) -> Decimal
Calculate the mean (average) of an array of Decimal values using SIMD acceleration
Sourcepub fn variance_f64(values: &[f64]) -> f64
pub fn variance_f64(values: &[f64]) -> f64
Calculate the variance of an array of f64 values using SIMD acceleration with Welford’s algorithm This is the population variance (divides by n, not n-1) - more numerically stable than naive method
Sourcepub fn std_dev_f64(values: &[f64]) -> f64
pub fn std_dev_f64(values: &[f64]) -> f64
Calculate the standard deviation of an array of f64 values using SIMD acceleration This is the population standard deviation (divides by n, not n-1)
Sourcepub fn variance_decimal(values: &[Decimal]) -> Decimal
pub fn variance_decimal(values: &[Decimal]) -> Decimal
Calculate the variance of an array of Decimal values using SIMD acceleration This is the population variance (divides by n, not n-1)
Sourcepub fn std_dev_decimal(values: &[Decimal]) -> Decimal
pub fn std_dev_decimal(values: &[Decimal]) -> Decimal
Calculate the standard deviation of an array of Decimal values using SIMD acceleration This is the population standard deviation (divides by n, not n-1)