pub struct SymCsrMatrix<T>{
pub data: Vec<T>,
pub indptr: Vec<usize>,
pub indices: Vec<usize>,
pub shape: (usize, usize),
}
Expand description
Symmetric Compressed Sparse Row (SymCSR) matrix
This format stores only the lower triangular part of a symmetric matrix to save memory and improve performance. Operations are optimized to take advantage of symmetry when possible.
§Note
All operations maintain symmetry implicitly.
Fields§
§data: Vec<T>
CSR format data for the lower triangular part (including diagonal)
indptr: Vec<usize>
Row pointers (indptr): indices where each row starts in indices array
indices: Vec<usize>
Column indices for each non-zero element
shape: (usize, usize)
Matrix shape (rows, cols), always square
Implementations§
Source§impl<T> SymCsrMatrix<T>
impl<T> SymCsrMatrix<T>
Sourcepub fn new(
data: Vec<T>,
indptr: Vec<usize>,
indices: Vec<usize>,
shape: (usize, usize),
) -> SparseResult<Self>
pub fn new( data: Vec<T>, indptr: Vec<usize>, indices: Vec<usize>, shape: (usize, usize), ) -> SparseResult<Self>
Create a new symmetric CSR matrix from raw data
§Arguments
data
- Non-zero values in the lower triangular partindptr
- Row pointersindices
- Column indicesshape
- Matrix shape (n, n)
§Returns
A symmetric CSR matrix
§Errors
Returns an error if:
- The shape is not square
- The indices array is incompatible with indptr
- Any column index is out of bounds
Sourcepub fn from_csr(matrix: &CsrMatrix<T>) -> SparseResult<Self>
pub fn from_csr(matrix: &CsrMatrix<T>) -> SparseResult<Self>
Sourcepub fn is_symmetric(matrix: &CsrMatrix<T>) -> bool
pub fn is_symmetric(matrix: &CsrMatrix<T>) -> bool
Sourcepub fn nnz_stored(&self) -> usize
pub fn nnz_stored(&self) -> usize
Get the number of stored non-zero elements
§Returns
The number of non-zero elements in the lower triangular part
Sourcepub fn nnz(&self) -> usize
pub fn nnz(&self) -> usize
Get the total number of non-zero elements in the full matrix
§Returns
The total number of non-zero elements in the full symmetric matrix
Sourcepub fn to_csr(&self) -> SparseResult<CsrMatrix<T>>
pub fn to_csr(&self) -> SparseResult<CsrMatrix<T>>
Convert to standard CSR matrix (reconstructing full symmetric matrix)
§Returns
A standard CSR matrix with both upper and lower triangular parts
Trait Implementations§
Source§impl<T> Clone for SymCsrMatrix<T>
impl<T> Clone for SymCsrMatrix<T>
Source§fn clone(&self) -> SymCsrMatrix<T>
fn clone(&self) -> SymCsrMatrix<T>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for SymCsrMatrix<T>
impl<T> RefUnwindSafe for SymCsrMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for SymCsrMatrix<T>where
T: Send,
impl<T> Sync for SymCsrMatrix<T>where
T: Sync,
impl<T> Unpin for SymCsrMatrix<T>where
T: Unpin,
impl<T> UnwindSafe for SymCsrMatrix<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
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>
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>
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