Class Eigen

java.lang.Object
  extended by Eigen

public class Eigen
extends java.lang.Object

this class takes in square matrix and computes the eigen values and its corresponding eigen vectors for the matrix


Field Summary
static double EPSILON
           
static double INFINITY
           
static int[] m_array
           
static int MAX_INITIAL_ITER
           
static int MAX_ITER
           
static int MAX_L_UPDATE
           
static int MAXRAND
           
static double MIN_DECREASE
           
static double MIN_INITIAL_GROWTH
           
static int MY_MAXINT
           
static int next_i
           
static int next_ip
           
static int RAND_ARRAY
           
static int RAND_BIG
           
static int RAND_CONST
           
static int rand_init
           
static int RAND_INIT
           
static double RAND_SCALE
           
static int RAND_SEED
           
static int temp_init
           
static double TINY
           
 
Constructor Summary
Eigen()
           
 
Method Summary
static void balanc(Matrix M)
          given a matrix this routine replaces it by a balanced matrix with identical eigenvalues.
static void calcEigVec(Matrix M, double eigVal, double[] eigVec)
          given a matrix 'M', an Eigenvalue 'eigVal', calculate the the Eigenvector 'eigVec'
static double[] compEigenVal(Matrix T)
          this method computes the eigen values of a symmetric matrix
static void copy_FV(double[] src, double[] dest, int dim)
          this routine copies one vectors contents to another
static void elmhes(Matrix M)
          this routine reduces a matrix to hessenberg's form by the elimination method.
static double Euclidian_Distance(double[] S1, double[] S2, int dim)
          this function computes the euclidean distance between two vwctors
static void hqr(Matrix M, double[] wr, double[] wi)
          this routine finds all eignvalues of an upper hessenberg matrix.
static void linearSolve(Matrix M, double eigVal, double[] y, double[] x)
          this routine uses the ludcmp and lubksb routines to find eigenvectors corresponding to a given eigen value using the inverse iteration method.
static void ludcmp(int n, int[] indx, double[][] a, java.lang.Double d)
          given a matrix a[1..n][1..n], this routine replaces it by the LU decomposition of a row wise permutation of itself.
static double myrandom()
          this routine uses knuth's subtractive algorithm to generate uniform random numbers in (0, 1) return random number between 0 and 1
static void norm_vector(double[] V, int dim)
          this routine takes in a vector and normalizes the vector
static void normEigVec(double eigVal, double[] eigVec)
          an Eigenvalue 'eigVal' and the corresponding Eigenvectors this method normalizes the eigen vectors i.e.
static void random_unit_vector(double[] x, int dim)
          this routine generates a random vector of length dim with unit size
static double[] sortEigen(double[] wr)
          this method sorts the eigen values in decreasing order of importance
static double vector_len(double[] V, int dim)
          this routine returns the length of the vector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXRAND

public static final int MAXRAND
See Also:
Constant Field Values

INFINITY

public static final double INFINITY
See Also:
Constant Field Values

MIN_INITIAL_GROWTH

public static final double MIN_INITIAL_GROWTH
See Also:
Constant Field Values

MAX_INITIAL_ITER

public static final int MAX_INITIAL_ITER
See Also:
Constant Field Values

EPSILON

public static final double EPSILON
See Also:
Constant Field Values

MAX_ITER

public static final int MAX_ITER
See Also:
Constant Field Values

MAX_L_UPDATE

public static final int MAX_L_UPDATE
See Also:
Constant Field Values

MIN_DECREASE

public static final double MIN_DECREASE
See Also:
Constant Field Values

TINY

public static final double TINY
See Also:
Constant Field Values

MY_MAXINT

public static final int MY_MAXINT
See Also:
Constant Field Values

RAND_INIT

public static final int RAND_INIT
See Also:
Constant Field Values

RAND_BIG

public static final int RAND_BIG
See Also:
Constant Field Values

RAND_SEED

public static final int RAND_SEED
See Also:
Constant Field Values

RAND_ARRAY

public static final int RAND_ARRAY
See Also:
Constant Field Values

RAND_CONST

public static final int RAND_CONST
See Also:
Constant Field Values

RAND_SCALE

public static final double RAND_SCALE
See Also:
Constant Field Values

