Learn R Programming

remotePARTS (version 1.0.4)

check_posdef: Check if a matrix is positive definite

Description

Check if a matrix is positive definite

Usage

check_posdef(M)

Value

returns a named logical vector with the following elements:

sqr

logical: indicating whether M is square

sym

logical: indicating whether M is symmetric

posdef

logical: indicating whether M is positive-definitive

Arguments

M

numeric matrix

Details

check if a matrix is 1) square, 2) symmetric, and 3) positive definite

Examples

Run this code

# 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))

Run the code above in your browser using DataLab