Class Eigen
- java.lang.Object
-
- dev.nm.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 iseigen
.- See Also:
- Wikipedia: Eigenvalue algorithm
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Eigen.Method
the available methods to compute eigenvalues and eigenvectors
-
Constructor Summary
Constructors Constructor Description Eigen(Matrix A)
Compute the eigenvalues and eigenvectors for a square matrix.Eigen(Matrix A, double epsilon)
UseEigen.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 Instance Methods Concrete Methods Modifier and Type Method Description Number
getEigenvalue(int i)
Get the i-th eigenvalue.List<Number>
getEigenvalues()
Get all the eigenvalues.EigenProperty
getProperty(int i)
Get the i-thEigenProperty
.EigenProperty
getProperty(Number eigenvalue)
Get theEigenProperty
by eigenvalue.double[]
getRealEigenvalues()
Get all real eigenvalues.int
size()
Get the number of distinct eigenvalues.
-
-
-
Constructor Detail
-
Eigen
public Eigen(Matrix A)
Compute the eigenvalues and eigenvectors for a square matrix.- Parameters:
A
- a square matrix- See Also:
- Wikipedia: QR algorithm
-
Eigen
public Eigen(Matrix A, Eigen.Method method)
Compute the eigenvalues and eigenvectors for a square matrix.- Parameters:
A
- a square matrixmethod
- the eigen decomposition algorithm, c.f.,Eigen.Method
-
Eigen
public Eigen(Matrix A, double epsilon)
UseEigen.Method.QR
method by default.- Parameters:
A
- a square matrixepsilon
- a precision parameter: when a number |x| ≤ ε, it is considered 0- See Also:
Eigen(dev.nm.algebra.linear.matrix.doubles.Matrix, double)
-
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 matrixmethod
- 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 interfaceSpectrum
- 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 theList<Number>
convention.- Parameters:
i
- an index, counting from 0- Returns:
- return the i-th eigenvalue
-
getProperty
public EigenProperty getProperty(Number eigenvalue)
Get theEigenProperty
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-thEigenProperty
. The eigenvalues are sorted in descending order. The index counts from 0 to agree with theList<Number>
convention.- Parameters:
i
- the index, counting from 0- Returns:
- the i-th
EigenProperty
-
-