Class EigenDecompositionSymmetric

java.lang.Object
org.hipparchus.linear.EigenDecompositionSymmetric

public class EigenDecompositionSymmetric extends Object
Calculates the eigen decomposition of a symmetric real matrix.

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:

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\).

This implementation is based on the paper by A. Drubrulle, R.S. Martin and J.H. Wilkinson "The Implicit QL Algorithm" in Wilksinson and Reinsch (1971) Handbook for automatic computation, vol. 2, Linear algebra, Springer-Verlag, New-York.
See Also:
  • Field Details

    • DEFAULT_EPSILON

      public static final double DEFAULT_EPSILON
      Default epsilon value to use for internal epsilon
      See Also:
  • Constructor Details

    • EigenDecompositionSymmetric

      public EigenDecompositionSymmetric(RealMatrix matrix)
      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

      public RealMatrix 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

      public DiagonalMatrix 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

      public RealMatrix 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

      public RealVector getEigenvector(int i)
      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

      public RealMatrix 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

      public DecompositionSolver getSolver()
      Gets a solver for finding the \(A \times X = B\) solution in exact linear sense.
      Returns:
      a solver