Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 88911 invoked from network); 1 Sep 2010 13:47:18 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Sep 2010 13:47:18 -0000 Received: (qmail 55538 invoked by uid 500); 1 Sep 2010 13:47:18 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 55200 invoked by uid 500); 1 Sep 2010 13:47:15 -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 55193 invoked by uid 99); 1 Sep 2010 13:47:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Sep 2010 13:47:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Wed, 01 Sep 2010 13:47:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 71AF623889E9; Wed, 1 Sep 2010 13:45:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r991535 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/util/MathUtils.java site/xdoc/changes.xml test/java/org/apache/commons/math/util/MathUtilsTest.java Date: Wed, 01 Sep 2010 13:45:56 -0000 To: commits@commons.apache.org From: erans@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100901134556.71AF623889E9@eris.apache.org> Author: erans Date: Wed Sep 1 13:45:55 2010 New Revision: 991535 URL: http://svn.apache.org/viewvc?rev=991535&view=rev Log: MATH-370 Removed deprecated methods. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java commons/proper/math/trunk/src/site/xdoc/changes.xml commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java 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=991535&r1=991534&r2=991535&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 Wed Sep 1 13:45:55 2010 @@ -407,20 +407,14 @@ public final class MathUtils { /** * Returns true iff they are equal as defined by - * {@link #equals(double,double,int) this method}. + * {@link #equals(double,double,int) equals(x, y, 1)}. * * @param x first value * @param y second value * @return {@code true} if the values are equal. - * @deprecated This method considers that {@code NaN == NaN}. In release - * 3.0, the semantics will change in order to comply with IEEE754 where it - * is specified that {@code NaN != NaN}. - * New methods have been added for those cases wher the old semantics is - * useful (see e.g. {@link #equalsIncludingNaN(double,double) - * equalsIncludingNaN}. */ public static boolean equals(double x, double y) { - return (Double.isNaN(x) && Double.isNaN(y)) || x == y; + return equals(x, y, 1); } /** @@ -524,12 +518,6 @@ public final class MathUtils { * @param y second array * @return true if the values are both null or have same dimension * and equal elements. - * @deprecated This method considers that {@code NaN == NaN}. In release - * 3.0, the semantics will change in order to comply with IEEE754 where it - * is specified that {@code NaN != NaN}. - * New methods have been added for those cases wher the old semantics is - * useful (see e.g. {@link #equalsIncludingNaN(double[],double[]) - * equalsIncludingNaN}. */ public static boolean equals(double[] x, double[] y) { if ((x == null) || (y == null)) { @@ -1102,29 +1090,6 @@ public final class MathUtils { } /** - * Get the next machine representable number after a number, moving - * in the direction of another number. - *

- * If direction is greater than or equal tod, - * the smallest machine representable number strictly greater than - * d is returned; otherwise the largest representable number - * strictly less than d is returned.

- *

- * If d is NaN or Infinite, it is returned unchanged.

