chol {spam} | R Documentation |
chol
performs a Cholesky
decomposition of a symmetric positive definite sparse matrix x
of class spam
.
chol(x, ...)
x |
symmetric positive definite matrix of class spam . |
... |
further arguments passed to or from other methods. |
chol
performs a Cholesky decomposition of a symmetric
positive definite sparse matrix x
of class
spam
. Currently, there is only the block sparse Cholesky
algorithm of Ng and Peyton (1993) implemented (method=NgPeyton
),
based on a minimum degree permutation (ordering=MinDeg
).
The
Cholesky routine is essentially identitcal to what is available in the
package SparseM
.
The output of chol
can be used with
forwardsolve
backsolve
to solve a system of linear equations.
The Cholesky decompositions may require additional parameters, linked to
memory allocation.
These memory parameters and their default values for the NgPeyton
method are tmpmax=500*nrow(x)
, nsubmax=length(x)
,
nnzlmax=max(4*nsubmax, floor(.2*nsubmax^1.3))
. In practice, only
the first one needs to be set to a larger value if one calculates the
Cholesky factor from a virtually full matrix.
The function returns the Cholesky factor in an object of class
spam.chol.
method. Recall that the latter is the Cholesky
factor of a reordered matrix x
, see also ordering
.
Reinhard Furrer, based on Ng and Peyton (1993) Fortran routines
Ng, E. G. and B. W. Peyton (1993), "Block sparse Cholesky algorithms on advanced uniprocessor computers", SIAM J. Sci. Comput., 14, pp. 1034-1056.
Koenker, R and Ng, P. (2002). SparseM: A Sparse Matrix Package for R,
http://www.econ.uiuc.edu/~roger/research
det
, solve
,
forwardsolve
, backsolve
and ordering
.
# generate multivariate normals: n <- 25 # dimension N <- 1000 # sample size Sigma <- .25^abs(outer(1:n,1:n,"-")) Sigma <- as.spam( Sigma, eps=1e-4) cholS <- chol( Sigma) # cholS is the upper triangular part of the permutated matrix Sigma iord <- ordering(cholS, inv=TRUE) R <- as.spam(cholS)[,iord] mvsample <- array(rnorm(N*n),c(N,n)) %*% R # 'mvsample' is of class 'spam'. We need to transform it to a # regular matrix, as there is no method 'var' for 'spam' (should there?). norm( var( as.matrix( mvsample)) - Sigma, type="HS") norm( t(R) %*% R - Sigma, type="sup")