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)
| 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'. |
| 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. |
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.
A = magic(5);
[Q, R] = qr(A);
norm(A - Q * R)
A = rand(10, 3);
[Q, R, p] = qr(A, 'econ', 'vector');
norm(A(:, p) - Q * R)
| Version | Description |
|---|---|
| 2.0.0 | initial version |