pub struct Matrix {}Expand description
Matrix operations class with high-performance implementations
Implementations§
Source§impl Matrix
impl Matrix
Sourcepub fn add(
&self,
a: &[f32],
b: &[f32],
result: &mut [f32],
rows: usize,
cols: usize,
) -> Result<MatrixResult>
pub fn add( &self, a: &[f32], b: &[f32], result: &mut [f32], rows: usize, cols: usize, ) -> Result<MatrixResult>
Matrix addition: result = a + b Matrices must have the same dimensions
Sourcepub fn multiply(
&self,
a: &[f32],
b: &[f32],
result: &mut [f32],
m: usize,
n: usize,
p: usize,
) -> Result<MatrixResult>
pub fn multiply( &self, a: &[f32], b: &[f32], result: &mut [f32], m: usize, n: usize, p: usize, ) -> Result<MatrixResult>
Matrix multiplication: result = a * b (m x n) * (n x p) = (m x p)
Sourcepub fn transpose(
&self,
input: &[f32],
output: &mut [f32],
rows: usize,
cols: usize,
) -> Result<MatrixResult>
pub fn transpose( &self, input: &[f32], output: &mut [f32], rows: usize, cols: usize, ) -> Result<MatrixResult>
Matrix transpose: result = a^T
Sourcepub fn dot_product(&self, a: &[f32], b: &[f32]) -> Result<MatrixResult>
pub fn dot_product(&self, a: &[f32], b: &[f32]) -> Result<MatrixResult>
Dot product of two vectors
Sourcepub fn normalize(
&self,
matrix: &mut [f32],
rows: usize,
cols: usize,
) -> Result<MatrixResult>
pub fn normalize( &self, matrix: &mut [f32], rows: usize, cols: usize, ) -> Result<MatrixResult>
Vector/matrix normalization (L2 normalization)
Sourcepub fn cosine_similarity(&self, a: &[f32], b: &[f32]) -> Result<MatrixResult>
pub fn cosine_similarity(&self, a: &[f32], b: &[f32]) -> Result<MatrixResult>
Cosine similarity between two vectors
Sourcepub fn vector_add(
&self,
a: &[f32],
b: &[f32],
result: &mut [f32],
) -> Result<MatrixResult>
pub fn vector_add( &self, a: &[f32], b: &[f32], result: &mut [f32], ) -> Result<MatrixResult>
Element-wise vector addition
Sourcepub fn vector_subtract(
&self,
a: &[f32],
b: &[f32],
result: &mut [f32],
) -> Result<MatrixResult>
pub fn vector_subtract( &self, a: &[f32], b: &[f32], result: &mut [f32], ) -> Result<MatrixResult>
Element-wise vector subtraction
Sourcepub fn vector_multiply(
&self,
a: &[f32],
b: &[f32],
result: &mut [f32],
) -> Result<MatrixResult>
pub fn vector_multiply( &self, a: &[f32], b: &[f32], result: &mut [f32], ) -> Result<MatrixResult>
Element-wise vector multiplication (Hadamard product)
Sourcepub fn vector_scale(
&self,
vector: &[f32],
scalar: f32,
result: &mut [f32],
) -> Result<MatrixResult>
pub fn vector_scale( &self, vector: &[f32], scalar: f32, result: &mut [f32], ) -> Result<MatrixResult>
Scalar multiplication of vector
Sourcepub fn determinant(&self, matrix: &[f32], size: usize) -> Result<MatrixResult>
pub fn determinant(&self, matrix: &[f32], size: usize) -> Result<MatrixResult>
Calculate matrix determinant (for square matrices only)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Matrix
impl RefUnwindSafe for Matrix
impl Send for Matrix
impl Sync for Matrix
impl Unpin for Matrix
impl UnwindSafe for Matrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more