pub struct CsrMatrixSet<T> { /* private fields */ }Expand description
A collection of CSR matrices stored efficiently in a single data structure.
This structure is designed to store multiple CSR matrices with different dimensions in a compact format. It’s particularly useful for applications that need to manage many sparse matrices with similar sparsity patterns or for systems that generate multiple matrices during computation.
§Format
The set stores all matrices in contiguous arrays:
col_indices: Column indices for all matrices concatenatedvalues: Non-zero values for all matrices concatenatedrow_offsets: Row offsets for all matrices concatenatedncols: Number of columns for each individual matrixpartition: Metadata to locate each matrix within the concatenated data
§Examples
use algebra_sparse::CsrMatrixSet;
use algebra_sparse::traits::IntoView;
use algebra_sparse::CsrMatrixSetMethods;
let mut set: CsrMatrixSet<f64> = CsrMatrixSet::default();
// Add first matrix to the set
{
let mut builder1 = set.new_matrix(3, 1e-10);
builder1.new_row().push(0, 1.0);
} // builder1 is dropped here and matrix is added to set
// Add second matrix to the set
{
let mut builder2 = set.new_matrix(2, 1e-10);
builder2.new_row().push(1, 3.0);
} // builder2 is dropped here and matrix is added to set
println!("Set contains {} matrices", (&set).len());Implementations§
Source§impl<T: Real> CsrMatrixSet<T>
impl<T: Real> CsrMatrixSet<T>
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all matrices from the set.
This removes all data and allows reuse of the set.
Sourcepub fn new_matrix(
&mut self,
ncol: usize,
zero_threshold: T,
) -> CsrMatrixBuilder<'_, T>
pub fn new_matrix( &mut self, ncol: usize, zero_threshold: T, ) -> CsrMatrixBuilder<'_, T>
Source§impl<T> CsrMatrixSet<T>
impl<T> CsrMatrixSet<T>
Sourcepub fn get(&self, index: usize) -> CsrMatrixView<'_, T>
pub fn get(&self, index: usize) -> CsrMatrixView<'_, T>
Sourcepub fn as_view(&self) -> CsrMatrixSetView<'_, T>
pub fn as_view(&self) -> CsrMatrixSetView<'_, T>
Returns a view of the entire matrix set.
Trait Implementations§
Source§impl<T: Clone> Clone for CsrMatrixSet<T>
impl<T: Clone> Clone for CsrMatrixSet<T>
Source§fn clone(&self) -> CsrMatrixSet<T>
fn clone(&self) -> CsrMatrixSet<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 moreSource§impl<T> Default for CsrMatrixSet<T>
impl<T> Default for CsrMatrixSet<T>
Auto Trait Implementations§
impl<T> Freeze for CsrMatrixSet<T>
impl<T> RefUnwindSafe for CsrMatrixSet<T>where
T: RefUnwindSafe,
impl<T> Send for CsrMatrixSet<T>where
T: Send,
impl<T> Sync for CsrMatrixSet<T>where
T: Sync,
impl<T> Unpin for CsrMatrixSet<T>where
T: Unpin,
impl<T> UnwindSafe for CsrMatrixSet<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<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.