R/pd_check.R

Defines functions pd_check

Documented in pd_check

pd_check <- function(A, pivot=TRUE, tol=1.e-07) {
# checks whether the input (symmetric) matrix is positive-definite
# Checks for errors or warnings
  result <- tryCatch({
    chol(A, pivot=pivot, tol=tol)   # Attempt Cholesky decomposition
    TRUE      # If successful, return TRUE
  }, warning = function(w) {
    FALSE      # Return FALSE if there's a warning
  }, error = function(e) {
    FALSE      # Return FALSE if there's an error
  })
  return(result)
}

Try the optimx package in your browser

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

optimx documentation built on April 11, 2025, 5:43 p.m.