Description
Eigenvalue example. Contributor: Erwin Kalvelagen, October 2008.
Small Model of Type : GAMS
Category : GAMS Test library
Main file : eigval01.gms
$title Test eigenvalue utility (EIGVAL01,SEQ=409)
$onText
Eigenvalue example.
Contributor: Erwin Kalvelagen, October 2008.
octave:1> a=[9 1 1; 1 9 1; 1 1 9]
a =
9 1 1
1 9 1
1 1 9
octave:2> eig(a)
ans =
8
8
11
$offText
set i /i1*i3/;
alias (i,j);
table a(i,j)
i1 i2 i3
i1 9 1 1
i2 1 9 1
i3 1 1 9
;
parameter e(i) 'eigenvalues';
execute_unload 'a.gdx', i, a;
executeTool.checkErrorLevel 'linalg.eigenvalue i a e -gdxin=a.gdx -gdxout=b.gdx';
execute_load 'b.gdx', e;
abort$(abs(e('i1')-8)>1e-3 or abs(e('i2')-8)>1e-3 or abs(e('i3')-11)>1e-3) 'Wrong Eingenvalues', e;
option clear=e;
executeTool.checkErrorLevel 'linalg.eigenvalue i a e';
abort$(abs(e('i1')-8)>1e-3 or abs(e('i2')-8)>1e-3 or abs(e('i3')-11)>1e-3) 'Wrong Eingenvalues', e;