- All Implemented Interfaces:
RealEigenDecomposition
Implements an efficient, closed form algorithm for calculating the real eigenvalues (λ) and eigenvectors (x) of a 2x2 matrix of the form
| a b | | c d |
There are typically (but not always) two pairs of real-valued solutions 〈λ0,
x0〉, 〈λ1, x1〉 such that A·xk =
λk·xk. The resulting eigensystems are ordered such that λ0 ≥
λ1. Eigenvectors are not normalized, i.e., no unit vectors (any scalar multiple of an Eigenvector
is an Eigenvector too). Non-real eigenvalues are not handled. Clients should call method
hasComplexEigenvalues() to check if the eigenvalue calculation was successful.
This implementation is inspired by Ch. 5 ("Consider the Lowly 2x2 Matrix") of [1]. Note that Blinn uses the notation x·A = λ·x for the matrix-vector product (as common in computer graphics), while this implementation uses A·x = λ·x. Thus x is treated as a column vector and matrix A is transposed (elements b/c are exchanged). See Appendix Sec. B.5 of [2] for more details.
This implementation is considerably faster (ca. factor 5) than the general solution (e.g.,
EigenDecompositionJama) for 2x2 matrices.
[1] Blinn, Jim: "Jim Blinn's Corner: Notation, Notation, Notation", Morgan Kaufmann (2002).
[2] W. Burger, M.J.
Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).
- Version:
- 2022/02/18
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEigensolver2x2(double[][] A) Constructor, takes a 2x2 matrix.Eigensolver2x2(double a, double b, double c, double d) Constructor, takes the individual elements of a 2x2 matrix A: -
Method Summary
Modifier and TypeMethodDescriptiongetEigenvector(int k) Returns the k-th eigenvector, i.e., the k-th column vector of the matrix returned byRealEigenDecomposition.getV().doublegetRealEigenvalue(int k) Returns the real part of the k-th eigenvaluedouble[]Returns a vector holding the real parts of the eigenvaluesgetV()Return the matrix of eigenvectors, which are its column vectors.booleanReturns whether the calculated eigenvalues are complex or real.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface imagingbook.common.math.eigen.RealEigenDecomposition
getD
-
Constructor Details
-
Eigensolver2x2
Constructor, takes a 2x2 matrix.- Parameters:
A- a 2x2 matrix
-
Eigensolver2x2
Constructor, takes the individual elements of a 2x2 matrix A:| a b | | c d |
- Parameters:
a- matrix element A[0,0]b- matrix element A[0,1]c- matrix element A[1,0]d- matrix element A[1,1]
-
-
Method Details
-
hasComplexEigenvalues
Description copied from interface:RealEigenDecompositionReturns whether the calculated eigenvalues are complex or real.- Specified by:
hasComplexEigenvaluesin interfaceRealEigenDecomposition- Returns:
trueif any of the eigenvalues is complex,falseotherwise
-
getRealEigenvalues
Description copied from interface:RealEigenDecompositionReturns a vector holding the real parts of the eigenvalues- Specified by:
getRealEigenvaluesin interfaceRealEigenDecomposition- Returns:
- real(diag(D))
-
getRealEigenvalue
Description copied from interface:RealEigenDecompositionReturns the real part of the k-th eigenvalue- Specified by:
getRealEigenvaluein interfaceRealEigenDecomposition- Parameters:
k- index of the eigenvalue @param k index of the eigenvector (0-based)- Returns:
- real part of the k-th eigenvalue
-
getV
Description copied from interface:RealEigenDecompositionReturn the matrix of eigenvectors, which are its column vectors.- Specified by:
getVin interfaceRealEigenDecomposition- Returns:
- the matrix of eigenvectors
-
getEigenvector
Description copied from interface:RealEigenDecompositionReturns the k-th eigenvector, i.e., the k-th column vector of the matrix returned byRealEigenDecomposition.getV().- Specified by:
getEigenvectorin interfaceRealEigenDecomposition- Parameters:
k- index of the eigenvector (0-based)- Returns:
- the k-th eigenvector (instance of
RealVector)
-
toString
-