Expand description
Trueno Sparse: Sparse matrix formats and operations
Provides CSR, COO, and BSR sparse matrix formats with SIMD-accelerated SpMV (sparse matrix-vector multiply) and SpMM (sparse matrix-dense matrix multiply).
§Design
- Provable contracts: Format invariants validated at construction time
- Backward error bounded: Numerical accuracy follows LAProof bounds
- SIMD dispatch: Scalar → AVX2 → AVX-512 runtime selection
- GPU ready: Formats are GPU-transfer-friendly (contiguous arrays)
§Quick Start
use trueno_sparse::{CsrMatrix, CooMatrix, SparseOps};
// Build from COO (triplets)
let coo = CooMatrix::new(3, 3, vec![0, 1, 2], vec![0, 1, 2], vec![1.0_f32, 2.0, 3.0]).unwrap();
let csr = CsrMatrix::from_coo(&coo);
// SpMV: y = A * x
let x = vec![1.0_f32, 1.0, 1.0];
let mut y = vec![0.0_f32; 3];
csr.spmv(1.0, &x, 0.0, &mut y);
assert!((y[0] - 1.0).abs() < 1e-6);
assert!((y[1] - 2.0).abs() < 1e-6);
assert!((y[2] - 3.0).abs() < 1e-6);§References
- Merrill & Garland, “Merge-Based Parallel SpMV”, PPoPP 2016
- LAProof (Princeton): formal backward error bounds for CSR SpMV
Structs§
- Avx2
Backend - AVX2 SpMV backend (x86_64 with AVX2+FMA).
- BsrMatrix
- Block Sparse Row matrix.
- CooMatrix
- Coordinate sparse matrix format.
- CsrMatrix
- Compressed Sparse Row matrix.
- Scalar
Backend - Scalar (portable) SpMV backend.
- Sell
Matrix - Sliced ELLPACK sparse matrix.
Enums§
- Sparse
Error - Errors that can occur during sparse matrix construction or operations.
Traits§
- Sparse
Backend - Backend dispatch trait for pluggable SIMD SpMV kernels.
- Sparse
Ops - Sparse matrix operations trait.
Functions§
- spgemm
- Sparse matrix-matrix multiply: C = A * B (both CSR).
- validate_
csr_ invariants - Validate CSR format invariants per provable contract.