MATH-370
Removed deprecated methods. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@991535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9f631fecc8
commit
495f04bcda
|
@ -407,20 +407,14 @@ public final class MathUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true iff they are equal as defined by
|
* 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 x first value
|
||||||
* @param y second value
|
* @param y second value
|
||||||
* @return {@code true} if the values are equal.
|
* @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) {
|
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
|
* @param y second array
|
||||||
* @return true if the values are both null or have same dimension
|
* @return true if the values are both null or have same dimension
|
||||||
* and equal elements.
|
* 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) {
|
public static boolean equals(double[] x, double[] y) {
|
||||||
if ((x == null) || (y == null)) {
|
if ((x == null) || (y == null)) {
|
||||||
|
@ -1101,29 +1089,6 @@ public final class MathUtils {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the next machine representable number after a number, moving
|
|
||||||
* in the direction of another number.
|
|
||||||
* <p>
|
|
||||||
* If <code>direction</code> is greater than or equal to<code>d</code>,
|
|
||||||
* the smallest machine representable number strictly greater than
|
|
||||||
* <code>d</code> is returned; otherwise the largest representable number
|
|
||||||
* strictly less than <code>d</code> is returned.</p>
|
|
||||||
* <p>
|
|
||||||
* If <code>d</code> is NaN or Infinite, it is returned unchanged.</p>
|
|
||||||
*
|
|
||||||
* @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 2<sup>scaleFactor</sup>.
|
* Scale a number by 2<sup>scaleFactor</sup>.
|
||||||
* <p>If <code>d</code> is 0 or NaN or Infinite, it is returned unchanged.</p>
|
* <p>If <code>d</code> is 0 or NaN or Infinite, it is returned unchanged.</p>
|
||||||
|
@ -1318,23 +1283,23 @@ public final class MathUtils {
|
||||||
switch (roundingMethod) {
|
switch (roundingMethod) {
|
||||||
case BigDecimal.ROUND_CEILING :
|
case BigDecimal.ROUND_CEILING :
|
||||||
if (sign == -1) {
|
if (sign == -1) {
|
||||||
unscaled = FastMath.floor(nextAfter(unscaled, Double.NEGATIVE_INFINITY));
|
unscaled = FastMath.floor(FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY));
|
||||||
} else {
|
} else {
|
||||||
unscaled = FastMath.ceil(nextAfter(unscaled, Double.POSITIVE_INFINITY));
|
unscaled = FastMath.ceil(FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BigDecimal.ROUND_DOWN :
|
case BigDecimal.ROUND_DOWN :
|
||||||
unscaled = FastMath.floor(nextAfter(unscaled, Double.NEGATIVE_INFINITY));
|
unscaled = FastMath.floor(FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY));
|
||||||
break;
|
break;
|
||||||
case BigDecimal.ROUND_FLOOR :
|
case BigDecimal.ROUND_FLOOR :
|
||||||
if (sign == -1) {
|
if (sign == -1) {
|
||||||
unscaled = FastMath.ceil(nextAfter(unscaled, Double.POSITIVE_INFINITY));
|
unscaled = FastMath.ceil(FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY));
|
||||||
} else {
|
} else {
|
||||||
unscaled = FastMath.floor(nextAfter(unscaled, Double.NEGATIVE_INFINITY));
|
unscaled = FastMath.floor(FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BigDecimal.ROUND_HALF_DOWN : {
|
case BigDecimal.ROUND_HALF_DOWN : {
|
||||||
unscaled = nextAfter(unscaled, Double.NEGATIVE_INFINITY);
|
unscaled = FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY);
|
||||||
double fraction = unscaled - FastMath.floor(unscaled);
|
double fraction = unscaled - FastMath.floor(unscaled);
|
||||||
if (fraction > 0.5) {
|
if (fraction > 0.5) {
|
||||||
unscaled = FastMath.ceil(unscaled);
|
unscaled = FastMath.ceil(unscaled);
|
||||||
|
@ -1361,7 +1326,7 @@ public final class MathUtils {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BigDecimal.ROUND_HALF_UP : {
|
case BigDecimal.ROUND_HALF_UP : {
|
||||||
unscaled = nextAfter(unscaled, Double.POSITIVE_INFINITY);
|
unscaled = FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY);
|
||||||
double fraction = unscaled - FastMath.floor(unscaled);
|
double fraction = unscaled - FastMath.floor(unscaled);
|
||||||
if (fraction >= 0.5) {
|
if (fraction >= 0.5) {
|
||||||
unscaled = FastMath.ceil(unscaled);
|
unscaled = FastMath.ceil(unscaled);
|
||||||
|
@ -1376,7 +1341,7 @@ public final class MathUtils {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BigDecimal.ROUND_UP :
|
case BigDecimal.ROUND_UP :
|
||||||
unscaled = FastMath.ceil(nextAfter(unscaled, Double.POSITIVE_INFINITY));
|
unscaled = FastMath.ceil(FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY));
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
throw MathRuntimeException.createIllegalArgumentException(
|
throw MathRuntimeException.createIllegalArgumentException(
|
||||||
|
@ -1904,24 +1869,6 @@ public final class MathUtils {
|
||||||
checkOrder(val, OrderDirection.INCREASING, true);
|
checkOrder(val, OrderDirection.INCREASING, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
* Returns the Cartesian norm (2-norm), handling both overflow and underflow.
|
||||||
* Translation of the minpack enorm subroutine.
|
* Translation of the minpack enorm subroutine.
|
||||||
|
|
|
@ -52,6 +52,14 @@ The <action> type attribute can be add,update,fix,remove.
|
||||||
If the output is not quite correct, check for invisible trailing spaces!
|
If the output is not quite correct, check for invisible trailing spaces!
|
||||||
-->
|
-->
|
||||||
<release version="3.0" date="TBD" description="TBD">
|
<release version="3.0" date="TBD" description="TBD">
|
||||||
|
<action dev="erans" type="update" issue="MATH-370">
|
||||||
|
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.
|
||||||
|
</action>
|
||||||
<action dev="erans" type="update" issue="MATH-397">
|
<action dev="erans" type="update" issue="MATH-397">
|
||||||
Removed methods referring to the concept of "iteration".
|
Removed methods referring to the concept of "iteration".
|
||||||
Removed interface methods to access the number of evaluations of the
|
Removed interface methods to access the number of evaluations of the
|
||||||
|
|
|
@ -447,16 +447,18 @@ public final class MathUtilsTest extends TestCase {
|
||||||
assertFalse(MathUtils.equals(new double[] { 1d }, new double[0]));
|
assertFalse(MathUtils.equals(new double[] { 1d }, new double[0]));
|
||||||
assertTrue(MathUtils.equals(new double[] { 1d }, new double[] { 1d }));
|
assertTrue(MathUtils.equals(new double[] { 1d }, new double[] { 1d }));
|
||||||
assertTrue(MathUtils.equals(new double[] {
|
assertTrue(MathUtils.equals(new double[] {
|
||||||
Double.NaN, Double.POSITIVE_INFINITY,
|
Double.POSITIVE_INFINITY,
|
||||||
Double.NEGATIVE_INFINITY, 1d, 0d
|
Double.NEGATIVE_INFINITY, 1d, 0d
|
||||||
}, new double[] {
|
}, new double[] {
|
||||||
Double.NaN, Double.POSITIVE_INFINITY,
|
Double.POSITIVE_INFINITY,
|
||||||
Double.NEGATIVE_INFINITY, 1d, 0d
|
Double.NEGATIVE_INFINITY, 1d, 0d
|
||||||
}));
|
}));
|
||||||
|
assertFalse(MathUtils.equals(new double[] { Double.NaN },
|
||||||
|
new double[] { Double.NaN }));
|
||||||
assertFalse(MathUtils.equals(new double[] { Double.POSITIVE_INFINITY },
|
assertFalse(MathUtils.equals(new double[] { Double.POSITIVE_INFINITY },
|
||||||
new double[] { Double.NEGATIVE_INFINITY }));
|
new double[] { Double.NEGATIVE_INFINITY }));
|
||||||
assertFalse(MathUtils.equals(new double[] { 1d },
|
assertFalse(MathUtils.equals(new double[] { 1d },
|
||||||
new double[] { FastMath.nextAfter(1d, 2d) }));
|
new double[] { FastMath.nextAfter(FastMath.nextAfter(1d, 2d), 2d) }));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue