Skip to content

lazymatrix::SparseRows ​

LazyMatrix for Rust · 0.8.1

Source

rust
pub trait SparseRows<F: Scalar>: MatrixShape

Borrowed access to rows stored contiguously in sparse form.

Implement this capability only when a backend can return the stored column indices and values for one row as slices in O(1) time, without gathering, copying, or allocating. Structurally absent entries are implicit zeros. This capability describes raw storage, independently of normalization.

Methods ​

sparse_row ​

rust
fn sparse_row(&self, i: usize) -> (&[usize], &[F])

Source

Return the stored (column index, raw value) slices for row i.

The two slices have equal length and corresponding entries in the backend's storage order. Explicitly stored zeros remain present, and each column index is less than self.ncols().

Panics ​

Panics if i >= self.nrows().

Implementation of SparseRows ​

Source

rust
impl<F, IP, IS, DS, Iptr> SparseRows<F> for SprsCsr<sprs::CsMatBase<F, usize, IP, IS, DS, Iptr>> where F: Scalar, Iptr: SpIndex, IP: Deref<Target = [Iptr]>, IS: Deref<Target = [usize]>, DS: Deref<Target = [F]>

Released under the MIT and Apache 2.0 licenses.