qre#

Purpose#

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

Format#

{ r, e } = qre(x)#
Parameters:

x (NxP matrix) – data

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

  • e (Px1 vector) – permutation vector

Remarks#

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

Given X[.,E], where E is a permutation vector that permutes the columns of x, there is an orthogonal matrix Q such that QX[.,E] is zero below its diagonal, i.e.,

QX[.,E]=[R0]

where R is upper triangular. If we partition

Q=[Q1Q2]

where Q1 has P columns, then

X[.,E]=Q1R

is the QR decomposition of X[.,E].

qre() 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 qqre(). If you need the entire Q matrix, call qyre() with Y set to a conformable identity matrix. For most problems QY, Q1Y, or QY, Q1 Y, for some y, are required. For these cases see qtyre() and qyre().

If X has rank P, then the columns of X will not be permuted. If X has rank M<P, then the M linearly independent columns are permuted to the front of X by E. Partition the permuted X in the following way:

X[.,E]=[X1X2]

where X1 is NxM and X2 is Nx(P-M). Further partition R in the following way:

R=[R11R1200]

where R11 is MxM and R12 is Mx(P-M). Then

A=R111R12

and

X2=X1A

that is, A is an Mx(P-N) matrix defining the linear combinations of X2 with respect to X1

If N<P the factorization assumes the form:

QX=[R1R2]

where R1 is a PxP upper triangular matrix and R2 is Px(N-P). 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. For the solution of

X[.,E]b=Y

it can be shown that

b = qrsol(Q'Y, R1)|zeros(N-P,1);

The explicit formation here of Q, which can be a very large matrix, can be avoided by using the function qtyre().

For further discussion of QR factorizations see the remarks under qqr().

Source#

qr.src

See also

Functions qqr(), olsqr()