#include <itkSymmetricEigenAnalysis.h>
Find Eigen values of a real 2D symmetric matrix. It serves as a thread-safe alternative to the class: vnl_symmetric_eigensystem, which uses netlib routines.
The class is templated over the input matrix (which is expected to provide access to its elements with the [][] operator), matrix to store eigen values (must provide write operations on its elements with the [] operator), and EigenMatrix to store eigen vectors (must provide write access to its elements with the [][] operator).
The SetOrderEigenValues() method can be used to order eigen values (and their corresponding eigen vectors if computed) in ascending order. This is the default ordering scheme. Eigen vectors and values can be obtained without ordering by calling SetOrderEigenValues(false).
The SetOrderEigenMagnitudes() method can be used to order eigen values (and their corresponding eigen vectors if computed) by magnitude in ascending order.
The user of this class is explicitly supposed to set the dimension of the 2D matrix using the SetDimension() method.
The class contains routines taken from netlib sources (www.netlib.org). netlib/tql1.c netlib/tql2.c netlib/tred1.c netlib/tred2.c
For algorithmic descriptions see [13] and [14].
Definition at line 207 of file itkSymmetricEigenAnalysis.h.
Public Types | |
| using | EigenMatrixType = TEigenMatrix |
| using | EigenValueOrderEnum = itk::EigenValueOrderEnum |
| using | MatrixType = TMatrix |
| using | VectorType = TVector |
Public Member Functions | |
| unsigned int | ComputeEigenValues (const TMatrix &A, TVector &D) const |
| unsigned int | ComputeEigenValuesAndVectors (const TMatrix &A, TVector &EigenValues, TEigenMatrix &EigenVectors) const |
| unsigned int | GetDimension () const |
| unsigned int | GetOrder () const |
| void | SetDimension (const unsigned int n) |
| void | SetOrder (const unsigned int n) |
| SymmetricEigenAnalysis ()=default | |
| SymmetricEigenAnalysis (const unsigned int dimension) | |
| ~SymmetricEigenAnalysis ()=default | |
| void | SetOrderEigenValues (const bool b) |
| bool | GetOrderEigenValues () const |
| void | SetOrderEigenMagnitudes (const bool b) |
| bool | GetOrderEigenMagnitudes () const |
| void | SetUseEigenLibrary (const bool input) |
| void | SetUseEigenLibraryOn () |
| void | SetUseEigenLibraryOff () |
| bool | GetUseEigenLibrary () const |
Private Member Functions | |
| unsigned int | ComputeEigenValuesAndVectorsLegacy (const TMatrix &A, TVector &EigenValues, TEigenMatrix &EigenVectors) const |
| unsigned int | ComputeEigenValuesAndVectorsUsingQL (double *d, double *e, double *z) const |
| unsigned int | ComputeEigenValuesAndVectorsWithEigenLibrary (const TMatrix &A, TVector &EigenValues, TEigenMatrix &EigenVectors) const |
| template<typename QMatrix> | |
| auto | ComputeEigenValuesAndVectorsWithEigenLibraryImpl (const QMatrix &A, TVector &EigenValues, TEigenMatrix &EigenVectors, bool) const -> decltype(GetPointerToMatrixData(A), 1U) |
| template<typename QMatrix> | |
| auto | ComputeEigenValuesAndVectorsWithEigenLibraryImpl (const QMatrix &A, TVector &EigenValues, TEigenMatrix &EigenVectors, long) const -> decltype(1U) |
| unsigned int | ComputeEigenValuesLegacy (const TMatrix &A, TVector &D) const |
| unsigned int | ComputeEigenValuesUsingQL (double *d, double *e) const |
| unsigned int | ComputeEigenValuesWithEigenLibrary (const TMatrix &A, TVector &EigenValues) const |
| template<typename QMatrix> | |
| auto | ComputeEigenValuesWithEigenLibraryImpl (const QMatrix &A, TVector &EigenValues, bool) const -> decltype(GetPointerToMatrixData(A), 1U) |
| template<typename QMatrix> | |
| auto | ComputeEigenValuesWithEigenLibraryImpl (const QMatrix &A, TVector &EigenValues, long) const -> decltype(1U) |
| template<typename QMatrix = TMatrix> | |
| auto | GetMatrixValueType (...) const -> typename QMatrix::ValueType |
| template<typename QMatrix = TMatrix> | |
| auto | GetMatrixValueType (bool) const -> typename QMatrix::element_type |
| void | ReduceToTridiagonalMatrix (double *a, double *d, double *e, double *e2) const |
| void | ReduceToTridiagonalMatrixAndGetTransformation (const double *a, double *d, double *e, double *z) const |
Private Attributes | |
| unsigned int | m_Dimension { 0 } |
| unsigned int | m_Order { 0 } |
| EigenValueOrderEnum | m_OrderEigenValues { EigenValueOrderEnum::OrderByValue } |
| bool | m_UseEigenLibrary { false } |
| using itk::SymmetricEigenAnalysis< TMatrix, TVector, TEigenMatrix >::EigenMatrixType = TEigenMatrix |
Definition at line 226 of file itkSymmetricEigenAnalysis.h.
| using itk::SymmetricEigenAnalysis< TMatrix, TVector, TEigenMatrix >::EigenValueOrderEnum = itk::EigenValueOrderEnum |
Definition at line 210 of file itkSymmetricEigenAnalysis.h.
| using itk::SymmetricEigenAnalysis< TMatrix, TVector, TEigenMatrix >::MatrixType = TMatrix |
Definition at line 225 of file itkSymmetricEigenAnalysis.h.
| using itk::SymmetricEigenAnalysis< TMatrix, TVector, TEigenMatrix >::VectorType = TVector |
Definition at line 227 of file itkSymmetricEigenAnalysis.h.
|
default |
|
inline |
Definition at line 218 of file itkSymmetricEigenAnalysis.h.
|
default |
| unsigned int itk::SymmetricEigenAnalysis< TMatrix, TVector, TEigenMatrix >::ComputeEigenValues | ( | const TMatrix & | A, |
| TVector & | D ) const |
Compute Eigen values of A A is any type that overloads the [][] operator and contains the symmetric matrix. In practice only the upper triangle of the matrix will be accessed. (Both itk::Matrix and vnl_matrix overload [][] operator.)
'EigenValues' is any type that overloads the [][] operator and will contain the eigen values.
No size checking is performed. A is expected to be a square matrix of size m_Dimension. 'EigenValues' is expected to be of length m_Dimension. The matrix is not checked to see if it is symmetric.
| unsigned int itk::SymmetricEigenAnalysis< TMatrix, TVector, TEigenMatrix >::ComputeEigenValuesAndVectors | ( | const TMatrix & | A, |
| TVector & | EigenValues, | ||
| TEigenMatrix & | EigenVectors ) const |
Compute Eigen values and vectors of A A is any type that overloads the [][] operator and contains the symmetric matrix. In practice only the upper triangle of the matrix will be accessed. (Both itk::Matrix and vnl_matrix overload [][] operator.)
'EigenValues' is any type that overloads the [] operator and will contain the eigen values.
'EigenVectors' is any type that provides access to its elements with the [][] operator. It is expected be of size m_Dimension * m_Dimension.
No size checking is performed. A is expected to be a square matrix of size m_Dimension. 'EigenValues' is expected to be of length m_Dimension. The matrix is not checked to see if it is symmetric.
Each row of the matrix 'EigenVectors' represents an eigen vector. (unlike MATLAB where the columns of the [EigenVectors, EigenValues] = eig(A) contains the eigenvectors).
|
private |
|
private |
Finds the eigenvalues and eigenvectors of a symmetric tridiagonal matrix by the ql method.
On input: 'd' contains the diagonal elements of the input matrix. 'e' contains the subdiagonal elements of the input matrix in its last n-1 positions. e(1) is arbitrary. 'z' contains the transformation matrix produced in the reduction by ReduceToTridiagonalMatrixAndGetTransformation(), if performed. If the eigenvectors of the tridiagonal matrix are desired, z must contain the identity matrix.
On Output: 'd' contains the eigenvalues. 'e' has been destroyed. 'z' contains orthonormal eigenvectors of the symmetric tridiagonal (or full) matrix.
Returns: zero for normal return, j if the j-th eigenvalue has not been determined after 1000 iterations.
Reference This subroutine is a translation of the algol procedure tql1, [13] and [14].
Questions and comments should be directed to Burton s. Garbow, Mathematics and Computer Science Div., Argonne National Laboratory. This version dated august 1983.
Function Adapted from netlib/tql2.c. [Changed: remove static vars, enforce const correctness. Use vnl routines as necessary]
|
inlineprivate |
Definition at line 532 of file itkSymmetricEigenAnalysis.h.
|
inlineprivate |
Definition at line 613 of file itkSymmetricEigenAnalysis.h.
|
inlineprivate |
Definition at line 547 of file itkSymmetricEigenAnalysis.h.
|
private |
|
private |
Finds the eigenvalues of a symmetric tridiagonal matrix by the ql method.
On input: 'd' contains the diagonal elements of the input matrix. 'e' contains the subdiagonal elements of the input matrix in its last n-1 positions. e(1) is arbitrary. On Output: 'd' contains the eigenvalues. 'e' has been destroyed.
Returns: zero for normal return, j if the j-th eigenvalue has not been determined after 30 iterations.
Reference This subroutine is a translation of the algol procedure tql1, [13] and [14].
Questions and comments should be directed to Burton s. Garbow, Mathematics and Computer Science Div., Argonne National Laboratory. This version dated august 1983.
Function Adapted from netlib/tql1.c. [Changed: remove static vars, enforce const correctness. Use vnl routines as necessary]
|
inlineprivate |
Definition at line 664 of file itkSymmetricEigenAnalysis.h.
|
inlineprivate |
Definition at line 716 of file itkSymmetricEigenAnalysis.h.
|
inlineprivate |
Definition at line 677 of file itkSymmetricEigenAnalysis.h.
|
inlinenodiscard |
Get Matrix dimension, Will be 0 unless explicitly set by a call to SetDimension.
Definition at line 348 of file itkSymmetricEigenAnalysis.h.
Referenced by itk::operator<<().
|
inlineprivate |
Definition at line 525 of file itkSymmetricEigenAnalysis.h.
|
inlinenodiscardprivate |
Definition at line 519 of file itkSymmetricEigenAnalysis.h.
|
inlinenodiscard |
Get the Matrix order. Will be 0 unless explicitly set, or unless a call to SetDimension has been made in which case it will be the matrix dimension.
Definition at line 280 of file itkSymmetricEigenAnalysis.h.
Referenced by itk::operator<<().
|
inlinenodiscard |
Set/Get methods to order the eigen value magnitudes in ascending order. In other words, |lambda_1| < |lambda_2| < .....
Definition at line 327 of file itkSymmetricEigenAnalysis.h.
Referenced by itk::operator<<().
|
inlinenodiscard |
Set/Get methods to order the eigen values in ascending order. This is the default. ie lambda_1 < lambda_2 < ....
Definition at line 303 of file itkSymmetricEigenAnalysis.h.
Referenced by itk::operator<<().
|
inlinenodiscard |
Set/Get to use Eigen library instead of vnl/netlib.
Definition at line 371 of file itkSymmetricEigenAnalysis.h.
Referenced by itk::operator<<().
|
private |
Reduces a real symmetric matrix to a symmetric tridiagonal matrix using orthogonal similarity transformations. 'inputMatrix' contains the real symmetric input matrix. Only the lower triangle of the matrix need be supplied. The upper triangle is unaltered. 'd' contains the diagonal elements of the tridiagonal matrix. 'e' contains the subdiagonal elements of the tridiagonal matrix in its last n-1 positions. e(1) is set to zero. 'e2' contains the squares of the corresponding elements of e. 'e2' may coincide with e if the squares are not needed. questions and comments should be directed to burton s. garbow. mathematics and computer science div, argonne national laboratory this version dated august 1983.
Function adapted from netlib/tred1.c. [Changed: remove static vars, enforce const correctness. Use vnl routines as necessary]. For algorithmic descriptions see [76] and [77].
|
private |
Reduces a real symmetric matrix to a symmetric tridiagonal matrix using and accumulating orthogonal similarity transformations. 'inputMatrix' contains the real symmetric input matrix. Only the lower triangle of the matrix need be supplied. The upper triangle is unaltered. 'diagonalElements' will contains the diagonal elements of the tridiagonal matrix. 'subDiagonalElements' will contain the subdiagonal elements of the tridiagonal matrix in its last n-1 positions. subDiagonalElements(1) is set to zero. 'transformMatrix' contains the orthogonal transformation matrix produced in the reduction.
Questions and comments should be directed to Burton s. Garbow, Mathematics and Computer Science Div., Argonne National Laboratory. This version dated august 1983.
Function adapted from netlib/tred2.c. [Changed: remove static vars, enforce const correctness. Use vnl routines as necessary]. For algorithmic descriptions see [76] and [77].
|
inline |
Set the dimension of the input matrix A. A is a square matrix of size m_Dimension.
Definition at line 336 of file itkSymmetricEigenAnalysis.h.
|
inline |
Matrix order. Defaults to matrix dimension if not set
Definition at line 271 of file itkSymmetricEigenAnalysis.h.
|
inline |
Set/Get methods to order the eigen value magnitudes in ascending order. In other words, |lambda_1| < |lambda_2| < .....
Definition at line 314 of file itkSymmetricEigenAnalysis.h.
|
inline |
Set/Get methods to order the eigen values in ascending order. This is the default. ie lambda_1 < lambda_2 < ....
Definition at line 290 of file itkSymmetricEigenAnalysis.h.
|
inline |
Set/Get to use Eigen library instead of vnl/netlib.
Definition at line 356 of file itkSymmetricEigenAnalysis.h.
|
inline |
Set/Get to use Eigen library instead of vnl/netlib.
Definition at line 366 of file itkSymmetricEigenAnalysis.h.
|
inline |
Set/Get to use Eigen library instead of vnl/netlib.
Definition at line 361 of file itkSymmetricEigenAnalysis.h.
|
private |
Definition at line 378 of file itkSymmetricEigenAnalysis.h.
|
private |
Definition at line 379 of file itkSymmetricEigenAnalysis.h.
|
private |
Definition at line 380 of file itkSymmetricEigenAnalysis.h.
|
private |
Definition at line 377 of file itkSymmetricEigenAnalysis.h.