algebra_linear -- Pure-Rust BLAS and LAPACK
No external library, no C in a normal build, nothing to link — it compiles for any
target, including wasm32-unknown-unknown.
What is here
| module | contents |
|---|---|
blas |
level 1–3: dgemm (+tn/nt/tt), dgemv (+trans), ddot, dnrm2, dasum, idamax, daxpy, dlange, dger, dsyrk, and the complex twins zgemm (+transposes), zgemv (+trans), zger, zherk, zsyrk, zaxpy, zscal, dznrm2 |
lapack |
drivers: dgesv, dgetrf, dgetri, dpotrf, dsyev, dgesvd, dgeev (+left vectors), dggev, and the complex zgesv, zgetrf, zgetri, zpotrf, zheev, zgeev, zgesvd, zggev, plus the auxiliary routines; the TESTING/LIN accuracy checkers and the TESTING/MATGEN families are test-only and are not compiled into the crate |
Not every BLAS or LAPACK routine is here: the port covers the drivers a dense
linear-algebra caller needs. Each function names the reference source it follows (for example
"transcription of dsytrd/dlatrd") so it can be checked against LAPACK 3.12.1.
Conventions
- Column-major, so element
(i, j)of annrow-row matrix isdata[i + j * nrow]. - 0-based indices and
usizelengths, unlike the Fortran the routines are derived from. - No workspace arguments. The workspace a Fortran routine asks the caller for is allocated internally here.
- Functions return
Result<(), LapackError>rather than LAPACK'sINFO, withINFO < 0mapped toBadShapeandINFO > 0toSingularorConvergence. - An AVX2+FMA micro-kernel is selected at run time on x86-64; every other target
(including
wasm32) takes the portable blocked kernel.
Tests
The reference-parity harness is development-only and lives behind a feature: it
compiles c_code/reference_lapack.c against a locally built LAPACK 3.12.1 and
compares the kernels against it.
ALGEBRA_LINEAR_DEV_LAPACK_ROOT=/path/to/lapack/build \
Do not reach for --all-features here: dev_lapack is the only feature, so it
selects the harness, which cannot build without a local LAPACK.
ALGEBRA_LINEAR_DEV_LAPACK_ROOT must be a CMake build directory holding
include/lapack.h and lib/liblapack.so. There is no default: recording one would
put a developer's directory layout into released source.
License
BSD 3-Clause. The kernels are a transcription of LAPACK 3.12.1 and its reference
BLAS, whose copyright notice and conditions are reproduced verbatim in
LICENSE and apply to the derived code; the Rust transcription is
copyright Dorival Pedroso. If you redistribute a binary that statically links this
crate, that notice must travel with it (BSD 3-Clause, clause 2).