Learn R Programming

Matrix (version 1.0-9)

CHMfactor-class: CHOLMOD-based Cholesky Factorizations

Description

The virtual class "CHMfactor" is a class of CHOLMOD-based Cholesky factorizations of symmetric, sparse, compressed, column-oriented matrices. Such a factorization is simplicial (virtual class "CHMsimpl") or supernodal (virtual class "CHMsuper"). Objects that inherit from these classes are either numeric factorizations (classes "dCHMsimpl" and "dCHMsuper") or symbolic factorizations (classes "nCHMsimpl" and "nCHMsuper").

Usage

isLDL(x)

## S3 method for class 'CHMfactor': update(object, parent, mult = 0, \dots) .updateCHMfactor(object, parent, mult) ## S3 method for class 'CHMfactor,ddenseMatrix': solve(a, b, system = c("A", "LDLt", "LD", "DLt", "L", "Lt", "D", "P", "Pt"), ...)

## and more methods, see below

Arguments

x,object,a
a "CHMfactor" object (almost always the result of Cholesky()).
parent
a "dsCMatrix" or "dgCMatrix" matrix object with the same nonzero pattern as the matrix that generated object. If parent is symmetric, of
mult
a numeric scalar (default 0). mult times the identity matrix is (implicitly) added to parent or tcrossprod(parent) before updating the decomposition object.
b
(for solve():) numeric vector or (dense) matrix as RHS of the linear system $Ax = b$.
system
(for solve():) character string indicating the kind of linear system to be solved. Note that the default, "A", does not solve the triangular system (but "L" does).
...
potentially further arguments to the methods.

Objects from the Class

Objects can be created by calls of the form new("dCHMsuper", ...) but are more commonly created via Cholesky(), applied to dsCMatrix or lsCMatrix objects.

For an introduction, it may be helpful to look at the expand() method and examples below.

See Also

Cholesky, also for examples; class dgCMatrix.

Examples

Run this code
## An example for the expand() method
n <- 1000; m <- 200; nnz <- 2000
set.seed(1)
M1 <- spMatrix(n, m,
               i = sample(n, nnz, replace = TRUE),
               j = sample(m, nnz, replace = TRUE),
               x = round(rnorm(nnz),1))
XX <- crossprod(M1) ## = M1'M1  = M M'  where M <- t(M1)
CX <- Cholesky(XX)
isLDL(CX)
str(CX) ## a "dCHMsimpl" object
r <- expand(CX)
L.P <- with(r, crossprod(L,P))  ## == L'P
PLLP <- crossprod(L.P)          ## == (L'P)' L'P == P'LL'P
b <- sample(m)
stopifnot(all.equal(PLLP, XX),          all(as.vector(solve(CX, b, system="P" )) == r$P %*% b),
          all(as.vector(solve(CX, b, system="Pt")) == t(r$P) %*% b) )

u1 <- update(CX, XX,    mult=pi)
if(FALSE) ## fails ___ FIXME ? ___
u2 <- update(CX, t(M1), mult=pi)


   ## [ See  help(Cholesky)  for more examples ]
   ##        -------------

Run the code above in your browser using DataLab