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: usize
Number of non-zero elements
format: SparseFormat
Primary 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§const fn clone_from(&mut self, source: &Self)
const 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 more