Expand description
Named results of matrix decompositions (Qr, Lu, HermiteNormalForm, …) shared by Matrix, ZMatrix and QMatrix.
Named results of matrix decompositions and normal forms.
Every factorisation here used to come back as a tuple of two or three
matrices — (Q, R), (P, D), (H, U), (S, U, V) — where nothing but
memory said which position was which, and a transposition compiled
silently. These structs name each factor and document the identity it
satisfies, at zero runtime cost. See CONTRIBUTING.md, “Tuples versus
structs”.
The structs are generic over the matrix type so that the symbolic
Matrix and the exact
ZMatrix / QMatrix
share one vocabulary: Qr<Matrix>, HermiteNormalForm<ZMatrix>, ….
§Examples
use symplex::prelude::*;
let ctx = Context::new();
let a = matrix![ctx, [4, 2], [2, 3]];
let ldl = a.ldl().unwrap();
assert_eq!((&(&ldl.l * &ldl.d) * &ldl.l.transpose()).eval(), a);
let Qr { q, r } = matrix![ctx, [1, 1], [0, 1]].qr().unwrap();
assert_eq!((&q * &r).simplify(), matrix![ctx, [1, 1], [0, 1]]);Structs§
- Diagonalization
- Eigendecomposition
A = P·D·P⁻¹: the columns ofPare eigenvectors,Dis diagonal with the eigenvalues in the same order. - Hermite
Normal Form - Row-style Hermite normal form
H = U·AwithUunimodular (det U = ±1). - Hessenberg
- Upper Hessenberg form by similarity:
H = P⁻¹·A·P(equivalentlyA·P = P·H) withh_ij = 0fori > j + 1. - Jordan
Form - Jordan normal form
A = P·J·P⁻¹:Jis block diagonal with Jordan blocksJ_k(λ)(eigenvalue on the diagonal, ones on the superdiagonal),Pholds the (generalized) eigenvectors. - Ldl
- LDLᵀ decomposition
A = L·D·Lᵀof a symmetric matrix:Lunit lower triangular,Ddiagonal. - LllReduction
- LLL reduction of the lattice basis formed by the rows of
A:reduced = transform·Awithtransformunimodular (det = ±1), so both span the same lattice. - Lu
- LU decomposition with partial pivoting
P·A = L·U:Lunit lower triangular,Uupper triangular, andpermthe row permutation — rowiofP·Ais rowperm[i]ofA. - Qr
- QR decomposition
A = Q·R:Qhas orthonormal columns,Ris upper triangular. - Rank
Decomposition - Full-rank factorisation
A = C·Fwithr = rank A:C(m × r) is made of the pivot columns ofA,F(r × n) of the nonzero rows ofrref(A). - Smith
Normal Form - Smith normal form
S = U·A·VwithU,Vunimodular (det U = det V = ±1) andS = diag(d₁, …, dᵣ, 0, …),dᵢ | dᵢ₊₁.