Matrix

Struct Matrix 

Source
pub struct Matrix {}
Expand description

Matrix operations class with high-performance implementations

Implementations§

Source§

impl Matrix

Source

pub fn new() -> Self

Create a new matrix operations instance

Source

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

Source

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)

Source

pub fn transpose( &self, input: &[f32], output: &mut [f32], rows: usize, cols: usize, ) -> Result<MatrixResult>

Matrix transpose: result = a^T

Source

pub fn dot_product(&self, a: &[f32], b: &[f32]) -> Result<MatrixResult>

Dot product of two vectors

Source

pub fn normalize( &self, matrix: &mut [f32], rows: usize, cols: usize, ) -> Result<MatrixResult>

Vector/matrix normalization (L2 normalization)

Source

pub fn cosine_similarity(&self, a: &[f32], b: &[f32]) -> Result<MatrixResult>

Cosine similarity between two vectors

Source

pub fn vector_add( &self, a: &[f32], b: &[f32], result: &mut [f32], ) -> Result<MatrixResult>

Element-wise vector addition

Source

pub fn vector_subtract( &self, a: &[f32], b: &[f32], result: &mut [f32], ) -> Result<MatrixResult>

Element-wise vector subtraction

Source

pub fn vector_multiply( &self, a: &[f32], b: &[f32], result: &mut [f32], ) -> Result<MatrixResult>

Element-wise vector multiplication (Hadamard product)

Source

pub fn vector_scale( &self, vector: &[f32], scalar: f32, result: &mut [f32], ) -> Result<MatrixResult>

Scalar multiplication of vector

Source

pub fn determinant(&self, matrix: &[f32], size: usize) -> Result<MatrixResult>

Calculate matrix determinant (for square matrices only)

Source

pub fn inverse( &self, matrix: &[f32], result: &mut [f32], size: usize, ) -> Result<MatrixResult>

Matrix inverse (for square matrices only)

Trait Implementations§

Source§

impl Debug for Matrix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Matrix

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V