Struct SimdOps

Source
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 wide f64x4 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

Source

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

Source

pub fn decimal_to_f64(values: &[Decimal]) -> Vec<f64>

Convert an array of decimal values to f64 for SIMD operations

Source

pub fn sum_decimal(values: &[Decimal]) -> Decimal

Sum an array of Decimal values using safe SIMD acceleration

Source

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 for the size values

Source

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

Source

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

Source

pub fn min_decimal(values: &[Decimal]) -> Decimal

Calculate the min value of an array of Decimal values using SIMD acceleration

Source

pub fn max_decimal(values: &[Decimal]) -> Decimal

Calculate the max value of an array of Decimal values using SIMD acceleration

Source

pub fn dot_product_f64(a: &[f64], b: &[f64]) -> f64

Calculate the dot product of two f64 arrays using safe SIMD acceleration

Source

pub fn mean_f64(values: &[f64]) -> f64

Calculate the mean (average) of an array of f64 values using SIMD acceleration

Source

pub fn mean_decimal(values: &[Decimal]) -> Decimal

Calculate the mean (average) of an array of Decimal values using SIMD acceleration

Source

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

Source

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)

Source

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)

Source

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)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,