Download this file

EigenLibAux.def    207 lines (176 with data), 12.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
DEFINITION MODULE EigenLibAux;
(*------------------------------------------------------------------------*)
(* Stellt Hilfsroutinen fuer die Eigenwertberechung zur Verfuegung. *)
(* Auxillary routines for the calculation of eigen systems. *)
(*------------------------------------------------------------------------*)
(* Implementation : Michael Riedl *)
(* Licence : GNU Lesser General Public License (LGPL) *)
(*------------------------------------------------------------------------*)
(* $Id: EigenLibAux.def,v 1.1 2017/09/27 08:17:37 mriedl Exp mriedl $ *)
FROM Deklera IMPORT VEKTOR,MATRIX;
PROCEDURE CSortEwEv(VAR Wr,Wi : VEKTOR;
VAR Vr,Vi : MATRIX;
eps : LONGREAL;
dim : INTEGER;
ord : INTEGER);
(*----------------------------------------------------------------*)
(* Sortiert Eigenwerte und Eigenvektoren nach Groesse der Eigen- *)
(* werte. Die komplexen Eigenwerde werden dabei in Wr,Wi *)
(* uebergeben, die komplexen Eigenvektoren in Vr,Vi. *)
(* *)
(* Wenn ord > 0 in absteigender Reihenfolge *)
(* Wenn ord < 0 in ansteigender Reihenfolge *)
(*----------------------------------------------------------------*)
PROCEDURE NormOne( N : INTEGER;
VAR V : ARRAY OF ARRAY OF LONGREAL;
Wi : ARRAY OF LONGREAL;
VAR iErr : INTEGER);
(*----------------------------------------------------------------*)
(* Normalize eigenvectors to have norm 1 *)
(* *)
(* N : Dimension of matrix *)
(* <==> V : Matrix with eigenvektors *)
(* ==> Wi : Imaginary parts of eigenvalues *)
(* <== iErr : return code *)
(*----------------------------------------------------------------*)
PROCEDURE NormTwo( N : INTEGER;
VAR V : MATRIX;
VAR Wi : VEKTOR;
VAR iErr : INTEGER);
(*----------------------------------------------------------------*)
(* Normalize eigenvectors to have one norm 2 *)
(* *)
(* N : Dimension of matrix *)
(* <==> V : Matrix with eigenvektors *)
(* ==> Wi : Imaginary parts of eigenvalues *)
(* <== iErr : return code *)
(*----------------------------------------------------------------*)
PROCEDURE ComRes( N,ii : INTEGER;
VAR Wr,Wi : VEKTOR;
VAR Vr,Vi : MATRIX;
VAR Ar,Ai : MATRIX;
VAR norm : LONGREAL);
(*---------------------------------------------------------------*)
(* Calculates the residual for eigenvector/value ii *)
(* *)
(* N : Dimension of the problem *)
(* ii : Index of Eigenvalue/vektor pair to be checked *)
(* (Wr,Wi) : Complex eigenvalues of the system *)
(* (Wr,Wi) : Complex eigenvalues of the system *)
(* (Vr,Vi) : Complex eigenvector of the system *)
(* (Ar,Ai) : Complex matrix under investigation *)
(*---------------------------------------------------------------*)
PROCEDURE CheckRGM( N : INTEGER;
VAR V : MATRIX;
VAR A : MATRIX;
VAR Wr,Wi : VEKTOR;
VAR Norm : LONGREAL;
VAR NormM : LONGREAL);
(*----------------------------------------------------------------*)
(* Calulates the norm of the residial of the eigensysem of A, *)
(* A beeing a real general matrix. *)
(* *)
(* N : Dimension of matrix *)
(* <==> V : Matrix with eigenvektors as provided by HQR2 *)
(* ==> A : Original Matrix for which the eigensystem had *)
(* been calculated *)
(* ==> Wr : Real parts of eigenvalues *)
(* ==> Wi : Imaginary parts of eigenvalues *)
(* <== Norm : Caluclated weighted norm of the matrix *)
(* Z = (A x V) - (W x V) *)
(* <== NormM : maximal norm of one columen in the matrix Z *)
(*----------------------------------------------------------------*)
PROCEDURE KonvCmplxC1( N : CARDINAL;
VAR Zreal : ARRAY OF ARRAY OF LONGREAL;
VAR Zcmplx : ARRAY OF ARRAY OF LONGCOMPLEX;
VAR Wi : ARRAY OF LONGREAL);
(*----------------------------------------------------------------*)
(* Wandelt die Ausgabe der Eigenvektoren von HQR2 in eine *)
(* Darstellung als komplexe Matrix (Zcmplx) um. *)
(*----------------------------------------------------------------*)
PROCEDURE KonvCmplxC2( N : CARDINAL;
VAR Zreal : ARRAY OF ARRAY OF LONGREAL;
VAR Zr,Zi : ARRAY OF ARRAY OF LONGREAL;
VAR Wi : ARRAY OF LONGREAL);
(*----------------------------------------------------------------*)
(* Wandelt die Ausgabe der Eigenvektoren von HQR2 in eine *)
(* Darstellung in zwei Matrizen (Zr,Zi) um. *)
(* Wandelt die Ausgabe der Eigenvektoren von HQR2 in eine *)
(* Darstellung in zwei Matrizen (Zr,Zi) um. *)
(* *)
(* Convertes the eigenvectors Z as calculated by HQR2 in a form *)
(* of two separated matrices (Zr,Zi). *)
(* *)
(* ==> N : the dimension of the matrices. *)
(* ==> Z : eigenvectors as provided by HQR2 *)
(* <== Zr : real part of the eigenvektors *)
(* <== Zi : imaginary part of the eigenvektors *)
(* ==> Wi : vector of the imaginaty parts of the eigenvalues *)
(*----------------------------------------------------------------*)
PROCEDURE InfMatNorm( N : CARDINAL;
VAR A : ARRAY OF ARRAY OF LONGREAL;
VAR imax : CARDINAL;
VAR Norm : LONGREAL);
(*----------------------------------------------------------------*)
(* Berechnet die Zeilensummennorm der Matrix A *)
(* Calculates the infinity norm of the Matrix A *)
(*----------------------------------------------------------------*)
PROCEDURE CNormMat(VAR A : ARRAY OF ARRAY OF LONGCOMPLEX;
dim : CARDINAL;
MaxNorm : BOOLEAN);
(*----------------------------------------------------------------*)
(* Normiert die in A "ubergebene komplex Matrix. *)
(* Wenn MaxNorm = TRUE, wird die Maximumnorm berechnet, *)
(* ansonsten die euklidische Norm. *)
(*----------------------------------------------------------------*)
PROCEDURE SplitHess( N : CARDINAL;
VAR A : ARRAY OF ARRAY OF LONGREAL;
VAR H : ARRAY OF ARRAY OF LONGREAL;
oben : BOOLEAN);
(*----------------------------------------------------------------*)
(* Trennt die Hessenbergmatrix H aus dem Ergebniss A^tr der *)
(* Transformations mit ElmHess oder einer vergleichbaren Routine *)
(* ab. Wenn oben = wahr wird die obere, ansonsten die untere *)
(* Hessenbergmatrix abgetrennt. *)
(*----------------------------------------------------------------*)
PROCEDURE CmplxComRes( N,ii : INTEGER;
VAR W : ARRAY OF LONGCOMPLEX;
VAR V : ARRAY OF ARRAY OF LONGCOMPLEX;
VAR A : ARRAY OF ARRAY OF LONGCOMPLEX;
VAR norm : LONGREAL);
(*---------------------------------------------------------------*)
(* Calculates the residual for eigenvector/value ii of a *)
(* complex general matrix A *)
(* *)
(* N : Dimension of the problem *)
(* ii : Index of Eigenvalue/vektor pair to be checked *)
(* W : Complex eigenvalues of the system *)
(* V : Complex eigenvector of the system *)
(* A : Complex matrix under investigation *)
(*---------------------------------------------------------------*)
PROCEDURE IstHermitisch(VAR H : ARRAY OF ARRAY OF LONGCOMPLEX;
dim : CARDINAL;
VAR I,J : CARDINAL) : BOOLEAN;
(*---------------------------------------------------------------*)
(* Prueft ob eine komplexe Matrix hermitisch ist *)
(* Wenn dem nicht so ist werden in I,J die Indizes der ersten *)
(* Elements zurueckgegeben das die Regeln einer hermitischen *)
(* verletzt (in 1..dim Zaehlung) *)
(*---------------------------------------------------------------*)
PROCEDURE CheckOrtho(VAR A : ARRAY OF ARRAY OF LONGREAL;
N : CARDINAL;
VAR S : ARRAY OF LONGREAL;
VAR Smax : LONGREAL;
VAR Ssqr : LONGREAL);
(*----------------------------------------------------------------*)
(* Berechnet das Skalarprodukt aller in A enthaltenen Vektoren *)
(* und gibt die N*(N+1)/2 Ergebnisse in S zurueck. *)
(* *)
(* Smax : Maximale Abweichung der Nichtdiagonalelemente *)
(* Ssqr : Summe der Quadrate der Abweichungen der Nicht- *)
(* diagonalelemente dividiert durch N*(N-1)/2 *)
(* *)
(* Sind alle Vektoren orthogonal und euklidisch normiert ist das *)
(* Ergebniss annaehernd eine Einheitsmatrix *)
(*----------------------------------------------------------------*)
END EigenLibAux.