Skip to main content

SimdOps

Trait SimdOps 

Source
pub trait SimdOps {
    // Required methods
    fn add(a: &[Self], b: &[Self]) -> Vec<Self>
       where Self: Sized;
    fn sub(a: &[Self], b: &[Self]) -> Vec<Self>
       where Self: Sized;
    fn mul(a: &[Self], b: &[Self]) -> Vec<Self>
       where Self: Sized;
    fn dot(a: &[Self], b: &[Self]) -> Self
       where Self: Sized;
    fn cosine_distance(a: &[Self], b: &[Self]) -> Self
       where Self: Sized;
    fn euclidean_distance(a: &[Self], b: &[Self]) -> Self
       where Self: Sized;
    fn manhattan_distance(a: &[Self], b: &[Self]) -> Self
       where Self: Sized;
    fn norm(a: &[Self]) -> Self
       where Self: Sized;
    fn sum(a: &[Self]) -> Self
       where Self: Sized;
    fn mean(a: &[Self]) -> Self
       where Self: Sized;
}
Expand description

Unified SIMD operations trait

Required Methods§

Source

fn add(a: &[Self], b: &[Self]) -> Vec<Self>
where Self: Sized,

Add two slices element-wise

Source

fn sub(a: &[Self], b: &[Self]) -> Vec<Self>
where Self: Sized,

Subtract two slices element-wise

Source

fn mul(a: &[Self], b: &[Self]) -> Vec<Self>
where Self: Sized,

Multiply two slices element-wise

Source

fn dot(a: &[Self], b: &[Self]) -> Self
where Self: Sized,

Compute dot product

Source

fn cosine_distance(a: &[Self], b: &[Self]) -> Self
where Self: Sized,

Compute cosine distance (1 - cosine_similarity)

Source

fn euclidean_distance(a: &[Self], b: &[Self]) -> Self
where Self: Sized,

Compute Euclidean distance

Source

fn manhattan_distance(a: &[Self], b: &[Self]) -> Self
where Self: Sized,

Compute Manhattan distance

Source

fn norm(a: &[Self]) -> Self
where Self: Sized,

Compute L2 norm

Source

fn sum(a: &[Self]) -> Self
where Self: Sized,

Sum all elements

Source

fn mean(a: &[Self]) -> Self
where Self: Sized,

Compute mean

Implementations on Foreign Types§

Source§

impl SimdOps for f32

SIMD implementation for f32

Source§

fn add(a: &[Self], b: &[Self]) -> Vec<Self>

Source§

fn sub(a: &[Self], b: &[Self]) -> Vec<Self>

Source§

fn mul(a: &[Self], b: &[Self]) -> Vec<Self>

Source§

fn dot(a: &[Self], b: &[Self]) -> Self

Source§

fn cosine_distance(a: &[Self], b: &[Self]) -> Self

Source§

fn euclidean_distance(a: &[Self], b: &[Self]) -> Self

Source§

fn manhattan_distance(a: &[Self], b: &[Self]) -> Self

Source§

fn norm(a: &[Self]) -> Self

Source§

fn sum(a: &[Self]) -> Self

Source§

fn mean(a: &[Self]) -> Self

Source§

impl SimdOps for f64

SIMD implementation for f64

Source§

fn add(a: &[Self], b: &[Self]) -> Vec<Self>

Source§

fn sub(a: &[Self], b: &[Self]) -> Vec<Self>

Source§

fn mul(a: &[Self], b: &[Self]) -> Vec<Self>

Source§

fn dot(a: &[Self], b: &[Self]) -> Self

Source§

fn cosine_distance(a: &[Self], b: &[Self]) -> Self

Source§

fn euclidean_distance(a: &[Self], b: &[Self]) -> Self

Source§

fn manhattan_distance(a: &[Self], b: &[Self]) -> Self

Source§

fn norm(a: &[Self]) -> Self

Source§

fn sum(a: &[Self]) -> Self

Source§

fn mean(a: &[Self]) -> Self

Implementors§