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 -abs(tolerance * max(eigen(X)$values)). A small nonzero tolerance is recommended since eigenvalues are nearly always computed with some floating-point error.
Returns
A logical value. TRUE if the matrix is deemed positive semidefinite. Negative otherwise (including if X is not symmetric).
Examples
X <- matrix( c(2,5,5,5,2,5,5,5,2), nrow =3, byrow =TRUE)is_psd_matrix(X)eigen(X)$values
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.