pub struct SparseCSR {
pub shape: (usize, usize),
pub row_ptr: Vec<usize>,
pub col_indices: Vec<usize>,
pub values: Vec<f64>,
}Expand description
Sparse matrix in CSR (Compressed Sparse Row) format.
Storage: O(nnz) where nnz is the number of non-zero elements Row access: O(1) Column access: O(nnz)
Fields§
§shape: (usize, usize)Shape of the matrix (rows, cols)
row_ptr: Vec<usize>Row pointers (length = rows + 1)
col_indices: Vec<usize>Column indices for each non-zero entry
values: Vec<f64>Values for each non-zero entry
Implementations§
Source§impl SparseCSR
impl SparseCSR
Sourcepub fn sparsity_ratio(&self) -> f64
pub fn sparsity_ratio(&self) -> f64
Get sparsity ratio (fraction of zero elements).
Sourcepub fn multiply_dense(&self, vec: &[f64]) -> Result<Vec<f64>, SparseError>
pub fn multiply_dense(&self, vec: &[f64]) -> Result<Vec<f64>, SparseError>
Multiply with a dense vector (matrix-vector multiplication).
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Get memory usage in bytes.
Sourcepub fn validate(&self) -> Result<(), SparseError>
pub fn validate(&self) -> Result<(), SparseError>
Validate the CSR structure.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SparseCSR
impl<'de> Deserialize<'de> for SparseCSR
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for SparseCSR
Auto Trait Implementations§
impl Freeze for SparseCSR
impl RefUnwindSafe for SparseCSR
impl Send for SparseCSR
impl Sync for SparseCSR
impl Unpin for SparseCSR
impl UnwindSafe for SparseCSR
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