pub struct OptimizedMatrix { /* private fields */ }Expand description
A wrapper around nalgebra’s DMatrix for consistency with our API
Implementations§
Source§impl OptimizedMatrix
impl OptimizedMatrix
Sourcepub fn new(data: Vec<Vec<f64>>) -> Result<Self, String>
pub fn new(data: Vec<Vec<f64>>) -> Result<Self, String>
Create a new optimized matrix from a nested vector
Sourcepub fn add(&self, other: &OptimizedMatrix) -> Result<OptimizedMatrix, String>
pub fn add(&self, other: &OptimizedMatrix) -> Result<OptimizedMatrix, String>
Matrix addition
Sourcepub fn sub(&self, other: &OptimizedMatrix) -> Result<OptimizedMatrix, String>
pub fn sub(&self, other: &OptimizedMatrix) -> Result<OptimizedMatrix, String>
Matrix subtraction
Sourcepub fn scalar_mul(&self, scalar: f64) -> Result<OptimizedMatrix, String>
pub fn scalar_mul(&self, scalar: f64) -> Result<OptimizedMatrix, String>
Scalar multiplication
Sourcepub fn mul(&self, other: &OptimizedMatrix) -> Result<OptimizedMatrix, String>
pub fn mul(&self, other: &OptimizedMatrix) -> Result<OptimizedMatrix, String>
Matrix multiplication
Sourcepub fn determinant(&self) -> Result<f64, String>
pub fn determinant(&self) -> Result<f64, String>
Calculate determinant
Sourcepub fn is_invertible(&self) -> Result<bool, String>
pub fn is_invertible(&self) -> Result<bool, String>
Check if matrix is invertible
Sourcepub fn inverse(&self) -> Result<OptimizedMatrix, String>
pub fn inverse(&self) -> Result<OptimizedMatrix, String>
Calculate matrix inverse
Sourcepub fn transpose(&self) -> Result<OptimizedMatrix, String>
pub fn transpose(&self) -> Result<OptimizedMatrix, String>
Transpose the matrix
Sourcepub fn frobenius_norm(&self) -> f64
pub fn frobenius_norm(&self) -> f64
Calculate the Frobenius norm
Sourcepub fn eigenvalues(&self) -> Result<Vec<f64>, String>
pub fn eigenvalues(&self) -> Result<Vec<f64>, String>
Calculate eigenvalues (for symmetric matrices)
Sourcepub fn qr_decomposition(
&self,
) -> Result<(OptimizedMatrix, OptimizedMatrix), String>
pub fn qr_decomposition( &self, ) -> Result<(OptimizedMatrix, OptimizedMatrix), String>
QR Decomposition
Sourcepub fn svd(
&self,
) -> Result<(OptimizedMatrix, Vec<f64>, OptimizedMatrix), String>
pub fn svd( &self, ) -> Result<(OptimizedMatrix, Vec<f64>, OptimizedMatrix), String>
Singular Value Decomposition
Sourcepub fn solve(&self, b: &OptimizedMatrix) -> Result<OptimizedMatrix, String>
pub fn solve(&self, b: &OptimizedMatrix) -> Result<OptimizedMatrix, String>
Solve linear system Ax = b
Sourcepub fn identity(n: usize) -> Result<OptimizedMatrix, String>
pub fn identity(n: usize) -> Result<OptimizedMatrix, String>
Create an identity matrix of size n×n
Sourcepub fn zeros(rows: usize, cols: usize) -> Result<OptimizedMatrix, String>
pub fn zeros(rows: usize, cols: usize) -> Result<OptimizedMatrix, String>
Create a zero matrix of size rows×cols
Trait Implementations§
Source§impl Debug for OptimizedMatrix
impl Debug for OptimizedMatrix
Auto Trait Implementations§
impl Freeze for OptimizedMatrix
impl RefUnwindSafe for OptimizedMatrix
impl Send for OptimizedMatrix
impl Sync for OptimizedMatrix
impl Unpin for OptimizedMatrix
impl UnsafeUnpin for OptimizedMatrix
impl UnwindSafe for OptimizedMatrix
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
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.