# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.algebra.linear.matrix.doubles.factorization.eigen

## Class Eigen

• java.lang.Object
• com.numericalmethod.suanshu.algebra.linear.matrix.doubles.factorization.eigen.Eigen
• All Implemented Interfaces:
Spectrum

public class Eigen
extends Object
implements Spectrum
Given a square matrix A, an eigenvalue λ and its associated eigenvector v are defined by Av = λv. We first find the eigenvalues and then the eigenvector space by solving a system of homogeneous linear equations. That is, (A - λ)v = 0.

TODO: For the moment, we compute both real and complex eigenvalues, but we do not compute the eigenvectors for complex eigenvalues.

The R equivalent function is eigen.

Wikipedia: Eigenvalue algorithm
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
static class  Eigen.Method
the available methods to compute eigenvalues and eigenvectors
• ### Constructor Summary

Constructors
Constructor and Description
Eigen(Matrix A)
Compute the eigenvalues and eigenvectors for a square matrix.
Eigen(Matrix A, double epsilon)
Use Eigen.Method.QR method by default.
Eigen(Matrix A, Eigen.Method method)
Compute the eigenvalues and eigenvectors for a square matrix.
Eigen(Matrix A, Eigen.Method method, double epsilon)
Compute the eigenvalues and eigenvectors for a square matrix.
• ### Method Summary

All Methods
Modifier and Type Method and Description
Number getEigenvalue(int i)
Get the i-th eigenvalue.
List<Number> getEigenvalues()
Get all the eigenvalues.
EigenProperty getProperty(int i)
EigenProperty getProperty(Number eigenvalue)
Get the EigenProperty by eigenvalue.
double[] getRealEigenvalues()
Get all real eigenvalues.
int size()
Get the number of distinct eigenvalues.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### Eigen

public Eigen(Matrix A)
Compute the eigenvalues and eigenvectors for a square matrix.
Parameters:
A - a square matrix
Wikipedia: QR algorithm
• #### Eigen

public Eigen(Matrix A,
Eigen.Method method)
Compute the eigenvalues and eigenvectors for a square matrix.
Parameters:
A - a square matrix
method - the eigen decomposition algorithm, c.f., Eigen.Method
• #### Eigen

public Eigen(Matrix A,
Eigen.Method method,
double epsilon)
Compute the eigenvalues and eigenvectors for a square matrix. For each eigenvalue, there are infinitely many associated eigenvectors, which forms a vector space. This implementation computes a set of linearly independent basis, any linear combination of them qualifies as an eigenvector.

TODO: For the moment, we compute both real and complex eigenvalues, but we do not compute the eigenvectors for complex eigenvalues.

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:
IllegalArgumentException - if A is not square
• ### Method Detail

• #### size

public int size()
Get the number of distinct eigenvalues.
Returns:
the number of distinct eigenvalues
• #### getEigenvalues

public List<Number> getEigenvalues()
Description copied from interface: Spectrum
Get all the eigenvalues.
Specified by:
getEigenvalues in interface Spectrum
Returns:
the eigenvalues
• #### getRealEigenvalues

public double[] getRealEigenvalues()
Get all real eigenvalues. The eigenvalues are sorted in descending order.
Returns:
all real eigenvalues
• #### getEigenvalue

public Number getEigenvalue(int i)
Get the i-th eigenvalue. The eigenvalues are sorted in descending order. The index counts from 0 to agree with the List<Number> convention.
Parameters:
i - an index, counting from 0
Returns:
return the i-th eigenvalue
• #### getProperty

public EigenProperty getProperty(Number eigenvalue)
Get the EigenProperty by 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., null returned.
Parameters:
eigenvalue - an eigenvalue
Returns:
the EigenProperty of the eigenvalue
• #### getProperty

public EigenProperty getProperty(int i)
Get the i-th EigenProperty. The eigenvalues are sorted in descending order. The index counts from 0 to agree with the List<Number> convention.
Parameters:
i - the index, counting from 0
Returns:
the i-th EigenProperty