NUMBERS-53: Fixed broken constructors in Utils and Test methods to accommodate ofReal()
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/b2c947bb Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/b2c947bb Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/b2c947bb Branch: refs/heads/master Commit: b2c947bb831898e6c0340f2e7e98361e7558ac8a Parents: 4924902 Author: Eric Barnhill <[email protected]> Authored: Thu Mar 22 10:37:49 2018 +0100 Committer: Eric Barnhill <[email protected]> Committed: Thu Mar 22 10:37:49 2018 +0100 ---------------------------------------------------------------------- .../commons/numbers/complex/ComplexUtils.java | 8 ++--- .../commons/numbers/complex/CStandardTest.java | 2 +- .../commons/numbers/complex/ComplexTest.java | 32 ++++++++++---------- .../numbers/complex/ComplexUtilsTest.java | 14 ++++----- 4 files changed, 28 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/b2c947bb/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java ---------------------------------------------------------------------- diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java index cdef79f..4684cea 100644 --- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java +++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java @@ -126,7 +126,7 @@ public class ComplexUtils { * @since 1.0 */ public static Complex extractComplexFromRealArray(double[] real, int index) { - return Complex.ofCartesian(real[index]); + return Complex.ofReal(real[index]); } /** @@ -140,7 +140,7 @@ public class ComplexUtils { * @since 1.0 */ public static Complex extractComplexFromRealArray(float[] real, int index) { - return Complex.ofCartesian(real[index]); + return Complex.ofReal(real[index]); } /** @@ -295,7 +295,7 @@ public class ComplexUtils { int index = 0; final Complex c[] = new Complex[real.length]; for (double d : real) { - c[index] = Complex.ofCartesian(d); + c[index] = Complex.ofReal(d); index++; } return c; @@ -313,7 +313,7 @@ public class ComplexUtils { int index = 0; final Complex c[] = new Complex[real.length]; for (float d : real) { - c[index] = Complex.ofCartesian(d); + c[index] = Complex.ofReal(d); index++; } return c; http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/b2c947bb/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 e7a595e..c16622a 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 @@ -90,7 +90,7 @@ public class CStandardTest { @Test public void testImplicitTrig() { - Complex z1 = Complex.ofCartesian(3.0); + Complex z1 = Complex.ofReal(3.0); Complex z2 = Complex.ofCartesian(0.0, 3.0); assertComplex(z1.asin(), negI.multiply(z2.asinh())); assertComplex(z1.atan(), negI.multiply(z2.atanh()), Math.ulp(1), Math.ulp(1)); http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/b2c947bb/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 0a5d3f5..abe4358 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 @@ -112,7 +112,7 @@ public class ComplexTest { public void testScalarAdd() { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = 2.0; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.add(yComplex), x.add(yDouble)); } @@ -120,7 +120,7 @@ public class ComplexTest { public void testScalarAddNaN() { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = Double.NaN; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.add(yComplex), x.add(yDouble)); } @@ -129,7 +129,7 @@ public class ComplexTest { Complex x = Complex.ofCartesian(1, 1); double yDouble = Double.POSITIVE_INFINITY; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.add(yComplex), x.add(yDouble)); x = Complex.ofCartesian(neginf, 0); @@ -222,7 +222,7 @@ public class ComplexTest { public void testScalarDivide() { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = 2.0; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.divide(yComplex), x.divide(yDouble)); } @@ -230,7 +230,7 @@ public class ComplexTest { public void testScalarDivideNaN() { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = Double.NaN; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.divide(yComplex), x.divide(yDouble)); } @@ -295,10 +295,10 @@ public class ComplexTest { public void testScalarMultiply() { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = 2.0; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); int zInt = -5; - Complex zComplex = Complex.ofCartesian(zInt); + Complex zComplex = Complex.ofReal(zInt); Assert.assertEquals(x.multiply(zComplex), x.multiply(zInt)); } @@ -306,7 +306,7 @@ public class ComplexTest { public void testScalarMultiplyNaN() { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = Double.NaN; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); } @@ -314,11 +314,11 @@ public class ComplexTest { public void testScalarMultiplyInf() { Complex x = Complex.ofCartesian(1, 1); double yDouble = Double.POSITIVE_INFINITY; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); yDouble = Double.NEGATIVE_INFINITY; - yComplex = Complex.ofCartesian(yDouble); + yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble)); } @@ -361,7 +361,7 @@ public class ComplexTest { public void testScalarSubtract() { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = 2.0; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); } @@ -369,7 +369,7 @@ public class ComplexTest { public void testScalarSubtractNaN() { Complex x = Complex.ofCartesian(3.0, 4.0); double yDouble = Double.NaN; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); } @@ -377,7 +377,7 @@ public class ComplexTest { public void testScalarSubtractInf() { Complex x = Complex.ofCartesian(1, 1); double yDouble = Double.POSITIVE_INFINITY; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble)); x = Complex.ofCartesian(neginf, 0); @@ -571,7 +571,7 @@ public class ComplexTest { public void testScalarPow() { Complex x = Complex.ofCartesian(3, 4); double yDouble = 5.0; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.pow(yComplex), x.pow(yDouble)); } @@ -579,7 +579,7 @@ public class ComplexTest { public void testScalarPowNaNBase() { Complex x = NAN; double yDouble = 5.0; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.pow(yComplex), x.pow(yDouble)); } @@ -587,7 +587,7 @@ public class ComplexTest { public void testScalarPowNaNExponent() { Complex x = Complex.ofCartesian(3, 4); double yDouble = Double.NaN; - Complex yComplex = Complex.ofCartesian(yDouble); + Complex yComplex = Complex.ofReal(yDouble); Assert.assertEquals(x.pow(yComplex), x.pow(yDouble)); } @Test http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/b2c947bb/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 b57a6b1..7f2cac2 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 @@ -110,7 +110,7 @@ public class ComplexUtilsTest { fi[i] = i; fi[i + 1] = i + 1; c[i / 2] = Complex.ofCartesian(i, i + 1); - cr[i / 2] = Complex.ofCartesian(i / 2); + cr[i / 2] = Complex.ofReal(i / 2); ci[i / 2] = Complex.ofCartesian(0, i / 2); sr[i / 2] = i; si[i / 2] = i + 1; @@ -130,7 +130,7 @@ public class ComplexUtilsTest { fi2d[i][j] = 10 * i + j; fi2d[i][j + 1] = 10 * i + j + 1; c2d[i][j / 2] = Complex.ofCartesian(10 * i + j, 10 * i + j + 1); - cr2d[i][j / 2] = Complex.ofCartesian(10 * i + j / 2); + cr2d[i][j / 2] = Complex.ofReal(10 * i + j / 2); ci2d[i][j / 2] = Complex.ofCartesian(0, 10 * i + j / 2); } } @@ -148,13 +148,13 @@ public class ComplexUtilsTest { fi3d[i][j][k] = 100 * i + 10 * j + k; fi3d[i][j][k + 1] = 100 * i + 10 * j + k + 1; c3d[i][j][k / 2] = Complex.ofCartesian(100 * i + 10 * j + k, 100 * i + 10 * j + k + 1); - cr3d[i][j][k / 2] = Complex.ofCartesian(100 * i + 10 * j + k / 2); + cr3d[i][j][k / 2] = Complex.ofReal(100 * i + 10 * j + k / 2); ci3d[i][j][k / 2] = Complex.ofCartesian(0, 100 * i + 10 * j + k / 2); } } } - ansArrayc1r = new Complex[] { Complex.ofCartesian(3), Complex.ofCartesian(4), Complex.ofCartesian(5), Complex.ofCartesian(6), Complex.ofCartesian(7) }; - ansArrayc2r = new Complex[] { Complex.ofCartesian(3), Complex.ofCartesian(5), Complex.ofCartesian(7) }; + ansArrayc1r = new Complex[] { Complex.ofReal(3), Complex.ofReal(4), Complex.ofReal(5), Complex.ofReal(6), Complex.ofReal(7) }; + ansArrayc2r = new Complex[] { Complex.ofReal(3), Complex.ofReal(5), Complex.ofReal(7) }; ansArrayc1i = new Complex[] { Complex.ofCartesian(0, 3), Complex.ofCartesian(0, 4), Complex.ofCartesian(0, 5), Complex.ofCartesian(0, 6), Complex.ofCartesian(0, 7) }; ansArrayc2i = new Complex[] { Complex.ofCartesian(0, 3), Complex.ofCartesian(0, 5), Complex.ofCartesian(0, 7) }; @@ -244,9 +244,9 @@ public class ComplexUtilsTest { public void testExtractionMethods() { setArrays(); // Extract complex from real double array, index 3 - TestUtils.assertSame(Complex.ofCartesian(3), ComplexUtils.extractComplexFromRealArray(d, 3)); + TestUtils.assertSame(Complex.ofReal(3), ComplexUtils.extractComplexFromRealArray(d, 3)); // Extract complex from real float array, index 3 - TestUtils.assertSame(Complex.ofCartesian(3), ComplexUtils.extractComplexFromRealArray(f, 3)); + TestUtils.assertSame(Complex.ofReal(3), ComplexUtils.extractComplexFromRealArray(f, 3)); // Extract real double from complex array, index 3 TestUtils.assertSame(6, ComplexUtils.extractRealFromComplexArray(c, 3)); // Extract real float from complex array, index 3
