GAMS [ Home | Downloads | Documentation | Solvers | APIs | Tools | Model Libraries | Resources | Sales | Support | Contact Us | Search ]

CHOLESKY

Table of Contents

CHOLESKY calculates the Choleksy decomposition of a symmetric positive definite matrix. Matrix decomposition A=LL^T.

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 Choleksy 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