Learn R Programming

fastQR (version 1.1.4)

qr_Q_reduced2full: Reconstruct the full Q matrix from the reduced Q matrix.

Description

returns the full \(Q\in\mathbb{R}^{n\times n}\) matrix.

Usage

qr_Q_reduced2full(Q)

Value

a \(n\times n\) orthogonal matrix \(Q\).

Arguments

Q

a \(n\times p\) reduced Q matrix from the QR decomposition (with \(n>p\)).

References

golub_van_loan.2013fastQR

bjorck.2015fastQR

bjorck.2024fastQR

bernardi_etal.2024fastQR

Examples

Run this code
## create data: n > p
set.seed(1234)
n <- 12
p <- 7
X <- matrix(rnorm(n * p), n, p)

## get the full QR decomposition with pivot
qr_res <- fastQR::qr_fast(X = X,
                          tol = sqrt(.Machine$double.eps),
                          pivot = TRUE)

## reconstruct the reduced Q matrix
Q1 <- qr_Q(qr = qr_res$qr, tau = qr_res$qraux,
           rank = qr_res$rank, complete = FALSE)

## complete the reduced Q matrix
Q2 <- fastQR::qr_Q_reduced2full(Q = Q1)
R  <- fastQR::qr_R(qr = qr_res$qr, rank = NULL, complete = TRUE)

X1 <- qr_X(Q = Q2, R = R, pivot = qr_res$pivot)
max(abs(X - X1))

Run the code above in your browser using DataLab