You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2015/05/05 17:01:45 UTC
[math] Use special dummy values to identify pow(x,
y) path without prints.
Repository: commons-math
Updated Branches:
refs/heads/h10-builds 209769691 -> 663f07f0c
Use special dummy values to identify pow(x,y) path without prints.
Beware this is for debug purpose only. It *will* make tests fail.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/663f07f0
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/663f07f0
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/663f07f0
Branch: refs/heads/h10-builds
Commit: 663f07f0c267d77a8114106d993fc0c3554b7127
Parents: 2097696
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue May 5 17:01:30 2015 +0200
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue May 5 17:01:30 2015 +0200
----------------------------------------------------------------------
.../org/apache/commons/math4/util/FastMath.java | 48 ++++++++++----------
.../apache/commons/math4/util/FastMathTest.java | 11 +++--
2 files changed, 30 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/663f07f0/src/main/java/org/apache/commons/math4/util/FastMath.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/util/FastMath.java b/src/main/java/org/apache/commons/math4/util/FastMath.java
index 24bb857..b42f708 100644
--- a/src/main/java/org/apache/commons/math4/util/FastMath.java
+++ b/src/main/java/org/apache/commons/math4/util/FastMath.java
@@ -1461,11 +1461,11 @@ public class FastMath {
final double lns[] = new double[2];
if (y == 0.0) {
- return 1.0;
+ return 100.0;//return 1.0;
}
if (x != x) { // X is NaN
- return x;
+ return 101.0;//return x;
}
if (x == 0) {
@@ -1475,81 +1475,81 @@ public class FastMath {
long yi = (long) y;
if (y < 0 && y == yi && (yi & 1) == 1) {
- return Double.NEGATIVE_INFINITY;
+ return 102.0;//return Double.NEGATIVE_INFINITY;
}
if (y > 0 && y == yi && (yi & 1) == 1) {
- return -0.0;
+ return 103.0;//return -0.0;
}
}
if (y < 0) {
- return Double.POSITIVE_INFINITY;
+ return 104.0;//return Double.POSITIVE_INFINITY;
}
if (y > 0) {
- return 0.0;
+ return 105.0;//return 0.0;
}
- return Double.NaN;
+ return 106.0;// returnDouble.NaN;
}
if (x == Double.POSITIVE_INFINITY) {
if (y != y) { // y is NaN
- return y;
+ return 107.0;//return y;
}
if (y < 0.0) {
- return 0.0;
+ return 108.0;//return 0.0;
} else {
- return Double.POSITIVE_INFINITY;
+ return 109.0;//return Double.POSITIVE_INFINITY;
}
}
if (y == Double.POSITIVE_INFINITY) {
if (x * x == 1.0) {
- return Double.NaN;
+ return 110.0;//return Double.NaN;
}
if (x * x > 1.0) {
- return Double.POSITIVE_INFINITY;
+ return 111.0;//return Double.POSITIVE_INFINITY;
} else {
- return 0.0;
+ return 112.0;//return 0.0;
}
}
if (x == Double.NEGATIVE_INFINITY) {
if (y != y) { // y is NaN
- return y;
+ return 113.0;//return y;
}
if (y < 0) {
long yi = (long) y;
if (y == yi && (yi & 1) == 1) {
- return -0.0;
+ return 114.0;//return -0.0;
}
- return 0.0;
+ return 115.0;//return 0.0;
}
if (y > 0) {
long yi = (long) y;
if (y == yi && (yi & 1) == 1) {
- return Double.NEGATIVE_INFINITY;
+ return 116.0;//return Double.NEGATIVE_INFINITY;
}
- return Double.POSITIVE_INFINITY;
+ return 117.0;//return Double.POSITIVE_INFINITY;
}
}
if (y == Double.NEGATIVE_INFINITY) {
if (x * x == 1.0) {
- return Double.NaN;
+ return 118.0;//return Double.NaN;
}
if (x * x < 1.0) {
- return Double.POSITIVE_INFINITY;
+ return 119.0;//return Double.POSITIVE_INFINITY;
} else {
- return 0.0;
+ return 120.0;//return 0.0;
}
}
@@ -1557,14 +1557,14 @@ public class FastMath {
if (x < 0) {
// y is an even integer in this case
if (y >= TWO_POWER_53 || y <= -TWO_POWER_53) {
- return pow(-x, y);
+ return 121.0;//return pow(-x, y);
}
if (y == (long) y) {
// If y is an integer
- return ((long)y & 1) == 0 ? pow(-x, y) : -pow(-x, y);
+ return 122.0;//return ((long)y & 1) == 0 ? pow(-x, y) : -pow(-x, y);
} else {
- return Double.NaN;
+ return 123.0;//return Double.NaN;
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/663f07f0/src/test/java/org/apache/commons/math4/util/FastMathTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/util/FastMathTest.java b/src/test/java/org/apache/commons/math4/util/FastMathTest.java
index 06f2e63..6ae3a5a 100644
--- a/src/test/java/org/apache/commons/math4/util/FastMathTest.java
+++ b/src/test/java/org/apache/commons/math4/util/FastMathTest.java
@@ -16,12 +16,10 @@
*/
package org.apache.commons.math4.util;
-import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.math.BigInteger;
-import java.util.Arrays;
import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.dfp.Dfp;
@@ -53,17 +51,20 @@ public class FastMathTest {
@Test
public void testH10OneHalfPowerPositiveInfinity() {
- Assert.assertEquals(0.0, FastMath.pow(0.5, Double.POSITIVE_INFINITY), 1.0e-15);
+ final double res = FastMath.pow(0.5, Double.POSITIVE_INFINITY);
+ Assert.assertEquals("0.5^∞ = " + res, 0.0, res, 1.0e-15);
}
@Test
public void testH10MinusZeroPowerPositiveInfinity() {
- Assert.assertEquals(0.0, FastMath.pow(-0.0, Double.POSITIVE_INFINITY), 1.0e-15);
+ final double res = FastMath.pow(-0.0, Double.POSITIVE_INFINITY);
+ Assert.assertEquals("-0.0^∞ = " + res, 0.0, res, 1.0e-15);
}
@Test
public void testH10MinusZeroPowerNaN() {
- Assert.assertTrue(Double.isNaN(FastMath.pow(-0.0, Double.NaN)));
+ final double res = FastMath.pow(-0.0, Double.NaN);
+ Assert.assertTrue("-0.0^NaN = " + res, Double.isNaN(res));
}
@Test