chol2inv
Invert a Matrix Given its Choleski Decomposition
Description
Computes the inverse of a symmetric, positive definite square matrix from its Choleski decomposition.
Usage
chol2inv(x, size = NCOL(x), LINPACK = FALSE)
Arguments
x |
an upper triangular matrix regarded as the Choleski decomposition of a
symmetric, positive definite matrix.
|
size |
the number of initial columns and columns of x to use as the Cholestki decomposition.
|
LINPACK |
this argument is ignored.
|
Details
This function uses the LAPACK library Fortran routine "dpotri" to
calculate the inverse of a matrix from its Cholesky decomposition.
It avoids the calculation of the intermediate crossprod(x)
that can result in singularity problems or loss of precision.
Value
returns the inverse matrix of a the positive definite matrix crossprod(x)[1:size, 1:size].
References
Dongarra, J. J., et al. 1978. LINPACK Users Guide. Pacific Grove, CA: Wadsworth & Brooks/Cole.
See Also
Examples
m <- matrix(1/(1:9)^2, 3, 3)
m[lower.tri(m)] <- 0
chol2inv(m)
solve(crossprod(m))