Checks if a matrix is symmetric and positive definite
Source:R/checkSymmetricPDMatrix.R
checkSymmetricPDMatrix.Rd
Checks if a matrix is symmetric and positive definite using an eigen value decomposition.
Arguments
- mat
(Required) The matrix to check
- tol
(Optional) The tolorence to use when comparing the value to 0. The default is "1e-06"
Value
Returns an error if the matrix does not satisfy symmetric or positive definite. Otherwise does not return anything
Examples
checkSymmetricPDMatrix( diag(4))
A <- matrix( c( 2, -1, 0, -1, 2, -1, 0, -1, 2 ), nrow=3, byrow=TRUE )
checkSymmetricPDMatrix( A )
if (FALSE) {
# 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)
}