Expand description
Sparse matrix types: CSR and COO representations. Sparse matrix representations and arithmetic.
Provides Compressed Sparse Row (SparseCsr) and Coordinate (SparseCoo)
formats, plus element-wise and matrix-matrix operations.
§Determinism Contract
- Row-wise reductions use [
kahan_sum_f64] or [binned_sum_f64]. - [
sparse_matmul] accumulates column contributions in a [BTreeMap] for deterministic iteration order, then reduces each column with [binned_sum_f64]. - No
HashMap, no parallel iteration.
Structs§
- Sparse
Coo - Coordinate (COO / triplet) sparse matrix representation.
- Sparse
Csr - Compressed Sparse Row (CSR) matrix representation.
Functions§
- sparse_
add - Element-wise addition of two CSR matrices (same dimensions).
- sparse_
matmul - Sparse matrix-matrix multiplication (SpGEMM): C = A * B. Uses row-wise accumulation with BTreeMap for deterministic column ordering. All floating-point reductions use binned summation.
- sparse_
mul - Element-wise multiplication (Hadamard product) of two CSR matrices. Only positions where BOTH matrices have non-zeros produce non-zeros.
- sparse_
scalar_ mul - Scalar multiplication: every non-zero element is multiplied by
s. - sparse_
sub - Element-wise subtraction of two CSR matrices (same dimensions).
- sparse_
transpose - Transpose a CSR matrix. Returns a new CSR where rows and columns are swapped.