Learn R Programming

fastQR (version 1.1.4)

qr_pivot2perm: Reconstruct the permutation matrix from the pivot vector.

Description

returns the permutation matrix for the QR decomposition.

Usage

qr_pivot2perm(pivot)

Value

the perumutation matrix \(P\) of dimension \(n \times n\).

Arguments

pivot

a vector of dimension \(n\) of pivot elements from the QR factorization.

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 full QR decomposition with pivot
qr_res <- fastQR::qr_fast(X = X,
                          tol = sqrt(.Machine$double.eps),
                          pivot = TRUE)

## get the pivot matrix
P <- qr_pivot2perm(qr_res$pivot)

Run the code above in your browser using DataLab