CHOLESKY
CHOLESKY
calculates the Cholesky decomposition of a symmetric positive definite matrix. Matrix decomposition A=LL^T
.
- Attention
CHOLESKY
is deprecated (see GAMS 36 Cholesky, Eigenvalue, Eigenvector, Invert release notes). Please use $libInclude linalg Cholesky instead.
Usage
cholesky gdxin i a gdxout L
where
gdxin
name of gdxfile with matrix
i
name of set used in matrix
a
name of 2 dimensional parameter inside gdxin
gdxout
name of gdxfile for results (factor L)
L
name of 2 dimensional parameter inside gdxout
Calculates the Cholesky decomposition A=LL^t
of a symmetric positive definite matrix A=a(i,j)
where i
and j
are aliased sets. L
will contain the Cholesky factor L(i,j)
.
Example
$onText
Finds the Cholesky decomposition A=LL' of a positive definite symmetric matrix
A through an external program.
Erwin Kalvelagen, may 2008
$offText
Set i / i1*i5 /;
Alias (i,j);
Table a(i,j) 'original matrix'
i1 i2 i3 i4 i5
i1 64 48 24 8 8
i2 48 72 42 54 36
i3 24 42 89 107 95
i4 8 54 107 210 186
i5 8 36 95 186 187;
Parameter L(i,j) 'cholesky factor';
execute_unload 'a.gdx', i, a;
execute '=cholesky.exe a.gdx i a b.gdx L';
execute_load 'b.gdx', L;
display a, L;
*
* only lower triangular part of A is used
*
Table a2(i,j) 'original matrix'
i1 i2 i3 i4 i5
i1 64
i2 48 72
i3 24 42 89
i4 8 54 107 210
i5 8 36 95 186 187;
Parameter L2(i,j) 'cholesky factor';
execute_unload 'a.gdx', i, a2;
execute '=cholesky.exe a.gdx i a2 b.gdx L2';
execute_load 'b.gdx', L2;
display a2, L2;