Class EigenDecompositionSymmetric
The eigen decomposition of matrix A is a set of two matrices: \(V\) and \(D\) such that \(A V = V D\) where $\(A\), \(V\) and \(D\) are all \(m \times m\) matrices.
This class is similar in spirit to the EigenvalueDecomposition
class from the JAMA
library, with the following changes:
- a
getVt
method has been added, - a
getEigenvalue
method to pick up a single eigenvalue has been added, - a
getEigenvector
method to pick up a single eigenvector has been added, - a
getDeterminant
method has been added. - a
getSolver
method has been added.
As \(A\) is symmetric, then \(A = V D V^T\) where the eigenvalue matrix \(D\)
is diagonal and the eigenvector matrix \(V\) is orthogonal, i.e.
A = V.multiply(D.multiply(V.transpose()))
and
V.multiply(V.transpose())
equals the identity matrix.
The columns of \(V\) represent the eigenvectors in the sense that \(A V = V D\),
i.e. A.multiply(V)
equals V.multiply(D)
.
The matrix \(V\) may be badly conditioned, or even singular, so the validity of the
equation \(A = V D V^{-1}\) depends upon the condition of \(V\).
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
Default epsilon value to use for internal epsilon -
Constructor Summary
ConstructorDescriptionEigenDecompositionSymmetric
(double[] main, double[] secondary) Calculates the eigen decomposition of the symmetric tridiagonal matrix.EigenDecompositionSymmetric
(double[] main, double[] secondary, double epsilon, boolean decreasing) Calculates the eigen decomposition of the symmetric tridiagonal matrix.Calculates the eigen decomposition of the given symmetric real matrix.EigenDecompositionSymmetric
(RealMatrix matrix, double epsilon, boolean decreasing) Calculates the eigen decomposition of the given real matrix. -
Method Summary
Modifier and TypeMethodDescriptiongetD()
Gets the diagonal matrix D of the decomposition.double
Computes the determinant of the matrix.double
getEigenvalue
(int i) Returns the ith eigenvalue of the original matrix.double[]
Gets a copy of the eigenvalues of the original matrix.getEigenvector
(int i) Gets a copy of the ith eigenvector of the original matrix.double
Get's the value for epsilon which is used for internal tests (e.g.Gets a solver for finding the \(A \times X = B\) solution in exact linear sense.Computes the square-root of the matrix.getV()
Gets the matrix V of the decomposition.getVT()
Gets the transpose of the matrix V of the decomposition.
-
Field Details
-
DEFAULT_EPSILON
public static final double DEFAULT_EPSILONDefault epsilon value to use for internal epsilon- See Also:
-
-
Constructor Details
-
EigenDecompositionSymmetric
Calculates the eigen decomposition of the given symmetric real matrix.This constructor uses the
default epsilon
and decreasing order for eigenvalues.- Parameters:
matrix
- Matrix to decompose.- Throws:
MathIllegalStateException
- if the algorithm fails to converge.MathRuntimeException
- if the decomposition of a general matrix results in a matrix with zero norm
-
EigenDecompositionSymmetric
public EigenDecompositionSymmetric(RealMatrix matrix, double epsilon, boolean decreasing) throws MathRuntimeException Calculates the eigen decomposition of the given real matrix.Supports decomposition of a general matrix since 3.1.
- Parameters:
matrix
- Matrix to decompose.epsilon
- Epsilon used for internal tests (e.g. is singular, eigenvalue ratio, etc.)decreasing
- if true, eigenvalues will be sorted in decreasing order- Throws:
MathIllegalStateException
- if the algorithm fails to converge.MathRuntimeException
- if the decomposition of a general matrix results in a matrix with zero norm- Since:
- 3.0
-
EigenDecompositionSymmetric
public EigenDecompositionSymmetric(double[] main, double[] secondary) Calculates the eigen decomposition of the symmetric tridiagonal matrix.The Householder matrix is assumed to be the identity matrix.
This constructor uses the
default epsilon
and decreasing order for eigenvalues.- Parameters:
main
- Main diagonal of the symmetric tridiagonal form.secondary
- Secondary of the tridiagonal form.- Throws:
MathIllegalStateException
- if the algorithm fails to converge.
-
EigenDecompositionSymmetric
public EigenDecompositionSymmetric(double[] main, double[] secondary, double epsilon, boolean decreasing) Calculates the eigen decomposition of the symmetric tridiagonal matrix. The Householder matrix is assumed to be the identity matrix.- Parameters:
main
- Main diagonal of the symmetric tridiagonal form.secondary
- Secondary of the tridiagonal form.epsilon
- Epsilon used for internal tests (e.g. is singular, eigenvalue ratio, etc.)decreasing
- if true, eigenvalues will be sorted in decreasing order- Throws:
MathIllegalStateException
- if the algorithm fails to converge.- Since:
- 3.0
-
-
Method Details
-
getV
Gets the matrix V of the decomposition. V is an orthogonal matrix, i.e. its transpose is also its inverse. The columns of V are the eigenvectors of the original matrix. No assumption is made about the orientation of the system axes formed by the columns of V (e.g. in a 3-dimension space, V can form a left- or right-handed system).- Returns:
- the V matrix.
-
getD
Gets the diagonal matrix D of the decomposition. D is a diagonal matrix.- Returns:
- the D matrix.
- See Also:
-
getEpsilon
public double getEpsilon()Get's the value for epsilon which is used for internal tests (e.g. is singular, eigenvalue ratio, etc.)- Returns:
- the epsilon value.
-
getVT
Gets the transpose of the matrix V of the decomposition. V is an orthogonal matrix, i.e. its transpose is also its inverse. The columns of V are the eigenvectors of the original matrix. No assumption is made about the orientation of the system axes formed by the columns of V (e.g. in a 3-dimension space, V can form a left- or right-handed system).- Returns:
- the transpose of the V matrix.
-
getEigenvalues
public double[] getEigenvalues()Gets a copy of the eigenvalues of the original matrix.- Returns:
- a copy of the eigenvalues of the original matrix.
- See Also:
-
getEigenvalue
public double getEigenvalue(int i) Returns the ith eigenvalue of the original matrix.- Parameters:
i
- index of the eigenvalue (counting from 0)- Returns:
- real part of the ith eigenvalue of the original matrix.
- See Also:
-
getEigenvector
Gets a copy of the ith eigenvector of the original matrix.Note that if the the ith is complex this method will throw an exception.
- Parameters:
i
- Index of the eigenvector (counting from 0).- Returns:
- a copy of the ith eigenvector of the original matrix.
- See Also:
-
getDeterminant
public double getDeterminant()Computes the determinant of the matrix.- Returns:
- the determinant of the matrix.
-
getSquareRoot
Computes the square-root of the matrix. This implementation assumes that the matrix is positive definite.- Returns:
- the square-root of the matrix.
- Throws:
MathRuntimeException
- if the matrix is not symmetric or not positive definite.
-
getSolver
Gets a solver for finding the \(A \times X = B\) solution in exact linear sense.- Returns:
- a solver
-