Class ComplexEigenDecomposition
- java.lang.Object
-
- org.hipparchus.linear.ComplexEigenDecomposition
-
- Direct Known Subclasses:
OrderedComplexEigenDecomposition
public class ComplexEigenDecomposition extends Object
Given a matrix A, it computes a complex eigen decomposition AV = VD.Complex Eigen Decomposition differs from the
EigenDecompositionSymmetric
since it computes the eigen vectors as complex eigen vectors (if applicable).Beware that in the complex case, you do not always have \(V \times V^{T} = I\) or even a diagonal matrix, even if the eigenvectors that form the columns of the V matrix are independent. On example is the square matrix \[ A = \left(\begin{matrix} 3 & -2\\ 4 & -1 \end{matrix}\right) \] which has two conjugate eigenvalues \(\lambda_1=1+2i\) and \(\lambda_2=1-2i\) with associated eigenvectors \(v_1^T = (1, 1-i)\) and \(v_2^T = (1, 1+i)\). \[ V\timesV^T = \left(\begin{matrix} 2 & 2\\ 2 & 0 \end{matrix}\right) \] which is not the identity matrix. Therefore, despite \(A \times V = V \times D\), \(A \ne V \times D \time V^T\), which would hold for real eigendecomposition.
Also note that for consistency with Wolfram langage eigenvectors, we add zero vectors when the geometric multiplicity of the eigenvalue is smaller than its algebraic multiplicity (hence the regular eigenvector matrix should be non-square). With these additional null vectors, the eigenvectors matrix becomes square. This happens for example with the square matrix \[ A = \left(\begin{matrix} 1 & 0 & 0\\ -2 & 1 & 0\\ 0 & 0 & 1 \end{matrix}\right) \] Its characteristic polynomial is \((1-\lambda)^3\), hence is has one eigen value \(\lambda=1\) with algebraic multiplicity 3. However, this eigenvalue leads to only two eigenvectors \(v_1=(0, 1, 0)\) and \(v_2=(0, 0, 1)\), hence its geometric multiplicity is only 2, not 3. So we add a third zero vector \(v_3=(0, 0, 0)\), in the same way Wolfram language does.
Compute complex eigen values from the Schur transform. Compute complex eigen vectors based on eigen values and the inverse iteration method. see: https://en.wikipedia.org/wiki/Inverse_iteration https://en.wikiversity.org/wiki/Shifted_inverse_iteration http://www.robots.ox.ac.uk/~sjrob/Teaching/EngComp/ecl4.pdf http://www.math.ohiou.edu/courses/math3600/lecture16.pdf
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_EIGENVECTORS_EQUALITY
Default threshold below which eigenvectors are considered equal.static double
DEFAULT_EPSILON
Default value to use for internal epsilon.static double
DEFAULT_EPSILON_AV_VD_CHECK
Internally used epsilon criteria for final AV=VD check.
-
Constructor Summary
Constructors Constructor Description ComplexEigenDecomposition(RealMatrix matrix)
Constructor for decomposition.ComplexEigenDecomposition(RealMatrix matrix, double eigenVectorsEquality, double epsilon, double epsilonAVVDCheck)
Constructor for decomposition.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkDefinition(RealMatrix matrix)
Check definition of the decomposition in runtime.protected void
findEigenValues(RealMatrix matrix)
Compute eigen values using the Schur transform.protected void
findEigenVectors(FieldMatrix<Complex> matrix)
Compute the eigen vectors using the inverse power method.FieldMatrix<Complex>
getD()
Getter D.double
getDeterminant()
Computes the determinant.Complex[]
getEigenvalues()
Getter of the eigen values.FieldVector<Complex>
getEigenvector(int i)
Getter of the eigen vectors.FieldMatrix<Complex>
getV()
Getter V.FieldMatrix<Complex>
getVT()
Getter VT.boolean
hasComplexEigenvalues()
Confirm if there are complex eigen values.protected void
matricesToEigenArrays()
Reset eigenvalues and eigen vectors from matrices.
-
-
-
Field Detail
-
DEFAULT_EIGENVECTORS_EQUALITY
public static final double DEFAULT_EIGENVECTORS_EQUALITY
Default threshold below which eigenvectors are considered equal.- See Also:
- Constant Field Values
-
DEFAULT_EPSILON
public static final double DEFAULT_EPSILON
Default value to use for internal epsilon.- See Also:
- Constant Field Values
-
DEFAULT_EPSILON_AV_VD_CHECK
public static final double DEFAULT_EPSILON_AV_VD_CHECK
Internally used epsilon criteria for final AV=VD check.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ComplexEigenDecomposition
public ComplexEigenDecomposition(RealMatrix matrix)
Constructor for decomposition.This constructor uses the default values
DEFAULT_EIGENVECTORS_EQUALITY
,DEFAULT_EPSILON
andDEFAULT_EPSILON_AV_VD_CHECK
- Parameters:
matrix
- real matrix.
-
ComplexEigenDecomposition
public ComplexEigenDecomposition(RealMatrix matrix, double eigenVectorsEquality, double epsilon, double epsilonAVVDCheck)
Constructor for decomposition.The
eigenVectorsEquality
threshold is used to ensure the L∞-normalized eigenvectors found using inverse iteration are different from each other. if \(min(|e_i-e_j|,|e_i+e_j|)\) is smaller than this threshold, the algorithm considers it has found again an already known vector, so it drops it and attempts a new inverse iteration with a different start vector. This value should be much larger thanepsilon
which is used for convergence- Parameters:
matrix
- real matrix.eigenVectorsEquality
- threshold below which eigenvectors are considered equalepsilon
- Epsilon used for internal tests (e.g. is singular, eigenvalue ratio, etc.)epsilonAVVDCheck
- Epsilon criteria for final AV=VD check- Since:
- 1.8
-
-
Method Detail
-
getEigenvalues
public Complex[] getEigenvalues()
Getter of the eigen values.- Returns:
- eigen values.
-
getEigenvector
public FieldVector<Complex> getEigenvector(int i)
Getter of the eigen vectors.- Parameters:
i
- which eigen vector.- Returns:
- eigen vector.
-
matricesToEigenArrays
protected void matricesToEigenArrays()
Reset eigenvalues and eigen vectors from matrices.This method is intended to be called by sub-classes (mainly
OrderedComplexEigenDecomposition
) that reorder the matrices elements. It rebuild the eigenvalues and eigen vectors arrays from the D and V matrices.- Since:
- 2.1
-
hasComplexEigenvalues
public boolean hasComplexEigenvalues()
Confirm if there are complex eigen values.- Returns:
- true if there are complex eigen values.
-
getDeterminant
public double getDeterminant()
Computes the determinant.- Returns:
- the determinant.
-
getV
public FieldMatrix<Complex> getV()
Getter V.- Returns:
- V.
-
getD
public FieldMatrix<Complex> getD()
Getter D.- Returns:
- D.
-
getVT
public FieldMatrix<Complex> getVT()
Getter VT.- Returns:
- VT.
-
findEigenValues
protected void findEigenValues(RealMatrix matrix)
Compute eigen values using the Schur transform.- Parameters:
matrix
- real matrix to compute eigen values.
-
findEigenVectors
protected void findEigenVectors(FieldMatrix<Complex> matrix)
Compute the eigen vectors using the inverse power method.- Parameters:
matrix
- real matrix to compute eigen vectors.
-
checkDefinition
protected void checkDefinition(RealMatrix matrix)
Check definition of the decomposition in runtime.- Parameters:
matrix
- matrix to be decomposed.
-
-