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 2019/09/29 01:19:05 UTC

[commons-numbers] branch master updated (7045693 -> 05e7ab8)

This is an automated email from the ASF dual-hosted git repository.

erans pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git.


    from 7045693  NUMBERS-135: Implementation details removed from public API.
     new 3b7ddc8  Links cleanup (Javadoc).
     new 5f066ed  Removed unused constant.
     new 05e7ab8  Javadoc.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/commons/numbers/complex/Complex.java    | 42 ++++++++++------------
 .../commons/numbers/complex/ComplexTest.java       | 26 ++++++++++++--
 2 files changed, 43 insertions(+), 25 deletions(-)


[commons-numbers] 03/03: Javadoc.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 05e7ab8c79129f5e2a451438fdc1d49ee652f5d9
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Sun Sep 29 03:18:03 2019 +0200

    Javadoc.
---
 .../org/apache/commons/numbers/complex/Complex.java |  6 ++----
 .../apache/commons/numbers/complex/ComplexTest.java | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)

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 9c414cf..dc69104 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
@@ -1296,10 +1296,8 @@ public final class Complex implements Serializable  {
      * are respectively the {@link #abs() modulus} and
      * {@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, {@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}.
+     * If one or both parts of this complex number is NaN, a list with all
+     * all elements set to {@code NaN + NaN i} is returned.
      *
      * @param n Degree of root.
      * @return a List of all {@code n}-th roots of {@code this}.
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 1d5be10..be763f9 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
@@ -17,6 +17,7 @@
 
 package org.apache.commons.numbers.complex;
 
+import java.util.List;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
@@ -783,6 +784,26 @@ public class ComplexTest {
         Assertions.assertEquals(0,   fourthRootsOfZ[3].getReal(),      1.0e-5);
         Assertions.assertEquals(1,    fourthRootsOfZ[3].getImaginary(), 1.0e-5);
     }
+
+    @Test
+    public void testNthRootNaN() {
+        final int n = 3;
+        final Complex z = Complex.ofReal(Double.NaN);
+        final List<Complex> r = z.nthRoot(n);
+        Assertions.assertEquals(n, r.size());
+        for (Complex c : r) {
+            Assertions.assertTrue(Double.isNaN(c.real()));
+            Assertions.assertTrue(Double.isNaN(c.imag()));
+        }
+    }
+    @Test
+    public void testNthRootInf() {
+        final int n = 3;
+        final Complex z = Complex.ofReal(Double.NEGATIVE_INFINITY);
+        final List<Complex> r = z.nthRoot(n);
+        Assertions.assertEquals(n, r.size());
+    }
+
     /**
      * Test standard values
      */


[commons-numbers] 02/03: Removed unused constant.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 5f066ed62191263420d491b996c5c22d737702cd
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Sun Sep 29 02:51:54 2019 +0200

    Removed unused constant.
---
 .../src/main/java/org/apache/commons/numbers/complex/Complex.java    | 2 --
 .../test/java/org/apache/commons/numbers/complex/ComplexTest.java    | 5 +++--
 2 files changed, 3 insertions(+), 4 deletions(-)

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 99ebb91..9c414cf 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
@@ -48,8 +48,6 @@ import org.apache.commons.numbers.core.Precision;
 public final class Complex implements Serializable  {
     /** The square root of -1, a.k.a. "i". */
     public static final Complex I = new Complex(0, 1);
-    /** A complex number representing "+INF + INF i" */
-    public static final Complex INF = new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
     /** A complex number representing one. */
     public static final Complex ONE = new Complex(1, 0);
     /** A complex number representing zero. */
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 a105dcc..1d5be10 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
@@ -49,6 +49,7 @@ public class ComplexTest {
     private static final Complex nanNegInf = Complex.ofCartesian(nan, neginf);
     private static final Complex nanZero = Complex.ofCartesian(nan, 0);
     private static final Complex NAN = Complex.ofCartesian(nan, nan);
+    private static final Complex INF = Complex.ofCartesian(inf, inf);
 
     @Test
     public void testConstructor() {
@@ -182,7 +183,7 @@ public class ComplexTest {
     public void testDivideZero() {
         Complex x = Complex.ofCartesian(3.0, 4.0);
         Complex z = x.divide(Complex.ZERO);
-        Assertions.assertEquals(Complex.INF, z);
+        Assertions.assertEquals(INF, z);
     }
 
     @Test
@@ -843,7 +844,7 @@ public class ComplexTest {
         Assertions.assertEquals(Complex.ZERO, Complex.parse(Complex.ZERO.toString()));
         Assertions.assertEquals(Complex.ONE, Complex.parse(Complex.ONE.toString()));
         Assertions.assertEquals(Complex.I, Complex.parse(Complex.I.toString()));
-        Assertions.assertEquals(Complex.INF, Complex.parse(Complex.INF.toString()));
+        Assertions.assertEquals(INF, Complex.parse(INF.toString()));
         Assertions.assertEquals(NAN, Complex.parse(NAN.toString()));
         Assertions.assertEquals(oneInf, Complex.parse(oneInf.toString()));
         Assertions.assertEquals(negInfZero, Complex.parse(negInfZero.toString()));


[commons-numbers] 01/03: Links cleanup (Javadoc).

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 3b7ddc8d12f344bb8406fa50ed2d20c2517a58f1
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Sun Sep 29 02:46:59 2019 +0200

    Links cleanup (Javadoc).
---
 .../apache/commons/numbers/complex/Complex.java    | 34 +++++++++++-----------
 1 file changed, 17 insertions(+), 17 deletions(-)

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 2321466..99ebb91 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
@@ -711,7 +711,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseCosine.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/InverseCosine.html">
      * inverse cosine</a> of this complex number.
      * Implements the formula:
      * <p>
@@ -753,7 +753,7 @@ public final class Complex implements Serializable  {
     }
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseSine.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/InverseSine.html">
      * inverse sine</a> of this complex number.
      * <p>
      *  {@code asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))}
@@ -765,7 +765,7 @@ public final class Complex implements Serializable  {
     }
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/InverseTangent.html">
      * inverse tangent</a> of this complex number.
      * Implements the formula:
      * <p>
@@ -779,7 +779,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseHyperbolicSine.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/InverseHyperbolicSine.html">
      * inverse hyperbolic sine</a> of this complex number.
      * Implements the formula:
      * <p>
@@ -812,7 +812,7 @@ public final class Complex implements Serializable  {
 
    /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseHyperbolicTangent.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/InverseHyperbolicTangent.html">
      * inverse hyperbolic tangent</a> of this complex number.
      * Implements the formula:
      * <p>
@@ -847,7 +847,7 @@ public final class Complex implements Serializable  {
     }
    /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseHyperbolicCosine.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/InverseHyperbolicCosine.html">
      * inverse hyperbolic cosine</a> of this complex number.
      * Implements the formula:
      * <p>
@@ -870,7 +870,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/Cosine.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/Cosine.html">
      * cosine</a> of this complex number.
      * Implements the formula:
      * <p>
@@ -890,7 +890,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/HyperbolicCosine.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/HyperbolicCosine.html">
      * hyperbolic cosine</a> of this complex number.
      * Implements the formula:
      * <pre>
@@ -932,7 +932,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/ExponentialFunction.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/ExponentialFunction.html">
      * exponential function</a> of this complex number.
      * Implements the formula:
      * <pre>
@@ -973,7 +973,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/NaturalLogarithm.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/NaturalLogarithm.html">
      * natural logarithm</a> of this complex number.
      * Implements the formula:
      * <pre>
@@ -1005,7 +1005,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the base 10 or
-     * <a href="http://mathworld.wolfram.com/CommonLogarithm.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/CommonLogarithm.html">
      * common logarithm</a> of this complex number.
      *
      *  @return the base 10 logarithm of <code>this</code>.
@@ -1067,7 +1067,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/Sine.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/Sine.html">
      * sine</a>
      * of this complex number.
      * Implements the formula:
@@ -1089,7 +1089,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/HyperbolicSine.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/HyperbolicSine.html">
      * hyperbolic sine</a> of this complex number.
      * Implements the formula:
      * <pre>
@@ -1132,7 +1132,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/SquareRoot.html">
      * square root</a> of this complex number.
      * Implements the following algorithm to compute {@code sqrt(a + bi)}:
      * <ol><li>Let {@code t = sqrt((|a| + |a + bi|) / 2)}</li>
@@ -1176,7 +1176,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/SquareRoot.html">
      * square root</a> of <code>1 - this<sup>2</sup></code> for this complex
      * number.
      * Computes the result directly as
@@ -1190,7 +1190,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/Tangent.html">
      * tangent</a> of this complex number.
      * Implements the formula:
      * <pre>
@@ -1222,7 +1222,7 @@ public final class Complex implements Serializable  {
 
     /**
      * Compute the
-     * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top">
+     * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html">
      * hyperbolic tangent</a> of this complex number.
      * Implements the formula:
      * <pre>