Skip to main content

SimdBatchProcessor

Struct SimdBatchProcessor 

Source
pub struct SimdBatchProcessor;
Expand description

SIMD-accelerated batch operations for numeric data.

This processor uses SIMD (Single Instruction, Multiple Data) instructions to accelerate common numeric operations on large datasets. Operations process 4 f64 values simultaneously, providing significant performance improvements for large-scale simulations.

§Examples

use legalis_sim::SimdBatchProcessor;

// Compute statistics on a large dataset
let data: Vec<f64> = (1..=1000).map(|x| x as f64).collect();

let sum = SimdBatchProcessor::sum_f64(&data);
let mean = SimdBatchProcessor::mean_f64(&data).unwrap();
let std_dev = SimdBatchProcessor::std_dev_f64(&data).unwrap();

assert_eq!(sum, 500500.0);
assert!((mean - 500.5).abs() < 0.01);
assert!(std_dev > 0.0);

Implementations§

Source§

impl SimdBatchProcessor

Source

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

Computes sum of f64 values using SIMD acceleration.

Processes values in batches of 4 using SIMD instructions for improved performance.

§Examples
use legalis_sim::SimdBatchProcessor;

let values = vec![1.0, 2.0, 3.0, 4.0, 5.0];
let sum = SimdBatchProcessor::sum_f64(&values);
assert_eq!(sum, 15.0);
Source

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

Computes mean of f64 values using SIMD acceleration.

Returns None if the input slice is empty.

§Examples
use legalis_sim::SimdBatchProcessor;

let values = vec![2.0, 4.0, 6.0, 8.0, 10.0];
let mean = SimdBatchProcessor::mean_f64(&values).unwrap();
assert_eq!(mean, 6.0);
Source

pub fn variance_f64(values: &[f64]) -> Option<f64>

Computes variance of f64 values using SIMD acceleration

Source

pub fn std_dev_f64(values: &[f64]) -> Option<f64>

Computes standard deviation using SIMD acceleration

Source

pub fn min_f64(values: &[f64]) -> Option<f64>

Computes minimum value using SIMD acceleration

Source

pub fn max_f64(values: &[f64]) -> Option<f64>

Computes maximum value using SIMD acceleration

Source

pub fn scale_f64(values: &mut [f64], scalar: f64)

Applies scalar multiplication using SIMD acceleration

Source

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

Computes dot product of two vectors using SIMD acceleration

Source

pub fn normalize_f64(values: &mut [f64]) -> Option<()>

Normalizes values to [0, 1] range using SIMD acceleration

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.

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.

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.
Source§

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

Source§

fn vzip(self) -> V