Learn R Programming

Matrix (version 0.999375-6)

Cholesky: Cholesky Decomposition of a Sparse Matrix

Description

Computes the Cholesky decomposition of a sparse, symmetric, positive-definite matrix. However, typically chol() should rather be used unless you are interested in the different kinds of sparse Cholesky decompositions.

Usage

Cholesky(A, perm = TRUE, LDL = TRUE, super = FALSE, ...)

Arguments

A
sparse symmetric matrix. No missing values or IEEE special values are allowed.
perm
logical scalar indicating if a fill-reducing permutation should be computed and applied to the rows and columns of A. Default is TRUE.
LDL
logical scalar indicating if the decomposition should be computed as LDL' where L is a unit lower triangular matrix. The alternative is LL' where L is lower triangular with arbitrary diagonal elements. Default is
super
logical scalar indicating is a supernodal decomposition should be created. The alternative is a simplicial decomposition. Default is FALSE.
...
further arguments passed to or from other methods.

Value

  • an object inheriting from either "CHMsuper", or "CHMsimpl", depending on the super argument; both classes extend "CHMfactor" which extends "MatrixFactorization".

    In other words, the result of Cholesky() is not a matrix, and if you want one, you should probably rather use chol().

Details

This is a generic function with special methods for different types of matrices. Use showMethods("Cholesky") to list all the methods for the Cholesky generic.

The method for class dsCMatrix of sparse matrices --- the only one available currently --- is based on functions from the CHOLMOD library.

Again: If you just want the Cholesky decomposition of a matrix, you should probably rather use chol(.).

References

Tim Davis (2005) {CHOLMOD}: sparse supernodal {Cholesky} factorization and update/downdate http://www.cise.ufl.edu/research/sparse/cholmod/

Timothy A. Davis (2006) Direct Methods for Sparse Linear Systems, SIAM Series Fundamentals of Algorithms.

See Also

Class definitions CHMfactor and dsCMatrix and function expand. Note the extra solve(*, system = . ) options in CHMfactor.

Note that chol() returns matrices (inheriting from "Matrix") whereas Cholesky() returns a "CHMfactor" object, and hence a typical user will rather use chol(A).

Examples

Run this code
data(KNex)
mtm <- with(KNex, crossprod(mm))
str(mtm@factors) # empty list()
Cholesky(mtm)             # uses show(<MatrixFactorization>)
str(mtm@factors) # 'sPDCholesky' (simpl)
(Cm <- Cholesky(mtm, super = TRUE))
str(mtm@factors) # 'sPDCholesky'  *and*  'SPDCholesky'
str(cmat <- as(Cm, "sparseMatrix"))
cmat[1:20, 1:20]
b <- matrix(c(rep(0, 711), 1), nc = 1)
## solve(Cm, b) by default solves  Ax = b, where A = Cm'Cm !
x <- solve(Cm, b)
stopifnot(identical(x, solve(Cm, b, system = "A")),
          all.equal(x, solve(mtm, b)))

Run the code above in your browser using DataLab