eigvec02.gms : Test eigenvector/eigenvalue utilities

Description

```Eigenvalue/vector test.
Construct A to have known eigenvalues/vectors: A X = X lam

A = 2 1   X = 1  1   lam =  1
1 2      -1  1            3

Contributor: Steve Dirkse, October 2008
```

Small Model of Type : GAMS

Category : GAMS Test library

Main file : eigvec02.gms

``````\$title Test eigenvector/eigenvalue utilities (EIGVEC02,SEQ=413)

\$ontext
Eigenvalue/vector test.
Construct A to have known eigenvalues/vectors: A X = X lam

A = 2 1   X = 1  1   lam =  1
1 2      -1  1            3

Contributor: Steve Dirkse, October 2008
\$offtext

set I / i1 * i2 /;
alias (I,J,K);

parameters
A(I,J)     'constructed to have known eigenvectors/values'
X0(I,J)    'known eigenvectors'
X(I,J)
lam0(I)    'known eigenvalues' /
i1       1
i2       3
/,
lam(I)
s(J)       'scales for the eigenvector comparison'
;

table A(I,J)
i1        i2
i1    2         1
i2    1         2   ;

table X0(I,J)
i1        i2
i1     1         1
i2    -1         1 ;

scalar rc;

execute 'eigenvalue A.gdx I A tmp1.gdx lam > tmp1.log';
rc=errorlevel;
abort\$(rc > 0) 'Nonzero return code from eigenvalue', rc;
rc=errorlevel;
abort\$[smax{I, abs(lam(I)-lam0(I))} > 1e-8] 'Bad eigenvalues in tmp1.gdx';

execute 'eigenvector A.gdx I A tmp2.gdx lam X > tmp2.log';
rc=errorlevel;
abort\$(rc > 0) 'Nonzero return code from eigenvector', rc;