definiteness: Definiteness of a 2D real-valued matrix

Description Usage Arguments Details Value Author(s) Examples

View source: R/definiteness.R

Description

This routine checks the definiteness of a two dimensional, real-valued matrix.

Usage

1

Arguments

x

matrix of type double - A real-valued, 2D matrix.

Details

This routine takes the symmetric part of the given matrix and decomposes its spectrum to find an answer.

Value

character string - A character string indicating the definiteness of the given matrix.

Author(s)

Philipp van Wickevoort Crommelin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# positive definite
A = matrix(data = c(1,0,0,0,7,0,0,0,2),
           ncol = 3)
definiteness(A)

# negative definite
definiteness(-A)

# positive semi-definite
A = matrix(data = c(1,0,0,0,0,0,0,0,2),
           ncol = 3)
definiteness(A)

# negative semi-definite
definiteness(-A)

# Example, that demonstrates the importance of symmetry of the given matrix:
B = matrix(data = c(4,1,9,4),
           ncol = 2) #Eigenvalues all positive but not symmetric
definiteness(B)
eigen(B)$values
# Scalar product maps to negative value
v = c(-1,1)
t(v)%*%B%*%v

PhilippVWC/myBayes documentation built on Oct. 2, 2020, 8:25 a.m.