chol#
Purpose#
Computes the Cholesky decomposition of a symmetric, positive definite square matrix.
Format#
- u = chol(x)#
- Parameters:
x (NxN matrix) – Symmetric, positive definite square matrix.
- Returns:
u (NxN matrix) – containing the Cholesky decomposition of x.
Examples#
// 'moment' calculates x'*x with options for handling missing data
x = moment(rndn(100, 4), 0);
u = chol(x);
// u'u is equivalent to u'*u
upu = u'u;
95.2801 8.6983 3.7248 1.5449 9.7612 0.8911 0.3816 0.1583
x = 8.6983 83.4547 -6.1455 -12.5551 u = 0.0000 9.0918 -0.7133 -1.3964
3.7248 -6.1455 87.6666 -3.0284 0.0000 0.0000 9.3280 -0.4379
1.5449 -12.5551 -3.0284 90.8311 0.0000 0.0000 0.0000 9.4162
95.2801 8.6983 3.7248 1.5449
upu = 8.6983 83.4547 -6.1455 -12.5551
3.7248 -6.1455 87.6666 -3.0284
1.5449 -12.5551 -3.0284 90.8311
Remarks#
u is the “square root” matrix of x. That is, it is an upper triangular matrix such that \(x = u'u\).
chol()
does not check to see that the matrix is symmetric. chol()
will look
only at the upper half of the matrix including the principal diagonal.
If the matrix x is symmetric but not positive definite, either an error message or an error code will be generated, depending on the lowest order bit of the trap flag:
trap 0 |
Print error message and terminate program. |
trap 1 |
Print error message and terminate program. |