Learn R Programming

rags2ridges (version 2.2.2)

isSymmetricPD: Test for symmetric positive (semi-)definiteness

Description

Function to test if a matrix is symmetric positive (semi)definite or not.

Usage

isSymmetricPD(M)
isSymmetricPSD(M, tol = 1e-4)

Arguments

M

A square symmetric matrix.

tol

A numeric giving the tolerance for determining positive semi-definiteness.

Value

Returns a logical value. Returns TRUE if the M is symmetric positive (semi)definite and FALSE if not. If M is not even symmetric, the function throws an error.

Details

Tests positive definiteness by Cholesky decomposition. Tests positive semi-definiteness by checking if all eigenvalues are larger than \(-\epsilon|\lambda_1|\) where \(\epsilon\) is the tolerance and \(\lambda_1\) is the largest eigenvalue.

See Also

isSymmetric

Examples

Run this code
# NOT RUN {
A <- matrix(rnorm(25), 5, 5)
# }
# NOT RUN {
isSymmetricPD(A)
# }
# NOT RUN {
B <- symm(A)
isSymmetricPD(B)

C <- crossprod(B)
isSymmetricPD(C)

isSymmetricPSD(C)
# }

Run the code above in your browser using DataLab