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/04/23 10:51:15 UTC

commons-numbers git commit: NUMBERS-65: Did not commit all changes in previous commit.

Repository: commons-numbers
Updated Branches:
  refs/heads/master a57399c7a -> fa5da2ab4


NUMBERS-65: Did not commit all changes in 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/fa5da2ab
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/fa5da2ab
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/fa5da2ab

Branch: refs/heads/master
Commit: fa5da2ab49420b3475d615b4ea14ae3dd04af854
Parents: a57399c
Author: Eric Barnhill <er...@apache.org>
Authored: Mon Apr 23 12:54:16 2018 +0200
Committer: Eric Barnhill <er...@apache.org>
Committed: Mon Apr 23 12:54:16 2018 +0200

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


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/fa5da2ab/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 dd03536..e65bc10 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
@@ -1256,8 +1256,8 @@ public final class Complex implements Serializable  {
      * @return a List of all {@code n}-th roots of {@code this}.
      */
     public List<Complex> nthRoot(int n) {
-        if (n <= 0) {
-            throw new IllegalArgumentException("cannot compute nth root for null or negative n: {0}");
+        if (n == 0) {
+            throw new IllegalArgumentException("cannot compute zeroth root");
         }
 
         final List<Complex> result = new ArrayList<Complex>();
@@ -1269,7 +1269,7 @@ public final class Complex implements Serializable  {
         final double nthPhi = getArgument() / n;
         final double slice = 2 * Math.PI / n;
         double innerPart = nthPhi;
-        for (int k = 0; k < n ; k++) {
+        for (int k = 0; k < Math.abs(n) ; k++) {
             // inner part
             final double realPart = nthRootOfAbs *  Math.cos(innerPart);
             final double imaginaryPart = nthRootOfAbs *  Math.sin(innerPart);

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/fa5da2ab/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 36fcde8..8247459 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
@@ -737,7 +737,7 @@ public class ComplexTest {
      * Test: compute <b>third roots</b> using a negative argument
      * to go clockwise around the unit circle. Fourth roots of one
      * are taken in both directions around the circle using
-     * positive and negative arguments:
+     * positive and negative arguments.
      * <pre>
      * <code>
      * <b>z = 1</b>