View source: R/checkSymmetricPDMatrix.R
checkSymmetricPDMatrix | R Documentation |
Checks if a matrix is symmetric and positive definite using an eigen value decomposition.
checkSymmetricPDMatrix(mat, tol = 1e-06)
mat |
(Required) The matrix to check |
tol |
(Optional) The tolorence to use when comparing the value to 0. The default is "1e-06" |
Returns an error if the matrix does not satisfy symmetric or positive definite. Otherwise does not return anything
Romain Francois
checkSymmetricPDMatrix( diag(4))
A <- matrix( c( 2, -1, 0, -1, 2, -1, 0, -1, 2 ), nrow=3, byrow=TRUE )
checkSymmetricPDMatrix( A )
## Not run:
# Not symmetric
B <- matrix( c( 1, 2, 3, 4, 5, 6, 7, 8, 9), nrow=3, byrow=TRUE )
checkSymmetricPDMatrix(B)
# Not positive definite
C <- matrix( c( -2, 1, 0, 1, -2, 1, 0, 1, -2 ), nrow=3, byrow=TRUE )
checkSymmetricPDMatrix(C)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.