Skip to contents

Returns the matrix unchanged when it already admits a Cholesky factor, and otherwise floors its eigenvalues at a small positive multiple of the largest absolute eigenvalue before reassembling it.

Usage

spd_floor(R, eps = 1e-12)

Arguments

R

Symmetric matrix.

eps

Minimum eigenvalue.

Value

A symmetric positive-definite matrix of the same dimension as R.

See also

Examples

spd_floor(matrix(c(1, 2, 2, 1), 2, 2))
#>      [,1] [,2]
#> [1,]  1.5  1.5
#> [2,]  1.5  1.5