R/is_M.R

Defines functions is.IM is.M

Documented in is.M

#' Checks if a positive definite matrix is an M-matrix
#'
#' Checks if all entries of K are smaller than a small positive number tol 
#' @param K an inverse covariance matrix
#' @param tol numbers greater than tol are treated as positive
#' @keywords M-matrix
#' @export
#' @examples
#' print(TRUE)
#' 
is.M <- function(K,tol=1e-10){
  p <- nrow(K)
  return(prod(1*(K<= 1e-10)+diag(p)))
}

is.IM <- function(S,tol=1e-10){
  p <- nrow(S)
  K <- solve(S)
  return(prod(1*(K<= 1e-10)+diag(p)))
}
pzwiernik/mtp2 documentation built on Aug. 9, 2020, 12:34 p.m.