Class JacobiDiagonalization

java.lang.Object
org.cicirello.math.la.JacobiDiagonalization

public final class JacobiDiagonalization extends Object
This class uses Jacobi iteration to compute the eigenvalues and eigenvectors of a symmetric matrix, provided as a 2-D Java array.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Default precision level for convergence check.
    static final int
    Default max number of iterations.
  • Constructor Summary

    Constructors
    Constructor
    Description
    JacobiDiagonalization(double[][] matrix)
    Initializes a Jacobi iteration for finding eigenvalues and eigenvectors of a matrix.
    JacobiDiagonalization(int[][] matrix)
    Initializes a Jacobi iteration for finding eigenvalues and eigenvectors of a matrix.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Computes the eigenvalues and eigenvectors using Jacobi Iteration.
    boolean
    compute(double epsilon)
    Computes the eigenvalues and eigenvectors using Jacobi Iteration.
    boolean
    compute(double epsilon, int maxIters)
    Computes the eigenvalues and eigenvectors using Jacobi Iteration.
    boolean
    compute(int maxIters)
    Computes the eigenvalues and eigenvectors using Jacobi Iteration.
    double[]
    Gets the computed eigenvalues.
    double[][]
    Gets the computed eigenvectors.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EPSILON

      public static final double EPSILON
      Default precision level for convergence check.
      See Also:
    • MAX_ITERATIONS

      public static final int MAX_ITERATIONS
      Default max number of iterations.
      See Also:
  • Constructor Details

    • JacobiDiagonalization

      public JacobiDiagonalization(int[][] matrix)
      Initializes a Jacobi iteration for finding eigenvalues and eigenvectors of a matrix.
      Parameters:
      matrix - a square matrix
    • JacobiDiagonalization

      public JacobiDiagonalization(double[][] matrix)
      Initializes a Jacobi iteration for finding eigenvalues and eigenvectors of a matrix.
      Parameters:
      matrix - a square matrix
  • Method Details

    • eigenvectors

      public double[][] eigenvectors()
      Gets the computed eigenvectors.
      Returns:
      The eigenvectors are the columns of the returned matrix. Returns null if not yet computed.
    • eigenvalues

      public double[] eigenvalues()
      Gets the computed eigenvalues.
      Returns:
      The eigenvalues. Returns null if not yet computed.
    • compute

      public boolean compute()
      Computes the eigenvalues and eigenvectors using Jacobi Iteration. Uses the default precision level JacobiDiagonalization.EPSILON where off-diagonal elements less than JacobiDiagonalization.EPSILON in absolute value are set to 0. Uses the default max number of iterations JacobiDiagonalization.MAX_ITERATIONS.
      Returns:
      true if Jacobi method converged, and false if terminated due to maximum number of iterations
    • compute

      public boolean compute(double epsilon)
      Computes the eigenvalues and eigenvectors using Jacobi Iteration. Uses the default max number of iterations JacobiDiagonalization.MAX_ITERATIONS.
      Parameters:
      epsilon - Precision level, where off-diagonal elements less than epsilon in absolute value are set to 0.
      Returns:
      true if Jacobi method converged, and false if terminated due to maximum number of iterations
    • compute

      public boolean compute(int maxIters)
      Computes the eigenvalues and eigenvectors using Jacobi Iteration. Uses the default precision level JacobiDiagonalization.EPSILON where off-diagonal elements less than JacobiDiagonalization.EPSILON in absolute value are set to 0.
      Parameters:
      maxIters - Maximum number of iterations.
      Returns:
      true if Jacobi method converged, and false if terminated due to maximum number of iterations
    • compute

      public boolean compute(double epsilon, int maxIters)
      Computes the eigenvalues and eigenvectors using Jacobi Iteration.
      Parameters:
      epsilon - Precision level, where off-diagonal elements less than epsilon in absolute value are set to 0.
      maxIters - Maximum number of iterations.
      Returns:
      true if Jacobi method converged, and false if terminated due to maximum number of iterations