R: Positive Definiteness

isposdef {pracma} | R Documentation

## Positive Definiteness

### Description

Test for positive definiteness.

### Usage

    isposdef(A, psd = FALSE, tol = 1e-10)

### Arguments

`A` | symmetric matrix
`psd` | logical, shall semi-positive definiteness be tested?
`tol` | tolerance to check symmetry and Cholesky decomposition.

### Details

Whether matrix `A` is positive definite will be determined by applying the Cholesky decomposition. The matrix must be symmetric.

With `psd=TRUE` the matrix will be tested for being semi-positive definite. If not positive definite, still a warning will be generated.

### Value

Returns `TRUE` or `FALSE`.

### Examples

    A <- magic(5)
    # isposdef(A)
    ## [1] FALSE
    ## Warning message:
    ## In isposdef(A) : Matrix 'A' is not symmetric.
    ## FALSE

    A <- t(A) %*% A
    isposdef(A)
    ## [1] TRUE

    A[5, 5] <- 0
    isposdef(A)
    ## [1] FALSE

[Package pracma version 2.0.4 Index]