qyr#
Purpose#
Computes the orthogonal-triangular (QR) decomposition of a matrix \(X\) and returns \(QY\) and \(R\).
Format#
- { qy, r } = qyr(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)\).
Remarks#
Given \(X\), there is an orthogonal matrix \(Q\) such that \(Q'X\) is zero below its diagonal, i.e.,
where \(R\) is upper triangular. If we partition
where \(Q_1\) has \(P\) columns, then
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 \(X'X\).
For most problems \(Q\) or \(Q_1\) is not what is required. Since \(Q\) can be a
very large matrix, qyr() 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 qtyr().
Examples#
// Create a 3x2 matrix
x = { 1 2,
3 4,
5 6 };
// Set Y to a conformable identity to recover the full Q matrix
y = eye(3);
// Compute Q*Y and R
{ qy, r } = qyr(y, x);
print "Q (full orthogonal matrix):";
print qy;
print "R (upper triangular):";
print r;
The above code produces the following output:
Q (full orthogonal matrix):
-0.16903085 0.89708523 0.40824829
-0.50709255 0.27602622 -0.81649658
-0.84515425 -0.34503278 0.40824829
R (upper triangular):
-5.9160798 -7.4373574
0.0000000 0.82807867
Source#
qyr.src