Skip to contents

Compute the Cholesky factorization of a real, symmetric, positive-definite square matrix. Returns the lower-left triangular matrix to match Stan's version. This function is simply an opinionated wrapper of the base R function, chol().

Usage

cholesky_decompose(x, ...)

Arguments

x

A symmetric, positive-definite square matrix.

...

Additional parameters to pass to chol().

Value

A lower-triangular square matrix the same size as x.

Examples

x <- matrix(c(2, 1, 1, 2), nrow = 2)
cholesky_decompose(x)
#>           [,1]     [,2]
#> [1,] 1.4142136 0.000000
#> [2,] 0.7071068 1.224745