You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2018/02/14 16:26:42 UTC

[1/2] commons-numbers git commit: Fix unit tests: "Complex.NAN" was made private in a previous commit.

Repository: commons-numbers
Updated Branches:
  refs/heads/master 118a2fdd1 -> af7b1d214


Fix unit tests: "Complex.NAN" was made private in a previous commit.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/d7f354f0
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/d7f354f0
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/d7f354f0

Branch: refs/heads/master
Commit: d7f354f0dcb945ecef5e0b664031631ba63c6cb5
Parents: 58f8953
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Wed Feb 14 17:14:58 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Wed Feb 14 17:16:08 2018 +0100

----------------------------------------------------------------------
 .../apache/commons/numbers/complex/Complex.java |  2 +-
 .../commons/numbers/complex/CStandardTest.java  | 61 ++++++++++----------
 .../commons/numbers/complex/ComplexTest.java    | 24 ++++----
 .../numbers/complex/ComplexUtilsTest.java       | 33 ++++++-----
 4 files changed, 61 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d7f354f0/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index 4490953..835c406 100644
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
+++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
@@ -1211,7 +1211,7 @@ public class Complex implements Serializable  {
      * {@link #getArgument() argument} of this complex number.
      * <p>
      * If one or both parts of this complex number is NaN, a list with just
-     * one element, {@link #NAN} is returned.
+     * one element, {@code NaN + NaN i} is returned.
      * if neither part is NaN, but at least one part is infinite, the result
      * is a one-element list containing {@link #INF}.
      *

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d7f354f0/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java
index e79ce9f..861da5a 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java
@@ -69,6 +69,7 @@ public class CStandardTest {
     private static final Complex piTwoNegZero = new Complex(piOverTwo, -0.0);
     private static final Complex threePiFourNegInf = new Complex(threePiOverFour,negInf);
     private static final Complex piFourNegInf = new Complex(piOverFour, negInf);
+    private static final Complex NAN = new Complex(nan, nan);
     
     public void assertComplex(Complex c1, Complex c2, double realTol, double imagTol) {
         Assert.assertEquals(c1.getReal(), c2.getReal(), realTol);
@@ -115,16 +116,16 @@ public class CStandardTest {
         assertComplex(negZeroZero.acos(), piTwoNegZero);
         assertComplex(zeroNaN.acos(), piTwoNaN);
         assertComplex(oneInf.acos(), piTwoNegInf);
-        assertComplex(oneNaN.acos(), Complex.NAN);
+        assertComplex(oneNaN.acos(), NAN);
         assertComplex(negInfOne.acos(), piNegInf);
         assertComplex(infOne.acos(), zeroNegInf);
         assertComplex(negInfPosInf.acos(), threePiFourNegInf);
         assertComplex(infInf.acos(), piFourNegInf);
         assertComplex(infNaN.acos(), nanInf);
         assertComplex(negInfNaN.acos(), nanNegInf);
-        assertComplex(nanOne.acos(), Complex.NAN);
+        assertComplex(nanOne.acos(), NAN);
         assertComplex(nanInf.acos(), nanNegInf);
-        assertComplex(Complex.NAN.acos(), Complex.NAN);
+        assertComplex(NAN.acos(), NAN);
     }
 
     /**
@@ -136,14 +137,14 @@ public class CStandardTest {
         assertComplex(oneOne.conj().asinh(), oneOne.asinh().conj());
         assertComplex(Complex.ZERO.asinh(), Complex.ZERO);
         assertComplex(oneInf.asinh(), infPiTwo);
-        assertComplex(oneNaN.asinh(), Complex.NAN);
+        assertComplex(oneNaN.asinh(), NAN);
         assertComplex(infOne.asinh(), infZero);
         assertComplex(infInf.asinh(), infPiFour);
         assertComplex(infNaN.asinh(), infNaN);
         assertComplex(nanZero.asinh(), nanZero);
-        assertComplex(nanOne.asinh(), Complex.NAN);
+        assertComplex(nanOne.asinh(), NAN);
         assertComplex(nanInf.asinh(), infNaN);
-        assertComplex(Complex.NAN, Complex.NAN);
+        assertComplex(NAN, NAN);
     }
 
     /**
@@ -156,13 +157,13 @@ public class CStandardTest {
         assertComplex(zeroNaN.atanh(), zeroNaN);
         assertComplex(oneZero.atanh(), infZero);
         assertComplex(oneInf.atanh(),zeroPiTwo);
-        assertComplex(oneNaN.atanh(), Complex.NAN);
+        assertComplex(oneNaN.atanh(), NAN);
         assertComplex(infOne.atanh(), zeroPiTwo);
         assertComplex(infInf.atanh(), zeroPiTwo);
         assertComplex(infNaN.atanh(), zeroNaN);
-        assertComplex(nanOne.atanh(), Complex.NAN);
+        assertComplex(nanOne.atanh(), NAN);
         assertComplex(nanInf.atanh(), zeroPiTwo);
-        assertComplex(Complex.NAN.atanh(), Complex.NAN);
+        assertComplex(NAN.atanh(), NAN);
     }
 
     /**
@@ -174,8 +175,8 @@ public class CStandardTest {
         assertComplex(Complex.ZERO.cosh(), Complex.ONE);
         assertComplex(zeroInf.cosh(), nanZero);
         assertComplex(zeroNaN.cosh(), nanZero);
-        assertComplex(oneInf.cosh(), Complex.NAN);
-        assertComplex(oneNaN.cosh(), Complex.NAN);
+        assertComplex(oneInf.cosh(), NAN);
+        assertComplex(oneNaN.cosh(), NAN);
         assertComplex(infZero.cosh(), infZero);
         // the next test does not appear to make sense:
         // (inf + iy) = inf + cis(y)
@@ -183,8 +184,8 @@ public class CStandardTest {
         assertComplex(infInf.cosh(), infNaN);
         assertComplex(infNaN.cosh(), infNaN);
         assertComplex(nanZero.cosh(), nanZero);
-        assertComplex(nanOne.cosh(), Complex.NAN);
-        assertComplex(Complex.NAN.cosh(), Complex.NAN);
+        assertComplex(nanOne.cosh(), NAN);
+        assertComplex(NAN.cosh(), NAN);
     }
 
     /**
@@ -196,15 +197,15 @@ public class CStandardTest {
         assertComplex(Complex.ZERO.sinh(), Complex.ZERO);
         assertComplex(zeroInf.sinh(), zeroNaN);
         assertComplex(zeroNaN.sinh(), zeroNaN);
-        assertComplex(oneInf.sinh(), Complex.NAN);
-        assertComplex(oneNaN.sinh(), Complex.NAN);
+        assertComplex(oneInf.sinh(), NAN);
+        assertComplex(oneNaN.sinh(), NAN);
         assertComplex(infZero.sinh(), infZero);
         // skipped test similar to previous section
         assertComplex(infInf.sinh(), infNaN);
         assertComplex(infNaN.sinh(), infNaN);
         assertComplex(nanZero.sinh(), nanZero);
-        assertComplex(nanOne.sinh(), Complex.NAN);
-        assertComplex(Complex.NAN.sinh(), Complex.NAN);
+        assertComplex(nanOne.sinh(), NAN);
+        assertComplex(NAN.sinh(), NAN);
     }
 
     /**
@@ -214,14 +215,14 @@ public class CStandardTest {
     public void testTanh() {
         assertComplex(oneOne.tanh().conj(), oneOne.conj().tanh()); // AND CSINH IS ODD
         assertComplex(Complex.ZERO.tanh(), Complex.ZERO);
-        assertComplex(oneInf.tanh(), Complex.NAN);
-        assertComplex(oneNaN.tanh(), Complex.NAN);
+        assertComplex(oneInf.tanh(), NAN);
+        assertComplex(oneNaN.tanh(), NAN);
         //Do Not Understand the Next Test
         assertComplex(infInf.tanh(), oneZero);
         assertComplex(infNaN.tanh(), oneZero);
         assertComplex(nanZero.tanh(), nanZero);
-        assertComplex(nanOne.tanh(), Complex.NAN);
-        assertComplex(Complex.NAN.tanh(), Complex.NAN);
+        assertComplex(nanOne.tanh(), NAN);
+        assertComplex(NAN.tanh(), NAN);
     }
 
     /**
@@ -232,8 +233,8 @@ public class CStandardTest {
         assertComplex(oneOne.conj().exp(), oneOne.exp().conj());
         assertComplex(Complex.ZERO.exp(), oneZero);
         assertComplex(negZeroZero.exp(), oneZero);
-        assertComplex(oneInf.exp(), Complex.NAN);
-        assertComplex(oneNaN.exp(), Complex.NAN);
+        assertComplex(oneInf.exp(), NAN);
+        assertComplex(oneNaN.exp(), NAN);
         assertComplex(infZero.exp(), infZero);
         // Do not understand next test
         assertComplex(negInfInf.exp(), Complex.ZERO);
@@ -241,8 +242,8 @@ public class CStandardTest {
         assertComplex(negInfNaN.exp(), Complex.ZERO);
         assertComplex(infNaN.exp(), infNaN);
         assertComplex(nanZero.exp(), nanZero);
-        assertComplex(nanOne.exp(), Complex.NAN);
-        assertComplex(Complex.NAN.exp(), Complex.NAN);
+        assertComplex(nanOne.exp(), NAN);
+        assertComplex(NAN.exp(), NAN);
     }
 
     /**
@@ -254,14 +255,14 @@ public class CStandardTest {
         assertComplex(negZeroZero.log(), negInfPi); 
         assertComplex(Complex.ZERO.log(), negInfZero);
         assertComplex(oneInf.log(), infPiTwo);
-        assertComplex(oneNaN.log(), Complex.NAN);
+        assertComplex(oneNaN.log(), NAN);
         assertComplex(negInfOne.log(), infPi);
         assertComplex(infOne.log(), infZero);
         assertComplex(infInf.log(), infPiFour);
         assertComplex(infNaN.log(), infNaN);
-        assertComplex(nanOne.log(), Complex.NAN);
+        assertComplex(nanOne.log(), NAN);
         assertComplex(nanInf.log(), infNaN);
-        assertComplex(Complex.NAN.log(), Complex.NAN);
+        assertComplex(NAN.log(), NAN);
     }
 
     /**
@@ -276,7 +277,7 @@ public class CStandardTest {
         assertComplex(infOne.sqrt(), infZero);
         assertComplex(negInfNaN.sqrt(), nanInf);
         assertComplex(infNaN.sqrt(), infNaN);
-        assertComplex(nanOne.sqrt(), Complex.NAN);
-        assertComplex(Complex.NAN.sqrt(), Complex.NAN);
+        assertComplex(nanOne.sqrt(), NAN);
+        assertComplex(NAN.sqrt(), NAN);
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d7f354f0/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
index 3e87320..80b433d 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
@@ -30,7 +30,6 @@ import org.junit.Test;
  */
 public class ComplexTest {
 
-
     private static final double inf = Double.POSITIVE_INFINITY;
     private static final double neginf = Double.NEGATIVE_INFINITY;
     private static final double nan = Double.NaN;
@@ -53,6 +52,7 @@ public class ComplexTest {
     private static final Complex nanInf = new Complex(nan, inf);
     private static final Complex nanNegInf = new Complex(nan, neginf);
     private static final Complex nanZero = new Complex(nan, 0);
+    private static final Complex NAN = new Complex(nan, nan);
 
     @Test
     public void testConstructor() {
@@ -81,7 +81,7 @@ public class ComplexTest {
 
     @Test
     public void testAbsNaN() {
-        Assert.assertTrue(Double.isNaN(Complex.NAN.abs()));
+        Assert.assertTrue(Double.isNaN(NAN.abs()));
         Complex z = new Complex(inf, nan);
         Assert.assertTrue(Double.isNaN(z.abs()));
     }
@@ -146,7 +146,7 @@ public class ComplexTest {
 
     @Test
     public void testConjugateNaN() {
-        Complex z = Complex.NAN.conjugate();
+        Complex z = NAN.conjugate();
         Assert.assertTrue(z.isNaN());
     }
 
@@ -187,20 +187,20 @@ public class ComplexTest {
         Complex x = new Complex(3.0, 4.0);
         Complex z = x.divide(Complex.ZERO);
         // Assert.assertEquals(z, Complex.INF); // See MATH-657
-        Assert.assertEquals(z, Complex.NAN);
+        Assert.assertEquals(z, NAN);
     }
 
     @Test
     public void testDivideZeroZero() {
         Complex x = new Complex(0.0, 0.0);
         Complex z = x.divide(Complex.ZERO);
-        Assert.assertEquals(z, Complex.NAN);
+        Assert.assertEquals(z, NAN);
     }
 
     @Test
     public void testDivideNaN() {
         Complex x = new Complex(3.0, 4.0);
-        Complex z = x.divide(Complex.NAN);
+        Complex z = x.divide(NAN);
         Assert.assertTrue(z.isNaN());
     }
 
@@ -274,7 +274,7 @@ public class ComplexTest {
 
     @Test
     public void testReciprocalNaN() {
-        Assert.assertTrue(Complex.NAN.reciprocal().isNaN());
+        Assert.assertTrue(NAN.reciprocal().isNaN());
     }
 
     @Test
@@ -333,7 +333,7 @@ public class ComplexTest {
 
     @Test
     public void testNegateNaN() {
-        Complex z = Complex.NAN.negate();
+        Complex z = NAN.negate();
         Assert.assertTrue(z.isNaN());
     }
 
@@ -521,7 +521,7 @@ public class ComplexTest {
         Complex realNaN = new Complex(Double.NaN, 0.0);
         Complex imaginaryNaN = new Complex(0.0, Double.NaN);
         Assert.assertEquals(realNaN.hashCode(), imaginaryNaN.hashCode());
-        Assert.assertEquals(imaginaryNaN.hashCode(), Complex.NAN.hashCode());
+        Assert.assertEquals(imaginaryNaN.hashCode(), NAN.hashCode());
 
         // MATH-1118
         // "equals" and "hashCode" must be compatible: if two objects have
@@ -578,7 +578,7 @@ public class ComplexTest {
 
     @Test
     public void testScalarPowNaNBase() {
-        Complex x = Complex.NAN;
+        Complex x = NAN;
         double yDouble = 5.0;
         Complex yComplex = new Complex(yDouble);
         Assert.assertEquals(x.pow(yComplex), x.pow(yDouble));
@@ -616,7 +616,7 @@ public class ComplexTest {
 
     @Test
     public void testSqrt1zNaN() {
-        Assert.assertTrue(Complex.NAN.sqrt1z().isNaN());
+        Assert.assertTrue(NAN.sqrt1z().isNaN());
     }
 
     /**
@@ -799,7 +799,7 @@ public class ComplexTest {
     public void testGetArgumentNaN() {
         Assert.assertTrue(Double.isNaN(nanZero.getArgument()));
         Assert.assertTrue(Double.isNaN(zeroNaN.getArgument()));
-        Assert.assertTrue(Double.isNaN(Complex.NAN.getArgument()));
+        Assert.assertTrue(Double.isNaN(NAN.getArgument()));
     }
 
     /*

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d7f354f0/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexUtilsTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexUtilsTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexUtilsTest.java
index 3989797..8ca143a 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexUtilsTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexUtilsTest.java
@@ -26,16 +26,17 @@ import org.junit.Test;
  */
 public class ComplexUtilsTest {
 
-    private final double inf = Double.POSITIVE_INFINITY;
-    private final double negInf = Double.NEGATIVE_INFINITY;
-    private final double nan = Double.NaN;
-    private final double pi = Math.PI;
+    private static final double inf = Double.POSITIVE_INFINITY;
+    private static final double negInf = Double.NEGATIVE_INFINITY;
+    private static final double nan = Double.NaN;
+    private static final double pi = Math.PI;
 
-    private final Complex negInfInf = new Complex(negInf, inf);
-    private final Complex infNegInf = new Complex(inf, negInf);
-    private final Complex infInf = new Complex(inf, inf);
-    private final Complex negInfNegInf = new Complex(negInf, negInf);
-    private final Complex infNaN = new Complex(inf, nan);
+    private static final Complex negInfInf = new Complex(negInf, inf);
+    private static final Complex infNegInf = new Complex(inf, negInf);
+    private static final Complex infInf = new Complex(inf, inf);
+    private static final Complex negInfNegInf = new Complex(negInf, negInf);
+    private static final Complex infNaN = new Complex(inf, nan);
+    private static final Complex NAN = new Complex(nan, nan);
 
     private static Complex c[]; // complex array with real values even and imag
                                 // values odd
@@ -209,17 +210,17 @@ public class ComplexUtilsTest {
 
     @Test
     public void testPolar2ComplexNaN() {
-        TestUtils.assertSame(Complex.NAN, ComplexUtils.polar2Complex(nan, 1));
-        TestUtils.assertSame(Complex.NAN, ComplexUtils.polar2Complex(1, nan));
-        TestUtils.assertSame(Complex.NAN, ComplexUtils.polar2Complex(nan, nan));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, 1));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, nan));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, nan));
     }
 
     @Test
     public void testPolar2ComplexInf() {
-        TestUtils.assertSame(Complex.NAN, ComplexUtils.polar2Complex(1, inf));
-        TestUtils.assertSame(Complex.NAN, ComplexUtils.polar2Complex(1, negInf));
-        TestUtils.assertSame(Complex.NAN, ComplexUtils.polar2Complex(inf, inf));
-        TestUtils.assertSame(Complex.NAN, ComplexUtils.polar2Complex(inf, negInf));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, inf));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, negInf));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(inf, inf));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(inf, negInf));
         TestUtils.assertSame(infInf, ComplexUtils.polar2Complex(inf, pi / 4));
         TestUtils.assertSame(infNaN, ComplexUtils.polar2Complex(inf, 0));
         TestUtils.assertSame(infNegInf, ComplexUtils.polar2Complex(inf, -pi / 4));


[2/2] commons-numbers git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/commons-numbers

Posted by er...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/commons-numbers


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/af7b1d21
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/af7b1d21
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/af7b1d21

Branch: refs/heads/master
Commit: af7b1d214eae66c9d9228b42c2d6f8a5d5d9c3f4
Parents: d7f354f 118a2fd
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Wed Feb 14 17:17:09 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Wed Feb 14 17:17:09 2018 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/commons/numbers/complex/Complex.java  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/af7b1d21/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
----------------------------------------------------------------------