Class JacobiDiagonalization


  • public 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 double EPSILON
      Default precision level for convergence check.
      static int MAX_ITERATIONS
      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.
    • Field Detail

      • EPSILON

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

        public static final int MAX_ITERATIONS
        Default max number of iterations.
        See Also:
        Constant Field Values
    • Constructor Detail

      • 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 Detail

      • 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