Learn R Programming

lmf (version 1.2)

inv: 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

Value

The inverse of the given 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.

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

Run this code
#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)

Run the code above in your browser using DataLab