R/isposdef.R

Defines functions isposdef

# check if a square symmetric matrix is positive definite 

# amat = symmetrix matrix
# Output: T if amat is positive definite, F otherwise
isposdef=function(amat)
{ tt=try(chol(amat), silent=T)
  ifelse(class(tt)=="matrix",T,F)
}

#a1=matrix(c(1,.5,.5,1),2,2)
#a2=matrix(c(1,1.5,1.5,1),2,2)
#t1=try(chol(a1))
#t2=try(chol(a2))
#print(isposdef(a1))
#print(isposdef(a2))

Try the FactorCopula package in your browser

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

FactorCopula documentation built on March 7, 2023, 5:29 p.m.