Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ldl

LDL Decomposition of a Matrix


Description

Function ldl computes the LDL decomposition of a positive semidefinite matrix.

Usage

ldl(x, tol)

Arguments

x

Symmetrix matrix.

tol

Tolerance parameter for LDL decomposition, determines which diagonal values are counted as zero. Same value is used in isSymmetric function. Default is max(100, max(abs(diag(as.matrix(x))))) * .Machine$double.eps.

Value

Transformed matrix with D in diagonal, L in strictly lower diagonal and zeros on upper diagonal.

Examples

# Positive semidefinite matrix, example matrix taken from ?chol
x <- matrix(c(1:5, (1:5)^2), 5, 2)
x <- cbind(x, x[, 1] + 3*x[, 2])
m <- crossprod(x)
l <- ldl(m, tol = 1e-8) # arm64 Mac setup in CRAN fails with default tolerance
d <- diag(diag(l))
diag(l) <- 1
all.equal(l %*% d %*% t(l), m, tol = 1e-15)

KFAS

Kalman Filter and Smoother for Exponential Family State Space Models

v1.4.5
GPL (>= 2)
Authors
Jouni Helske [aut, cre] (<https://orcid.org/0000-0001-7130-793X>)
Initial release
2021-05-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.