fhm.edu.fem.calc.objects.matrix
Class RayleighS

java.lang.Object
  extended by fhm.edu.fem.calc.objects.matrix.RayleighS

public class RayleighS
extends java.lang.Object

Class Description: This class offers methods to calculate Eigenvalues and Eigenvectors via the Rayleigh-S Algorithm. The algorithms used in this class are Copyright by Ewe Leonties taken from the C-Classes he wrote as diploma thesis. The conversion to Java and the percentage displays have been done by the authors mentioned below.

Author:
Thomas Woellert (thomas@woellert.net), Stefan Weissbach (weissbst@gmx.de)

Field Summary
protected  Vector eigenvalueVector
           
protected static Logger localLogger
           
protected  double[][] X
           
 
Constructor Summary
RayleighS()
          Constructor
 
Method Summary
protected  void abxvavb(int pof, int p, int n, double[] A, double[] B, int[] D, double[][] X, double[][] VA, double[][] VB)
          Builds the matrix product A*X=VA and B*X=VB
protected  void aschlange(int pof, int p, int n, double[] A, int[] D, double[][] X, double[][] S, double[][] AS)
          Calculates the projection matrix AS = XT*A*X
protected  void bog(int k, int n, double[] H, double[][] X, double[][] VB)
          b-orthogonalization of h in relation to the k-first vectors in matrix X
protected  void borthonormx(int p, int n, double[][] X, double[][] VA, double[][] VB)
          b-orthonomizes the matrix X and leads the matrices VA and VB to
protected  int cholesky(int n, double[] A, int[] D)
          Calculate the Cholesky (by Ewe Leonties) A is changed in the progress containing the result
 boolean compute(int n, double[] A, double[] B, int[] D, int p, double spv, double tol, int maxit)
          Preconditioned simultane Rayleigh-Quotient-Minimization via the konjugated gradients of the general EWA A*x=lambda*B*x
 Vector getEigenvalueVector()
          Grab the vector holding the calculated eigenvalues (you need to call compute()) first
 double[][] getEigenvectorArray()
          Grab the double array holding the calculated eigenvectors (you need to call compute()) first
protected  void initx(int p, int n, double[][] X)
          Init the Matrix X with random numbers 0 <= xij <= 1
protected  void jacobi(int n, double gen, double[][] A, double[][] V, int ord)
          Calculates the Eigenvalues and Eigenvectors of the symmetric Matrix A
protected  void ritzmat(int pof, int p, int n, double[][] X, double[][] U)
          Calculates the matrix product Y = X*U
protected  void sqny(int pof, int p, int n, double[][] VA, double[][] X, double[][] S, double[] NY, double[] Q)
          Reserves rayleigh's quotients and helpvector Initializes matrix in downward-direction
protected  void vrenv(int n, double[] L, int[] D, double[] B, double[] X)
          Solves L * LT * x = b via "Vorwaerts- und Rueckwaertseinsetzen"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eigenvalueVector

protected Vector eigenvalueVector

localLogger

protected static Logger localLogger

X

protected double[][] X
Constructor Detail

RayleighS

public RayleighS()
Constructor

Method Detail

abxvavb

protected void abxvavb(int pof,
                       int p,
                       int n,
                       double[] A,
                       double[] B,
                       int[] D,
                       double[][] X,
                       double[][] VA,
                       double[][] VB)
Builds the matrix product A*X=VA and B*X=VB

Parameters:
pof, - offset in matrix X
p, - columns in matrix X
n, - size of matrix A and B
A, - matrix A in HullMatrix style
B, - matrix B in HullMatrix style
D, - the diagonal pointer vector
X, - iteration matrix
VA, - RETURN VALUE
VB, - RETURN VALUE

aschlange

protected void aschlange(int pof,
                         int p,
                         int n,
                         double[] A,
                         int[] D,
                         double[][] X,
                         double[][] S,
                         double[][] AS)
Calculates the projection matrix AS = XT*A*X

Parameters:
pof, - offset in matrix X
p, - amount of columns in X
n, - size of matrix A
A, - matrix A in HullMatrix style
D, - diagonal pointer vector
X, - iterations vector matrix
S, - helper matrix
AS, - RETURN VALUE

