java.lang.Object
org.cicirello.math.la.JacobiDiagonalization
This class uses Jacobi iteration to compute the eigenvalues and eigenvectors of a symmetric
matrix, provided as a 2-D Java array.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
Default precision level for convergence check.static final int
Default max number of iterations. -
Constructor Summary
ConstructorDescriptionJacobiDiagonalization
(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 TypeMethodDescriptionboolean
compute()
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.
-
Field Details
-
EPSILON
public static final double EPSILONDefault precision level for convergence check.- See Also:
-
MAX_ITERATIONS
public static final int MAX_ITERATIONSDefault 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
-