pub struct CSRStorage {
pub values: Vec<Precision>,
pub col_indices: Vec<IndexType>,
pub row_ptr: Vec<IndexType>,
}Expand description
Compressed Sparse Row (CSR) storage format.
Efficient for row-wise operations and matrix-vector multiplication.
Fields§
§values: Vec<Precision>Non-zero values in row-major order
col_indices: Vec<IndexType>Column indices corresponding to values
row_ptr: Vec<IndexType>Row pointers: row_ptr[i] is the start of row i in values/col_indices
Implementations§
Source§impl CSRStorage
impl CSRStorage
Sourcepub fn from_coo(
coo: &COOStorage,
rows: DimensionType,
cols: DimensionType,
) -> Result<Self>
pub fn from_coo( coo: &COOStorage, rows: DimensionType, cols: DimensionType, ) -> Result<Self>
Create CSR storage from COO format.
Sourcepub fn from_csc(
csc: &CSCStorage,
rows: DimensionType,
cols: DimensionType,
) -> Result<Self>
pub fn from_csc( csc: &CSCStorage, rows: DimensionType, cols: DimensionType, ) -> Result<Self>
Create CSR storage from CSC format.
Sourcepub fn get(&self, row: usize, col: usize) -> Option<Precision>
pub fn get(&self, row: usize, col: usize) -> Option<Precision>
Get matrix element at (row, col).
Sourcepub fn row_iter(&self, row: usize) -> CSRRowIter<'_> ⓘ
pub fn row_iter(&self, row: usize) -> CSRRowIter<'_> ⓘ
Iterate over non-zero elements in a row.
Sourcepub fn col_iter(&self, col: usize) -> CSRColIter<'_> ⓘ
pub fn col_iter(&self, col: usize) -> CSRColIter<'_> ⓘ
Iterate over non-zero elements in a column (slow for CSR).
Sourcepub fn multiply_vector(&self, x: &[Precision], result: &mut [Precision])
pub fn multiply_vector(&self, x: &[Precision], result: &mut [Precision])
Matrix-vector multiplication: result = A * x
Sourcepub fn multiply_vector_add(&self, x: &[Precision], result: &mut [Precision])
pub fn multiply_vector_add(&self, x: &[Precision], result: &mut [Precision])
Matrix-vector multiplication with accumulation: result += A * x
Sourcepub fn to_triplets(&self) -> Result<Vec<(usize, usize, Precision)>>
pub fn to_triplets(&self) -> Result<Vec<(usize, usize, Precision)>>
Extract as coordinate triplets.
Sourcepub fn add_diagonal(&mut self, alpha: Precision)
pub fn add_diagonal(&mut self, alpha: Precision)
Add a value to the diagonal.
Trait Implementations§
Source§impl Clone for CSRStorage
impl Clone for CSRStorage
Source§fn clone(&self) -> CSRStorage
fn clone(&self) -> CSRStorage
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 moreSource§impl Debug for CSRStorage
impl Debug for CSRStorage
Source§impl<'de> Deserialize<'de> for CSRStorage
impl<'de> Deserialize<'de> for CSRStorage
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
Auto Trait Implementations§
impl Freeze for CSRStorage
impl RefUnwindSafe for CSRStorage
impl Send for CSRStorage
impl Sync for CSRStorage
impl Unpin for CSRStorage
impl UnwindSafe for CSRStorage
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