Learn R Programming

fastQR (version 1.1.4)

qr_thin: Fast thin QR decomposition

Description

qr_thin provides the thin QR factorization of the matrix \(X\in\mathbb{R}^{n\times p}\) with \(n>p\). The thin QR factorization of the matrix \(X\) returns the matrices \(Q\in\mathbb{R}^{n\times p}\) and the upper triangular matrix \(R\in\mathbb{R}^{p\times p}\) such that \(X=QR\). See Golub and Van Loan (2013) for further details on the method.

Usage

qr_thin(X)

Value

A named list containing

Q

the Q matrix.

R

the R matrix.

Arguments

X

a \(n\times p\) matrix with \(n>p\).

References

golub_van_loan.2013fastQR

bjorck.2015fastQR

bjorck.2024fastQR

bernardi_etal.2024fastQR

Examples

Run this code
## generate sample data
set.seed(1234)
n <- 12
p <- 5
X <- matrix(rnorm(n * p), n, p)

## get the thin QR factorization
output <- qr_thin(X = X)
Q      <- output$Q
R      <- output$R

## check
max(abs(Q %*% R - X))

Run the code above in your browser using DataLab