Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8C5459355 for ; Thu, 27 Oct 2011 03:12:31 +0000 (UTC) Received: (qmail 24391 invoked by uid 500); 27 Oct 2011 03:12:30 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 23984 invoked by uid 500); 27 Oct 2011 03:12:29 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 23970 invoked by uid 99); 27 Oct 2011 03:12:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Oct 2011 03:12:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Oct 2011 03:12:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 821F62388A64 for ; Thu, 27 Oct 2011 03:11:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1189593 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/analysis/integration/ main/java/org/apache/commons/math/geometry/euclidean/threed/ main/java/org/apache/commons/math/linear/ main/java/org/apache/commons/math/o... Date: Thu, 27 Oct 2011 03:11:55 -0000 To: commits@commons.apache.org From: psteitz@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111027031156.821F62388A64@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: psteitz Date: Thu Oct 27 03:11:54 2011 New Revision: 1189593 URL: http://svn.apache.org/viewvc?rev=1189593&view=rev Log: Moved "SAFE_MIN" and "EPSILON" from "MathUtils" to "Precision." JIRA: MATH-689 (Committing on behalf of erans) Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Line.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecomposition.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/MatrixUtils.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecomposition.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/JacobianMatrices.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/AbstractConvergenceChecker.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/MillerUpdatingRegression.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/Precision.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpTest.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionTest.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathStrictComparisonTest.java commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/UnivariateRealIntegratorImpl.java Thu Oct 27 03:11:54 2011 @@ -81,7 +81,7 @@ public abstract class UnivariateRealInte * achieved due to large values or short mantissa length. If this * should be the primary criterion for convergence rather then a * safety measure, set the absolute accuracy to a ridiculously small value, - * like {@link org.apache.commons.math.util.MathUtils#SAFE_MIN MathUtils.SAFE_MIN}. + * like {@link org.apache.commons.math.util.Precision#SAFE_MIN Precision.SAFE_MIN}. *
  • absolute accuracy: * The default is usually chosen so that results in the interval * -10..-0.1 and +0.1..+10 can be found with a reasonable accuracy. If the Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Line.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Line.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Line.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Line.java Thu Oct 27 03:11:54 2011 @@ -24,7 +24,7 @@ import org.apache.commons.math.geometry. import org.apache.commons.math.geometry.euclidean.oned.Vector1D; import org.apache.commons.math.geometry.partitioning.Embedding; import org.apache.commons.math.util.FastMath; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; /** The class represent lines in a three dimensional space. @@ -172,7 +172,7 @@ public class Line implements Embedding *

    * As of 2.0, this class supports only symmetric matrices, and - * hence computes only real real Eigenvalues. This implies the D matrix returned + * hence computes only real realEigenvalues. This implies the D matrix returned * by {@link #getD()} is always diagonal and the imaginary values returned * {@link #getImagEigenvalue(int)} and {@link #getImagEigenvalues()} are always * null. @@ -153,7 +153,7 @@ public class EigenDecomposition{ boolean raiseException) { final int rows = matrix.getRowDimension(); final int columns = matrix.getColumnDimension(); - final double eps = 10 * rows * columns * MathUtils.EPSILON; + final double eps = 10 * rows * columns * Precision.EPSILON; for (int i = 0; i < rows; ++i) { for (int j = i + 1; j < columns; ++j) { final double mij = matrix.getEntry(i, j); @@ -497,10 +497,10 @@ public class EigenDecomposition{ // Make null any main and secondary value too small to be significant if (maxAbsoluteValue!=0.0) { for (int i=0; i < n; i++) { - if (FastMath.abs(realEigenvalues[i])<=MathUtils.EPSILON*maxAbsoluteValue) { + if (FastMath.abs(realEigenvalues[i])<=Precision.EPSILON*maxAbsoluteValue) { realEigenvalues[i]=0.0; } - if (FastMath.abs(e[i])<=MathUtils.EPSILON*maxAbsoluteValue) { + if (FastMath.abs(e[i])<=Precision.EPSILON*maxAbsoluteValue) { e[i]=0.0; } } @@ -606,7 +606,7 @@ public class EigenDecomposition{ // Make null any eigen value too small to be significant if (maxAbsoluteValue!=0.0) { for (int i=0; i < n; i++) { - if (FastMath.abs(realEigenvalues[i])-1 ; i-- ){ double diag = rm.getEntry(i, i); - if( FastMath.abs(diag) < MathUtils.SAFE_MIN ){ + if( FastMath.abs(diag) < Precision.SAFE_MIN ){ throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR); } double bi = b.getEntry(i)/diag; Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecomposition.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecomposition.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecomposition.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecomposition.java Thu Oct 27 03:11:54 2011 @@ -19,7 +19,7 @@ package org.apache.commons.math.linear; import org.apache.commons.math.exception.NumberIsTooLargeException; import org.apache.commons.math.exception.util.LocalizedFormats; import org.apache.commons.math.util.FastMath; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; /** * Calculates the compact Singular Value Decomposition of a matrix. @@ -465,7 +465,7 @@ public class SingularValueDecomposition // Set the small value tolerance used to calculate rank and pseudo-inverse tol = FastMath.max(m * singularValues[0] * EPS, - FastMath.sqrt(MathUtils.SAFE_MIN)); + FastMath.sqrt(Precision.SAFE_MIN)); if (!transposed) { cachedU = MatrixUtils.createRealMatrix(U); @@ -505,7 +505,7 @@ public class SingularValueDecomposition /** * Returns the diagonal matrix Σ of the decomposition. *

    Σ is a diagonal matrix. The singular values are provided in - * non-increasing order, for compatibility with JAMA.

    + * non-increasing order, for compatibility with Jama.

    * @return the Σ matrix */ public RealMatrix getS() { Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/JacobianMatrices.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/JacobianMatrices.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/JacobianMatrices.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/JacobianMatrices.java Thu Oct 27 03:11:54 2011 @@ -198,7 +198,7 @@ public class JacobianMatrices { *

    *

    * Given a non zero parameter value pval for the parameter, a reasonable value - * for such a step is {@code pval * FastMath.sqrt(MathUtils.EPSILON)}. + * for such a step is {@code pval * FastMath.sqrt(Precision.EPSILON)}. *

    *

    * A zero value for such a step doesn't enable to compute the parameter Jacobian matrix. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/AbstractConvergenceChecker.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/AbstractConvergenceChecker.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/AbstractConvergenceChecker.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/AbstractConvergenceChecker.java Thu Oct 27 03:11:54 2011 @@ -17,7 +17,7 @@ package org.apache.commons.math.optimization; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; /** * Base class for all convergence checker implementations. @@ -32,11 +32,11 @@ public abstract class AbstractConvergenc /** * Default relative threshold. */ - private static final double DEFAULT_RELATIVE_THRESHOLD = 100 * MathUtils.EPSILON; + private static final double DEFAULT_RELATIVE_THRESHOLD = 100 * Precision.EPSILON; /** * Default absolute threshold. */ - private static final double DEFAULT_ABSOLUTE_THRESHOLD = 100 * MathUtils.SAFE_MIN; + private static final double DEFAULT_ABSOLUTE_THRESHOLD = 100 * Precision.SAFE_MIN; /** * Relative tolerance threshold. */ Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java Thu Oct 27 03:11:54 2011 @@ -22,7 +22,7 @@ import org.apache.commons.math.exception import org.apache.commons.math.exception.util.LocalizedFormats; import org.apache.commons.math.optimization.VectorialPointValuePair; import org.apache.commons.math.optimization.ConvergenceChecker; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; import org.apache.commons.math.util.FastMath; @@ -144,11 +144,11 @@ public class LevenbergMarquardtOptimizer *

  • Cost relative tolerance: 1e-10
  • *
  • Parameters relative tolerance: 1e-10
  • *
  • Orthogonality tolerance: 1e-10
  • - *
  • QR ranking threshold: {@link MathUtils#SAFE_MIN}
  • + *
  • QR ranking threshold: {@link Precision#SAFE_MIN}
  • * */ public LevenbergMarquardtOptimizer() { - this(100, 1e-10, 1e-10, 1e-10, MathUtils.SAFE_MIN); + this(100, 1e-10, 1e-10, 1e-10, Precision.SAFE_MIN); } /** @@ -161,13 +161,13 @@ public class LevenbergMarquardtOptimizer *
  • Cost relative tolerance: 1e-10
  • *
  • Parameters relative tolerance: 1e-10
  • *
  • Orthogonality tolerance: 1e-10
  • - *
  • QR ranking threshold: {@link MathUtils#SAFE_MIN}
  • + *
  • QR ranking threshold: {@link Precision#SAFE_MIN}
  • * * * @param checker Convergence checker. */ public LevenbergMarquardtOptimizer(ConvergenceChecker checker) { - this(100, checker, 1e-10, 1e-10, 1e-10, MathUtils.SAFE_MIN); + this(100, checker, 1e-10, 1e-10, 1e-10, Precision.SAFE_MIN); } /** @@ -214,7 +214,7 @@ public class LevenbergMarquardtOptimizer * The default values for the algorithm settings are: *
      *
    • Initial step bound factor}: 100
    • - *
    • QR ranking threshold}: {@link MathUtils#SAFE_MIN}
    • + *
    • QR ranking threshold}: {@link Precision#SAFE_MIN}
    • *
    * * @param costRelativeTolerance Desired relative error in the sum of @@ -229,7 +229,7 @@ public class LevenbergMarquardtOptimizer double orthoTolerance) { this(100, costRelativeTolerance, parRelativeTolerance, orthoTolerance, - MathUtils.SAFE_MIN); + Precision.SAFE_MIN); } /** Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java Thu Oct 27 03:11:54 2011 @@ -141,7 +141,7 @@ public class RandomDataImpl implements R /** * MathUtils provides factorials up to 20, so let's use that limit together - * with MathUtils.EPSILON to generate the following code (a priori, we know that + * with Precision.EPSILON to generate the following code (a priori, we know that * there will be 16 elements, but instead of hardcoding that, this is * prettier): */ Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/MillerUpdatingRegression.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/MillerUpdatingRegression.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/MillerUpdatingRegression.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/MillerUpdatingRegression.java Thu Oct 27 03:11:54 2011 @@ -19,7 +19,7 @@ package org.apache.commons.math.stat.reg import java.util.Arrays; import org.apache.commons.math.exception.util.LocalizedFormats; import org.apache.commons.math.util.FastMath; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; import org.apache.commons.math.util.MathArrays; /** @@ -153,7 +153,7 @@ public class MillerUpdatingRegression im * @param includeConstant include a constant automatically */ public MillerUpdatingRegression(int numberOfVariables, boolean includeConstant) { - this(numberOfVariables, includeConstant, MathUtils.EPSILON); + this(numberOfVariables, includeConstant, Precision.EPSILON); } /** @@ -271,7 +271,7 @@ public class MillerUpdatingRegression im if (di != 0.0) { dpi = smartAdd(di, wxi * xi); double tmp = wxi * xi / di; - if (FastMath.abs(tmp) > MathUtils.EPSILON) { + if (FastMath.abs(tmp) > Precision.EPSILON) { w = (di * w) / dpi; } } else { @@ -312,13 +312,13 @@ public class MillerUpdatingRegression im double _a = FastMath.abs(a); double _b = FastMath.abs(b); if (_a > _b) { - double eps = _a * MathUtils.EPSILON; + double eps = _a * Precision.EPSILON; if (_b > eps) { return a + b; } return a; } else { - double eps = _b * MathUtils.EPSILON; + double eps = _b * Precision.EPSILON; if (_a > eps) { return a + b; } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java Thu Oct 27 03:11:54 2011 @@ -26,7 +26,7 @@ import org.apache.commons.math.exception import org.apache.commons.math.exception.NoDataException; import org.apache.commons.math.exception.util.LocalizedFormats; import org.apache.commons.math.util.FastMath; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; /** * Estimates an ordinary least squares regression model @@ -706,7 +706,7 @@ public class SimpleRegression implements if( n < 3 ){ throw new NoDataException( LocalizedFormats.NOT_ENOUGH_DATA_REGRESSION ); } - if( FastMath.abs( sumXX ) > MathUtils.SAFE_MIN ){ + if( FastMath.abs( sumXX ) > Precision.SAFE_MIN ){ final double[] params = new double[]{ getIntercept(), getSlope() }; final double mse = getMeanSquareError(); final double _syy = sumYY + sumY * sumY / ((double) n); Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java Thu Oct 27 03:11:54 2011 @@ -101,9 +101,9 @@ public class FastMath { * already computed ones provided as literal arrays below. *

    */ - private static final boolean RECOMPUTE_TABLES_AT_RUNTIME = false; + private static /* final */ boolean RECOMPUTE_TABLES_AT_RUNTIME = false; /** Indicator for loading big tables from "resource" files. */ - private static final boolean LOAD_RESOURCES = false; + private static /* final */ boolean LOAD_RESOURCES = false; /** log(2) (high bits). */ private static final double LN_2_A = 0.693147063255310059; @@ -358,7 +358,7 @@ public class FastMath { * @return the high order part of the mantissa */ private static double doubleHighPart(double d) { - if (d > -MathUtils.SAFE_MIN && d < MathUtils.SAFE_MIN){ + if (d > -Precision.SAFE_MIN && d < Precision.SAFE_MIN){ return d; // These are un-normalised - don't try to convert } long xl = Double.doubleToLongBits(d); Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java Thu Oct 27 03:11:54 2011 @@ -32,16 +32,6 @@ import org.apache.commons.math.exception * @version $Id$ */ public final class MathUtils { - - /** Smallest positive number such that 1 - EPSILON is not numerically equal to 1. */ - public static final double EPSILON = 0x1.0p-53; - - /** Safe minimum, such that 1 / SAFE_MIN does not overflow. - *

    In IEEE 754 arithmetic, this is also the smallest normalized - * number 2-1022.

    - */ - public static final double SAFE_MIN = 0x1.0p-1022; - /** * 2 π. * @since 2.1 Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/Precision.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/Precision.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/Precision.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/Precision.java Thu Oct 27 03:11:54 2011 @@ -30,9 +30,19 @@ import org.apache.commons.math.util.Fast * @version $Id$ */ public class Precision { + /** + * Smallest positive number such that {@code 1 - EPSILON} is not + * numerically equal to 1: {@value}. + */ + public static final double EPSILON = 0x1.0p-53; + /** + * Safe minimum, such that {@code 1 / SAFE_MIN} does not overflow. + * In IEEE 754 arithmetic, this is also the smallest normalized + * number 2-1022: {@value}. + */ + public static final double SAFE_MIN = 0x1.0p-1022; /** Offset to order signed double numbers lexicographically. */ private static final long SGN_MASK = 0x8000000000000000L; - /** Offset to order signed double numbers lexicographically. */ private static final int SGN_MASK_FLOAT = 0x80000000; Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpTest.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpTest.java Thu Oct 27 03:11:54 2011 @@ -18,7 +18,7 @@ package org.apache.commons.math.dfp; import org.apache.commons.math.util.FastMath; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -1549,10 +1549,10 @@ public class DfpTest { @Test public void testIssue567() { DfpField field = new DfpField(100); - Assert.assertEquals(0.0, field.getZero().toDouble(), MathUtils.SAFE_MIN); - Assert.assertEquals(0.0, field.newDfp(0.0).toDouble(), MathUtils.SAFE_MIN); - Assert.assertEquals(-1, FastMath.copySign(1, field.newDfp(-0.0).toDouble()), MathUtils.EPSILON); - Assert.assertEquals(+1, FastMath.copySign(1, field.newDfp(+0.0).toDouble()), MathUtils.EPSILON); + Assert.assertEquals(0.0, field.getZero().toDouble(), Precision.SAFE_MIN); + Assert.assertEquals(0.0, field.newDfp(0.0).toDouble(), Precision.SAFE_MIN); + Assert.assertEquals(-1, FastMath.copySign(1, field.newDfp(-0.0).toDouble()), Precision.EPSILON); + Assert.assertEquals(+1, FastMath.copySign(1, field.newDfp(+0.0).toDouble()), Precision.EPSILON); } @Test Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionTest.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionTest.java Thu Oct 27 03:11:54 2011 @@ -22,7 +22,7 @@ import java.util.Random; import org.apache.commons.math.util.FastMath; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -38,7 +38,7 @@ public class EigenDecompositionTest { RealMatrix matrix = MatrixUtils.createRealMatrix(new double[][] { { 1.5 } }); EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); Assert.assertEquals(1.5, ed.getRealEigenvalue(0), 1.0e-15); } @@ -50,7 +50,7 @@ public class EigenDecompositionTest { { 12.0, 66.0 } }); EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); Assert.assertEquals(75.0, ed.getRealEigenvalue(0), 1.0e-15); Assert.assertEquals(50.0, ed.getRealEigenvalue(1), 1.0e-15); } @@ -64,7 +64,7 @@ public class EigenDecompositionTest { { -16560.0, 7920.0, 17300.0 } }); EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); Assert.assertEquals(50000.0, ed.getRealEigenvalue(0), 3.0e-11); Assert.assertEquals(12500.0, ed.getRealEigenvalue(1), 3.0e-11); Assert.assertEquals( 3125.0, ed.getRealEigenvalue(2), 3.0e-11); @@ -79,7 +79,7 @@ public class EigenDecompositionTest { { 15, 30, 45 } }); EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); Assert.assertEquals(70.0, ed.getRealEigenvalue(0), 3.0e-11); Assert.assertEquals(0.0, ed.getRealEigenvalue(1), 3.0e-11); Assert.assertEquals(0.0, ed.getRealEigenvalue(2), 3.0e-11); @@ -95,7 +95,7 @@ public class EigenDecompositionTest { { 0.000, 0.000, -0.048, 0.136 } }); EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); Assert.assertEquals(1.0, ed.getRealEigenvalue(0), 1.0e-15); Assert.assertEquals(0.4, ed.getRealEigenvalue(1), 1.0e-15); Assert.assertEquals(0.2, ed.getRealEigenvalue(2), 1.0e-15); @@ -112,7 +112,7 @@ public class EigenDecompositionTest { { -0.2976, 0.1152, -0.1344, 0.3872 } }); EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); Assert.assertEquals(1.0, ed.getRealEigenvalue(0), 1.0e-15); Assert.assertEquals(0.4, ed.getRealEigenvalue(1), 1.0e-15); Assert.assertEquals(0.2, ed.getRealEigenvalue(2), 1.0e-15); @@ -146,7 +146,7 @@ public class EigenDecompositionTest { EigenDecomposition decomposition; decomposition = new EigenDecomposition(mainTridiagonal, secondaryTridiagonal, - MathUtils.SAFE_MIN); + Precision.SAFE_MIN); double[] eigenValues = decomposition.getRealEigenvalues(); for (int i = 0; i < refEigenValues.length; ++i) { @@ -191,7 +191,7 @@ public class EigenDecompositionTest { EigenDecomposition decomposition; decomposition = new EigenDecomposition(mainTridiagonal, secondaryTridiagonal, - MathUtils.SAFE_MIN); + Precision.SAFE_MIN); double[] eigenValues = decomposition.getRealEigenvalues(); for (int i = 0; i < refEigenValues.length; ++i) { @@ -238,7 +238,7 @@ public class EigenDecompositionTest { EigenDecomposition decomposition; decomposition = new EigenDecomposition(mainTridiagonal, secondaryTridiagonal, - MathUtils.SAFE_MIN); + Precision.SAFE_MIN); double[] eigenValues = decomposition.getRealEigenvalues(); for (int i = 0; i < refEigenValues.length; ++i) { @@ -270,7 +270,7 @@ public class EigenDecompositionTest { EigenDecomposition ed; ed = new EigenDecomposition(t.getMainDiagonalRef(), t.getSecondaryDiagonalRef(), - MathUtils.SAFE_MIN); + Precision.SAFE_MIN); double[] eigenValues = ed.getRealEigenvalues(); Assert.assertEquals(ref.length, eigenValues.length); for (int i = 0; i < ref.length; ++i) { @@ -284,7 +284,7 @@ public class EigenDecompositionTest { public void testDimensions() { final int m = matrix.getRowDimension(); EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); Assert.assertEquals(m, ed.getV().getRowDimension()); Assert.assertEquals(m, ed.getV().getColumnDimension()); Assert.assertEquals(m, ed.getD().getColumnDimension()); @@ -297,7 +297,7 @@ public class EigenDecompositionTest { @Test public void testEigenvalues() { EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); double[] eigenValues = ed.getRealEigenvalues(); Assert.assertEquals(refValues.length, eigenValues.length); for (int i = 0; i < refValues.length; ++i) { @@ -316,7 +316,7 @@ public class EigenDecompositionTest { Arrays.sort(bigValues); EigenDecomposition ed; ed = new EigenDecomposition(createTestMatrix(r, bigValues), - MathUtils.SAFE_MIN); + Precision.SAFE_MIN); double[] eigenValues = ed.getRealEigenvalues(); Assert.assertEquals(bigValues.length, eigenValues.length); for (int i = 0; i < bigValues.length; ++i) { @@ -328,7 +328,7 @@ public class EigenDecompositionTest { @Test public void testEigenvectors() { EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); for (int i = 0; i < matrix.getRowDimension(); ++i) { double lambda = ed.getRealEigenvalue(i); RealVector v = ed.getEigenvector(i); @@ -341,7 +341,7 @@ public class EigenDecompositionTest { @Test public void testAEqualVDVt() { EigenDecomposition ed; - ed = new EigenDecomposition(matrix, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(matrix, Precision.SAFE_MIN); RealMatrix v = ed.getV(); RealMatrix d = ed.getD(); RealMatrix vT = ed.getVT(); @@ -352,7 +352,7 @@ public class EigenDecompositionTest { /** test that V is orthogonal */ @Test public void testVOrthogonal() { - RealMatrix v = new EigenDecomposition(matrix, MathUtils.SAFE_MIN).getV(); + RealMatrix v = new EigenDecomposition(matrix, Precision.SAFE_MIN).getV(); RealMatrix vTv = v.transpose().multiply(v); RealMatrix id = MatrixUtils.createRealIdentityMatrix(vTv.getRowDimension()); Assert.assertEquals(0, vTv.subtract(id).getNorm(), 2.0e-13); @@ -364,7 +364,7 @@ public class EigenDecompositionTest { double[] diagonal = new double[] { -3.0, -2.0, 2.0, 5.0 }; RealMatrix m = createDiagonalMatrix(diagonal, diagonal.length, diagonal.length); EigenDecomposition ed; - ed = new EigenDecomposition(m, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(m, Precision.SAFE_MIN); Assert.assertEquals(diagonal[0], ed.getRealEigenvalue(3), 2.0e-15); Assert.assertEquals(diagonal[1], ed.getRealEigenvalue(2), 2.0e-15); Assert.assertEquals(diagonal[2], ed.getRealEigenvalue(1), 2.0e-15); @@ -382,7 +382,7 @@ public class EigenDecompositionTest { {4, 2, 3} }); EigenDecomposition ed; - ed = new EigenDecomposition(repeated, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(repeated, Precision.SAFE_MIN); checkEigenValues((new double[] {8, -1, -1}), ed, 1E-12); checkEigenVector((new double[] {2, 1, 2}), ed, 1E-12); } @@ -398,7 +398,7 @@ public class EigenDecompositionTest { {-4, -4, 8} }); EigenDecomposition ed; - ed = new EigenDecomposition(distinct, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(distinct, Precision.SAFE_MIN); checkEigenValues((new double[] {2, 0, 12}), ed, 1E-12); checkEigenVector((new double[] {1, -1, 0}), ed, 1E-12); checkEigenVector((new double[] {1, 1, 1}), ed, 1E-12); @@ -416,7 +416,7 @@ public class EigenDecompositionTest { { -1.0,0.0, 1.0 } }); EigenDecomposition ed; - ed = new EigenDecomposition(indefinite, MathUtils.SAFE_MIN); + ed = new EigenDecomposition(indefinite, Precision.SAFE_MIN); checkEigenValues((new double[] {2, 1, -1}), ed, 1E-12); double isqrt3 = 1/FastMath.sqrt(3.0); checkEigenVector((new double[] {isqrt3,isqrt3,-isqrt3}), ed, 1E-12); Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java Thu Oct 27 03:11:54 2011 @@ -19,7 +19,7 @@ package org.apache.commons.math.linear; import java.util.Random; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; import org.apache.commons.math.exception.MathIllegalArgumentException; import org.junit.Test; @@ -33,7 +33,7 @@ public class EigenSolverTest { Random r = new Random(9994100315209l); RealMatrix m = EigenDecompositionTest.createTestMatrix(r, new double[] { 1.0, 0.0, -1.0, -2.0, -3.0 }); - DecompositionSolver es = new EigenDecomposition(m, MathUtils.SAFE_MIN).getSolver(); + DecompositionSolver es = new EigenDecomposition(m, Precision.SAFE_MIN).getSolver(); Assert.assertFalse(es.isNonSingular()); try { es.getInverse(); @@ -49,7 +49,7 @@ public class EigenSolverTest { Random r = new Random(9994100315209l); RealMatrix m = EigenDecompositionTest.createTestMatrix(r, new double[] { 1.0, 0.5, -1.0, -2.0, -3.0 }); - DecompositionSolver es = new EigenDecomposition(m, MathUtils.SAFE_MIN).getSolver(); + DecompositionSolver es = new EigenDecomposition(m, Precision.SAFE_MIN).getSolver(); Assert.assertTrue(es.isNonSingular()); RealMatrix inverse = es.getInverse(); RealMatrix error = @@ -65,7 +65,7 @@ public class EigenSolverTest { }; final RealMatrix matrix = EigenDecompositionTest.createTestMatrix(new Random(35992629946426l), refValues); - DecompositionSolver es = new EigenDecomposition(matrix, MathUtils.SAFE_MIN).getSolver(); + DecompositionSolver es = new EigenDecomposition(matrix, Precision.SAFE_MIN).getSolver(); RealMatrix b = MatrixUtils.createRealMatrix(new double[2][2]); try { es.solve(b); @@ -98,7 +98,7 @@ public class EigenSolverTest { { 40, 2, 21, 9, 51, 19 }, { 14, -1, 8, 0, 19, 14 } }); - DecompositionSolver es = new EigenDecomposition(m, MathUtils.SAFE_MIN).getSolver(); + DecompositionSolver es = new EigenDecomposition(m, Precision.SAFE_MIN).getSolver(); RealMatrix b = MatrixUtils.createRealMatrix(new double[][] { { 1561, 269, 188 }, { 69, -21, 70 }, Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java Thu Oct 27 03:11:54 2011 @@ -35,7 +35,7 @@ import org.apache.commons.math.linear.Re import org.apache.commons.math.linear.SingularMatrixException; import org.apache.commons.math.optimization.SimpleVectorialValueChecker; import org.apache.commons.math.optimization.VectorialPointValuePair; -import org.apache.commons.math.util.MathUtils; +import org.apache.commons.math.util.Precision; import org.apache.commons.math.util.FastMath; import org.junit.Assert; import org.junit.Test; @@ -376,7 +376,7 @@ public class LevenbergMarquardtOptimizer costRelativeTolerance, parRelativeTolerance, orthoTolerance, - MathUtils.SAFE_MIN); + Precision.SAFE_MIN); optimizer.optimize(maxCostEval, problem, new double[] { 0, 0, 0, 0, 0 }, new double[] { 1, 1, 1, 1, 1 }, new double[] { 98.680, 47.345 }); Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathStrictComparisonTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathStrictComparisonTest.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathStrictComparisonTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathStrictComparisonTest.java Thu Oct 27 03:11:54 2011 @@ -48,8 +48,8 @@ public class FastMathStrictComparisonTes Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, // 4,5 -Double.MAX_VALUE, Double.MAX_VALUE, // 6,7 // decreasing order of absolute value to help catch first failure - -MathUtils.EPSILON, MathUtils.EPSILON, // 8,9 - -MathUtils.SAFE_MIN, MathUtils.SAFE_MIN, // 10,11 + -Precision.EPSILON, Precision.EPSILON, // 8,9 + -Precision.SAFE_MIN, Precision.SAFE_MIN, // 10,11 -Double.MIN_VALUE, Double.MIN_VALUE, // 12,13 }; Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java?rev=1189593&r1=1189592&r2=1189593&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java Thu Oct 27 03:11:54 2011 @@ -58,25 +58,25 @@ public class FastMathTest { { Double.NaN, 0.0 }, { Double.NaN, Double.NEGATIVE_INFINITY }, { Double.NaN, Double.POSITIVE_INFINITY }, - { MathUtils.SAFE_MIN, MathUtils.EPSILON } + { Precision.SAFE_MIN, Precision.EPSILON } }; for (double[] pair : pairs) { Assert.assertEquals("min(" + pair[0] + ", " + pair[1] + ")", Math.min(pair[0], pair[1]), FastMath.min(pair[0], pair[1]), - MathUtils.EPSILON); + Precision.EPSILON); Assert.assertEquals("min(" + pair[1] + ", " + pair[0] + ")", Math.min(pair[1], pair[0]), FastMath.min(pair[1], pair[0]), - MathUtils.EPSILON); + Precision.EPSILON); Assert.assertEquals("max(" + pair[0] + ", " + pair[1] + ")", Math.max(pair[0], pair[1]), FastMath.max(pair[0], pair[1]), - MathUtils.EPSILON); + Precision.EPSILON); Assert.assertEquals("max(" + pair[1] + ", " + pair[0] + ")", Math.max(pair[1], pair[0]), FastMath.max(pair[1], pair[0]), - MathUtils.EPSILON); + Precision.EPSILON); } } @@ -97,19 +97,19 @@ public class FastMathTest { Assert.assertEquals("min(" + pair[0] + ", " + pair[1] + ")", Math.min(pair[0], pair[1]), FastMath.min(pair[0], pair[1]), - MathUtils.EPSILON); + Precision.EPSILON); Assert.assertEquals("min(" + pair[1] + ", " + pair[0] + ")", Math.min(pair[1], pair[0]), FastMath.min(pair[1], pair[0]), - MathUtils.EPSILON); + Precision.EPSILON); Assert.assertEquals("max(" + pair[0] + ", " + pair[1] + ")", Math.max(pair[0], pair[1]), FastMath.max(pair[0], pair[1]), - MathUtils.EPSILON); + Precision.EPSILON); Assert.assertEquals("max(" + pair[1] + ", " + pair[0] + ")", Math.max(pair[1], pair[0]), FastMath.max(pair[1], pair[0]), - MathUtils.EPSILON); + Precision.EPSILON); } } @@ -123,10 +123,10 @@ public class FastMathTest { public void testAtan2() { double y1 = 1.2713504628280707e10; double x1 = -5.674940885228782e-10; - Assert.assertEquals(Math.atan2(y1, x1), FastMath.atan2(y1, x1), 2 * MathUtils.EPSILON); + Assert.assertEquals(Math.atan2(y1, x1), FastMath.atan2(y1, x1), 2 * Precision.EPSILON); double y2 = 0.0; double x2 = Double.POSITIVE_INFINITY; - Assert.assertEquals(Math.atan2(y2, x2), FastMath.atan2(y2, x2), MathUtils.SAFE_MIN); + Assert.assertEquals(Math.atan2(y2, x2), FastMath.atan2(y2, x2), Precision.SAFE_MIN); } @Test @@ -172,7 +172,7 @@ public class FastMathTest { Assert.assertEquals(0, maxErr, 2); maxErr = 0; - for (double x = -1 + MathUtils.EPSILON; x < 1 - MathUtils.EPSILON; x += 0.0001) { + for (double x = -1 + Precision.EPSILON; x < 1 - Precision.EPSILON; x += 0.0001) { maxErr = FastMath.max(maxErr, FastMath.abs(x - FastMath.tanh(FastMath.atanh(x))) / (2 * FastMath.ulp(x))); } Assert.assertEquals(0, maxErr, 2); @@ -270,7 +270,7 @@ public class FastMathTest { Assert.assertTrue("Log of negative number should be NaN", Double.isNaN(FastMath.log(-1.0))); - Assert.assertEquals("Log of Double.MIN_VALUE should be -744.4400719213812", -744.4400719213812, FastMath.log(Double.MIN_VALUE), MathUtils.EPSILON); + Assert.assertEquals("Log of Double.MIN_VALUE should be -744.4400719213812", -744.4400719213812, FastMath.log(Double.MIN_VALUE), Precision.EPSILON); Assert.assertTrue("Log of infinity should be infinity", Double.isInfinite(FastMath.log(Double.POSITIVE_INFINITY))); } @@ -278,29 +278,29 @@ public class FastMathTest { public void testExpSpecialCases() { // Smallest value that will round up to Double.MIN_VALUE - Assert.assertEquals(Double.MIN_VALUE, FastMath.exp(-745.1332191019411), MathUtils.EPSILON); + Assert.assertEquals(Double.MIN_VALUE, FastMath.exp(-745.1332191019411), Precision.EPSILON); - Assert.assertEquals("exp(-745.1332191019412) should be 0.0", 0.0, FastMath.exp(-745.1332191019412), MathUtils.EPSILON); + Assert.assertEquals("exp(-745.1332191019412) should be 0.0", 0.0, FastMath.exp(-745.1332191019412), Precision.EPSILON); Assert.assertTrue("exp of NaN should be NaN", Double.isNaN(FastMath.exp(Double.NaN))); Assert.assertTrue("exp of infinity should be infinity", Double.isInfinite(FastMath.exp(Double.POSITIVE_INFINITY))); - Assert.assertEquals("exp of -infinity should be 0.0", 0.0, FastMath.exp(Double.NEGATIVE_INFINITY), MathUtils.EPSILON); + Assert.assertEquals("exp of -infinity should be 0.0", 0.0, FastMath.exp(Double.NEGATIVE_INFINITY), Precision.EPSILON); - Assert.assertEquals("exp(1) should be Math.E", Math.E, FastMath.exp(1.0), MathUtils.EPSILON); + Assert.assertEquals("exp(1) should be Math.E", Math.E, FastMath.exp(1.0), Precision.EPSILON); } @Test public void testPowSpecialCases() { - Assert.assertEquals("pow(-1, 0) should be 1.0", 1.0, FastMath.pow(-1.0, 0.0), MathUtils.EPSILON); + Assert.assertEquals("pow(-1, 0) should be 1.0", 1.0, FastMath.pow(-1.0, 0.0), Precision.EPSILON); - Assert.assertEquals("pow(-1, -0) should be 1.0", 1.0, FastMath.pow(-1.0, -0.0), MathUtils.EPSILON); + Assert.assertEquals("pow(-1, -0) should be 1.0", 1.0, FastMath.pow(-1.0, -0.0), Precision.EPSILON); - Assert.assertEquals("pow(PI, 1.0) should be PI", FastMath.PI, FastMath.pow(FastMath.PI, 1.0), MathUtils.EPSILON); + Assert.assertEquals("pow(PI, 1.0) should be PI", FastMath.PI, FastMath.pow(FastMath.PI, 1.0), Precision.EPSILON); - Assert.assertEquals("pow(-PI, 1.0) should be -PI", -FastMath.PI, FastMath.pow(-FastMath.PI, 1.0), MathUtils.EPSILON); + Assert.assertEquals("pow(-PI, 1.0) should be -PI", -FastMath.PI, FastMath.pow(-FastMath.PI, 1.0), Precision.EPSILON); Assert.assertTrue("pow(PI, NaN) should be NaN", Double.isNaN(FastMath.pow(Math.PI, Double.NaN))); @@ -310,13 +310,13 @@ public class FastMathTest { Assert.assertTrue("pow(0.5, -Infinity) should be Infinity", Double.isInfinite(FastMath.pow(0.5, Double.NEGATIVE_INFINITY))); - Assert.assertEquals("pow(0.5, Infinity) should be 0.0", 0.0, FastMath.pow(0.5, Double.POSITIVE_INFINITY), MathUtils.EPSILON); + Assert.assertEquals("pow(0.5, Infinity) should be 0.0", 0.0, FastMath.pow(0.5, Double.POSITIVE_INFINITY), Precision.EPSILON); - Assert.assertEquals("pow(2.0, -Infinity) should be 0.0", 0.0, FastMath.pow(2.0, Double.NEGATIVE_INFINITY), MathUtils.EPSILON); + Assert.assertEquals("pow(2.0, -Infinity) should be 0.0", 0.0, FastMath.pow(2.0, Double.NEGATIVE_INFINITY), Precision.EPSILON); - Assert.assertEquals("pow(0.0, 0.5) should be 0.0", 0.0, FastMath.pow(0.0, 0.5), MathUtils.EPSILON); + Assert.assertEquals("pow(0.0, 0.5) should be 0.0", 0.0, FastMath.pow(0.0, 0.5), Precision.EPSILON); - Assert.assertEquals("pow(Infinity, -0.5) should be 0.0", 0.0, FastMath.pow(Double.POSITIVE_INFINITY, -0.5), MathUtils.EPSILON); + Assert.assertEquals("pow(Infinity, -0.5) should be 0.0", 0.0, FastMath.pow(Double.POSITIVE_INFINITY, -0.5), Precision.EPSILON); Assert.assertTrue("pow(0.0, -0.5) should be Inf", Double.isInfinite(FastMath.pow(0.0, -0.5))); @@ -330,7 +330,7 @@ public class FastMathTest { Assert.assertTrue("pow(Inf, 3.5) should be Inf", Double.isInfinite(FastMath.pow(Double.POSITIVE_INFINITY, 3.5))); - Assert.assertEquals("pow(-2.0, 3.0) should be -8.0", -8.0, FastMath.pow(-2.0, 3.0), MathUtils.EPSILON); + Assert.assertEquals("pow(-2.0, 3.0) should be -8.0", -8.0, FastMath.pow(-2.0, 3.0), Precision.EPSILON); Assert.assertTrue("pow(-2.0, 3.5) should be NaN", Double.isNaN(FastMath.pow(-2.0, 3.5))); @@ -342,9 +342,9 @@ public class FastMathTest { Assert.assertTrue("pow(-Inf, NaN) should be NaN", Double.isNaN(FastMath.pow(Double.NEGATIVE_INFINITY, Double.NaN))); - Assert.assertEquals("pow(-Inf, -1.0) should be 0.0", 0.0, FastMath.pow(Double.NEGATIVE_INFINITY, -1.0), MathUtils.EPSILON); + Assert.assertEquals("pow(-Inf, -1.0) should be 0.0", 0.0, FastMath.pow(Double.NEGATIVE_INFINITY, -1.0), Precision.EPSILON); - Assert.assertEquals("pow(-Inf, -2.0) should be 0.0", 0.0, FastMath.pow(Double.NEGATIVE_INFINITY, -2.0), MathUtils.EPSILON); + Assert.assertEquals("pow(-Inf, -2.0) should be 0.0", 0.0, FastMath.pow(Double.NEGATIVE_INFINITY, -2.0), Precision.EPSILON); Assert.assertTrue("pow(-Inf, 1.0) should be -Inf", Double.isInfinite(FastMath.pow(Double.NEGATIVE_INFINITY, 1.0))); @@ -361,53 +361,53 @@ public class FastMathTest { Assert.assertTrue("atan2(0.0, NaN) should be NaN", Double.isNaN(FastMath.atan2(0.0, Double.NaN))); - Assert.assertEquals("atan2(0.0, 0.0) should be 0.0", 0.0, FastMath.atan2(0.0, 0.0), MathUtils.EPSILON); + Assert.assertEquals("atan2(0.0, 0.0) should be 0.0", 0.0, FastMath.atan2(0.0, 0.0), Precision.EPSILON); - Assert.assertEquals("atan2(0.0, 0.001) should be 0.0", 0.0, FastMath.atan2(0.0, 0.001), MathUtils.EPSILON); + Assert.assertEquals("atan2(0.0, 0.001) should be 0.0", 0.0, FastMath.atan2(0.0, 0.001), Precision.EPSILON); - Assert.assertEquals("atan2(0.1, +Inf) should be 0.0", 0.0, FastMath.atan2(0.1, Double.POSITIVE_INFINITY), MathUtils.EPSILON); + Assert.assertEquals("atan2(0.1, +Inf) should be 0.0", 0.0, FastMath.atan2(0.1, Double.POSITIVE_INFINITY), Precision.EPSILON); - Assert.assertEquals("atan2(-0.0, 0.0) should be -0.0", -0.0, FastMath.atan2(-0.0, 0.0), MathUtils.EPSILON); + Assert.assertEquals("atan2(-0.0, 0.0) should be -0.0", -0.0, FastMath.atan2(-0.0, 0.0), Precision.EPSILON); - Assert.assertEquals("atan2(-0.0, 0.001) should be -0.0", -0.0, FastMath.atan2(-0.0, 0.001), MathUtils.EPSILON); + Assert.assertEquals("atan2(-0.0, 0.001) should be -0.0", -0.0, FastMath.atan2(-0.0, 0.001), Precision.EPSILON); - Assert.assertEquals("atan2(-0.0, +Inf) should be -0.0", -0.0, FastMath.atan2(-0.1, Double.POSITIVE_INFINITY), MathUtils.EPSILON); + Assert.assertEquals("atan2(-0.0, +Inf) should be -0.0", -0.0, FastMath.atan2(-0.1, Double.POSITIVE_INFINITY), Precision.EPSILON); - Assert.assertEquals("atan2(0.0, -0.0) should be PI", FastMath.PI, FastMath.atan2(0.0, -0.0), MathUtils.EPSILON); + Assert.assertEquals("atan2(0.0, -0.0) should be PI", FastMath.PI, FastMath.atan2(0.0, -0.0), Precision.EPSILON); - Assert.assertEquals("atan2(0.1, -Inf) should be PI", FastMath.PI, FastMath.atan2(0.1, Double.NEGATIVE_INFINITY), MathUtils.EPSILON); + Assert.assertEquals("atan2(0.1, -Inf) should be PI", FastMath.PI, FastMath.atan2(0.1, Double.NEGATIVE_INFINITY), Precision.EPSILON); - Assert.assertEquals("atan2(-0.0, -0.0) should be -PI", -FastMath.PI, FastMath.atan2(-0.0, -0.0), MathUtils.EPSILON); + Assert.assertEquals("atan2(-0.0, -0.0) should be -PI", -FastMath.PI, FastMath.atan2(-0.0, -0.0), Precision.EPSILON); - Assert.assertEquals("atan2(0.1, -Inf) should be -PI", -FastMath.PI, FastMath.atan2(-0.1, Double.NEGATIVE_INFINITY), MathUtils.EPSILON); + Assert.assertEquals("atan2(0.1, -Inf) should be -PI", -FastMath.PI, FastMath.atan2(-0.1, Double.NEGATIVE_INFINITY), Precision.EPSILON); - Assert.assertEquals("atan2(0.1, 0.0) should be PI/2", FastMath.PI / 2.0, FastMath.atan2(0.1, 0.0), MathUtils.EPSILON); + Assert.assertEquals("atan2(0.1, 0.0) should be PI/2", FastMath.PI / 2.0, FastMath.atan2(0.1, 0.0), Precision.EPSILON); - Assert.assertEquals("atan2(0.1, -0.0) should be PI/2", FastMath.PI / 2.0, FastMath.atan2(0.1, -0.0), MathUtils.EPSILON); + Assert.assertEquals("atan2(0.1, -0.0) should be PI/2", FastMath.PI / 2.0, FastMath.atan2(0.1, -0.0), Precision.EPSILON); - Assert.assertEquals("atan2(Inf, 0.1) should be PI/2", FastMath.PI / 2.0, FastMath.atan2(Double.POSITIVE_INFINITY, 0.1), MathUtils.EPSILON); + Assert.assertEquals("atan2(Inf, 0.1) should be PI/2", FastMath.PI / 2.0, FastMath.atan2(Double.POSITIVE_INFINITY, 0.1), Precision.EPSILON); - Assert.assertEquals("atan2(Inf, -0.1) should be PI/2", FastMath.PI / 2.0, FastMath.atan2(Double.POSITIVE_INFINITY, -0.1), MathUtils.EPSILON); + Assert.assertEquals("atan2(Inf, -0.1) should be PI/2", FastMath.PI / 2.0, FastMath.atan2(Double.POSITIVE_INFINITY, -0.1), Precision.EPSILON); - Assert.assertEquals("atan2(-0.1, 0.0) should be -PI/2", -FastMath.PI / 2.0, FastMath.atan2(-0.1, 0.0), MathUtils.EPSILON); + Assert.assertEquals("atan2(-0.1, 0.0) should be -PI/2", -FastMath.PI / 2.0, FastMath.atan2(-0.1, 0.0), Precision.EPSILON); - Assert.assertEquals("atan2(-0.1, -0.0) should be -PI/2", -FastMath.PI / 2.0, FastMath.atan2(-0.1, -0.0), MathUtils.EPSILON); + Assert.assertEquals("atan2(-0.1, -0.0) should be -PI/2", -FastMath.PI / 2.0, FastMath.atan2(-0.1, -0.0), Precision.EPSILON); - Assert.assertEquals("atan2(-Inf, 0.1) should be -PI/2", -FastMath.PI / 2.0, FastMath.atan2(Double.NEGATIVE_INFINITY, 0.1), MathUtils.EPSILON); + Assert.assertEquals("atan2(-Inf, 0.1) should be -PI/2", -FastMath.PI / 2.0, FastMath.atan2(Double.NEGATIVE_INFINITY, 0.1), Precision.EPSILON); - Assert.assertEquals("atan2(-Inf, -0.1) should be -PI/2", -FastMath.PI / 2.0, FastMath.atan2(Double.NEGATIVE_INFINITY, -0.1), MathUtils.EPSILON); + Assert.assertEquals("atan2(-Inf, -0.1) should be -PI/2", -FastMath.PI / 2.0, FastMath.atan2(Double.NEGATIVE_INFINITY, -0.1), Precision.EPSILON); Assert.assertEquals("atan2(Inf, Inf) should be PI/4", FastMath.PI / 4.0, FastMath.atan2(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY), - MathUtils.EPSILON); + Precision.EPSILON); Assert.assertEquals("atan2(Inf, -Inf) should be PI * 3/4", FastMath.PI * 3.0 / 4.0, - FastMath.atan2(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY), MathUtils.EPSILON); + FastMath.atan2(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY), Precision.EPSILON); Assert.assertEquals("atan2(-Inf, Inf) should be -PI/4", -FastMath.PI / 4.0, FastMath.atan2(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), - MathUtils.EPSILON); + Precision.EPSILON); Assert.assertEquals("atan2(-Inf, -Inf) should be -PI * 3/4", - FastMath.PI * 3.0 / 4.0, - FastMath.atan2(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY), MathUtils.EPSILON); + FastMath.atan2(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY), Precision.EPSILON); } @Test @@ -713,11 +713,11 @@ public class FastMathTest { Assert.assertTrue("acos(-1.1) should be NaN", Double.isNaN(FastMath.acos(1.1))); - Assert.assertEquals("acos(-1.0) should be PI", FastMath.acos(-1.0), FastMath.PI, MathUtils.EPSILON); + Assert.assertEquals("acos(-1.0) should be PI", FastMath.acos(-1.0), FastMath.PI, Precision.EPSILON); - Assert.assertEquals("acos(1.0) should be 0.0", FastMath.acos(1.0), 0.0, MathUtils.EPSILON); + Assert.assertEquals("acos(1.0) should be 0.0", FastMath.acos(1.0), 0.0, Precision.EPSILON); - Assert.assertEquals("acos(0.0) should be PI/2", FastMath.acos(0.0), FastMath.PI / 2.0, MathUtils.EPSILON); + Assert.assertEquals("acos(0.0) should be PI/2", FastMath.acos(0.0), FastMath.PI / 2.0, Precision.EPSILON); } /** @@ -732,11 +732,11 @@ public class FastMathTest { Assert.assertTrue("asin(-1.1) should be NaN", Double.isNaN(FastMath.asin(-1.1))); - Assert.assertEquals("asin(1.0) should be PI/2", FastMath.asin(1.0), FastMath.PI / 2.0, MathUtils.EPSILON); + Assert.assertEquals("asin(1.0) should be PI/2", FastMath.asin(1.0), FastMath.PI / 2.0, Precision.EPSILON); - Assert.assertEquals("asin(-1.0) should be -PI/2", FastMath.asin(-1.0), -FastMath.PI / 2.0, MathUtils.EPSILON); + Assert.assertEquals("asin(-1.0) should be -PI/2", FastMath.asin(-1.0), -FastMath.PI / 2.0, Precision.EPSILON); - Assert.assertEquals("asin(0.0) should be 0.0", FastMath.asin(0.0), 0.0, MathUtils.EPSILON); + Assert.assertEquals("asin(0.0) should be 0.0", FastMath.asin(0.0), 0.0, Precision.EPSILON); } private Dfp cosh(Dfp x) {