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.