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.
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)
d <- diag(diag(l))
diag(l) <- 1
all.equal(l %*% d %*% t(l), m, tol = 1e-15)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(KFAS)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/KFAS/ldl.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ldl
> ### Title: LDL Decomposition of a Matrix
> ### Aliases: ldl
>
> ### ** 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)
> d <- diag(diag(l))
> diag(l) <- 1
> all.equal(l %*% d %*% t(l), m, tol = 1e-15)
[1] TRUE
>
>
>
>
>
> dev.off()
null device
1
>