Class GeneralizedEigenDecomposition

java.lang.Object
imagingbook.common.math.eigen.GeneralizedEigenDecomposition
All Implemented Interfaces:
RealEigenDecomposition

Solves the generalized eigenproblem of the form A x = λ B x, for square matrices A, B.

This implementation was ported from original EISPACK code [1] using a finite state machine concept [2] to untangle Fortran's GOTO statements (which are not available in Java), with some inspirations from this C# implementation. See mipav.cit.nih.gov (file gov.nih.mipav.model.structures.jama.GeneralizedEigenvalue.java) for another Java implementation based on EISPACK.

Note: Results have limited accuracy. For some reason the first eigenvalue/-vector (k=0) is reasonably accurate, but the remaining ones are not. If matrices A, B are symmetric and B is positive definite, better use GeneralizedSymmetricEigenDecomposition instead, which is more accurate.

[1] http://www.netlib.no/netlib/eispack/
[2] D. E. Knuth, "Structured Programming with Goto Statements", Computing Surveys, Vol. 6, No. 4 (1974).

Version:
2022/12/22
See Also:
  • Field Details

    • VERBOSE

      public static boolean VERBOSE
  • Constructor Details

    • GeneralizedEigenDecomposition

      Constructor, solves the generalized eigenproblem A x = λ B x, for square matrices A, B.
      Parameters:
      A - square matrix A
      B - square matrix B
    • GeneralizedEigenDecomposition

      public GeneralizedEigenDecomposition(double[][] A, double[][] B)
      Constructor, solves the generalized eigenproblem A x = λ B x, for square matrices A, B.
      Parameters:
      A - square matrix A
      B - square matrix B
  • Method Details

    • getRealEigenvalues

      public double[] getRealEigenvalues()
      Returns a vector with the real parts of the eigenvalues.
      Specified by:
      getRealEigenvalues in interface RealEigenDecomposition
      Returns:
      the real parts of the eigenvalues
    • getRealEigenvalue

      public double getRealEigenvalue(int k)
      Description copied from interface: RealEigenDecomposition
      Returns the real part of the k-th eigenvalue
      Specified by:
      getRealEigenvalue in interface RealEigenDecomposition
      Parameters:
      k - index of the eigenvalue @param k index of the eigenvector (0-based)
      Returns:
      real part of the k-th eigenvalue
    • getImagEigenvalues

      public double[] getImagEigenvalues()
      Returns a vector with the imaginary parts of the eigenvalues.
      Returns:
      the imaginary parts of the eigenvalues
    • getV

      public RealMatrix getV()
      Return the matrix of eigenvectors, which are its column vectors.
      Specified by:
      getV in interface RealEigenDecomposition
      Returns:
      the matrix of eigenvectors
    • getEigenvector

      public RealVector getEigenvector(int k)
      Returns the specified eigenvector.
      Specified by:
      getEigenvector in interface RealEigenDecomposition
      Parameters:
      k - index
      Returns:
      the kth eigenvector
    • hasComplexEigenvalues

      public boolean hasComplexEigenvalues()
      Returns whether the calculated eigenvalues are complex or real. The method performs a zero check on each element of the getImagEigenvalues() array and returns true if any element is not equal to zero.
      Specified by:
      hasComplexEigenvalues in interface RealEigenDecomposition
      Returns:
      true if any of the eigenvalues is complex, false otherwise
    • getD

      public RealMatrix getD()
      Returns the block diagonal eigenvalue matrix D.
      Specified by:
      getD in interface RealEigenDecomposition
      Returns:
      the block diagonal eigenvalue matrix
    • isSingular

      public boolean isSingular()
      This method checks if any of the generated betas is zero. It does not says that the problem is singular, but only that one of the matrices A, B is singular.
      Returns:
      true if A or B is singular
    • IsDegenerate

      public boolean IsDegenerate()
      Returns true if the eigenvalue problem is degenerate (i.e., ill-posed).
      Returns:
      true if degenerate