- All Implemented Interfaces:
RealEigenDecomposition
This is intended as a temporary substitute for Apache Commons Math's implementation
(EigenDecomposition
, whose symmetry tolerance appears to be too low and thus
returns complex eigenvalues for close-to-symmetric matrices although solutions with real eigenvalues exist.
If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is diagonal and the eigenvector matrix V is orthogonal. I.e. A = V.times(D.times(V.transpose())) and V.times(V.transpose()) 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, i.e. A.times(V) equals V.times(D). The matrix V may be badly conditioned, or even singular, so the validity of the equation A = V*D*inverse(V) depends upon V.cond().
See Appendix Sec. B.5 of [1] for more details.
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).
- Version:
- 2022/06/19
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
static final double
static final int
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor using default tolerance setting.EigenDecompositionJama
(RealMatrix M, double symmetryTol, double zeroTol) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetD()
Gets the block diagonal matrix D of the decomposition.double
Calculates and returns the determinant of the decomposed matrix.getEigenvector
(int k) Returns a copy of the specified eigenvector, i.e., the associated column vector of the matrix returned bygetV()
.double
getImagEigenvalue
(int k) double[]
Return the imaginary parts of the eigenvaluesdouble
getRealEigenvalue
(int k) Returns the real part of the k-th eigenvaluedouble[]
Return the real parts of the eigenvaluesgetV()
Return the matrix of eigenvectors, which are its column vectors.getVT()
Return the transpose of the eigenvector matrix.boolean
Returns whether the calculated eigenvalues are complex or real.boolean
Returns true if the decomposed matrix is considered symmetric.
-
Field Details
-
DefaultSymmetryTolerance
- See Also:
-
DefaultZeroTolerance
- See Also:
-
SchurMaxIterations
- See Also:
-
-
Constructor Details
-
EigenDecompositionJama
public EigenDecompositionJama(RealMatrix M, double symmetryTol, double zeroTol) throws MaxIterationsExceededException Constructor. Checks for symmetry, then constructs the eigenvalue decomposition.- Parameters:
M
- matrix to be decomposedsymmetryTol
- absolute threshold for determining matrix symmetryzeroTol
- absolute threshold for determining zero matrix entries- Throws:
MaxIterationsExceededException
- if the maximum number of iterations is exceeded (seeSchurMaxIterations
)
-
EigenDecompositionJama
Constructor using default tolerance setting. See alsoDefaultSymmetryTolerance
,DefaultZeroTolerance
.- Parameters:
M
- matrix to be decomposed
-
-
Method Details
-
isSymmetric
Returns true if the decomposed matrix is considered symmetric. See alsoEigenDecompositionJama(RealMatrix, double, double)
,DefaultSymmetryTolerance
.- Returns:
- true if symmetric, false otherwise
-
getV
Return the matrix of eigenvectors, which are its column vectors.- Specified by:
getV
in interfaceRealEigenDecomposition
- Returns:
- the matrix of eigenvectors
-
getVT
Return the transpose of the eigenvector matrix. The eigenvectors are the rows of the returned matrix.- Returns:
- the transposed matrix of eigenvectors
-
getEigenvector
Returns a copy of the specified eigenvector, i.e., the associated column vector of the matrix returned bygetV()
.- Specified by:
getEigenvector
in interfaceRealEigenDecomposition
- Parameters:
k
- index of the eigenvector (counting from 0).- Returns:
- a copy of the k-th eigenvector
-
getRealEigenvalues
Return the real parts of the eigenvalues- Specified by:
getRealEigenvalues
in interfaceRealEigenDecomposition
- Returns:
- real(diag(D))
-
getImagEigenvalues
Return the imaginary parts of the eigenvalues- Returns:
- imag(diag(D))
-
getRealEigenvalue
Description copied from interface:RealEigenDecomposition
Returns the real part of the k-th eigenvalue- Specified by:
getRealEigenvalue
in interfaceRealEigenDecomposition
- Parameters:
k
- index of the eigenvalue @param k index of the eigenvector (0-based)- Returns:
- real part of the k-th eigenvalue
-
getImagEigenvalue
-
hasComplexEigenvalues
Returns whether the calculated eigenvalues are complex or real. The method performs a zero check on each element of thegetImagEigenvalues()
array and returnstrue
if any element is not equal to zero.- Specified by:
hasComplexEigenvalues
in interfaceRealEigenDecomposition
- Returns:
true
if any of the eigenvalues is complex,false
otherwise
-
getD
Gets the block diagonal matrix D of the decomposition. D is a block diagonal matrix. Real eigenvalues are on the diagonal while complex values are on 2x2 blocks {{real pos imaginary}, {neg imaginary, real}}. WB: Wonder if indexes are safe!- Specified by:
getD
in interfaceRealEigenDecomposition
- Returns:
- D
-
getDeterminant
Calculates and returns the determinant of the decomposed matrix.- Returns:
- the determinant of the matrix.
-