Learn R Programming

fastQR (version 1.1.4)

rchol: Cholesky decomposition via R factorization.

Description

rchol, provides the Cholesky decomposition of the symmetric and positive definite matrix \(X^\top X\in\mathbb{R}^{p\times p}\), where \(X\in\mathbb{R}^{n\times p}\) is the input matrix.

Value

an upper triangular matrix of dimension \(p\times p\) which represents the Cholesky decomposition of \(X^\top X\).

Arguments

X

an \((n\times p)\) matrix, with \(n\geq p\). If \(n< p\) an error message is returned.

References

golub_van_loan.2013fastQR

bjorck.2015fastQR

bjorck.2024fastQR

bernardi_etal.2024fastQR

Examples

Run this code

set.seed(1234)
n <- 10
p <- 6
X <- matrix(rnorm(n * p, 1), n, p)

## compute the Cholesky decomposition of X^TX
S <- fastQR::rchol(X = X)
S

## check
round(S - chol(crossprod(X)), 5)

Run the code above in your browser using DataLab