is_psd_matrix {svrep} | R Documentation |
Check whether a matrix is positive semidefinite
Description
Check whether a matrix is positive semidefinite, based on checking for symmetric and negative eigenvalues.
Usage
is_psd_matrix(X, tolerance = sqrt(.Machine$double.eps))
Arguments
X |
A matrix with no missing or infinite values. |
tolerance |
Tolerance for controlling whether
a tiny computed eigenvalue will actually be considered negative.
Computed negative eigenvalues will be considered
negative if they are less than which are less than
|
Value
A logical value. TRUE
if the matrix is deemed positive semidefinite.
Negative otherwise (including if X
is not symmetric).
See Also
The function get_nearest_psd_matrix()
can be used to approximate a symmetric matrix which is not positive semidefinite,
by a similar positive semidefinite matrix.
Examples
X <- matrix(
c(2, 5, 5,
5, 2, 5,
5, 5, 2),
nrow = 3, byrow = TRUE
)
is_psd_matrix(X)
eigen(X)$values