VectorMath

Trait VectorMath 

Source
pub trait VectorMath {
    // Required methods
    fn dot(&self, other: &[f64]) -> MathResult<f64>;
    fn norm(&self, p: f64) -> MathResult<f64>;
    fn normalize(&self) -> MathResult<Vec<f64>>;
    fn standardize(&self) -> MathResult<Vec<f64>>;
    fn clip(&self, min: f64, max: f64) -> Vec<f64>;
    fn add(&self, other: &[f64]) -> MathResult<Vec<f64>>;
    fn subtract(&self, other: &[f64]) -> MathResult<Vec<f64>>;
    fn multiply(&self, scalar: f64) -> Vec<f64>;
}
Expand description

Re-exported mathematical utilities.

This includes statistical functions, vector/matrix operations, activation functions, and distance metrics used throughout the library. Vector mathematical operations.

Provides linear algebra operations for 1D numeric arrays.

Required Methods§

Source

fn dot(&self, other: &[f64]) -> MathResult<f64>

Computes dot product with another vector.

Source

fn norm(&self, p: f64) -> MathResult<f64>

Computes Lp norm (p > 0).

  • p = 1: Manhattan norm
  • p = 2: Euclidean norm (default)
Source

fn normalize(&self) -> MathResult<Vec<f64>>

Normalizes vector to unit length (L2 norm = 1).

Source

fn standardize(&self) -> MathResult<Vec<f64>>

Standardizes to zero mean and unit variance.

Source

fn clip(&self, min: f64, max: f64) -> Vec<f64>

Clips values to [min, max] range.

Source

fn add(&self, other: &[f64]) -> MathResult<Vec<f64>>

Element-wise addition with another vector.

Source

fn subtract(&self, other: &[f64]) -> MathResult<Vec<f64>>

Element-wise subtraction with another vector.

Source

fn multiply(&self, scalar: f64) -> Vec<f64>

Scalar multiplication.

Implementations on Foreign Types§

Source§

impl VectorMath for Vec<f64>

Source§

fn dot(&self, other: &[f64]) -> MathResult<f64>

Source§

fn norm(&self, p: f64) -> MathResult<f64>

Source§

fn normalize(&self) -> MathResult<Vec<f64>>

Source§

fn standardize(&self) -> MathResult<Vec<f64>>

Source§

fn clip(&self, min: f64, max: f64) -> Vec<f64>

Source§

fn add(&self, other: &[f64]) -> MathResult<Vec<f64>>

Source§

fn subtract(&self, other: &[f64]) -> MathResult<Vec<f64>>

Source§

fn multiply(&self, scalar: f64) -> Vec<f64>

Implementors§