bog

protected void bog(int k,
                   int n,
                   double[] H,
                   double[][] X,
                   double[][] VB)
b-orthogonalization of h in relation to the k-first vectors in matrix X

Parameters:
k, - column index
n, - dimension of vector H
H, - vector (is changed in the progress and used as RETURN VALUE)
X, - matrix of iterationvectors
VB, - Matrix of the product VB = B * X

borthonormx

protected void borthonormx(int p,
                           int n,
                           double[][] X,
                           double[][] VA,
                           double[][] VB)
b-orthonomizes the matrix X and leads the matrices VA and VB to

Parameters:
p, - dimension of matrices X, VA and VB
n, - dimension of matrices X, VA and VB
X, - RETURN VALUE
VA, - RETURN VALUE
VB, - RETURN VALUE

cholesky

protected int cholesky(int n,
                       double[] A,
                       int[] D)
Calculate the Cholesky (by Ewe Leonties) A is changed in the progress containing the result

Parameters:
n, - size of Matrix A
A, - Matrix A in HullMatrix style
D, - diagonal pointer vector
Returns:
int, 0 = ERROR, 1 = SUCCESS

compute

public boolean compute(int n,
                       double[] A,
                       double[] B,
                       int[] D,
                       int p,
                       double spv,
                       double tol,
                       int maxit)
Preconditioned simultane Rayleigh-Quotient-Minimization via the konjugated gradients of the general EWA A*x=lambda*B*x

Parameters:
n, - the size of the matrix A and B
A, - matrix B in HullMatrix style
B, - matrix B in HullMatrix style
D, - the diagonal pointer vector (same for both A and B)
spv, - the "Spektralverschiebung"
tol, - the calculation precision
maxit, - the maximum number of steps
Returns:
bool, true if all went well, false otherwise

getEigenvalueVector

public Vector getEigenvalueVector()
Grab the vector holding the calculated eigenvalues (you need to call compute()) first

Returns:
Vector, the vector holding all eigenvalues

getEigenvectorArray

public double[][] getEigenvectorArray()
Grab the double array holding the calculated eigenvectors (you need to call compute()) first

Returns:
double[][], the array holding all eigenvectors

initx

protected void initx(int p,
                     int n,
                     double[][] X)
Init the Matrix X with random numbers 0 <= xij <= 1

Parameters:
p, - the dimension of X
n, - the dimension of X
X, - RETURN VALUE, linear independent start vectors

jacobi

protected void jacobi(int n,
                      double gen,
                      double[][] A,
                      double[][] V,
                      int ord)
Calculates the Eigenvalues and Eigenvectors of the symmetric Matrix A

Parameters:
n, - size of Matrix A
gen, - machine precision
A, - double[][] array of Matrix A
V, - RETURN VALUE, matrix of eigenvectors
ord, - if >0 the eigenvalues and associated eigenvectors are sorted from upwards, else downwards

ritzmat

protected void ritzmat(int pof,
                       int p,
                       int n,
                       double[][] X,
                       double[][] U)
Calculates the matrix product Y = X*U

Parameters:
pof, - offset in matrix x
p, - size of matrix U
n, - amount of rows in X
X, - RETURN VALUE, Y instead of X
U, - the matrix U

sqny

protected void sqny(int pof,
                    int p,
                    int n,
                    double[][] VA,
                    double[][] X,
                    double[][] S,
                    double[] NY,
                    double[] Q)
Reserves rayleigh's quotients and helpvector Initializes matrix in downward-direction

Parameters:
pof, - offset in matrix X and S
p, - dimension of matrices VA, X and S
n, - dimension of matrices VA, X and S
VA -
X -
S, - RETURN VALUE
NY, - RETURN VALUE
Q, - RETURN VALUE, Quotientvector

vrenv

protected void vrenv(int n,
                     double[] L,
                     int[] D,
                     double[] B,
                     double[] X)
Solves L * LT * x = b via "Vorwaerts- und Rueckwaertseinsetzen"

Parameters:
n, - size of matrix L
L, - matrix L in HullMatrix style
D, - diagonal pointer vector
B, - constant vector
X, - RETUrN VALUE