isSymmetricPD: Test for symmetric positive (semi-)definiteness

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/rags2ridgesFused.R

Description

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

Usage

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

Arguments

M

A square symmetric matrix.

tol

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

Details

Tests positive definiteness by Cholesky decomposition. Tests positive semi-definiteness by checking if all eigenvalues are larger than -ε|λ_1| where ε is the tolerance and λ_1 is the largest eigenvalue.

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.

Author(s)

Anders Ellern Bilgrau Carel F.W. Peeters <[email protected]>, Wessel N. van Wieringen

See Also

isSymmetric

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
A <- matrix(rnorm(25), 5, 5)
## Not run: 
isSymmetricPD(A)

## End(Not run)
B <- symm(A)
isSymmetricPD(B)

C <- crossprod(B)
isSymmetricPD(C)

isSymmetricPSD(C)

CFWP/rags2ridges documentation built on Sept. 23, 2017, 6:38 a.m.