pub struct SparseMatrix<T> {
pub format: SparseFormat,
pub rows: usize,
pub cols: usize,
pub nnz: usize,
pub values: Vec<T>,
pub row_indices: Vec<usize>,
pub col_indices: Vec<usize>,
pub block_size: Option<(usize, usize)>,
}Expand description
Sparse matrix structure
Fields§
§format: SparseFormatStorage format
rows: usizeNumber of rows
cols: usizeNumber of columns
nnz: usizeNumber of non-zero elements
values: Vec<T>Values of non-zero elements
row_indices: Vec<usize>Row indices (format-dependent meaning)
col_indices: Vec<usize>Column indices (format-dependent meaning)
block_size: Option<(usize, usize)>Block size for BSR format
Implementations§
Source§impl<T: Clone + Default + PartialEq> SparseMatrix<T>
impl<T: Clone + Default + PartialEq> SparseMatrix<T>
Sourcepub fn insert_coo(
&mut self,
row: usize,
col: usize,
value: T,
) -> BackendResult<()>
pub fn insert_coo( &mut self, row: usize, col: usize, value: T, ) -> BackendResult<()>
Insert a value at (row, col) for COO format
Sourcepub fn to_csr(&self) -> BackendResult<SparseMatrix<T>>
pub fn to_csr(&self) -> BackendResult<SparseMatrix<T>>
Convert COO to CSR format
Sourcepub fn to_csc(&self) -> BackendResult<SparseMatrix<T>>
pub fn to_csc(&self) -> BackendResult<SparseMatrix<T>>
Convert COO to CSC format
Sourcepub fn sparsity_ratio(&self) -> f64
pub fn sparsity_ratio(&self) -> f64
Get sparsity ratio (percentage of non-zero elements)
Source§impl<T: Clone + Default + PartialEq> SparseMatrix<T>
impl<T: Clone + Default + PartialEq> SparseMatrix<T>
Sourcepub fn to_bsr(
&self,
block_size: (usize, usize),
) -> BackendResult<SparseMatrix<T>>
pub fn to_bsr( &self, block_size: (usize, usize), ) -> BackendResult<SparseMatrix<T>>
Create BSR (Block Sparse Row) matrix from COO
Sourcepub fn optimize(&mut self) -> BackendResult<()>
pub fn optimize(&mut self) -> BackendResult<()>
Optimize matrix structure by removing explicit zeros and sorting
Sourcepub fn statistics(&self) -> SparseMatrixStatistics
pub fn statistics(&self) -> SparseMatrixStatistics
Get matrix statistics for performance analysis
Trait Implementations§
Source§impl<T: Clone> Clone for SparseMatrix<T>
impl<T: Clone> Clone for SparseMatrix<T>
Source§fn clone(&self) -> SparseMatrix<T>
fn clone(&self) -> SparseMatrix<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for SparseMatrix<T>
impl<T: Debug> Debug for SparseMatrix<T>
Auto Trait Implementations§
impl<T> Freeze for SparseMatrix<T>
impl<T> RefUnwindSafe for SparseMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for SparseMatrix<T>where
T: Send,
impl<T> Sync for SparseMatrix<T>where
T: Sync,
impl<T> Unpin for SparseMatrix<T>where
T: Unpin,
impl<T> UnsafeUnpin for SparseMatrix<T>
impl<T> UnwindSafe for SparseMatrix<T>where
T: UnwindSafe,
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more