pub struct SparseMatrix<T> {
pub shape: (usize, usize),
pub nnz: usize,
pub format: SparseFormat,
pub coo: SparseMatrixCOO<T>,
pub csr: Option<SparseMatrixCSR<T>>,
pub csc: Option<SparseMatrixCSC<T>>,
pub metadata: HashMap<String, String>,
}Expand description
Comprehensive sparse matrix supporting multiple formats
Fields§
§shape: (usize, usize)Matrix dimensions (rows, cols)
nnz: usizeNumber of non-zero elements
format: SparseFormatPrimary format for storage
coo: SparseMatrixCOO<T>COO format data (always available)
csr: Option<SparseMatrixCSR<T>>CSR format data (computed on demand)
csc: Option<SparseMatrixCSC<T>>CSC format data (computed on demand)
metadata: HashMap<String, String>Additional metadata
Implementations§
Source§impl<T> SparseMatrix<T>
impl<T> SparseMatrix<T>
Sourcepub fn from_coo(coo: SparseMatrixCOO<T>) -> Self
pub fn from_coo(coo: SparseMatrixCOO<T>) -> Self
Create a sparse matrix from COO data
Sourcepub fn from_triplets(
rows: usize,
cols: usize,
row_indices: Vec<usize>,
col_indices: Vec<usize>,
values: Vec<T>,
) -> Result<Self>
pub fn from_triplets( rows: usize, cols: usize, row_indices: Vec<usize>, col_indices: Vec<usize>, values: Vec<T>, ) -> Result<Self>
Create a sparse matrix from triplets (row, col, value)
Sourcepub fn push(&mut self, row: usize, col: usize, value: T) -> Result<()>
pub fn push(&mut self, row: usize, col: usize, value: T) -> Result<()>
Add a non-zero element to the matrix
Sourcepub fn to_csr(&mut self) -> Result<&SparseMatrixCSR<T>>
pub fn to_csr(&mut self) -> Result<&SparseMatrixCSR<T>>
Convert to CSR format (cached)
Sourcepub fn to_csc(&mut self) -> Result<&SparseMatrixCSC<T>>
pub fn to_csc(&mut self) -> Result<&SparseMatrixCSC<T>>
Convert to CSC format (cached)
Sourcepub fn to_coo(&self) -> &SparseMatrixCOO<T>
pub fn to_coo(&self) -> &SparseMatrixCOO<T>
Convert to COO format (always available)
Sourcepub fn stats(&mut self) -> Result<SparseStats>
pub fn stats(&mut self) -> Result<SparseStats>
Get comprehensive statistics about the sparse matrix
Source§impl<T> SparseMatrix<T>
impl<T> SparseMatrix<T>
Sourcepub fn from_dense_2d(array: &Array2<T>, threshold: T) -> Result<Self>
pub fn from_dense_2d(array: &Array2<T>, threshold: T) -> Result<Self>
Create a sparse matrix from a dense 2D array with threshold
Sourcepub fn from_dense<S, D>(array: &ArrayBase<S, D>, threshold: T) -> Result<Self>
pub fn from_dense<S, D>(array: &ArrayBase<S, D>, threshold: T) -> Result<Self>
Create a sparse matrix from a dense array with threshold (generic version)
Source§impl SparseMatrix<f64>
impl SparseMatrix<f64>
Trait Implementations§
Source§impl Add for &SparseMatrix<f64>
impl Add for &SparseMatrix<f64>
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 moreAuto 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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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.