Learn R Programming

Matrix (version 0.999375-6)

chol: Choleski Decomposition - 'Matrix' S4 Generic

Description

Compute the Choleski factorization of a real symmetric positive-definite square matrix.

Usage

chol(x, pivot = FALSE, ...)

Arguments

x
a (sparse or dense) square matrix, here inheriting from class Matrix; if x is not positive definite, an error is signalled.
pivot
logical indicating if pivoting is used.
...
potentially further arguments passed to methods.

Value

  • ~Describe the value returned If it is a LIST, use
  • comp1Description of 'comp1'
  • comp2Description of 'comp2'
  • ...

See Also

The default from base, chol.

Examples

Run this code
showMethods(chol, inherited = FALSE) # show different methods

sy2 <- new("dsyMatrix", Dim = as.integer(c(2,2)), x = c(14, NA,32,77))
(c2 <- chol(sy2))#-> "Cholesky" matrix
stopifnot(all.equal(c2, chol(as(sy2, "dpoMatrix")), tol= 1e-13))
str(c2)

## An example where chol() can't work
(sy3 <- new("dsyMatrix", Dim = as.integer(c(2,2)), x = c(14, -1, 2, -7)))
try(chol(sy3)) # error, since it is not positive definite

Run the code above in your browser using DataLab