Skip to main content

VectorArithmetic

Trait VectorArithmetic 

Source
pub trait VectorArithmetic<T> {
    // Required methods
    fn add(&self, a: &[T], b: &[T]) -> Result<Vec<T>, SimdError>;
    fn sub(&self, a: &[T], b: &[T]) -> Result<Vec<T>, SimdError>;
    fn mul(&self, a: &[T], b: &[T]) -> Result<Vec<T>, SimdError>;
    fn div(&self, a: &[T], b: &[T]) -> Result<Vec<T>, SimdError>;
    fn fma(&self, a: &[T], b: &[T], c: &[T]) -> Result<Vec<T>, SimdError>;
    fn scale(&self, vector: &[T], scalar: T) -> Result<Vec<T>, SimdError>;
}
Expand description

Trait for vectorized arithmetic operations

Required Methods§

Source

fn add(&self, a: &[T], b: &[T]) -> Result<Vec<T>, SimdError>

Add two vectors element-wise

Source

fn sub(&self, a: &[T], b: &[T]) -> Result<Vec<T>, SimdError>

Subtract two vectors element-wise

Source

fn mul(&self, a: &[T], b: &[T]) -> Result<Vec<T>, SimdError>

Multiply two vectors element-wise

Source

fn div(&self, a: &[T], b: &[T]) -> Result<Vec<T>, SimdError>

Divide two vectors element-wise

Source

fn fma(&self, a: &[T], b: &[T], c: &[T]) -> Result<Vec<T>, SimdError>

Compute fused multiply-add: a * b + c

Source

fn scale(&self, vector: &[T], scalar: T) -> Result<Vec<T>, SimdError>

Scale a vector by a scalar

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl VectorArithmetic<f32> for TargetOptimizedOps

Target-specific vector arithmetic implementation