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§
Sourcefn dot(&self, other: &[f64]) -> MathResult<f64>
fn dot(&self, other: &[f64]) -> MathResult<f64>
Computes dot product with another vector.
Sourcefn norm(&self, p: f64) -> MathResult<f64>
fn norm(&self, p: f64) -> MathResult<f64>
Computes Lp norm (p > 0).
- p = 1: Manhattan norm
- p = 2: Euclidean norm (default)
Sourcefn normalize(&self) -> MathResult<Vec<f64>>
fn normalize(&self) -> MathResult<Vec<f64>>
Normalizes vector to unit length (L2 norm = 1).
Sourcefn standardize(&self) -> MathResult<Vec<f64>>
fn standardize(&self) -> MathResult<Vec<f64>>
Standardizes to zero mean and unit variance.
Sourcefn add(&self, other: &[f64]) -> MathResult<Vec<f64>>
fn add(&self, other: &[f64]) -> MathResult<Vec<f64>>
Element-wise addition with another vector.