pub enum SparseFormat {
Coo,
Csr,
Csc,
Bsr,
Dia,
Dsr,
Ell,
Rle,
Symmetric,
}
Expand description
Layout format for sparse tensors
Different sparse formats are optimized for different use cases and access patterns. Choose the appropriate format based on your matrix characteristics and operations.
Variants§
Coo
Coordinate format (COO) - stores (row, col, value) triplets
Best for: Matrix construction, format conversion, random insertion Memory: 3 * nnz storage (row indices, col indices, values) Operations: Efficient addition, inefficient matrix-vector multiplication
Csr
Compressed Sparse Row (CSR) - row-oriented compressed format
Best for: Matrix-vector multiplication, row slicing, iterating by rows Memory: (nnz + n + 1) storage (values, col_indices, row_ptr) Operations: Fast row access, efficient SpMV, slow column access
Csc
Compressed Sparse Column (CSC) - column-oriented compressed format
Best for: Matrix-vector multiplication (A^T * x), column slicing Memory: (nnz + m + 1) storage (values, row_indices, col_ptr) Operations: Fast column access, efficient transpose operations
Bsr
Block Sparse Row (BSR) - stores dense blocks in sparse locations
Best for: Matrices with dense block structure, finite element methods Memory: Efficient for matrices with natural block structure Operations: BLAS-optimized operations on dense blocks
Dia
Diagonal format (DIA) - stores diagonals efficiently
Best for: Matrices with few non-zero diagonals, finite difference schemes Memory: Very compact for diagonal-dominant matrices Operations: Fast diagonal operations, limited to diagonal patterns
Dsr
Dynamic Sparse Row (DSR) - dynamic insertion/deletion support
Best for: Matrices that change structure frequently during computation Memory: Tree-based storage allows dynamic modifications Operations: Efficient insertion/deletion, slower than static formats
Ell
ELLPACK format (ELL) - fixed-width row storage
Best for: GPU operations, SIMD vectorization, matrices with uniform row density Memory: Can have significant overhead for irregular matrices Operations: SIMD-friendly, efficient on parallel architectures
Rle
Run-Length Encoded format (RLE) - compresses consecutive zeros
Best for: Matrices with long runs of consecutive non-zeros Memory: Excellent compression for specific patterns Operations: Specialized for pattern-specific matrices
Symmetric
Symmetric sparse format (SYM) - stores only lower/upper triangle
Best for: Symmetric matrices from finite element analysis, optimization Memory: Roughly half the storage of equivalent full format Operations: Specialized symmetric operations, automatic symmetry enforcement
Trait Implementations§
Source§impl Clone for SparseFormat
impl Clone for SparseFormat
Source§fn clone(&self) -> SparseFormat
fn clone(&self) -> SparseFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SparseFormat
impl Debug for SparseFormat
Source§impl From<ScipyFormat> for SparseFormat
impl From<ScipyFormat> for SparseFormat
Source§fn from(format: ScipyFormat) -> Self
fn from(format: ScipyFormat) -> Self
Source§impl From<SparseFormat> for ScipyFormat
impl From<SparseFormat> for ScipyFormat
Source§fn from(format: SparseFormat) -> Self
fn from(format: SparseFormat) -> Self
Source§impl Hash for SparseFormat
impl Hash for SparseFormat
Source§impl PartialEq for SparseFormat
impl PartialEq for SparseFormat
impl Copy for SparseFormat
impl Eq for SparseFormat
impl StructuralPartialEq for SparseFormat
Auto Trait Implementations§
impl Freeze for SparseFormat
impl RefUnwindSafe for SparseFormat
impl Send for SparseFormat
impl Sync for SparseFormat
impl Unpin for SparseFormat
impl UnwindSafe for SparseFormat
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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>
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>
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