isposdef | R Documentation |
Test for positive definiteness.
isposdef(A, psd = FALSE, tol = 1e-10)
A |
symmetric matrix |
psd |
logical, shall semi-positive definiteness be tested? |
tol |
tolerance to check symmetry and Cholesky decomposition. |
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.
Returns TRUE
or FALSE
.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.