qr#

Purpose#

Computes the orthogonal-triangular (QR) decomposition of a matrix x, such that: X=Q1R

Format#

r = qr(x)#
Parameters:

x (NxP matrix) – data

Returns:

r (KxP matrix) – upper triangular matrix, K=min(N,P).

Remarks#

qr() is the same as qqr() but doesn’t return the Q1 matrix. If Q1 is not wanted, qr() will save a significant amount of time and memory usage, especially for large problems.

Given X, there is an orthogonal matrix Q such that QX is zero below its diagonal, i.e.,

QX=[R0]

where R is upper triangular. If we partition

Q=[Q1Q2]

where Q1 has P columns, then

X=Q1R

is the QR decomposition of X. If X has linearly independent columns, R is also the Cholesky factorization of the moment matrix of X, i.e., of XX.

qr() does not return the Q1 matrix because in most cases it is not required and can be very large. If you need the Q1 matrix, see the function qqr(). If you need the entire Q matrix, call qyr() with Y set to a conformable identity matrix.

For most problems QY, Q1Y, or QY, Q1Y, for some Y, are required. For these cases see qtyr() and qyr().

For linear equation or least squares problems, which require Q2 for computing residuals and residual sums of squares, see olsqr().

If N<P, the factorization assumes the form:

QX=[R1R2]

where R1 is a PxP upper triangular matrix and R2 is P×(NP). Thus Q is a PxP matrix and R is a PxN matrix containing R1 and R2. This type of factorization is useful for the solution of underdetermined systems. However, unless the linearly independent columns happen to be the initial rows, such an analysis also requires pivoting (see qre() and qrep()).

Source#

qr.src

See also

Functions qqr(), qrep(), qtyre()