Learn R Programming

lrstat (version 0.2.13)

qrcpp: QR Decomposition of a Matrix

Description

Computes the QR decomposition of a matrix.

Usage

qrcpp(X, tol = 1e-12)

Value

A list with the following components:

  • qr: A matrix with the same dimensions as X. The upper triangle contains the R of the decomposition and the lower triangle contains Householder vectors (stored in compact form).

  • rank: The rank of X as computed by the decomposition.

  • pivot: The column permutation for the pivoting strategy used during the decomposition.

  • Q: The complete \(m\)-by-\(m\) orthogonal matrix \(Q\).

  • R: The complete \(m\)-by-\(n\) upper triangular matrix \(R\).

Arguments

X

A numeric matrix whose QR decomposition is to be computed.

tol

The tolerance for detecting linear dependencies in the columns of X.

Author

Kaifeng Lu, kaifenglu@gmail.com

Details

This function performs Householder QR with column pivoting: Given an \(m\)-by-\(n\) matrix \(A\) with \(m \geq n\), the following algorithm computes \(r = \textrm{rank}(A)\) and the factorization \(Q^T A P\) equal to

|\(R_{11}\)\(R_{12}\)|\(r\)
|00|\(m-r\)
\(r\)\(n-r\)

with \(Q = H_1 \cdots H_r\) and \(P = P_1 \cdots P_r\). The upper triangular part of \(A\) is overwritten by the upper triangular part of \(R\) and components \((j+1):m\) of the \(j\)th Householder vector are stored in \(A((j+1):m, j)\). The permutation \(P\) is encoded in an integer vector pivot.

References

Gene N. Golub and Charles F. Van Loan. Matrix Computations, second edition. Baltimore, Maryland: The John Hopkins University Press, 1989, p.235.

Examples

Run this code

hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, `+`) }
h9 <- hilbert(9)
qrcpp(h9)

Run the code above in your browser using DataLab