Skip to main content

Crate lib_jsl_linalg_reference

Crate lib_jsl_linalg_reference 

Source
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:

ModuleAlgorithmsThe lesson
gaussian_eliminationElimination without and with partial pivotingPivoting is what makes elimination stable
luDoolittle LU, triangular solves, determinant, inverseFactor once, solve many times
choleskyCholesky-BanachiewiczSymmetry halves the work and needs no pivoting
qrClassical and modified Gram-Schmidt, HouseholderOrthogonality is lost by Gram-Schmidt and kept by reflections
power_iterationPower, inverse and Rayleigh-quotient iterationRepeated multiplication finds dominant eigenvectors; shifts make it fast
jacobi_eigenvalueCyclic Jacobi rotationsAnnihilating off-diagonal entries one at a time converges quadratically
qr_algorithmUnshifted and shifted QR iterationThe QR algorithm is subspace iteration in disguise; shifts accelerate it
naive_svdSVD from the eigenvalues of AᵀAForming AᵀA squares the condition number
least_squaresNormal equations versus QRThe 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 tall A, two ways.
lu
The LU factorisation P A = L U (Doolittle form, unit lower triangular L).
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.