pub struct SymCooMatrix<T>{
pub data: Vec<T>,
pub rows: Vec<usize>,
pub cols: Vec<usize>,
pub shape: (usize, usize),
}
Expand description
Symmetric Coordinate (SymCOO) matrix
This format stores only the lower triangular part of a symmetric matrix to save memory. It’s particularly useful for construction of symmetric matrices and for conversion to other symmetric formats.
§Note
All operations maintain symmetry implicitly.
Fields§
§data: Vec<T>
Non-zero values in the lower triangular part
rows: Vec<usize>
Row indices for each non-zero element
cols: Vec<usize>
Column indices for each non-zero element
shape: (usize, usize)
Matrix shape (rows, cols), always square
Implementations§
Source§impl<T> SymCooMatrix<T>
impl<T> SymCooMatrix<T>
Sourcepub fn new(
data: Vec<T>,
rows: Vec<usize>,
cols: Vec<usize>,
shape: (usize, usize),
) -> SparseResult<Self>
pub fn new( data: Vec<T>, rows: Vec<usize>, cols: Vec<usize>, shape: (usize, usize), ) -> SparseResult<Self>
Create a new symmetric COO matrix from raw data
§Arguments
data
- Non-zero values in the lower triangular partrows
- Row indicescols
- Column indicesshape
- Matrix shape (n, n)
§Returns
A symmetric COO matrix
§Errors
Returns an error if:
- The shape is not square
- The arrays have inconsistent lengths
- Any index is out of bounds
- Upper triangular elements are included
Sourcepub fn from_coo(matrix: &CooMatrix<T>) -> SparseResult<Self>
pub fn from_coo(matrix: &CooMatrix<T>) -> SparseResult<Self>
Sourcepub fn is_symmetric(matrix: &CooMatrix<T>) -> bool
pub fn is_symmetric(matrix: &CooMatrix<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_coo(&self) -> SparseResult<CooMatrix<T>>
pub fn to_coo(&self) -> SparseResult<CooMatrix<T>>
Convert to standard COO matrix (reconstructing full symmetric matrix)
§Returns
A standard COO matrix with both upper and lower triangular parts
Trait Implementations§
Source§impl<T> Clone for SymCooMatrix<T>
impl<T> Clone for SymCooMatrix<T>
Source§fn clone(&self) -> SymCooMatrix<T>
fn clone(&self) -> SymCooMatrix<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for SymCooMatrix<T>
impl<T> RefUnwindSafe for SymCooMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for SymCooMatrix<T>where
T: Send,
impl<T> Sync for SymCooMatrix<T>where
T: Sync,
impl<T> Unpin for SymCooMatrix<T>where
T: Unpin,
impl<T> UnwindSafe for SymCooMatrix<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