pub struct SparseCSR {
pub row_ptr: Vec<usize>,
pub col_indices: Vec<usize>,
pub values: Vec<f32>,
pub shape: Vec<usize>,
}Expand description
Sparse tensor in CSR (Compressed Sparse Row) format.
Efficient for row-wise operations and sparse matrix-vector products.
Fields§
§row_ptr: Vec<usize>Row pointers (length = nrows + 1)
col_indices: Vec<usize>Column indices for each non-zero
values: Vec<f32>Values for each non-zero
shape: Vec<usize>Shape [nrows, ncols]
Implementations§
Source§impl SparseCSR
impl SparseCSR
Sourcepub fn new(
row_ptr: Vec<usize>,
col_indices: Vec<usize>,
values: Vec<f32>,
shape: Vec<usize>,
) -> Self
pub fn new( row_ptr: Vec<usize>, col_indices: Vec<usize>, values: Vec<f32>, shape: Vec<usize>, ) -> Self
Creates a new CSR sparse matrix.
Sourcepub fn row(&self, row_idx: usize) -> impl Iterator<Item = (usize, f32)> + '_
pub fn row(&self, row_idx: usize) -> impl Iterator<Item = (usize, f32)> + '_
Gets entries for a specific row.
Trait Implementations§
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
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