inv: Calculate the inverse of a matrix

invR Documentation

Calculate the inverse of a matrix

Description

Calculates the inverse of a symmetric positive definite matrix from its Cholesky composition.

Usage

inv(a)

Arguments

a

a symmetric positive definite matrix

Details

This is an interface to the LAPACK routine DPOTRI implemented in the function chol2inv. The function calculates cholesky decomposition of the given matrix and inputs this into chol2inv.

Value

The inverse of the given matrix.

Author(s)

Thomas Kvalnes

References

Anderson. E. et al. 1999. LAPACK Users' Guide. Third Edition. SIAM [Available online at: http://www.netlib.org/lapack/lug/lapack_lug.html].

See Also

chol, chol2inv

Examples

#Example matrix
mat <- matrix(c(1, 0.5, -3, 0.5, 3, 0.5, -3, 0.5, 12), ncol = 3)
#Show that it is positive definite
eigen(mat)$values
#Calculate inverse
inv(mat)

lmf documentation built on June 24, 2022, 5:06 p.m.