diff --git a/src/main/java/org/apache/commons/math3/linear/EigenDecomposition.java b/src/main/java/org/apache/commons/math3/linear/EigenDecomposition.java index aa9672531..ceb278e63 100644 --- a/src/main/java/org/apache/commons/math3/linear/EigenDecomposition.java +++ b/src/main/java/org/apache/commons/math3/linear/EigenDecomposition.java @@ -75,6 +75,8 @@ import org.apache.commons.math3.util.FastMath; * @since 2.0 (changed to concrete class in 3.0) */ public class EigenDecomposition { + /** Internally used epsilon criteria. */ + private static final double EPSILON = 1e-12; /** Maximum number of iterations accepted in the implicit QL transformation */ private byte maxIter = 30; /** Main diagonal of the tridiagonal matrix. */ @@ -99,9 +101,6 @@ public class EigenDecomposition { /** Cached value of Vt. */ private RealMatrix cachedVt; - /** Internally used epsilon criteria. */ - private final double epsilon = 1e-12; - /** * Calculates the eigen decomposition of the given real matrix. *
@@ -246,9 +245,9 @@ public class EigenDecomposition { cachedD = MatrixUtils.createRealDiagonalMatrix(realEigenvalues); for (int i = 0; i < imagEigenvalues.length; i++) { - if (Precision.compareTo(imagEigenvalues[i], 0.0, epsilon) > 0) { + if (Precision.compareTo(imagEigenvalues[i], 0.0, EPSILON) > 0) { cachedD.setEntry(i, i+1, imagEigenvalues[i]); - } else if (Precision.compareTo(imagEigenvalues[i], 0.0, epsilon) < 0) { + } else if (Precision.compareTo(imagEigenvalues[i], 0.0, EPSILON) < 0) { cachedD.setEntry(i, i-1, imagEigenvalues[i]); } } @@ -291,7 +290,7 @@ public class EigenDecomposition { */ public boolean hasComplexEigenvalues() { for (int i = 0; i < imagEigenvalues.length; i++) { - if (!Precision.equals(imagEigenvalues[i], 0.0, epsilon)) { + if (!Precision.equals(imagEigenvalues[i], 0.0, EPSILON)) { return true; } } @@ -726,7 +725,7 @@ public class EigenDecomposition { for (int i = 0; i < realEigenvalues.length; i++) { if (i == (realEigenvalues.length - 1) || - Precision.equals(matT[i + 1][i], 0.0, epsilon)) { + Precision.equals(matT[i + 1][i], 0.0, EPSILON)) { realEigenvalues[i] = matT[i][i]; } else { final double x = matT[i + 1][i + 1]; @@ -777,7 +776,7 @@ public class EigenDecomposition { } // we can not handle a matrix with zero norm - if (Precision.equals(norm, 0.0, epsilon)) { + if (Precision.equals(norm, 0.0, EPSILON)) { throw new MathArithmeticException(LocalizedFormats.ZERO_NORM); } @@ -801,7 +800,7 @@ public class EigenDecomposition { for (int j = l; j <= idx; j++) { r = r + matrixT[i][j] * matrixT[j][idx]; } - if (Precision.compareTo(imagEigenvalues[i], 0.0, epsilon) < 0.0) { + if (Precision.compareTo(imagEigenvalues[i], 0.0, EPSILON) < 0.0) { z = w; s = r; } else { @@ -863,7 +862,7 @@ public class EigenDecomposition { } double w = matrixT[i][i] - p; - if (Precision.compareTo(imagEigenvalues[i], 0.0, epsilon) < 0.0) { + if (Precision.compareTo(imagEigenvalues[i], 0.0, EPSILON) < 0.0) { z = w; r = ra; s = sa;