Group: | Linear Algebra |
See also: | svd eigsm ludecomp chol |
Function: | chold | |
Description: | The function chold is calculating the triangularisation and the Cholesky decomposition of x into matrices b and d, so that b'*d*b = x. |
Usage: | bd = chold(x,l) | |
Input: | ||
x | n x n matrix, the input matrix | |
l | scalar, the number of lower non-zero subdiagonals including the diagonal, l<=dim(x) | |
Output: | ||
bd | n x n matrix, see note |
Set d = diag(xdiag(bd)) and b = bd-d+eye(rows(bd)), then
b'*d*b = x. (The quantlet xdiag() extracts the diagonal and
is in library("xplore"). The quantlet eye() create an identity matrix and
is in library("multi").)
Setting L = b'*sqrt(d) you get the resulting matrix of the
quantlet chol() ( from library("multi") ) transposed, i.e. L*L'=x
randomize(0) x = normal(3,3) x = x*x' x[1,3]=0 x[3,1]=0 x chold(x,2) ; since the third lower diagonal is zero
Contents of x [1,] 1.9005 2.6997 0 [2,] 2.6997 5.5519 -2.5479 [3,] 0 -2.5479 4.3615 Contents of chol [1,] 1.9005 1.4205 0 [2,] 0 1.717 -1.4839 [3,] 0 0 0.5808
randomize(0) x = normal(3,3) x = x*x' x bd = chold(x, 3) d = diag(xdiag(bd)) b = bd -d + eye(rows(bd)) b'*d*b ; triangularisation l = b'*sqrt(d) ; cholesky l*l'
Contents of x [1,] 1.9005 2.6997 -1.2229 [2,] 2.6997 5.5519 -2.5479 [3,] -1.2229 -2.5479 4.3615 Contents of _tmp [1,] 1.9005 2.6997 -1.2229 [2,] 2.6997 5.5519 -2.5479 [3,] -1.2229 -2.5479 4.3615 Contents of _tmp [1,] 1.9005 2.6997 -1.2229 [2,] 2.6997 5.5519 -2.5479 [3,] -1.2229 -2.5479 4.3615