Skip to content

qr

QR decomposition.

[Q, R] = qr(A)
[Q, R, E] = qr(A) % with column pivoting
Y = qr(A) % packed form

Decomposes A into an orthogonal/unitary Q and upper-triangular R such that A = Q*R. With three outputs, applies column pivoting and returns the permutation E such that A*E = Q*R with R having descending diagonal magnitudes — useful for rank-revealing QR.

For non-square A: with two outputs, Q is full size (m×m); pass an additional 0 argument or use the economy form for the thinner m×n Q.

[Q, R] = qr(magic(4));
norm(Q*R - magic(4)) % near-zero
Q' * Q % I (within eps)
  • lu — LU decomposition (with partial pivoting).
  • chol — Cholesky factorization of a Hermitian positive-definite matrix.
  • svd — Singular value decomposition.
  • linsolve — Solve a linear system with optional structure hints.