qr
QR matrix factorization.
📝Syntax
R = qr(A)
[Q, R] = qr(A)
[Q, R, P] = qr(A)
[...] = qr(A, 'econ')
[Q, R, P] = qr(A, outputForm)
[...] = qr(A, 0)
[C, R] = qr(S, B)
[C, R, P] = qr(S, B)
📥Input Arguments
Parameter Description
A a full or sparse single or double matrix, real or complex.
S a sparse coefficient matrix.
B a right-hand side matrix with the same numeric class as S.
outputForm 'matrix' or 'vector'.
📤Output Arguments
Parameter Description
Q orthogonal or unitary factor.
R upper triangular factor.
P column permutation matrix or vector.
C factor equal to Q' * B for sparse least-squares forms.
📄Description

qr computes a QR factorization. For full matrices, A = Q * R. With three outputs, a column permutation is returned and A * P = Q * R, or A(:, P) = Q * R when outputForm is 'vector'.

The 'econ' option returns economy-size factors for tall matrices. The legacy option 0 is equivalent to economy-size output with permutation vectors.

For sparse S and right-hand side B, qr(S, B) returns C = Q' * B and R for least-squares solves.

💡Examples
A = magic(5);
[Q, R] = qr(A);
norm(A - Q * R)
Economy-size QR factorization.
A = rand(10, 3);
[Q, R, p] = qr(A, 'econ', 'vector');
norm(A(:, p) - Q * R)
🔗See Also
lucholsvd
Used Functions
LAPACK dgeqrf, LAPACK sgeqrf, LAPACK zgeqrf, LAPACK cgeqrf, LAPACK dgeqp3, LAPACK sgeqp3, LAPACK zgeqp3, LAPACK cgeqp3, Eigen::SparseQR
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub