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 <[email protected]> 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 */
