trueno_sparse/lib.rs
1#![cfg_attr(
2 test,
3 allow(
4 clippy::expect_used,
5 clippy::unwrap_used,
6 clippy::disallowed_methods,
7 clippy::float_cmp,
8 clippy::panic,
9 clippy::cast_precision_loss,
10 clippy::unnecessary_wraps
11 )
12)]
13//! Trueno Sparse: Sparse matrix formats and operations
14//!
15//! Provides CSR, COO, and BSR sparse matrix formats with SIMD-accelerated
16//! SpMV (sparse matrix-vector multiply) and SpMM (sparse matrix-dense matrix multiply).
17//!
18//! # Design
19//!
20//! - **Provable contracts**: Format invariants validated at construction time
21//! - **Backward error bounded**: Numerical accuracy follows LAProof bounds
22//! - **SIMD dispatch**: Scalar → AVX2 → AVX-512 runtime selection
23//! - **GPU ready**: Formats are GPU-transfer-friendly (contiguous arrays)
24//!
25//! # Quick Start
26//!
27//! ```
28//! use trueno_sparse::{CsrMatrix, CooMatrix, SparseOps};
29//!
30//! // Build from COO (triplets)
31//! let coo = CooMatrix::new(3, 3, vec![0, 1, 2], vec![0, 1, 2], vec![1.0_f32, 2.0, 3.0]).unwrap();
32//! let csr = CsrMatrix::from_coo(&coo);
33//!
34//! // SpMV: y = A * x
35//! let x = vec![1.0_f32, 1.0, 1.0];
36//! let mut y = vec![0.0_f32; 3];
37//! csr.spmv(1.0, &x, 0.0, &mut y);
38//! assert!((y[0] - 1.0).abs() < 1e-6);
39//! assert!((y[1] - 2.0).abs() < 1e-6);
40//! assert!((y[2] - 3.0).abs() < 1e-6);
41//! ```
42//!
43//! # References
44//!
45//! - Merrill & Garland, "Merge-Based Parallel SpMV", PPoPP 2016
46//! - LAProof (Princeton): formal backward error bounds for CSR SpMV
47
48mod bsr;
49mod coo;
50mod csr;
51mod error;
52mod ops;
53mod sell;
54mod spgemm;
55mod validate;
56
57pub use bsr::BsrMatrix;
58pub use coo::CooMatrix;
59pub use csr::CsrMatrix;
60pub use error::SparseError;
61#[cfg(target_arch = "x86_64")]
62pub use ops::Avx2Backend;
63#[cfg(target_arch = "aarch64")]
64pub use ops::NeonBackend;
65pub use ops::{ScalarBackend, SparseBackend, SparseOps};
66pub use sell::SellMatrix;
67pub use spgemm::spgemm;
68pub use validate::validate_csr_invariants;
69
70#[cfg(test)]
71mod tests;