| Cholesky {RandomFieldsUtils} | R Documentation |
This function calculates the Choleskey decomposition of a matrix.
cholx(a)
a |
a square real-valued positive definite matrix |
If the matrix is diagonal direct calculations are performed.
Else the Cholesky decomposition is tried.
a matrix containing the Choleskey decomposition (in its upper part)
Martin Schlather, schlather@math.uni-mannheim.de
chol.spam in the package spam
if (FALSE) {
## This examples shows that 'cholesky' can be much faster
## than 'chol'
## creating a covariance matrix for a temporal process
covmatrix <- function(model, x) {
x <- as.matrix(dist(x))
return(eval(substitute(model)))
}
size <- 600
x <- runif(size, 0, size / 10)
M <- covmatrix((1 - x) * (x < 1) , x) ## Askey's model of covariance
b <- seq(0, 1, len=size)
system.time(C2 <- chol(M))
system.time(C1 <- cholx(M))
range(C2 - C1)
stopifnot(all(abs(C2 - C1) < 10^{-9}))
}