- * - * @param d base number - * @param direction (the only important thing is whether - * direction is greater or smaller than d) - * @return the next machine representable number in the specified direction - * @since 1.2 - * @deprecated as of 2.2, replaced by {@link FastMath#nextAfter(double, double)} - */ - @Deprecated - public static double nextAfter(double d, double direction) { - return FastMath.nextAfter(d, direction); - } - - /** * Scale a number by 2scaleFactor. *

If d is 0 or NaN or Infinite, it is returned unchanged.

* @@ -1318,23 +1283,23 @@ public final class MathUtils { switch (roundingMethod) { case BigDecimal.ROUND_CEILING : if (sign == -1) { - unscaled = FastMath.floor(nextAfter(unscaled, Double.NEGATIVE_INFINITY)); + unscaled = FastMath.floor(FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY)); } else { - unscaled = FastMath.ceil(nextAfter(unscaled, Double.POSITIVE_INFINITY)); + unscaled = FastMath.ceil(FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY)); } break; case BigDecimal.ROUND_DOWN : - unscaled = FastMath.floor(nextAfter(unscaled, Double.NEGATIVE_INFINITY)); + unscaled = FastMath.floor(FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY)); break; case BigDecimal.ROUND_FLOOR : if (sign == -1) { - unscaled = FastMath.ceil(nextAfter(unscaled, Double.POSITIVE_INFINITY)); + unscaled = FastMath.ceil(FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY)); } else { - unscaled = FastMath.floor(nextAfter(unscaled, Double.NEGATIVE_INFINITY)); + unscaled = FastMath.floor(FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY)); } break; case BigDecimal.ROUND_HALF_DOWN : { - unscaled = nextAfter(unscaled, Double.NEGATIVE_INFINITY); + unscaled = FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY); double fraction = unscaled - FastMath.floor(unscaled); if (fraction > 0.5) { unscaled = FastMath.ceil(unscaled); @@ -1361,7 +1326,7 @@ public final class MathUtils { break; } case BigDecimal.ROUND_HALF_UP : { - unscaled = nextAfter(unscaled, Double.POSITIVE_INFINITY); + unscaled = FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY); double fraction = unscaled - FastMath.floor(unscaled); if (fraction >= 0.5) { unscaled = FastMath.ceil(unscaled); @@ -1376,7 +1341,7 @@ public final class MathUtils { } break; case BigDecimal.ROUND_UP : - unscaled = FastMath.ceil(nextAfter(unscaled, Double.POSITIVE_INFINITY)); + unscaled = FastMath.ceil(FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY)); break; default : throw MathRuntimeException.createIllegalArgumentException( @@ -1905,24 +1870,6 @@ public final class MathUtils { } /** - * Checks that the given array is sorted. - * - * @param val Values - * @param dir Order direction (-1 for decreasing, 1 for increasing) - * @param strict Whether the order should be strict - * @throws NonMonotonousSequenceException if the array is not sorted. - * @deprecated as of 2.2 (please use the new {@link #checkOrder(double[],OrderDirection,boolean) - * checkOrder} method). To be removed in 3.0. - */ - public static void checkOrder(double[] val, int dir, boolean strict) { - if (dir > 0) { - checkOrder(val, OrderDirection.INCREASING, strict); - } else { - checkOrder(val, OrderDirection.DECREASING, strict); - } - } - - /** * Returns the Cartesian norm (2-norm), handling both overflow and underflow. * Translation of the minpack enorm subroutine. * Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=991535&r1=991534&r2=991535&view=diff ============================================================================== --- commons/proper/math/trunk/src/site/xdoc/changes.xml (original) +++ commons/proper/math/trunk/src/site/xdoc/changes.xml Wed Sep 1 13:45:55 2010 @@ -52,6 +52,14 @@ The type attribute can be add,u If the output is not quite correct, check for invisible trailing spaces! --> + + Modified semantics: "equals" methods now consider that NaNs are not + equal (compliant with IEEE754). + Also, two adjacent floating point numbers are considered equal (this + is consistent with the fact that all real numbers between them can be + represented by either of the two). One consequence of that is that + "equals" is not transitive. + Removed methods referring to the concept of "iteration". Removed interface methods to access the number of evaluations of the Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java?rev=991535&r1=991534&r2=991535&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java Wed Sep 1 13:45:55 2010 @@ -447,16 +447,18 @@ public final class MathUtilsTest extends assertFalse(MathUtils.equals(new double[] { 1d }, new double[0])); assertTrue(MathUtils.equals(new double[] { 1d }, new double[] { 1d })); assertTrue(MathUtils.equals(new double[] { - Double.NaN, Double.POSITIVE_INFINITY, + Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1d, 0d }, new double[] { - Double.NaN, Double.POSITIVE_INFINITY, + Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1d, 0d })); + assertFalse(MathUtils.equals(new double[] { Double.NaN }, + new double[] { Double.NaN })); assertFalse(MathUtils.equals(new double[] { Double.POSITIVE_INFINITY }, new double[] { Double.NEGATIVE_INFINITY })); assertFalse(MathUtils.equals(new double[] { 1d }, - new double[] { FastMath.nextAfter(1d, 2d) })); + new double[] { FastMath.nextAfter(FastMath.nextAfter(1d, 2d), 2d) })); }