Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

isposdef

Positive Definiteness


Description

Test for positive definiteness.

Usage

isposdef(A, psd = FALSE, tol = 1e-10)

Arguments

A

symmetric matrix

psd

logical, shall semi-positive definiteness be tested?

tol

tolerance to check symmetry and Cholesky decomposition.

Details

Whether matrix A is positive definite will be determined by applying the Cholesky decomposition. The matrix must be symmetric.

With psd=TRUE the matrix will be tested for being semi-positive definite. If not positive definite, still a warning will be generated.

Value

Returns TRUE or FALSE.

Examples

A <- magic(5)
# isposdef(A)
## [1] FALSE
## Warning message:
## In isposdef(A) : Matrix 'A' is not symmetric.
## FALSE

A <- t(A) %*% A
isposdef(A)
## [1] TRUE

A[5, 5] <- 0
isposdef(A)
## [1] FALSE

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.