SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix.doubles.factorization.eigen
Class Eigen

java.lang.Object
  extended by com.numericalmethod.suanshu.matrix.doubles.factorization.eigen.Eigen
All Implemented Interfaces:
EigenDecomposition

public class Eigen
extends java.lang.Object
implements EigenDecomposition

This class implements the eigenvalue decomposition of a matrix.

Given a square matrix A, an eigenvalue λ and its associated eigenvector v are defined by

Av = λv

We first find the eigenvalue and then the eigenvector space by solving a system of homogeneous linear equations. That is,

(A - λ)v = 0

The eigen information is stored in the read-only structure Eigen.Property. The keys are the eigenvalue.

TODO: Complex eigenvectors is not yet supported. Note that, for now, we compute eigenvectors only for real eigenvalue. Although we compute the complex eigenvalue, we do not compute the eigenvectors associated with them.

The R equivalent function is eigen.

See Also:
Wikipedia: Eigenvalue algorithm

Nested Class Summary
static class Eigen.Method
          the methods available to compute eigenvalue and eigenvectors
static class Eigen.Property
          Property contains the eigen information about a particular eigen value, such as its multiplicity and the associated eigen vectors.
 
Field Summary
 double epsilon
          a precision parameter: when a number |x| ≤ ε, it is considered 0
 
Constructor Summary
Eigen(Matrix A)
          Compute the eigenvalue and eigenvectors for a matrix.
Eigen(Matrix A, Eigen.Method method, double epsilon)
          Compute the eigenvalue and eigenvectors for a matrix.
 
Method Summary
 DiagonalMatrix D()
          Get a copy of the diagonal matrix D as in Q %*% D %*% Q' = A Note that we only support real eigenvalues for now.
 java.lang.Number eigenvalue(int i)
          Get the i-th eigenvalue.
 NumberList eigenvalues()
          Get all the eigenvalues.
 Eigen.Property getProperty(int i)
          Get the i-th property.
 Eigen.Property property(java.lang.Number eigenvalue)
          Get a Property object by its eigenvalue.
 Matrix Q()
          Get a copy of Q as in Q %*% D %*% Q' = A Note that we only support real eigenvalues for now.
 Matrix Qt()
          Get a copy of Q.t() as in Q %*% D %*% Q' = A Note that we only support real eigenvalues for now.
 double[] realEigenvalues()
          Get the real eigenvalue.
 int size()
          Get the number of distinct eigenvalue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

epsilon

public final double epsilon
a precision parameter: when a number |x| ≤ ε, it is considered 0

Constructor Detail

Eigen

public Eigen(Matrix A,
             Eigen.Method method,
             double epsilon)
Compute the eigenvalue and eigenvectors for a matrix.

For each eigenvalue, we compute for its properties as in Eigen.Property. There is no single eigenvector. There are infinitely many. The set of eigenvectors forms a vector space. Any linear combination of the eigen basis vectors qualifies as an eigenvector.

Note that, for now, this implementation computes the Eigen.Property only for real eigenvalue. Although we compute the complex eigenvalue, we do not compute the eigenvectors associated with them.

Parameters:
A - a square matrix
method - the eigen decomposition algorithm, c.f., Eigen.Method
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
Throws:
java.lang.IllegalArgumentException - if A is not square

Eigen

public Eigen(Matrix A)
Compute the eigenvalue and eigenvectors for a matrix.

Parameters:
A - a square matrix
See Also:
Wikipedia: QR algorithm
Method Detail

D

public DiagonalMatrix D()
Description copied from interface: EigenDecomposition
Get a copy of the diagonal matrix D as in
 Q %*% D %*% Q' = A
 

Note that we only support real eigenvalues for now.

Specified by:
D in interface EigenDecomposition
Returns:
a copy of D

Q

public Matrix Q()
Description copied from interface: EigenDecomposition
Get a copy of Q as in
 Q %*% D %*% Q' = A
 

Note that we only support real eigenvalues for now.

Specified by:
Q in interface EigenDecomposition
Returns:
a copy of Q

Qt

public Matrix Qt()
Description copied from interface: EigenDecomposition
Get a copy of Q.t() as in
 Q %*% D %*% Q' = A
 

Note that we only support real eigenvalues for now.

Specified by:
Qt in interface EigenDecomposition
Returns:
a copy of Q.t()

size

public int size()
Get the number of distinct eigenvalue.

Returns:
the number of distinct eigenvalue

eigenvalue

public java.lang.Number eigenvalue(int i)
Get the i-th eigenvalue.

The eigenvalues are sorted in ascending order.

Parameters:
i - the index, counting from 0
Returns:
return the i-th eigenvalue

eigenvalues

public NumberList eigenvalues()
Get all the eigenvalues.

Returns:
the eigenvalues

realEigenvalues

public double[] realEigenvalues()
Get the real eigenvalue.

The eigenvalues are sorted in ascending order.

Returns:
a double[] array of real eigenvalue

property

public Eigen.Property property(java.lang.Number eigenvalue)
Get a Property object by its eigenvalue.

Note that the number passed in must be exactly the same as the eigenvalue in binary representation. Passing in an approximate number (up to precision) will likely result in an unmatched error, i.e., a null object returned.

Parameters:
eigenvalue - an eigenvalue
Returns:
the Property of the eigenvalue

getProperty

public Eigen.Property getProperty(int i)
Get the i-th property.

The properties are sorted in ascending order by their eigenvalues.

Parameters:
i - the index, counting from 0
Returns:
the i-th property

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.