checkSymmetricPDMatrix: Checks if a matrix is symmetric and positive definite

View source: R/checkSymmetricPDMatrix.R

checkSymmetricPDMatrixR Documentation

Checks if a matrix is symmetric and positive definite

Description

Checks if a matrix is symmetric and positive definite using an eigen value decomposition.

Usage

checkSymmetricPDMatrix(mat, tol = 1e-06)

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

Author(s)

Romain Francois

Examples

  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)


MikeKSmith/MSToolkit documentation built on Feb. 15, 2024, 5:32 p.m.