algebra_linear 1.1.1

Pure-Rust BLAS, LAPACK, and sparse LU
Documentation

algebra_linear -- Pure-Rust BLAS, LAPACK, and sparse LU

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, dtrsv (+transpose), dtrsm, and the complex twins zgemm (+transposes), zgemv (+trans), zger, zherk, zsyrk, zaxpy, zscal, ztrsv (+transpose), ztrsm, dznrm2
sparse a simplicial sparse LU (CscView, SymbolicLu, LuFactors) and a supernodal one (SymbolicSupernodal, SupernodalLu) in CSC form, with real and complex scalars, plus the ported COLAMD ordering; LuSymbolic/LuMethod choose between the methods
lapack drivers: dgesv, dgetrf, dgetrf_rect (the nrows x ncols panel), dgetri, dpotrf, dsyev, dgesvd, dgeev (+left vectors), dggev, and the complex zgesv, zgetrf, zgetrf_rect, 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, plus a sparse LU with a COLAMD ordering. 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 an nrow-row matrix is data[i + j * nrow].
  • 0-based indices and usize lengths, 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's INFO, with INFO < 0 mapped to BadShape and INFO > 0 to Singular or Convergence.
  • An AVX2+FMA micro-kernel is selected at run time on x86-64; every other target (including wasm32) takes the portable blocked kernel.

Tests

cargo test                      # the kernels against closed-form results and invariants

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 \
  cargo test --features dev_lapack            # the same, plus the parity tests

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).