Invert a symmetric, positive definite square matrix from its Choleski
decomposition. Equivalently, compute (X'X)^(-1)
from the (R part) of the QR decomposition of X.
Usage
chol2inv(x, size = NCOL(x), LINPACK = FALSE)
Arguments
x
a matrix. The first size columns of the upper triangle
contain the Choleski decomposition of the matrix to be inverted.
size
the number of columns of x containing the
Choleski decomposition.
LINPACK
logical. Defunct and ignored (with a warning for true value).
Value
The inverse of the matrix whose Choleski decomposition was given.
Unsuccessful results from the underlying LAPACK code will result in an
error giving a positive error code: these can only be interpreted by
detailed study of the FORTRAN code.
Source
This is an interface to the LAPACK routine DPOTRI.
LAPACK is from http://www.netlib.org/lapack and its guide is listed
in the references.
Dongarra, J. J., Bunch, J. R., Moler, C. B. and Stewart, G. W. (1978)
LINPACK Users Guide.
Philadelphia: SIAM Publications.
See Also
chol, solve.
Examples
cma <- chol(ma <- cbind(1, 1:3, c(1,3,7)))
ma %*% chol2inv(cma)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(base)
> png(filename="/home/ddbj/snapshot/RGM3/R_rel/result/base/chol2inv.Rd_%03d_medium.png", width=480, height=480)
> ### Name: chol2inv
> ### Title: Inverse from Choleski (or QR) Decomposition
> ### Aliases: chol2inv
> ### Keywords: algebra array
>
> ### ** Examples
>
> cma <- chol(ma <- cbind(1, 1:3, c(1,3,7)))
> ma %*% chol2inv(cma)
[,1] [,2] [,3]
[1,] 1 0 0
[2,] 0 1 0
[3,] 0 0 1
>
>
>
>
>
> dev.off()
null device
1
>