kleene-sparse
Sparse matrices and vectors over semirings, on Arrow buffers, behind a backend trait.
CsrandCscmatrices built from Arrowu64offsets andu32indices with no copy, or from edge lists;Vector(sparse or dense) andMask(a bitset, complemented or not).- Semirings:
BoolOrAnd,MinPlus,PlusTimes,BitsetUnion, or your ownSemiring. mxv,vxm,mxm, element-wise operations,reduce,select,transposeand masked assignment behindSparseBackend;CpuBackendruns on every core. The GPU backend is kleene-cubecl.
It depends on Arrow only. Part of kleene.
use kleene_sparse::{BoolOrAnd, CpuBackend, CpuDevice, Csr, SparseBackend, Vector};
// The graph 0 -> 1 -> 2 as a structural matrix: every entry is the semiring's one.
let a = Csr::from_edges(3, 3, &[0, 1], &[1, 2], None, BoolOrAnd)?;
let device = CpuDevice::new(2);
// One step from vertex 0: the frontier times the matrix over (or, and).
let frontier = Vector::from_indices(3, &[0], 1u8)?;
let next = CpuBackend::vxm(&frontier, &a, None, BoolOrAnd, &device)?;
assert_eq!(next.iter().collect::<Vec<_>>(), [(1, 1)]);
# Ok::<(), kleene_sparse::SparseError>(())
Licence
MIT or Apache-2.0, at your option.