rand_init

public static int rand_init

temp_init

public static int temp_init

m_array

public static int[] m_array

next_i

public static int next_i

next_ip

public static int next_ip
Constructor Detail

Eigen

public Eigen()
Method Detail

ludcmp

public static void ludcmp(int n,
                          int[] indx,
                          double[][] a,
                          java.lang.Double d)
given a matrix a[1..n][1..n], this routine replaces it by the LU decomposition of a row wise permutation of itself. this routine is combined with lubksb to solve linear equations to invert a matrix. see numerical recipes, the art of scientific computing, second edition, cambridge university press. pages 46 - 47.

Parameters:
n - dimensions of the input square matrix
indx - row permutations effected by partial pivoting
a - input matrix
d - +/- 1, if row interchanges was even or odd respectively

linearSolve

public static void linearSolve(Matrix M,
                               double eigVal,
                               double[] y,
                               double[] x)
this routine uses the ludcmp and lubksb routines to find eigenvectors corresponding to a given eigen value using the inverse iteration method. see numerical recipes, the art of scientific computing, second edition, cambridge university press. pages 493 - 495

Parameters:
M - input matrix
eigVal - eigen value
y - random vector
x - random vector

normEigVec

public static void normEigVec(double eigVal,
                              double[] eigVec)
an Eigenvalue 'eigVal' and the corresponding Eigenvectors this method normalizes the eigen vectors i.e. divides each Eigenvector with the square root of the corresponding Eigenvalue

Parameters:
eigVal - eigen value
eigVec - eigen vectors

calcEigVec

public static void calcEigVec(Matrix M,
                              double eigVal,
                              double[] eigVec)
given a matrix 'M', an Eigenvalue 'eigVal', calculate the the Eigenvector 'eigVec'

Parameters:
M - input matrix
eigVal - eigen value
eigVec - eigen vectors

random_unit_vector

public static void random_unit_vector(double[] x,
                                      int dim)
this routine generates a random vector of length dim with unit size

Parameters:
x - input vector
dim - vector dimension

myrandom

public static double myrandom()
this routine uses knuth's subtractive algorithm to generate uniform random numbers in (0, 1) return random number between 0 and 1


norm_vector

public static void norm_vector(double[] V,
                               int dim)
this routine takes in a vector and normalizes the vector

Parameters:
V - input vector
dim - vector dimension

vector_len

public static double vector_len(double[] V,
                                int dim)
this routine returns the length of the vector

Parameters:
V - input vector
dim - vector dimension

copy_FV

public static void copy_FV(double[] src,
                           double[] dest,
                           int dim)
this routine copies one vectors contents to another

Parameters:
src - source vector
dest - destination vector
dim - vector dimension

Euclidian_Distance

public static double Euclidian_Distance(double[] S1,
                                        double[] S2,
                                        int dim)
this function computes the euclidean distance between two vwctors

Parameters:
S1 - first vector
S2 - second vector
dim - vector dimension
Returns:
Euclidian Distance

hqr

public static void hqr(Matrix M,
                       double[] wr,
                       double[] wi)
this routine finds all eignvalues of an upper hessenberg matrix. see numerical recipes, the art of scientific computing, second edition, cambridge university press. pages 491 - 493.

Parameters:
M - input matrix
wr - real part of the eigen vectors
wi - immaginary part of the eigen vectors

elmhes

public static void elmhes(Matrix M)
this routine reduces a matrix to hessenberg's form by the elimination method. see numerical recipes, the art of scientific computing, second edition, cambridge university press. pages 484 - 486.

Parameters:
M - input matrix

balanc

public static void balanc(Matrix M)
given a matrix this routine replaces it by a balanced matrix with identical eigenvalues. see numerical recipes, the art of scientific computing, second edition, cambridge university press. pages 482 - 484.

Parameters:
M - input matrix

compEigenVal

public static double[] compEigenVal(Matrix T)
this method computes the eigen values of a symmetric matrix

Parameters:
T - input matrix
Returns:
eigen values of the input matrix

sortEigen

public static double[] sortEigen(double[] wr)
this method sorts the eigen values in decreasing order of importance

Parameters:
wr - real eigen values
Returns:
sorted eigen values in increasing order