R/isPD.R

Defines functions isPD

Documented in isPD

#' Helper function to check if matrix is positive definite
#'
#' @param mat The matrix
#' @param tol The tolerance
#'
#' @return A boolean indicating positive definiteness
isPD = function(mat, tol = 1e-6){
    ev = eigen(mat, symmetric = TRUE)$values
    all(ev >= -tol * abs(ev[1L]))
}

Try the oosse package in your browser

Any scripts or data that you put into this service are public.

oosse documentation built on May 29, 2024, 10:35 a.m.