jsat.linear
Class EigenValueDecomposition
- java.lang.Object
-
- jsat.linear.EigenValueDecomposition
-
- All Implemented Interfaces:
- java.io.Serializable
public class EigenValueDecomposition extends java.lang.Object implements java.io.SerializableClass for performing the Eigen Value Decomposition of a matrix. The EVD of a real matrix may contain complex results. When this occurs, the EVD is less useful since JSAT only supports real matrices. TheSingularValueDecompositionof a real matrix is always real, and may be more useful.
Implementation adapted from the Public Domain work of JAMA: A Java Matrix Package
If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is diagonal and the eigenvector matrix V is orthogonal. V * V' equals the identity matrix.
If A is not symmetric, then the eigenvalue matrix D is block diagonal with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues, lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The columns of V represent the eigenvectors in the sense that A*V = V*D. The matrix V may be badly conditioned, or even singular, so the validity of the equation A = V*D*inverse(V) depends upon the condition of V.
If there are no complex eigen values, which can be checked usingisComplex(), then D is a normal diagonal matrix.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description EigenValueDecomposition(Matrix A)Creates a new new Eigen Value Decomposition.EigenValueDecomposition(Matrix A, double eps)Creates a new new Eigen Value Decomposition.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description MatrixgetD()Return the block diagonal eigenvalue matrixdouble[]getImagEigenvalues()Return the imaginary parts of the eigenvaluesdouble[]getRealEigenvalues()Return the real parts of the eigenvaluesMatrixgetV()Return a copy of the eigenvector matrixMatrixgetVRaw()Returns the raw eigenvector matrix.MatrixgetVT()Returns a copy of the transposed eigenvector matrix.booleanisComplex()Indicates wether or not the EVD contains complex eigen values.voidsortByEigenValue(java.util.Comparator<java.lang.Double> cmp)Sorts the eigen values and the corresponding eigenvector columns by the associated eigen value.
-
-
-
Constructor Detail
-
EigenValueDecomposition
public EigenValueDecomposition(Matrix A)
Creates a new new Eigen Value Decomposition. The input matrix will not be altered. If the input is symmetric, a more efficient algorithm will be used.- Parameters:
A- the square matrix to work on.
-
EigenValueDecomposition
public EigenValueDecomposition(Matrix A, double eps)
Creates a new new Eigen Value Decomposition. The input matrix will not be altered. If the input is symmetric, a more efficient algorithm will be used.- Parameters:
A- the square matrix to work on.eps- the numerical tolerance for differences in value to be considered the same.
-
-
Method Detail
-
sortByEigenValue
public void sortByEigenValue(java.util.Comparator<java.lang.Double> cmp)
Sorts the eigen values and the corresponding eigenvector columns by the associated eigen value. Sorting can not occur if complex values are present.- Parameters:
cmp- the comparator to use to sort the eigen values
-
getV
public Matrix getV()
Return a copy of the eigenvector matrix- Returns:
- the eigen vector matrix
-
getVRaw
public Matrix getVRaw()
Returns the raw eigenvector matrix. Modifying this matrix will effect others using the same matrix.- Returns:
- the eigen vector matrix
-
getVT
public Matrix getVT()
Returns a copy of the transposed eigenvector matrix.- Returns:
- the transposed eigen the eigen vector matrix
-
getRealEigenvalues
public double[] getRealEigenvalues()
Return the real parts of the eigenvalues- Returns:
- real(diag(D))
-
getImagEigenvalues
public double[] getImagEigenvalues()
Return the imaginary parts of the eigenvalues- Returns:
- imag(diag(D))
-
getD
public Matrix getD()
Return the block diagonal eigenvalue matrix- Returns:
- D
-
isComplex
public boolean isComplex()
Indicates wether or not the EVD contains complex eigen values. Because EVD works with real matrices, the complex eigen vectors are lost - and the complex eigen values are in the off diagonal spaces of the D matrix.- Returns:
- true if the EVD results in complex eigen values.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG