Skip to content

qr

builtin · libnexusinterp/corefcn/qr-proprietary.cc

: R = qr (A)
: [Q, R] = qr (A)
: [Q, R, P] = qr (A)
: [C, R] = qr (A, B)
: X = qr (A, B)
: […] = qr (…, "econ")
: […] = qr (…, "vector")
: […] = qr (…, "matrix")
: […] = qr (…, 0)

Factor the matrix A into an orthogonal (or, for complex input, unitary) matrix Q times an upper triangular matrix R, so that Q*R reproduces A.

The number of outputs selects what is returned. With a single output only the triangular factor R is produced. With two outputs both Q and R are returned. With three outputs the factorization is computed with column pivoting for improved numerical behavior, and the extra output P records that reordering so that A*P equals Q*R.

[C, R] = qr (A, B) returns R and C = Q'*B; for a sparse A the matrix Q is never formed. For sparse A, X = qr (A, B) returns the least-squares solution of A*X = B.

The option "econ" (or a final argument of 0, which also selects the vector form of P) returns the economy-sized factorization, which trims the rows of R and columns of Q that are not needed when A has more rows than columns. "vector" and "matrix" select whether P is a permutation vector or a permutation matrix (the default is a matrix; 0 is equivalent to "econ" plus "vector"). A must be a real or complex single or double 2-D matrix, full or sparse. The qr (A, B) forms require sparse A.