Expand description
Readable reference implementations of the classical dense linear algebra algorithms, kept for study and as benchmark baselines.
If you just want to solve a system or decompose a matrix, use lib_jsl_linalg instead.
The routines here work on real f64 matrices, favour the shape of the textbook formulas over
speed, and several are included precisely to show why production code does something else:
| Module | Algorithms | The lesson |
|---|---|---|
gaussian_elimination | Elimination without and with partial pivoting | Pivoting is what makes elimination stable |
lu | Doolittle LU, triangular solves, determinant, inverse | Factor once, solve many times |
cholesky | Cholesky-Banachiewicz | Symmetry halves the work and needs no pivoting |
qr | Classical and modified Gram-Schmidt, Householder | Orthogonality is lost by Gram-Schmidt and kept by reflections |
power_iteration | Power, inverse and Rayleigh-quotient iteration | Repeated multiplication finds dominant eigenvectors; shifts make it fast |
jacobi_eigenvalue | Cyclic Jacobi rotations | Annihilating off-diagonal entries one at a time converges quadratically |
qr_algorithm | Unshifted and shifted QR iteration | The QR algorithm is subspace iteration in disguise; shifts accelerate it |
naive_svd | SVD from the eigenvalues of AᵀA | Forming AᵀA squares the condition number |
least_squares | Normal equations versus QR | The same trade-off for least squares |
Run cargo bench -p lib_jsl_linalg_reference to compare them with the production crate.
See the book chapter Dense linear algebra.
Modules§
- cholesky
- The Cholesky factorisation
A = L Lᵀof a symmetric positive-definite matrix. - gaussian_
elimination - Gaussian elimination: the algorithm every linear solver descends from.
- jacobi_
eigenvalue - The Jacobi eigenvalue method for symmetric matrices (Jacobi, 1846).
- least_
squares - Linear least squares,
min ‖A x − b‖₂for a tallA, two ways. - lu
- The LU factorisation
P A = L U(Doolittle form, unit lower triangularL). - naive_
svd - The singular value decomposition computed the obvious way, from the eigenproblem of
AᵀA. - power_
iteration - Power iteration and its two refinements, for one eigenpair of a symmetric matrix.
- qr
- The QR factorisation
A = Q R: orthonormal columns times an upper triangular matrix. - qr_
algorithm - The QR algorithm (Francis and Kublanovskaya, 1961) for the eigenvalues of a symmetric matrix.
Functions§
- off_
diagonal_ norm - The off-diagonal Frobenius norm, used to measure how far a matrix is from diagonal.
- random_
matrix - A deterministic pseudo-random matrix with entries in [−1, 1), for tests and benchmarks.
- random_
positive_ definite - A random symmetric positive-definite matrix
G Gᵀ + n I. - random_
symmetric - A random symmetric matrix
G + Gᵀ.
Type Aliases§
- Error
- Why a reference routine failed.