LICENSE=BSD-3-ClauseCGO_ENABLED=0go-sparse is the sparse linear algebra layer of the Go scientific stack built on go-ndarray: sparse formats, fill-reducing orderings and iterative solvers with preconditioners, following scipy.sparse.linalg. Its tests replay recorded SciPy answers. No cgo. sparse v0.1.0 is released; what is not provided yet (sparse direct factorisations, eigensolvers, multigrid) is said in the documentation.
a := gallery.Laplacian2D(100, 100) // *sparse.CSR[float64]
b := make([]float64, a.Rows)
ic, _ := iter.NewIC0(a) // incomplete Cholesky
res, _ := iter.CG(a, b, &iter.Options{RTol: 1e-8, M: ic})
fmt.Println(res.Info, res.Iterations) // 0 = converged, as in SciPyEach package names the reference it corresponds to: SciPy's scipy.sparse and scipy.sparse.linalg, MATLAB's sparse functions, and SuiteSparse AMD and COLAMD as the reference algorithms for the orderings.
COO, CSR, CSC and DOK over float64 and complex128; conversions, O(1) transpose, SpMV, SpMM, SpGEMM, Diags, Tril, Triu and norms.
RCM, AMD and COLAMD, with bandwidth, profile and Cholesky and QR fill counts to compare them.
CG, GMRES(m), BiCGSTAB, MINRES, LSQR and LSMR, with Jacobi, SSOR, IC0, ILU0 and ILUT preconditioners, on any LinearOperator.
Read and write coordinate and array files, real, integer, pattern and complex, with limits against hostile input.
The nd package takes and returns *ndarray.Array for vectors, dense matrices, SpMV and SpMM.
No cgo. CI runs the tests with the race detector, on 386 and the other architectures of the fleet.
Every repository of the organization. The orderings are written from the papers; GPL and LGPL code was not consulted.
The fixtures are written by a Go harness that calls SciPy 1.18.1, committed, and compared in the tests. The performance table is in the library's docs/perf.md and the documentation, measured against SciPy on one core.
CG, GMRES, MINRES, LSQR and LSMR take the same number of iterations as SciPy 1.18.1 on the committed suite; BiCGSTAB agrees within a few iterations. The stopping rule, rtol, maxiter and info follow scipy.sparse.linalg. (sparse)
AMD Cholesky fill is within 1% of SuiteSparse AMD, COLAMD LU fill within 4% of SuperLU’s COLAMD, and RCM bandwidth equals SciPy’s. Tie-breaking differs, so permutations differ; quality is compared by fill. (sparse)
SpMV, CG and GMRES(30) on 2-D Laplacians of 1.1e5 and 1e6 nonzeros take 0.56 to 0.98 of SciPy’s time (Go time / SciPy time), interleaved on one core, measured on 2026-10-20 at load 5; SpMV is bit-identical to SciPy’s csr_matvec order. (sparse)
A Go harness drives SciPy over a pipe and records the answers in a committed fixture; the regression tests replay it, so they need neither Python nor network. (sparse)
mtx.Read checks declared sizes before allocating, counts stored values in int64, cuts a gzip bomb off at a byte limit, and has a fuzz target with a committed corpus. (sparse)
go test -race with 100% statement coverage over all packages, 386 and the other architectures in CI, and govulncheck. (sparse)
Released v0.1.0. COO, CSR, CSC and DOK matrices over float64 and complex128, Matrix Market I/O, the RCM, AMD and COLAMD orderings, and the iterative solvers CG, GMRES, BiCGSTAB, MINRES, LSQR and LSMR with Jacobi, SSOR, IC0, ILU0 and ILUT preconditioners, following scipy.sparse.linalg.
The documentation (Hugo + Hextra): one section per library, made of its own README and what it verifies and measures. Source โ
Logos and icons for the organization, in SVG / PNG / JPG / ICO / ICNS across colour, white and black variants.
go-sparse works with the arrays of go-ndarray, next to go-numerics and go-statistics, and a go-notebook cell can use all of them. What is not provided yet is listed in the documentation.
Read the source on GitHub โ