Repository navigation
feat(linalg): numpy.linalg in pure Go - #46
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…numpy fixture Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iagonalization Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…coverage Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Package
linalg:numpy.linalgfor ndarray arrays, in pure Go (CGO=0), over the package's packed SIMD GEMM.What it has
Solve,Inv,Det,Slogdet,Cholesky(lower/upper),QR(reduced, complete, r, raw),SVD/SVDVals,Eigh/Eigvalsh(UPLO),Eig/Eigvals(always complex, as in numpy 2),Lstsq/LstsqRcond,Pinv/PinvRcond,MatrixRank/MatrixRankTol,Norm(all vector and matrix orders, axes, keepdims),Cond,MatrixPower,MultiDot.(..., M, N)inputs, one matrix per goroutine;Solvebroadcasts like numpy's gufunc.ErrLinAlg(numpy's LinAlgError), whichErrSingular,ErrNotPosDefandErrNoConvergencewrap;ErrShape;ErrArgs.Algorithms (LAPACK's, generic over float64/complex128)
docs/linalg.md explains the choice of Golub–Kahan with QR over one-sided Jacobi: it has the same backward-error class as numpy's gesdd, at a fraction of Jacobi's sweeps.
Verification
linalg/testdata/cases.py). 914 are checked on their values and 124 must raise the same kind of error. The other 2 are logged as deliberate differences, listed in the docs.32·n·ε·κ. Factors that are not unique are checked through their identities: orthogonality, residuals, triangularity, the eigenvalue order, dgeev's normalization and exact conjugate pairs. Eig's eigenvalues are checked against an empirical sensitivity stored in the fixture, which is how defective matrices are covered.-race -coverpkg).go vet(native, 386, wasm), the s390x test build andgofmtare clean.Speed against numpy (Accelerate) — numpy wins on single matrices
Medians of three interleaved rounds on a shared host (load 16–23 on 16 cores). Go time ÷ numpy time at n = 64 / 256 / 1024:
eiglacks LAPACK's multishift QR with aggressive early deflation.Not done
eigat large n.hermitian=andrtol=options.Eighon NaN input returnsErrNoConvergence, where numpy returns NaNs.🤖 Generated with Claude Code