check_posdef | R Documentation |
Check if a matrix is positive definite
check_posdef(M)
M |
numeric matrix |
check if a matrix is 1) square, 2) symmetric, and 3) positive definite
returns a named logical vector with the following elements:
logical: indicating whether M
is square
logical: indicating whether M
is symmetric
logical: indicating whether M
is positive-definitive
# distance matrix
M = distm_scaled(expand.grid(x = 1:3, y = 1:3))
# check if it is positive definitive
check_posdef(M)
# check if the covariance matrix is positive definitive
check_posdef(covar_exp(M, .1))
# non-symmetric matrix
check_posdef(matrix(1:9, 3, 3))
# non-square matrix
check_posdef(matrix(1:6, 3, 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.