Check if a matrix is positive definite This function checks whether a given matrix is positive definite, i.e., all of its eigenvalues are positive.
is_positive_definite.Rd
Check if a matrix is positive definite This function checks whether a given matrix is positive definite, i.e., all of its eigenvalues are positive.
Examples
# Create a positive definite matrix
mat1 <- matrix(c(4, 2, 2, 3), nrow = 2)
is_positive_definite(mat1)
#> [1] TRUE
# Expected output: TRUE
# Create a non-positive definite matrix
mat2 <- matrix(c(4, 2, 2, -3), nrow = 2)
is_positive_definite(mat2)
#> [1] FALSE
# Expected output: FALSE
# Check an empty matrix
mat3 <- matrix(nrow = 0, ncol = 0)
is_positive_definite(mat3)
#> [1] TRUE
# Expected output: TRUE