qyre#

Purpose#

Computes the orthogonal-triangular (QR) decomposition of a matrix x and returns \(QY\) and \(R\).

Format#

{ qy, r, e } = qyre(y, x)#
Parameters:
  • y (NxL matrix) – data

  • x (NxP matrix) – data

Returns:
  • qy (NxL matrix) – unitary matrix

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

  • e (Px1 vector) – permutation vector

Remarks#

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

\[\begin{split}Q′R[ ., E ] = \begin{bmatrix} R \\ 0 \end{bmatrix}\end{split}\]

where \(R\) is upper triangular. If we partition

\[Q = [Q_1 Q_2]\]

where \(Q_1\) has \(P\) columns, then

\[X[ ., E ] = Q_1R\]

is the QR decomposition of \(X[., E]\).

For most problems \(Q\) or \(Q_1\) is not what is required. Since \(Q\) can be a very large matrix, qyre() has been provided for the calculation of \(QY\), where \(Y\) is some NxL matrix, which will be a much smaller matrix.

If either \(Q'Y\) or \(Q_1'Y\) are required, see qtyre().

If \(N < P\), the factorization assumes the form:

\[Q′R[ ., E ] = [R_1 R_2]\]

where \(R_1\) is a PxP upper triangular matrix and \(R_2\) is \(P \times (N-P)`\). Thus \(Q\) is a PxP matrix and \(R\) is a PxN matrix containing \(R_1\) and \(R_2\).

Examples#

// Create a 3x2 matrix
x = { 1 2,
      3 4,
      5 6 };

// Set Y to identity to recover the full Q matrix
y = eye(3);

// Compute Q*Y, R, and permutation vector E
{ qy, r, e } = qyre(y, x);

print "Q (full orthogonal matrix):";
print qy;
print "R (upper triangular):";
print r;
print "Permutation vector E:";
print e;

The above code produces the following output:

Q (full orthogonal matrix):

 -0.26726124       0.87287156       0.40824829
 -0.53452248       0.21821789      -0.81649658
 -0.80178373      -0.43643578       0.40824829

R (upper triangular):

  -7.4833148       -5.8797473
   0.0000000      -0.65465367

Permutation vector E:

   2.0000000
   1.0000000

Source#

qyr.src

See also

Functions qqr(), qre(), qyr()