QR
Shippingmatrix_qrQR decomposition A = Q·R with orthonormal Q and upper-triangular R
Signature
Inputs
aSignal|Arrayrequired— A 2-D matrix (may be rectangular).
Outputs
qMatrix— The orthonormal factor $Q$ ($Q^\top Q = I$).rMatrix— The upper-triangular factor $R$.
Description
QR decomposes a matrix as , where has orthonormal columns () and is upper-triangular, using the MKL LAPACK backend (Householder reflections). It is the numerically stable backbone of least-squares fitting, orthogonalization, and iterative eigen-algorithms.
Both factors are dimensionless. QR is the preferred route for solving over-determined systems when you want an explicit orthonormal basis, and for Gram-Schmidt-style orthogonalization done stably.
Mathematics
Examples
Orthonormal basis for a column space
Feed a tall matrix of (linearly independent) columns into a. The q output's columns form an orthonormal basis for the column space, and r records the upper-triangular coefficients that reconstruct the original columns as .
Applications
- Stable least-squares solving and Gram-Schmidt orthogonalization.
- Building orthonormal bases for subspaces / column spaces.
- The core step of QR-iteration eigenvalue algorithms.
- Conditioning-friendly alternative to the normal equations.
Neat
Householder QR is backward-stable, so it orthogonalizes columns far more reliably than classical Gram-Schmidt.
Because $Q$ is orthonormal, $R$ carries all the scaling — a compact, upper-triangular summary of the original columns.
Known issues
Sign conventions of $Q$ columns / $R$ diagonal are not unique; a valid decomposition may differ in sign across platforms.
For rank-deficient inputs the trailing $R$ rows become near-zero — QR alone does not rank-reveal without column pivoting.