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 ;

\$libInclude linalg eigenvalue I A lam
abort\$execerror 'Trouble with calculating Eigenvalue';
abort\$[smax{I, abs(lam(I)-lam0(I))} > 1e-8] 'Bad eigenvalues in lam (1)';

\$libInclude linalg eigenvector I A lam X
abort\$execerror 'Trouble with calculating Eigenvector';
abort\$[smax{I, abs(lam(I)-lam0(I))} > 1e-8] 'Bad eigenvalues in lam (2)';
s(J) = X0('i1',J) / X('i1',J);
X(I,J) = X(I,J) * s(J);
abort\$[smax{(I,J), abs(X(I,J)-X0(I,J))} > 1e-8] 'Bad eigenvectors in X';
``````
GAMS Development Corp.
GAMS Software GmbH

General Information and Sales
U.S. (+1) 202 342-0180
Europe: (+49) 221 949-9170