You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/11/08 18:51:27 UTC

[commons-numbers] branch master updated (1e9d978 -> e47e31d)

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

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


    from 1e9d978  Classes are "final" (ValJO).
     new 9b22dde  Numbers requires Java 8 (not 6).
     new 0f02bba  Use Math.ulp(double) not Math.ulp(float) for Complex test.
     new aec4ea5  Reference conjugate from conj method javadoc.
     new 5d289a7  Use Double.hashCode from JDK 1.8.
     new a3d48c7  Javadoc requires period at end of first line.
     new 397d1a3  Update checkstyle configuration.
     new 27f71ae  Fix spotbugs configuration in build section.
     new 2b03836  Update PMD version from 3.9.0 to 3.12.0.
     new 1e1e408  Ignore checkstyle failures.
     new e9ac506  Fixed javadoc plugin configuration for default target 1.8.
     new 9067e4d  Added license header.
     new 7357e4b  Upgrade to parent 49. Allows build on Java 11.
     new c34dd95  Added .gitattributes for text file line endings.
     new 1bfd5f3  Added default goal.
     new f1e7924  Travis to use default maven goal for all checks.
     new caf92f0  Run a custom Travis install to reduce verbosity.
     new fc8e0ae  End-of-line normalization
     new 5caefb1  Add commons-rng-simple to dependency management.
     new 7775ba7  [NUMBERS-78] Increase test coverage.
     new 594ffad  [NUMBERS-78] Increase test coverage of divide/multiply.
     new 86996be  [NUMBERS-78] Optimise the trigonomic identities.
     new ce3b6d5  Code style and javadoc.
     new 90c8689  Fixed checkstyle in core.
     new 2d0ef91  Fixed checkstyle in complex-streams.
     new d803bf5  Fixed checkstyle in primes.
     new a706656  Suppress MethodName rule in checkstyle for tests.
     new 5326c6a  Fixed checkstyle in quaternion.
     new eb10d9f  Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-numbers
     new 5942878  Fixed checkstyle in fraction.
     new 6592e77  Fixed checkstyle in gamma.
     new c4bf150  Fixed checkstyle in combinatorics.
     new e47e31d  Suppression of ConstantName is in the global checkstyle configuration.

The 32 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:
 .gitattributes                                     |    1 +
 .travis.yml                                        |   12 +-
 commons-numbers-arrays/pom.xml                     |    2 -
 .../numbers/combinatorics/BinomialCoefficient.java |    2 +-
 .../combinatorics/BinomialCoefficientDouble.java   |    2 +-
 .../numbers/combinatorics/Combinations.java        |   10 +-
 .../commons/numbers/combinatorics/Factorial.java   |    5 +-
 .../numbers/combinatorics/FactorialDouble.java     |    6 +-
 .../combinatorics/LogBinomialCoefficient.java      |    2 +-
 .../numbers/combinatorics/LogFactorial.java        |    2 +-
 .../BinomialCoefficientDoubleTest.java             |   12 +-
 .../combinatorics/BinomialCoefficientTest.java     |   30 +-
 .../numbers/combinatorics/CombinationsTest.java    |   22 +-
 .../numbers/combinatorics/FactorialDoubleTest.java |    4 +-
 .../combinatorics/LogBinomialCoefficientTest.java  |   10 +-
 .../numbers/combinatorics/LogFactorialTest.java    |    2 +-
 commons-numbers-complex-streams/README.md          |  210 ++--
 .../numbers/complex/streams/ComplexUtils.java      |   30 +-
 .../numbers/complex/streams/ComplexUtilsTest.java  |   86 +-
 .../commons/numbers/complex/streams/TestUtils.java |   26 +-
 commons-numbers-complex/pom.xml                    |    5 +
 .../apache/commons/numbers/complex/Complex.java    |  843 ++++++++++------
 .../commons/numbers/complex/CStandardTest.java     |  484 ++++++++--
 .../commons/numbers/complex/ComplexTest.java       |  545 +++++++----
 .../apache/commons/numbers/complex/TestUtils.java  |   53 +-
 .../commons/numbers/core/ArithmeticUtils.java      |   21 +-
 .../org/apache/commons/numbers/core/Precision.java |   17 +-
 .../commons/numbers/core/ArithmeticUtilsTest.java  |   71 +-
 .../apache/commons/numbers/core/PrecisionTest.java |   25 +-
 .../org/apache/commons/numbers/core/TestUtils.java |    8 +-
 .../commons/numbers/fraction/BigFraction.java      |    2 +-
 .../apache/commons/numbers/fraction/Fraction.java  |    6 +-
 .../commons/numbers/fraction/BigFractionTest.java  |  130 ++-
 .../commons/numbers/fraction/CommonTestCases.java  |  114 ++-
 .../commons/numbers/fraction/FractionTest.java     |  168 ++--
 .../org/apache/commons/numbers/gamma/Digamma.java  |    3 +-
 .../java/org/apache/commons/numbers/gamma/Erf.java |    3 +-
 .../commons/numbers/gamma/ErfDifference.java       |    3 +-
 .../org/apache/commons/numbers/gamma/Erfc.java     |    3 +-
 .../org/apache/commons/numbers/gamma/Gamma.java    |    3 +-
 .../apache/commons/numbers/gamma/InvGamma1pm1.java |    4 +-
 .../apache/commons/numbers/gamma/InverseErf.java   |    3 +-
 .../apache/commons/numbers/gamma/InverseErfc.java  |    3 +-
 .../numbers/gamma/LanczosApproximation.java        |    3 +-
 .../org/apache/commons/numbers/gamma/LogBeta.java  |   16 +-
 .../org/apache/commons/numbers/gamma/LogGamma.java |    3 +-
 .../apache/commons/numbers/gamma/LogGamma1p.java   |    3 +-
 .../apache/commons/numbers/gamma/LogGammaSum.java  |    3 +-
 .../commons/numbers/gamma/RegularizedBeta.java     |    3 +-
 .../commons/numbers/gamma/RegularizedGamma.java    |    7 +-
 .../org/apache/commons/numbers/gamma/Trigamma.java |    3 +-
 .../apache/commons/numbers/gamma/DigammaTest.java  |   10 +-
 .../commons/numbers/gamma/ErfDifferenceTest.java   |    6 +-
 .../org/apache/commons/numbers/gamma/ErfTest.java  |    2 +-
 .../apache/commons/numbers/gamma/GammaTest.java    |  923 +++++++++---------
 .../commons/numbers/gamma/InvGamma1pm1Test.java    |   44 +-
 .../commons/numbers/gamma/InverseErfcTest.java     |    2 +-
 .../apache/commons/numbers/gamma/LogBetaTest.java  | 1008 ++++++++++----------
 .../commons/numbers/gamma/LogGamma1pTest.java      |   38 +-
 .../commons/numbers/gamma/LogGammaSumTest.java     |  168 ++--
 .../apache/commons/numbers/gamma/LogGammaTest.java |  304 +++---
 .../apache/commons/numbers/gamma/TrigammaTest.java |   26 +-
 .../org/apache/commons/numbers/primes/Primes.java  |    7 +-
 .../apache/commons/numbers/primes/SmallPrimes.java |   63 +-
 .../apache/commons/numbers/primes/PrimesTest.java  |   96 +-
 .../commons/numbers/primes/SmallPrimesTest.java    |   32 +-
 .../commons/numbers/quaternion/Quaternion.java     |   12 +-
 .../commons/numbers/quaternion/QuaternionTest.java |   18 +-
 .../commons/numbers/quaternion/SlerpTest.java      |   54 +-
 pom.xml                                            |   93 +-
 .../checkstyle-suppressions.xml}                   |   17 +-
 src/main/resources/checkstyle/checkstyle.xml       |  291 +++---
 .../resources/spotbugs/spotbugs-exclude-filter.xml |    7 +-
 73 files changed, 3566 insertions(+), 2689 deletions(-)
 create mode 100644 .gitattributes
 copy src/main/resources/{clirr/clirr-ignored.xml => checkstyle/checkstyle-suppressions.xml} (52%)


[commons-numbers] 07/32: Fix spotbugs configuration in build section.

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

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

commit 27f71ae31852905feef8ad2a821a65fad911ce78
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 22:49:45 2019 +0000

    Fix spotbugs configuration in build section.
    
    Added an exclusion for the BrentSolver.
---
 pom.xml                                                 | 5 +++++
 src/main/resources/spotbugs/spotbugs-exclude-filter.xml | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 9958e8c..f44a230 100644
--- a/pom.xml
+++ b/pom.xml
@@ -265,6 +265,11 @@
         <groupId>com.github.spotbugs</groupId>
         <artifactId>spotbugs-maven-plugin</artifactId>
         <version>${commons.spotbugs.version}</version>
+        <configuration>
+          <threshold>Normal</threshold>
+          <effort>Default</effort>
+          <excludeFilterFile>${numbers.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile>
+        </configuration>
       </plugin>
       <plugin>
         <groupId>org.apache.rat</groupId>
diff --git a/src/main/resources/spotbugs/spotbugs-exclude-filter.xml b/src/main/resources/spotbugs/spotbugs-exclude-filter.xml
index 9993593..d533776 100644
--- a/src/main/resources/spotbugs/spotbugs-exclude-filter.xml
+++ b/src/main/resources/spotbugs/spotbugs-exclude-filter.xml
@@ -26,6 +26,11 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="https://github.com/spotbugs/filter/3.1.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
 
-  <Class name="~.*\.jmh\.generated\..*" />
+  <Match>
+    <!-- The Brent method deliberately checks equality. -->
+    <Class name="org.apache.commons.numbers.rootfinder.BrentSolver"/>
+    <Method name="brent"/>
+    <BugPattern name="FE_FLOATING_POINT_EQUALITY"/>
+  </Match>
 
 </FindBugsFilter>


[commons-numbers] 13/32: Added .gitattributes for text file line endings.

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

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

commit c34dd95b54f8d366da6756884d17d95e477417fc
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 23:40:09 2019 +0000

    Added .gitattributes for text file line endings.
---
 .gitattributes | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..97037d1
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+*         text=auto


[commons-numbers] 21/32: [NUMBERS-78] Optimise the trigonomic identities.

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

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

commit 86996be0572bf5de61ae3177b851070d34e1cfb6
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 17:14:35 2019 +0000

    [NUMBERS-78] Optimise the trigonomic identities.
    
    Use a static method that accepts (real, imaginary) and a functional
    interface for the Complex constructor.
    
    The identities have the same runtime as the original complex function
    that is used by the identity.
---
 .../apache/commons/numbers/complex/Complex.java    | 247 ++++++++++++++-------
 1 file changed, 161 insertions(+), 86 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 3a86fd3..ce2c5e4 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
@@ -66,8 +66,6 @@ public final class Complex implements Serializable  {
     private static final double PI_OVER_2 = 0.5 * Math.PI;
     /** &pi;/4. */
     private static final double PI_OVER_4 = 0.25 * Math.PI;
-    /** "-i". */
-    private static final Complex MINUS_I = new Complex(0, -1);
 
     /** Serializable version identifier. */
     private static final long serialVersionUID = 20180201L;
@@ -85,6 +83,22 @@ public final class Complex implements Serializable  {
     private final double real;
 
     /**
+     * Define a constructor for a Complex.
+     * This is used in functions that implement trigonomic identities.
+     */
+    @FunctionalInterface
+    private interface ComplexConstructor {
+        /**
+         * Create a complex number given the real and imaginary parts.
+         *
+         * @param real Real part.
+         * @param imaginary Imaginary part.
+         * @return {@code Complex} object
+         */
+        Complex create(double real, double imaginary);
+    }
+
+    /**
      * Private default constructor.
      *
      * @param real Real part.
@@ -863,23 +877,27 @@ public final class Complex implements Serializable  {
                    imaginary == Double.POSITIVE_INFINITY) {
             return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
         }
-        return add(sqrt1z().multiply(I)).log().multiply(I.negate());
+        return add(sqrt1z().multiplyByI()).log().multiplyByNegI();
     }
     /**
      * Compute the
      * <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))}
-     * </p><p>
+     * <pre>
+     *  asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))
+     * </pre>
+     *
+     * <p>As per the C.99 standard this function is computed using the trigonomic identity:</p>
+     * <pre>
+     *   asin(z) = -i asinh(iz)
+     * </pre>
+     *
      * @return the inverse sine of this complex number
      */
     public Complex asin() {
         // Define in terms of asinh
         // asin(z) = -i asinh(iz)
         return multiplyByI().asinh().multiplyByNegI();
-
-        //return sqrt1z().add(multiply(I)).log().multiply(I.negate());
     }
 
     /**
@@ -887,18 +905,21 @@ public final class Complex implements Serializable  {
      * <a href="http://mathworld.wolfram.com/InverseTangent.html">
      * inverse tangent</a> of this complex number.
      * Implements the formula:
-     * <p>
-     * {@code atan(z) = (i/2) log((i + z)/(i - z))}
-     * </p><p>
+     * <pre>
+     *  atan(z) = (i/2) log((i + z)/(i - z))
+     * </pre>
+     *
+     * <p>As per the C.99 standard this function is computed using the trigonomic identity:</p>
+     * <pre>
+     *   atan(z) = -i atanh(iz)
+     * </pre>
+     *
      * @return the inverse tangent of this complex number
      */
     public Complex atan() {
         // Define in terms of atanh
         // atan(z) = -i atanh(iz)
         return multiplyByI().atanh().multiplyByNegI();
-
-        // This is not exact to 1 ulp
-        //return add(I).divide(I.subtract(this)).log().multiply(I.multiply(0.5));
     }
 
     /**
@@ -924,10 +945,11 @@ public final class Complex implements Serializable  {
      * <a href="http://mathworld.wolfram.com/InverseHyperbolicSine.html">
      * inverse hyperbolic sine</a> of this complex number.
      * Implements the formula:
-     * <p>
-     * {@code asinh(z) = log(z+sqrt(z^2+1))}
-     * </p><p>
-     * @return the inverse hyperbolic cosine of this complex number
+     * <pre>
+     *   asinh(z) = log(z+sqrt(z^2+1))
+     * </pre>
+     *
+     * @return the inverse hyperbolic sine of this complex number
      */
     public Complex asinh() {
         if (neitherInfiniteNorZeroNorNaN(real) &&
@@ -952,15 +974,16 @@ public final class Complex implements Serializable  {
         return square().add(ONE).sqrt().add(this).log();
     }
 
-   /**
+    /**
      * Compute the
      * <a href="http://mathworld.wolfram.com/InverseHyperbolicTangent.html">
      * inverse hyperbolic tangent</a> of this complex number.
      * Implements the formula:
-     * <p>
-     * {@code atanh(z) = log((1+z)/(1-z))/2}
-     * </p><p>
-     * @return the inverse hyperbolic cosine of this complex number
+     * <pre>
+     *   atanh(z) = log((1+z)/(1-z))/2
+     * </pre>
+     *
+     * @return the inverse hyperbolic tangent of this complex number
      */
     public Complex atanh() {
         if (real == 0 &&
@@ -993,9 +1016,9 @@ public final class Complex implements Serializable  {
      * <a href="http://mathworld.wolfram.com/InverseHyperbolicCosine.html">
      * inverse hyperbolic cosine</a> of this complex number.
      * Implements the formula:
-     * <p>
-     * {@code acosh(z) = log(z+sqrt(z^2-1))}
-     * </p>
+     * <pre>
+     *   acosh(z) = log(z+sqrt(z^2-1))
+     * </pre>
      *
      * @return the inverse hyperbolic cosine of this complex number
      */
@@ -1058,23 +1081,25 @@ public final class Complex implements Serializable  {
      * <a href="http://mathworld.wolfram.com/Cosine.html">
      * cosine</a> of this complex number.
      * Implements the formula:
-     * <p>
-     * {@code cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i}
-     * </p><p>
+     * <pre>
+     *   cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i}
+     * </pre>
      * where the (real) functions on the right-hand side are
      * {@link Math#sin}, {@link Math#cos},
      * {@link Math#cosh} and {@link Math#sinh}.
-     * </p><p>
+     *
+     * <p>As per the C.99 standard this function is computed using the trigonomic identity:</p>
+     * <pre>
+     *   cos(z) = cosh(iz)
+     * </pre>
      *
      * @return the cosine of this complex number.
      */
     public Complex cos() {
         // Define in terms of cosh
         // cos(z) = cosh(iz)
-        return multiplyByI().cosh();
-
-        //return new Complex(Math.cos(real) * Math.cosh(imaginary),
-        //                  -Math.sin(real) * Math.sinh(imaginary));
+        // Multiply this number by I and compute cosh.
+        return cosh(-imaginary, real, Complex::ofCartesian);
     }
 
     /**
@@ -1083,37 +1108,49 @@ public final class Complex implements Serializable  {
      * hyperbolic cosine</a> of this complex number.
      * Implements the formula:
      * <pre>
-     *  <code>
      *   cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i
-     *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
      * {@link Math#sin}, {@link Math#cos},
      * {@link Math#cosh} and {@link Math#sinh}.
-     * <p>
      *
      * @return the hyperbolic cosine of this complex number.
      */
     public Complex cosh() {
+        return cosh(real, imaginary, Complex::ofCartesian);
+    }
+
+    /**
+     * Compute the hyperbolic cosine of the complex number.
+     *
+     * <p>This function exists to allow implementation of the identity
+     * {@code cos(z) = cosh(iz)}.<p>
+     *
+     * @param real Real part.
+     * @param imaginary Imaginary part.
+     * @param constructor Constructor.
+     * @return the hyperbolic cosine of this complex number
+     */
+    private static Complex cosh(double real, double imaginary, ComplexConstructor constructor) {
         if (real == 0 &&
             imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.NaN, 0);
+            return constructor.create(Double.NaN, 0);
         } else if (real == 0 &&
                    Double.isNaN(imaginary)) {
-            return new Complex(Double.NaN, 0);
+            return constructor.create(Double.NaN, 0);
         } else if (real == Double.POSITIVE_INFINITY &&
                    imaginary == 0) {
-            return new Complex(Double.POSITIVE_INFINITY, 0);
+            return constructor.create(Double.POSITIVE_INFINITY, 0);
         } else if (real == Double.POSITIVE_INFINITY &&
                    (imaginary == Double.POSITIVE_INFINITY || Double.isNaN(imaginary))) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+            return constructor.create(Double.POSITIVE_INFINITY, Double.NaN);
         } else if (Double.isNaN(real) &&
                    imaginary == 0) {
-            return new Complex(Double.NaN, 0);
+            return constructor.create(Double.NaN, 0);
         }
 
-        return new Complex(Math.cosh(real) * Math.cos(imaginary),
-                           Math.sinh(real) * Math.sin(imaginary));
+        return constructor.create(Math.cosh(real) * Math.cos(imaginary),
+                                  Math.sinh(real) * Math.sin(imaginary));
     }
 
     /**
@@ -1264,23 +1301,24 @@ public final class Complex implements Serializable  {
      * of this complex number.
      * Implements the formula:
      * <pre>
-     *  <code>
      *   sin(a + bi) = sin(a)cosh(b) - cos(a)sinh(b)i
-     *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
      * {@link Math#sin}, {@link Math#cos},
      * {@link Math#cosh} and {@link Math#sinh}.
      *
+     * <p>As per the C.99 standard this function is computed using the trigonomic identity:</p>
+     * <pre>
+     *   sin(z) = -i sinh(iz)
+     * </pre>
+     *
      * @return the sine of this complex number.
      */
     public Complex sin() {
         // Define in terms of sinh
         // sin(z) = -i sinh(iz)
-        return multiplyByI().sinh().multiplyByNegI();
-
-        //return new Complex(Math.sin(real) * Math.cosh(imaginary),
-        //                   Math.cos(real) * Math.sinh(imaginary));
+        // Multiply this number by I, compute cosh, then multiply by back
+        return sinh(-imaginary, real, Complex::multiplyNegativeI);
     }
 
     /**
@@ -1300,30 +1338,48 @@ public final class Complex implements Serializable  {
      * @return the hyperbolic sine of {@code this}.
      */
     public Complex sinh() {
+        return sinh(real, imaginary, Complex::ofCartesian);
+    }
+
+    /**
+     * Compute the hyperbolic sine of the complex number.
+     *
+     * <p>This function exists to allow implementation of the identity
+     * {@code sin(z) = -i sinh(iz)}.<p>
+     *
+     * @param real Real part.
+     * @param imaginary Imaginary part.
+     * @param constructor Constructor.
+     * @return the hyperbolic sine of this complex number
+     */
+    private static Complex sinh(double real, double imaginary, ComplexConstructor constructor) {
         if (real == 0 &&
             imaginary == 0) {
+            // Ignore the constructor.
+            // It is used in trignomic identities to multiply the result by -i.
+            // Here the result would still be zero.
             return Complex.ZERO;
         } else if (real == 0 &&
                    imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(0, Double.NaN);
+            return constructor.create(0, Double.NaN);
         } else if (real == 0 &&
                    Double.isNaN(imaginary)) {
-            return new Complex(0, Double.NaN);
+            return constructor.create(0, Double.NaN);
         } else if (real == Double.POSITIVE_INFINITY &&
                    imaginary == 0) {
-            return new Complex(Double.POSITIVE_INFINITY, 0);
+            return constructor.create(Double.POSITIVE_INFINITY, 0);
         } else if (real == Double.POSITIVE_INFINITY &&
                    imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+            return constructor.create(Double.POSITIVE_INFINITY, Double.NaN);
         } else if (real == Double.POSITIVE_INFINITY &&
                    Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+            return constructor.create(Double.POSITIVE_INFINITY, Double.NaN);
         } else if (Double.isNaN(real) &&
                    imaginary == 0) {
-            return new Complex(Double.NaN, 0);
+            return constructor.create(Double.NaN, 0);
         }
-        return new Complex(Math.sinh(real) * Math.cos(imaginary),
-                           Math.cosh(real) * Math.sin(imaginary));
+        return constructor.create(Math.sinh(real) * Math.cos(imaginary),
+                                  Math.cosh(real) * Math.sin(imaginary));
     }
 
     /**
@@ -1389,34 +1445,24 @@ public final class Complex implements Serializable  {
      * tangent</a> of this complex number.
      * Implements the formula:
      * <pre>
-     *  <code>
      *   tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i
-     *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
      * {@link Math#sin}, {@link Math#cos}, {@link Math#cosh} and
      * {@link Math#sinh}.
      *
+     * <p>As per the C.99 standard this function is computed using the trigonomic identity:</p>
+     * <pre>
+     *   tan(z) = -i tanh(iz)
+     * </pre>
+     *
      * @return the tangent of {@code this}.
      */
     public Complex tan() {
         // Define in terms of tanh
         // tan(z) = -i tanh(iz)
-        return multiplyByI().tanh().multiplyByNegI();
-
-        //if (imaginary > 20) {
-        //    return ONE;
-        //}
-        //if (imaginary < -20) {
-        //    return MINUS_I;
-        //}
-        //
-        //final double real2 = 2 * real;
-        //final double imaginary2 = 2 * imaginary;
-        //final double d = Math.cos(real2) + Math.cosh(imaginary2);
-        //
-        //return new Complex(Math.sin(real2) / d,
-        //                   Math.sinh(imaginary2) / d);
+        // Multiply this number by I, compute cosh, then multiply by back
+        return tanh(-imaginary, real, Complex::multiplyNegativeI);
     }
 
     /**
@@ -1425,9 +1471,7 @@ public final class Complex implements Serializable  {
      * hyperbolic tangent</a> of this complex number.
      * Implements the formula:
      * <pre>
-     *  <code>
      *   tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i
-     *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
      * {@link Math#sin}, {@link Math#cos}, {@link Math#cosh} and
@@ -1436,27 +1480,41 @@ public final class Complex implements Serializable  {
      * @return the hyperbolic tangent of {@code this}.
      */
     public Complex tanh() {
+        return tanh(real, imaginary, Complex::ofCartesian);
+    }
+
+    /**
+     * Compute the hyperbolic tangent of this complex number.
+     *
+     * <p>This function exists to allow implementation of the identity
+     * {@code tan(z) = -i tanh(iz)}.<p>
+     *
+     * @param real Real part.
+     * @param imaginary Imaginary part.
+     * @param constructor Constructor.
+     * @return the hyperbolic tangent of this complex number
+     */
+    private static Complex tanh(double real, double imaginary, ComplexConstructor constructor) {
         // TODO - should these checks be made on real2 and imaginary2?
+        // Compare to other library implementations.
+        //
         // Math.cos and Math.sin return NaN for infinity.
         // Math.cosh returns positive infinity for infinity.
         // Math.sinh returns the input infinity for infinity.
 
         if (real == Double.POSITIVE_INFINITY &&
-            imaginary == Double.POSITIVE_INFINITY) {
-            return ONE;
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return ONE;
+            (imaginary == Double.POSITIVE_INFINITY || Double.isNaN(imaginary))) {
+            return constructor.create(1, 0);
         } else if (Double.isNaN(real) &&
                    imaginary == 0) {
-            return new Complex(Double.NaN, 0);
+            return constructor.create(Double.NaN, 0);
         }
         final double real2 = 2 * real;
         final double imaginary2 = 2 * imaginary;
         final double d = Math.cosh(real2) + Math.cos(imaginary2);
 
-        return new Complex(Math.sinh(real2) / d,
-                           Math.sin(imaginary2) / d);
+        return constructor.create(Math.sinh(real2) / d,
+                                  Math.sin(imaginary2) / d);
     }
 
    /**
@@ -1594,7 +1652,24 @@ public final class Complex implements Serializable  {
         return (Double.isFinite(d) && d > 0) || Double.doubleToLongBits(d) == 0;
     }
 
-    /** See {@link #parse(String)}. */
+    /**
+     * Create a complex number given the real and imaginary parts, then multiply by {@code -i}.
+     * This is used in functions that implement trigonomic identities. It is the functional
+     * equivalent of:
+     *
+     * <pre>
+     *  z = new Complex(real, imaginary).multiply(new Complex(0, -1));
+     * </pre>
+     *
+     * @param real Real part.
+     * @param imaginary Imaginary part.
+     * @return {@code Complex} object
+     */
+    private static Complex multiplyNegativeI(double real, double imaginary) {
+        return new Complex(imaginary, -real);
+    }
+
+     /** See {@link #parse(String)}. */
     private static class ComplexParsingException extends NumberFormatException {
         /** Serializable version identifier. */
         private static final long serialVersionUID = 20180430L;


[commons-numbers] 16/32: Run a custom Travis install to reduce verbosity.

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

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

commit caf92f02891bd6deb2a6675233216e4e1c2b58a5
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Thu Nov 7 00:43:46 2019 +0000

    Run a custom Travis install to reduce verbosity.
    
    This that hides all the Maven ‘Downloading’ messages.
---
 .travis.yml | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 65de1db..54e6a5b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,9 +18,10 @@ language: java
 jdk:
   - openjdk8
 
-# Skip the installation step:
-#   https://docs.travis-ci.com/user/job-lifecycle/#skipping-the-installation-phase
-install: true
+# The default build is so verbose the travis log file can exceed the allowed limit.
+# Run a custom install that hides all the Maven ‘Downloading’ messages.
+install:
+  - mvn install -Dmaven.javadoc.skip=true -V -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
 
 script:
   - mvn


[commons-numbers] 17/32: End-of-line normalization

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

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

commit fc8e0ae99f822552ce5f51885577d7faf504bf18
Author: aherbert <ah...@apache.org>
AuthorDate: Thu Nov 7 10:30:10 2019 +0000

    End-of-line normalization
---
 commons-numbers-complex-streams/README.md | 210 +++++++++++++++---------------
 1 file changed, 105 insertions(+), 105 deletions(-)

diff --git a/commons-numbers-complex-streams/README.md b/commons-numbers-complex-streams/README.md
index 30a03eb..9d8f917 100644
--- a/commons-numbers-complex-streams/README.md
+++ b/commons-numbers-complex-streams/README.md
@@ -1,105 +1,105 @@
-<!---
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements.  See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!---
- +======================================================================+
- |****                                                              ****|
- |****      THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN      ****|
- |****                    DO NOT EDIT DIRECTLY                      ****|
- |****                                                              ****|
- +======================================================================+
- | TEMPLATE FILE: readme-md-template.md                                 |
- | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
- +======================================================================+
- |                                                                      |
- | 1) Re-generate using: mvn commons:readme-md                          |
- |                                                                      |
- | 2) Set the following properties in the component's pom:              |
- |    - commons.componentid (required, alphabetic, lower case)          |
- |    - commons.release.version (required)                              |
- |                                                                      |
- | 3) Example Properties                                                |
- |                                                                      |
- |  <properties>                                                        |
- |    <commons.componentid>math</commons.componentid>                   |
- |    <commons.release.version>1.2</commons.release.version>            |
- |  </properties>                                                       |
- |                                                                      |
- +======================================================================+
---->
-Apache Commons Numbers Complex Streams
-===================
-
-[![Build Status](https://travis-ci.org/apache/commons-numbers-complex-streams.svg?branch=master)](https://travis-ci.org/apache/commons-numbers-complex-streams)
-[![Coverage Status](https://coveralls.io/repos/apache/commons-numbers-complex-streams/badge.svg?branch=master)](https://coveralls.io/r/apache/commons-numbers-complex-streams)
-[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-numbers-complex-streams/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-numbers-complex-streams/)
-[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
-
-Arrays, streams and collections of complex numbers.
-
-Documentation
--------------
-
-More information can be found on the [Apache Commons Numbers Complex Streams homepage](https://commons.apache.org/proper/commons-numbers).
-The [JavaDoc](https://commons.apache.org/proper/commons-numbers/javadocs/api-release) can be browsed.
-Questions related to the usage of Apache Commons Numbers Complex Streams should be posted to the [user mailing list][ml].
-
-Where can I get the latest release?
------------------------------------
-You can download source and binaries from our [download page](https://commons.apache.org/proper/commons-numbers/download_numbers.cgi).
-
-Alternatively you can pull it from the central Maven repositories:
-
-```xml
-<dependency>
-  <groupId>org.apache.commons</groupId>
-  <artifactId>commons-numbers-complex-streams</artifactId>
-  <version>1.0</version>
-</dependency>
-```
-
-Contributing
-------------
-
-We accept Pull Requests via GitHub. The [developer mailing list][ml] is the main channel of communication for contributors.
-There are some guidelines which will make applying PRs easier for us:
-+ No tabs! Please use spaces for indentation.
-+ Respect the code style.
-+ Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
-+ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running ```mvn clean test```.
-
-If you plan to contribute on a regular basis, please consider filing a [contributor license agreement](https://www.apache.org/licenses/#clas).
-You can learn more about contributing via GitHub in our [contribution guidelines](CONTRIBUTING.md).
-
-License
--------
-This code is under the [Apache Licence v2](https://www.apache.org/licenses/LICENSE-2.0).
-
-See the `NOTICE.txt` file for required notices and attributions.
-
-Donations
----------
-You like Apache Commons Numbers Complex Streams? Then [donate back to the ASF](https://www.apache.org/foundation/contributing.html) to support the development.
-
-Additional Resources
---------------------
-
-+ [Apache Commons Homepage](https://commons.apache.org/)
-+ [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/NUMBERS)
-+ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
-+ `#apache-commons` IRC channel on `irc.freenode.org`
-
-[ml]:https://commons.apache.org/mail-lists.html
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!---
+ +======================================================================+
+ |****                                                              ****|
+ |****      THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN      ****|
+ |****                    DO NOT EDIT DIRECTLY                      ****|
+ |****                                                              ****|
+ +======================================================================+
+ | TEMPLATE FILE: readme-md-template.md                                 |
+ | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+ +======================================================================+
+ |                                                                      |
+ | 1) Re-generate using: mvn commons:readme-md                          |
+ |                                                                      |
+ | 2) Set the following properties in the component's pom:              |
+ |    - commons.componentid (required, alphabetic, lower case)          |
+ |    - commons.release.version (required)                              |
+ |                                                                      |
+ | 3) Example Properties                                                |
+ |                                                                      |
+ |  <properties>                                                        |
+ |    <commons.componentid>math</commons.componentid>                   |
+ |    <commons.release.version>1.2</commons.release.version>            |
+ |  </properties>                                                       |
+ |                                                                      |
+ +======================================================================+
+--->
+Apache Commons Numbers Complex Streams
+===================
+
+[![Build Status](https://travis-ci.org/apache/commons-numbers-complex-streams.svg?branch=master)](https://travis-ci.org/apache/commons-numbers-complex-streams)
+[![Coverage Status](https://coveralls.io/repos/apache/commons-numbers-complex-streams/badge.svg?branch=master)](https://coveralls.io/r/apache/commons-numbers-complex-streams)
+[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-numbers-complex-streams/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-numbers-complex-streams/)
+[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
+
+Arrays, streams and collections of complex numbers.
+
+Documentation
+-------------
+
+More information can be found on the [Apache Commons Numbers Complex Streams homepage](https://commons.apache.org/proper/commons-numbers).
+The [JavaDoc](https://commons.apache.org/proper/commons-numbers/javadocs/api-release) can be browsed.
+Questions related to the usage of Apache Commons Numbers Complex Streams should be posted to the [user mailing list][ml].
+
+Where can I get the latest release?
+-----------------------------------
+You can download source and binaries from our [download page](https://commons.apache.org/proper/commons-numbers/download_numbers.cgi).
+
+Alternatively you can pull it from the central Maven repositories:
+
+```xml
+<dependency>
+  <groupId>org.apache.commons</groupId>
+  <artifactId>commons-numbers-complex-streams</artifactId>
+  <version>1.0</version>
+</dependency>
+```
+
+Contributing
+------------
+
+We accept Pull Requests via GitHub. The [developer mailing list][ml] is the main channel of communication for contributors.
+There are some guidelines which will make applying PRs easier for us:
++ No tabs! Please use spaces for indentation.
++ Respect the code style.
++ Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
++ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running ```mvn clean test```.
+
+If you plan to contribute on a regular basis, please consider filing a [contributor license agreement](https://www.apache.org/licenses/#clas).
+You can learn more about contributing via GitHub in our [contribution guidelines](CONTRIBUTING.md).
+
+License
+-------
+This code is under the [Apache Licence v2](https://www.apache.org/licenses/LICENSE-2.0).
+
+See the `NOTICE.txt` file for required notices and attributions.
+
+Donations
+---------
+You like Apache Commons Numbers Complex Streams? Then [donate back to the ASF](https://www.apache.org/foundation/contributing.html) to support the development.
+
+Additional Resources
+--------------------
+
++ [Apache Commons Homepage](https://commons.apache.org/)
++ [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/NUMBERS)
++ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
++ `#apache-commons` IRC channel on `irc.freenode.org`
+
+[ml]:https://commons.apache.org/mail-lists.html


[commons-numbers] 15/32: Travis to use default maven goal for all checks.

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

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

commit f1e79241ef6bc688f0c5dc158ae0ed5098997c5b
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 23:52:51 2019 +0000

    Travis to use default maven goal for all checks.
---
 .travis.yml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 88452ce..65de1db 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,4 +23,7 @@ jdk:
 install: true
 
 script:
-  - mvn clean test pmd:pmd findbugs:findbugs checkstyle:checkstyle jacoco:report coveralls:report
+  - mvn
+
+after_success:
+  - mvn jacoco:report coveralls:report


[commons-numbers] 30/32: Fixed checkstyle in gamma.

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

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

commit 6592e777fa5ea084f46252f2ecff71772ac19674
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 18:33:02 2019 +0000

    Fixed checkstyle in gamma.
    
    Changed all classes with private constructors to final.
    
    Updated whitespace around array initializers in tests.
---
 .../org/apache/commons/numbers/gamma/Digamma.java  |    3 +-
 .../java/org/apache/commons/numbers/gamma/Erf.java |    3 +-
 .../commons/numbers/gamma/ErfDifference.java       |    3 +-
 .../org/apache/commons/numbers/gamma/Erfc.java     |    3 +-
 .../org/apache/commons/numbers/gamma/Gamma.java    |    3 +-
 .../apache/commons/numbers/gamma/InvGamma1pm1.java |    4 +-
 .../apache/commons/numbers/gamma/InverseErf.java   |    3 +-
 .../apache/commons/numbers/gamma/InverseErfc.java  |    3 +-
 .../numbers/gamma/LanczosApproximation.java        |    3 +-
 .../org/apache/commons/numbers/gamma/LogBeta.java  |   16 +-
 .../org/apache/commons/numbers/gamma/LogGamma.java |    3 +-
 .../apache/commons/numbers/gamma/LogGamma1p.java   |    3 +-
 .../apache/commons/numbers/gamma/LogGammaSum.java  |    3 +-
 .../commons/numbers/gamma/RegularizedBeta.java     |    3 +-
 .../commons/numbers/gamma/RegularizedGamma.java    |    7 +-
 .../org/apache/commons/numbers/gamma/Trigamma.java |    3 +-
 .../apache/commons/numbers/gamma/DigammaTest.java  |   10 +-
 .../commons/numbers/gamma/ErfDifferenceTest.java   |    6 +-
 .../org/apache/commons/numbers/gamma/ErfTest.java  |    2 +-
 .../apache/commons/numbers/gamma/GammaTest.java    |  923 +++++++++---------
 .../commons/numbers/gamma/InvGamma1pm1Test.java    |   44 +-
 .../commons/numbers/gamma/InverseErfcTest.java     |    2 +-
 .../apache/commons/numbers/gamma/LogBetaTest.java  | 1008 ++++++++++----------
 .../commons/numbers/gamma/LogGamma1pTest.java      |   38 +-
 .../commons/numbers/gamma/LogGammaSumTest.java     |  168 ++--
 .../apache/commons/numbers/gamma/LogGammaTest.java |  304 +++---
 .../apache/commons/numbers/gamma/TrigammaTest.java |   26 +-
 27 files changed, 1287 insertions(+), 1310 deletions(-)

diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
index e30a1ff..c96d740 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
@@ -26,8 +26,7 @@ package org.apache.commons.numbers.gamma;
  *
  * @see Gamma
  */
-public class Digamma {
-
+public final class Digamma {
     /** <a href="http://en.wikipedia.org/wiki/Euler-Mascheroni_constant">Euler-Mascheroni constant</a>. */
     private static final double GAMMA = 0.577215664901532860606512090082;
 
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erf.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erf.java
index eba9a7c..4434b58 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erf.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erf.java
@@ -19,8 +19,7 @@ package org.apache.commons.numbers.gamma;
 /**
  * <a href="http://mathworld.wolfram.com/Erf.html">Error function</a>.
  */
-public class Erf {
-
+public final class Erf {
     /** Private constructor. */
     private Erf() {
         // intenitonal empty.
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/ErfDifference.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/ErfDifference.java
index 2c2e70d..1fbd36f 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/ErfDifference.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/ErfDifference.java
@@ -19,8 +19,7 @@ package org.apache.commons.numbers.gamma;
 /**
  * Computes the difference between {@link Erf error function values}.
  */
-public class ErfDifference {
-
+public final class ErfDifference {
     /**
      * This number solves {@code erf(x) = 0.5} within 1 ulp.
      * More precisely, the current implementations of
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erfc.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erfc.java
index b5b7752..07a7cbc 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erfc.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erfc.java
@@ -19,8 +19,7 @@ package org.apache.commons.numbers.gamma;
 /**
  * <a href="http://mathworld.wolfram.com/Erfc.html">Complementary error function</a>.
  */
-public class Erfc {
-
+public final class Erfc {
     /** Private constructor. */
     private Erfc() {
         // intentionally empty.
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Gamma.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Gamma.java
index 9b1c5aa..2698a73 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Gamma.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Gamma.java
@@ -30,8 +30,7 @@ package org.apache.commons.numbers.gamma;
  * This class is immutable.
  * </p>
  */
-public class Gamma {
-
+public final class Gamma {
     /** &radic;(2&pi;). */
     private static final double SQRT_TWO_PI = 2.506628274631000502;
 
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InvGamma1pm1.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InvGamma1pm1.java
index f98fed5..710ccdd 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InvGamma1pm1.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InvGamma1pm1.java
@@ -21,9 +21,7 @@ package org.apache.commons.numbers.gamma;
  *
  * Class is immutable.
  */
-class InvGamma1pm1 {
-
-
+final class InvGamma1pm1 {
     /*
      * Constants copied from DGAM1 in the NSWC library.
      */
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InverseErf.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InverseErf.java
index 6944e38..95c9966 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InverseErf.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InverseErf.java
@@ -26,8 +26,7 @@ package org.apache.commons.numbers.gamma;
  * The source code is available <a href="http://gpucomputing.net/?q=node/1828">here</a>.
  * </p>
  */
-public class InverseErf {
-
+public final class InverseErf {
     /** Private constructor. */
     private InverseErf() {
         // intentionally empty.
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InverseErfc.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InverseErfc.java
index 8cef231..513ea49 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InverseErfc.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/InverseErfc.java
@@ -26,8 +26,7 @@ package org.apache.commons.numbers.gamma;
  * The source code is available <a href="http://gpucomputing.net/?q=node/1828">here</a>.
  * </p>
  */
-public class InverseErfc {
-
+public final class InverseErfc {
     /** Private constructor. */
     private InverseErfc() {
         // intentional empty.
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LanczosApproximation.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LanczosApproximation.java
index 5440d47..8005561 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LanczosApproximation.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LanczosApproximation.java
@@ -31,8 +31,7 @@ package org.apache.commons.numbers.gamma;
  * <a href="http://my.fit.edu/~gabdo/gamma.txt">Note on the computation
  * of the convergent Lanczos complex Gamma approximation</a>.
  */
-public class LanczosApproximation {
-
+public final class LanczosApproximation {
     /** \( g = \frac{607}{128} \). */
     private static final double LANCZOS_G = 607d / 128d;
     /** Lanczos coefficients. */
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java
index b394300..04ea5b8 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java
@@ -22,20 +22,18 @@ package org.apache.commons.numbers.gamma;
  * This class is immutable.
  * </p>
  */
-public class LogBeta {
-
-
+public final class LogBeta {
     /** The constant value of ½log 2π. */
     private static final double HALF_LOG_TWO_PI = 0.9189385332046727;
 
     /**
-     * <p>
      * The coefficients of the series expansion of the Δ function. This function
-     * is defined as follows
-     * </p>
-     * <center>Δ(x) = log Γ(x) - (x - 0.5) log a + a - 0.5 log 2π,</center>
+     * is defined as follows:
+     * <pre>
+     * Δ(x) = log Γ(x) - (x - 0.5) log a + a - 0.5 log 2π,
+     * </pre>
      * <p>
-     * see equation (23) in Didonato and Morris (1992). The series expansion,
+     * See equation (23) in Didonato and Morris (1992). The series expansion,
      * which applies for x ≥ 10, reads
      * </p>
      * <pre>
@@ -46,7 +44,7 @@ public class LogBeta {
      *             x  /      n
      *                ====
      *                n = 0
-     * <pre>
+     * </pre>
      */
     private static final double[] DELTA = {
         .833333333333333333333333333333E-01,
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java
index 4e491be..f367f20 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java
@@ -21,8 +21,7 @@ package org.apache.commons.numbers.gamma;
  *
  * Class is immutable.
  */
-public class LogGamma {
-
+public final class LogGamma {
     /** Lanczos constant. */
     private static final double LANCZOS_G = 607d / 128d;
     /** Performance. */
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma1p.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma1p.java
index 95da30c..6940eda 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma1p.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma1p.java
@@ -21,8 +21,7 @@ package org.apache.commons.numbers.gamma;
  *
  * Class is immutable.
  */
-class LogGamma1p {
-
+final class LogGamma1p {
     /** Private constructor. */
     private LogGamma1p() {
         // intentionally empty
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGammaSum.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGammaSum.java
index b437b35..299d281 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGammaSum.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGammaSum.java
@@ -22,8 +22,7 @@ package org.apache.commons.numbers.gamma;
  * This class is immutable.
  * </p>
  */
-class LogGammaSum {
-
+final class LogGammaSum {
     /** Private constructor. */
     private LogGammaSum() {
         // intentionally empty
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedBeta.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedBeta.java
index f93a697..2a4d4fa 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedBeta.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedBeta.java
@@ -25,8 +25,7 @@ import org.apache.commons.numbers.fraction.ContinuedFraction;
  * This class is immutable.
  * </p>
  */
-public class RegularizedBeta {
-
+public final class RegularizedBeta {
     /** Maximum allowed numerical error. */
     private static final double DEFAULT_EPSILON = 1e-14;
 
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java
index e3eb69a..031cb59 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java
@@ -24,8 +24,7 @@ import org.apache.commons.numbers.fraction.ContinuedFraction;
  *
  * Class is immutable.
  */
-public class RegularizedGamma {
-
+public final class RegularizedGamma {
     /** Maximum allowed numerical error. */
     private static final double DEFAULT_EPSILON = 1e-15;
 
@@ -40,7 +39,7 @@ public class RegularizedGamma {
      *
      * Class is immutable.
      */
-    public static class P {
+    public static final class P {
         /** Prevent instantiation. */
         private P() {}
 
@@ -127,7 +126,7 @@ public class RegularizedGamma {
      *
      * Class is immutable.
      */
-    public static class Q {
+    public static final class Q {
         /** Prevent instantiation. */
         private Q() {}
 
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Trigamma.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Trigamma.java
index 487b6c3..0eef4e3 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Trigamma.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Trigamma.java
@@ -22,8 +22,7 @@ package org.apache.commons.numbers.gamma;
  * It is the derivative of the {@link Digamma digamma function}:
  * \( \psi_1(x) = \frac{d^2}{dx^2} (\ln \Gamma(x)) \).
  */
-public class Trigamma {
-
+public final class Trigamma {
     /** C limit. */
     private static final double C_LIMIT = 49;
 
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java
index 6985104..1d708bd 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/DigammaTest.java
@@ -45,11 +45,11 @@ public class DigammaTest {
         // values for negative powers of 10 from 1 to 30 as computed by webMathematica with 20 digits
         // see functions.wolfram.com
         double[] expected = {-10.423754940411076795, -100.56088545786867450, -1000.5755719318103005,
-                -10000.577051183514335, -100000.57719921568107, -1.0000005772140199687e6, -1.0000000577215500408e7,
-                -1.0000000057721564845e8, -1.0000000005772156633e9, -1.0000000000577215665e10, -1.0000000000057721566e11,
-                -1.0000000000005772157e12, -1.0000000000000577216e13, -1.0000000000000057722e14, -1.0000000000000005772e15, -1e+16,
-                -1e+17, -1e+18, -1e+19, -1e+20, -1e+21, -1e+22, -1e+23, -1e+24, -1e+25, -1e+26,
-                -1e+27, -1e+28, -1e+29, -1e+30};
+            -10000.577051183514335, -100000.57719921568107, -1.0000005772140199687e6, -1.0000000577215500408e7,
+            -1.0000000057721564845e8, -1.0000000005772156633e9, -1.0000000000577215665e10, -1.0000000000057721566e11,
+            -1.0000000000005772157e12, -1.0000000000000577216e13, -1.0000000000000057722e14, -1.0000000000000005772e15, -1e+16,
+            -1e+17, -1e+18, -1e+19, -1e+20, -1e+21, -1e+22, -1e+23, -1e+24, -1e+25, -1e+26,
+            -1e+27, -1e+28, -1e+29, -1e+30};
         for (double n = 1; n < 30; n++) {
             checkRelativeError(String.format("Test %.0f: ", n), expected[(int) (n - 1)], Digamma.value(Math.pow(10.0, -n)), 1e-8);
         }
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfDifferenceTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfDifferenceTest.java
index ee49a8f..da9bf8a 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfDifferenceTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfDifferenceTest.java
@@ -29,9 +29,9 @@ public class ErfDifferenceTest {
      */
     @Test
     public void testTwoArgumentErf() {
-        final double[] xi = new double[] { -2, -1, -0.9, -0.1, 0, 0.1, 0.9, 1, 2 };
-        for(double x1 : xi) {
-            for(double x2 : xi) {
+        final double[] xi = new double[] {-2, -1, -0.9, -0.1, 0, 0.1, 0.9, 1, 2};
+        for (double x1 : xi) {
+            for (double x2 : xi) {
                 double a = ErfDifference.value(x1, x2);
                 double b = Erf.value(x2) - Erf.value(x1);
                 double c = Erfc.value(x1) - Erfc.value(x2);
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfTest.java
index 461d128..c1a021d 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfTest.java
@@ -130,7 +130,7 @@ public class ErfTest {
             0.99999999980338395581, 0.99999999999846254017, 0.99999999999999264217, 0.99999999999999997848,
             1,  1,  1,  1,
             1,  1,  1,  1};
-        
+
         double x = -10;
         for (int i = 0; i < 41; i++) {
             Assertions.assertEquals(gnuValues[i], Erf.value(x), tol);
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/GammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/GammaTest.java
index 832caf9..f14606b 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/GammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/GammaTest.java
@@ -44,466 +44,466 @@ public class GammaTest {
      * </pre>
      */
     private static final double[][] GAMMA_REF = {
-        { - 19.875 , 4.920331854832504e-18 },
-        { - 19.75 , 3.879938752480031e-18 },
-        { - 19.625 , 4.323498423815027e-18 },
-        { - 19.5 , 5.811045977502237e-18 },
-        { - 19.375 , 9.14330910942125e-18 },
-        { - 19.25 , 1.735229114436739e-17 },
-        { - 19.125 , 4.653521565668223e-17 },
-        { - 18.875 , - 9.779159561479603e-17 },
-        { - 18.75 , - 7.662879036148061e-17 },
-        { - 18.625 , - 8.484865656736991e-17 },
-        { - 18.5 , - 1.133153965612936e-16 },
-        { - 18.375 , - 1.771516139950367e-16 },
-        { - 18.25 , - 3.340316045290721e-16 },
-        { - 18.125 , - 8.899859994340475e-16 },
-        { - 17.875 , 1.845816367229275e-15 },
-        { - 17.75 , 1.436789819277761e-15 },
-        { - 17.625 , 1.580306228567265e-15 },
-        { - 17.5 , 2.096334836383932e-15 },
-        { - 17.375 , 3.255160907158799e-15 },
-        { - 17.25 , 6.096076782655566e-15 },
-        { - 17.125 , 1.613099623974211e-14 },
-        { - 16.875 , - 3.29939675642233e-14 },
-        { - 16.75 , - 2.550301929218027e-14 },
-        { - 16.625 , - 2.785289727849803e-14 },
-        { - 16.5 , - 3.66858596367188e-14 },
-        { - 16.375 , - 5.655842076188414e-14 },
-        { - 16.25 , - 1.051573245008085e-13 },
-        { - 16.125 , - 2.762433106055837e-13 },
-        { - 15.875 , 5.567732026462681e-13 },
-        { - 15.75 , 4.271755731440195e-13 },
-        { - 15.625 , 4.630544172550298e-13 },
-        { - 15.5 , 6.053166840058604e-13 },
-        { - 15.375 , 9.261441399758529e-13 },
-        { - 15.25 , 1.708806523138138e-12 },
-        { - 15.125 , 4.454423383515037e-12 },
-        { - 14.875 , - 8.838774592009505e-12 },
-        { - 14.75 , - 6.728015277018307e-12 },
-        { - 14.625 , - 7.235225269609841e-12 },
-        { - 14.5 , - 9.382408602090835e-12 },
-        { - 14.375 , - 1.423946615212874e-11 },
-        { - 14.25 , - 2.605929947785661e-11 },
-        { - 14.125 , - 6.737315367566492e-11 },
-        { - 13.875 , 1.314767720561414e-10 },
-        { - 13.75 , 9.923822533602004e-11 },
-        { - 13.625 , 1.058151695680439e-10 },
-        { - 13.5 , 1.360449247303171e-10 },
-        { - 13.375 , 2.046923259368506e-10 },
-        { - 13.25 , 3.713450175594567e-10 },
-        { - 13.125 , 9.516457956687671e-10 },
-        { - 12.875 , - 1.8242402122789617e-9 },
-        { - 12.75 , - 1.3645255983702756e-9 },
-        { - 12.625 , - 1.4417316853645984e-9 },
-        { - 12.5 , - 1.836606483859281e-9 },
-        { - 12.375 , - 2.7377598594053765e-9 },
-        { - 12.25 , - 4.9203214826628017e-9 },
-        { - 12.125 , - 1.2490351068152569e-8 },
-        { - 11.875 , 2.3487092733091633e-8 },
-        { - 11.75 , 1.7397701379221012e-8 },
-        { - 11.625 , 1.8201862527728055e-8 },
-        { - 11.5 , 2.295758104824101e-8 },
-        { - 11.375 , 3.3879778260141535e-8 },
-        { - 11.25 , 6.027393816261931e-8 },
-        { - 11.125 , 1.5144550670134987e-7 },
-        { - 10.875 , - 2.7890922620546316e-7 },
-        { - 10.75 , - 2.044229912058469e-7 },
-        { - 10.625 , - 2.1159665188483867e-7 },
-        { - 10.5 , - 2.640121820547716e-7 },
-        { - 10.375 , - 3.8538247770911e-7 },
-        { - 10.25 , - 6.780818043294673e-7 },
-        { - 10.125 , - 1.6848312620525174e-6 },
-        { - 9.875 , 3.0331378349844124e-6 },
-        { - 9.75 , 2.1975471554628537e-6 },
-        { - 9.625 , 2.2482144262764103e-6 },
-        { - 9.5 , 2.772127911575102e-6 },
-        { - 9.375 , 3.998343206232017e-6 },
-        { - 9.25 , 6.95033849437704e-6 },
-        { - 9.125 , 1.7058916528281737e-5 },
-        { - 8.875 , - 2.9952236120471065e-5 },
-        { - 8.75 , - 2.1426084765762826e-5 },
-        { - 8.625 , - 2.163906385291045e-5 },
-        { - 8.5 , - 2.633521515996347e-5 },
-        { - 8.375 , - 3.748446755842515e-5 },
-        { - 8.25 , - 6.429063107298763e-5 },
-        { - 8.125 , - 1.5566261332057085e-4 },
-        { - 7.875 , 2.658260955691807e-4 },
-        { - 7.75 , 1.874782417004247e-4 },
-        { - 7.625 , 1.8663692573135265e-4 },
-        { - 7.5 , 2.238493288596895e-4 },
-        { - 7.375 , 3.1393241580181064e-4 },
-        { - 7.25 , 5.303977063521479e-4 },
-        { - 7.125 , .001264758733229638 },
-        { - 6.875 , - .002093380502607298 },
-        { - 6.75 , - .001452956373178292 },
-        { - 6.625 , - .001423106558701564 },
-        { - 6.5 , - .001678869966447671 },
-        { - 6.375 , - .002315251566538353 },
-        { - 6.25 , - .003845383371053072 },
-        { - 6.125 , - .009011405974261174 },
-        { - 5.875 , .01439199095542518 },
-        { - 5.75 , .009807455518953468 },
-        { - 5.625 , .009428080951397862 },
-        { - 5.5 , .01091265478190986 },
-        { - 5.375 , 0.014759728736682 },
-        { - 5.25 , 0.0240336460690817 },
-        { - 5.125 , .05519486159234969 },
-        { - 4.875 , - 0.0845529468631229 },
-        { - 4.75 , - .05639286923398244 },
-        { - 4.625 , - .05303295535161297 },
-        { - 4.5 , - .06001960130050425 },
-        { - 4.375 , - .07933354195966577 },
-        { - 4.25 , - .1261766418626789 },
-        { - 4.125 , - .2828736656607921 },
-        { - 3.875 , .4121956159577241 },
-        { - 3.75 , .2678661288614166 },
-        { - 3.625 , 0.24527741850121 },
-        { - 3.5 , .2700882058522691 },
-        { - 3.375 , .3470842460735378 },
-        { - 3.25 , .5362507279163854 },
-        { - 3.125 , 1.166853870850768 },
-        { - 2.875 , - 1.597258011836181 },
-        { - 2.75 , - 1.004497983230312 },
-        { - 2.625 , - .8891306420668862 },
-        { - 2.5 , - .9453087204829419 },
-        { - 2.375 , - 1.17140933049819 },
-        { - 2.25 , - 1.742814865728253 },
-        { - 2.125 , - 3.646418346408649 },
-        { - 1.875 , 4.59211678402902 },
-        { - 1.75 , 2.762369453883359 },
-        { - 1.625 , 2.333967935425576 },
-        { - 1.5 , 2.363271801207355 },
-        { - 1.375 , 2.782097159933201 },
-        { - 1.25 , 3.921333447888569 },
-        { - 1.125 , 7.748638986118379 },
-        { - 0.875 , - 8.610218970054413 },
-        { - 0.75 , - 4.834146544295877 },
-        { - 0.625 , - 3.792697895066561 },
-        { - 0.5 , - 3.544907701811032 },
-        { - 0.375 , - 3.825383594908152 },
-        { - 0.25 , - 4.901666809860711 },
-        { - 0.125 , - 8.717218859383175 },
-        { 0.125 , 7.533941598797612 },
-        { 0.25 , 3.625609908221908 },
-        { 0.375 , 2.370436184416601 },
-        { 0.5 , 1.772453850905516 },
-        { 0.625 , 1.434518848090557 },
-        { 0.75 , 1.225416702465178 },
-        { 0.875 , 1.089652357422897 },
-        { 1.0 , 1.0 },
-        { 1.125 , .9417426998497015 },
-        { 1.25 , 0.906402477055477 },
-        { 1.375 , .8889135691562253 },
-        { 1.5 , 0.886226925452758 },
-        { 1.625 , 0.896574280056598 },
-        { 1.75 , .9190625268488832 },
-        { 1.875 , .9534458127450348 },
-        { 2.0 , 1.0 },
-        { 2.125 , 1.059460537330914 },
-        { 2.25 , 1.133003096319346 },
-        { 2.375 , 1.22225615758981 },
-        { 2.5 , 1.329340388179137 },
-        { 2.625 , 1.456933205091972 },
-        { 2.75 , 1.608359421985546 },
-        { 2.875 , 1.78771089889694 },
-        { 3.0 , 2.0 },
-        { 3.125 , 2.251353641828193 },
-        { 3.25 , 2.549256966718529 },
-        { 3.375 , 2.902858374275799 },
-        { 3.5 , 3.323350970447843 },
-        { 3.625 , 3.824449663366426 },
-        { 3.75 , 4.422988410460251 },
-        { 3.875 , 5.139668834328703 },
-        { 4.0 , 6.0 },
-        { 4.125 , 7.035480130713102 },
-        { 4.25 , 8.28508514183522 },
-        { 4.375 , 9.797147013180819 },
-        { 4.5 , 11.63172839656745 },
-        { 4.625 , 13.86363002970329 },
-        { 4.75 , 16.58620653922594 },
-        { 4.875 , 19.91621673302373 },
-        { 5.0 , 24.0 },
-        { 5.125 , 29.02135553919155 },
-        { 5.25 , 35.21161185279968 },
-        { 5.375 , 42.86251818266609 },
-        { 5.5 , 52.34277778455352 },
-        { 5.625 , 64.11928888737773 },
-        { 5.75 , 78.78448106132322 },
-        { 5.875 , 97.09155657349066 },
-        { 6.0 , 120.0 },
-        { 6.125 , 148.7344471383567 },
-        { 6.25 , 184.8609622271983 },
-        { 6.375 , 230.3860352318302 },
-        { 6.5 , 287.8852778150443 },
-        { 6.625 , 360.6709999914997 },
-        { 6.75 , 453.0107661026085 },
-        { 6.875 , 570.4128948692577 },
-        { 7.0 , 720.0 },
-        { 7.125 , 910.9984887224346 },
-        { 7.25 , 1155.38101391999 },
-        { 7.375 , 1468.710974602918 },
-        { 7.5 , 1871.254305797788 },
-        { 7.625 , 2389.445374943686 },
-        { 7.75 , 3057.822671192607 },
-        { 7.875 , 3921.588652226146 },
-        { 8.0 , 5040.0 },
-        { 8.125 , 6490.864232147346 },
-        { 8.25 , 8376.512350919926 },
-        { 8.375 , 10831.74343769652 },
-        { 8.5 , 14034.40729348341 },
-        { 8.625 , 18219.5209839456 },
-        { 8.75 , 23698.12570174271 },
-        { 8.875 , 30882.5106362809 },
-        { 9.0 , 40320.0 },
-        { 9.125 , 52738.27188619719 },
-        { 9.25 , 69106.22689508938 },
-        { 9.375 , 90715.85129070834 },
-        { 9.5 , 119292.461994609 },
-        { 9.625 , 157143.3684865308 },
-        { 9.75 , 207358.5998902487 },
-        { 9.875 , 274082.281896993 },
-        { 10.0 , 362880.0 },
-        { 10.125 , 481236.7309615494 },
-        { 10.25 , 639232.5987795768 },
-        { 10.375 , 850461.1058503906 },
-        { 10.5 , 1133278.388948786 },
-        { 10.625 , 1512504.921682859 },
-        { 10.75 , 2021746.348929925 },
-        { 10.875 , 2706562.533732806 },
-        { 11.0 , 3628800.0 },
-        { 11.125 , 4872521.900985687 },
-        { 11.25 , 6552134.137490662 },
-        { 11.375 , 8823533.973197803 },
-        { 11.5 , 1.1899423083962249e+7 },
-        { 11.625 , 1.6070364792880382e+7 },
-        { 11.75 , 2.1733773250996688e+7 },
-        { 11.875 , 2.943386755434427e+7 },
-        { 12.0 , 3.99168e+7 },
-        { 12.125 , 5.420680614846578e+7 },
-        { 12.25 , 7.371150904676994e+7 },
-        { 12.375 , 1.0036769894512501e+8 },
-        { 12.5 , 1.3684336546556586e+8 },
-        { 12.625 , 1.8681799071723443e+8 },
-        { 12.75 , 2.5537183569921107e+8 },
-        { 12.875 , 3.4952717720783816e+8 },
-        { 13.0 , 4.790016e+8 },
-        { 13.125 , 6.572575245501475e+8 },
-        { 13.25 , 9.029659858229319e+8 },
-        { 13.375 , 1.2420502744459219e+9 },
-        { 13.5 , 1.7105420683195732e+9 },
-        { 13.625 , 2.3585771328050845e+9 },
-        { 13.75 , 3.2559909051649416e+9 },
-        { 13.875 , 4.500162406550916e+9 },
-        { 14.0 , 6.2270208e+9 },
-        { 14.125 , 8.626505009720685e+9 },
-        { 14.25 , 1.196429931215385e+10 },
-        { 14.375 , 1.66124224207142e+10 },
-        { 14.5 , 2.309231792231424e+10 },
-        { 14.625 , 3.213561343446927e+10 },
-        { 14.75 , 4.476987494601794e+10 },
-        { 14.875 , 6.243975339089396e+10 },
-        { 15.0 , 8.71782912e+10 },
-        { 15.125 , 1.218493832623047e+11 },
-        { 15.25 , 1.704912651981923e+11 },
-        { 15.375 , 2.388035722977667e+11 },
-        { 15.5 , 3.348386098735565e+11 },
-        { 15.625 , 4.699833464791132e+11 },
-        { 15.75 , 6.603556554537646e+11 },
-        { 15.875 , 9.287913316895475e+11 },
-        { 16.0 , 1.307674368e+12 },
-        { 16.125 , 1.842971921842358e+12 },
-        { 16.25 , 2.599991794272433e+12 },
-        { 16.375 , 3.671604924078163e+12 },
-        { 16.5 , 5.189998453040126e+12 },
-        { 16.625 , 7.343489788736144e+12 },
-        { 16.75 , 1.040060157339679e+13 },
-        { 16.875 , 1.474456239057157e+13 },
-        { 17.0 , 2.0922789888e+13 },
-        { 17.125 , 2.971792223970803e+13 },
-        { 17.25 , 4.224986665692704e+13 },
-        { 17.375 , 6.012253063177992e+13 },
-        { 17.5 , 8.563497447516206e+13 },
-        { 17.625 , 1.220855177377384e+14 },
-        { 17.75 , 1.742100763543963e+14 },
-        { 17.875 , 2.488144903408952e+14 },
-        { 18.0 , 3.55687428096e+14 },
-        { 18.125 , 5.08919418355e+14 },
-        { 18.25 , 7.288101998319914e+14 },
-        { 18.375 , 1.044628969727176e+15 },
-        { 18.5 , 1.498612053315336e+15 },
-        { 18.625 , 2.151757250127639e+15 },
-        { 18.75 , 3.092228855290534e+15 },
-        { 18.875 , 4.447559014843502e+15 },
-        { 19.0 , 6.402373705728e+15 },
-        { 19.125 , 9.224164457684374e+15 },
-        { 19.25 , 1.330078614693384e+16 },
-        { 19.375 , 1.919505731873686e+16 },
-        { 19.5 , 2.772432298633372e+16 },
-        { 19.625 , 4.007647878362728e+16 },
-        { 19.75 , 5.797929103669752e+16 },
-        { 19.875 , 8.39476764051711e+16 },
-        { 20.0 , 1.21645100408832e+17 },
-        { 20.5 , 5.406242982335075e+17 },
-        { 21.0 , 2.43290200817664e+18 },
-        { 21.5 , 1.10827981137869e+19 },
-        { 22.0 , 5.109094217170944e+19 },
-        { 22.5 , 2.382801594464184e+20 },
-        { 23.0 , 1.124000727777608e+21 },
-        { 23.5 , 5.361303587544415e+21 },
-        { 24.0 , 2.585201673888498e+22 },
-        { 24.5 , 1.259906343072938e+23 },
-        { 25.0 , 6.204484017332395e+23 },
-        { 25.5 , 3.086770540528697e+24 },
-        { 26.0 , 1.551121004333099e+25 },
-        { 26.5 , 7.871264878348176e+25 },
-        { 27.0 , 4.032914611266056e+26 },
-        { 27.5 , 2.085885192762267e+27 },
-        { 28.0 , 1.088886945041835e+28 },
-        { 28.5 , 5.736184280096234e+28 },
-        { 29.0 , 3.048883446117139e+29 },
-        { 29.5 , 1.634812519827427e+30 },
-        { 30.0 , 8.841761993739702e+30 },
-        { 30.5 , 4.822696933490909e+31 },
-        { 31.0 , 2.65252859812191e+32 },
-        { 31.5 , 1.470922564714727e+33 },
-        { 32.0 , 8.222838654177922e+33 },
-        { 32.5 , 4.633406078851391e+34 },
-        { 33.0 , 2.631308369336935e+35 },
-        { 33.5 , 1.505856975626702e+36 },
-        { 34.0 , 8.683317618811885e+36 },
-        { 34.5 , 5.044620868349451e+37 },
-        { 35.0 , 2.952327990396041e+38 },
-        { 35.5 , 1.740394199580561e+39 },
-        { 36.0 , 1.033314796638614e+40 },
-        { 36.5 , 6.178399408510991e+40 },
-        { 37.0 , 3.719933267899013e+41 },
-        { 37.5 , 2.255115784106512e+42 },
-        { 38.0 , 1.376375309122634e+43 },
-        { 38.5 , 8.456684190399419e+43 },
-        { 39.0 , 5.230226174666011e+44 },
-        { 39.5 , 3.255823413303776e+45 },
-        { 40.0 , 2.039788208119745e+46 },
-        { 40.5 , 1.286050248254992e+47 },
-        { 41.0 , 8.159152832478976e+47 },
-        { 41.5 , 5.208503505432716e+48 },
-        { 42.0 , 3.345252661316381e+49 },
-        { 42.5 , 2.161528954754577e+50 },
-        { 43.0 , 1.40500611775288e+51 },
-        { 43.5 , 9.186498057706953e+51 },
-        { 44.0 , 6.041526306337383e+52 },
-        { 44.5 , 3.996126655102524e+53 },
-        { 45.0 , 2.658271574788449e+54 },
-        { 45.5 , 1.778276361520623e+55 },
-        { 46.0 , 1.196222208654802e+56 },
-        { 46.5 , 8.091157444918836e+56 },
-        { 47.0 , 5.502622159812088e+57 },
-        { 47.5 , 3.762388211887259e+58 },
-        { 48.0 , 2.586232415111682e+59 },
-        { 48.5 , 1.787134400646448e+60 },
-        { 49.0 , 1.241391559253607e+61 },
-        { 49.5 , 8.667601843135273e+61 },
-        { 50.0 , 6.082818640342675e+62 },
-        { 50.5 , 4.290462912351959e+63 },
-        { 51.0 , 3.041409320171338e+64 },
-        { 51.5 , 2.16668377073774e+65 },
-        { 52.0 , 1.551118753287382e+66 },
-        { 52.5 , 1.115842141929936e+67 },
-        { 53.0 , 8.065817517094388e+67 },
-        { 53.5 , 5.858171245132164e+68 },
-        { 54.0 , 4.274883284060025e+69 },
-        { 54.5 , 3.134121616145708e+70 },
-        { 55.0 , 2.308436973392413e+71 },
-        { 55.5 , 1.70809628079941e+72 },
-        { 56.0 , 1.269640335365828e+73 },
-        { 56.5 , 9.479934358436728e+73 },
-        { 57.0 , 7.109985878048635e+74 },
-        { 57.5 , 5.356162912516752e+75 },
-        { 58.0 , 4.052691950487721e+76 },
-        { 58.5 , 3.079793674697132e+77 },
-        { 59.0 , 2.350561331282878e+78 },
-        { 59.5 , 1.801679299697822e+79 },
-        { 60.0 , 1.386831185456898e+80 },
-        { 60.5 , 1.071999183320204e+81 },
-        { 61.0 , 8.320987112741391e+81 },
-        { 61.5 , 6.485595059087236e+82 },
-        { 62.0 , 5.075802138772249e+83 },
-        { 62.5 , 3.98864096133865e+84 },
-        { 63.0 , 3.146997326038794e+85 },
-        { 63.5 , 2.492900600836656e+86 },
-        { 64.0 , 1.98260831540444e+87 },
-        { 64.5 , 1.582991881531277e+88 },
-        { 65.0 , 1.268869321858841e+89 },
-        { 65.5 , 1.021029763587673e+90 },
-        { 66.0 , 8.247650592082472e+90 },
-        { 66.5 , 6.687744951499262e+91 },
-        { 67.0 , 5.443449390774431e+92 },
-        { 67.5 , 4.447350392747009e+93 },
-        { 68.0 , 3.647111091818868e+94 },
-        { 68.5 , 3.001961515104231e+95 },
-        { 69.0 , 2.48003554243683e+96 },
-        { 69.5 , 2.056343637846398e+97 },
-        { 70.0 , 1.711224524281413e+98 },
-        { 70.5 , 1.429158828303247e+99 },
-        { 71.0 , 1.19785716699699e+100 },
-        { 71.5 , 1.00755697395379e+101 },
-        { 72.0 , 8.50478588567862e+101 },
-        { 72.5 , 7.20403236376959e+102 },
-        { 73.0 , 6.12344583768861e+103 },
-        { 73.5 , 5.22292346373295e+104 },
-        { 74.0 , 4.47011546151268e+105 },
-        { 74.5 , 3.83884874584372e+106 },
-        { 75.0 , 3.30788544151939e+107 },
-        { 75.5 , 2.85994231565357e+108 },
-        { 76.0 , 2.48091408113954e+109 },
-        { 76.5 , 2.15925644831845e+110 },
-        { 77.0 , 1.88549470166605e+111 },
-        { 77.5 , 1.65183118296361e+112 },
-        { 78.0 , 1.45183092028286e+113 },
-        { 78.5 , 1.2801691667968e+114 },
-        { 79.0 , 1.13242811782063e+115 },
-        { 79.5 , 1.00493279593549e+116 },
-        { 80.0 , 8.94618213078298e+116 },
-        { 80.5 , 7.98921572768712e+117 },
-        { 81.0 , 7.15694570462638e+118 },
-        { 81.5 , 6.43131866078814e+119 },
-        { 82.0 , 5.79712602074737e+120 },
-        { 82.5 , 5.24152470854233e+121 },
-        { 83.0 , 4.75364333701284e+122 },
-        { 83.5 , 4.32425788454742e+123 },
-        { 84.0 , 3.94552396972066e+124 },
-        { 84.5 , 3.6107553335971e+125 },
-        { 85.0 , 3.31424013456535e+126 },
-        { 85.5 , 3.05108825688955e+127 },
-        { 86.0 , 2.81710411438055e+128 },
-        { 86.5 , 2.60868045964056e+129 },
-        { 87.0 , 2.42270953836727e+130 },
-        { 87.5 , 2.25650859758909e+131 },
-        { 88.0 , 2.10775729837953e+132 },
-        { 88.5 , 1.97444502289045e+133 },
-        { 89.0 , 1.85482642257398e+134 },
-        { 89.5 , 1.74738384525805e+135 },
-        { 90.0 , 1.65079551609085e+136 },
-        { 90.5 , 1.56390854150595e+137 },
-        { 91.0 , 1.48571596448176e+138 },
-        { 91.5 , 1.41533723006289e+139 },
-        { 92.0 , 1.3520015276784e+140 },
-        { 92.5 , 1.29503356550754e+141 },
-        { 93.0 , 1.24384140546413e+142 },
-        { 93.5 , 1.19790604809448e+143 },
-        { 94.0 , 1.15677250708164e+144 },
-        { 94.5 , 1.12004215496834e+145 },
-        { 95.0 , 1.08736615665674e+146 },
-        { 95.5 , 1.05843983644508e+147 },
-        { 96.0 , 1.03299784882391e+148 },
-        { 96.5 , 1.01081004380505e+149 },
-        { 97.0 , 9.9167793487095e+149 },
-        { 97.5 , 9.75431692271873e+150 },
-        { 98.0 , 9.61927596824821e+151 },
-        { 98.5 , 9.51045899965076e+152 },
-        { 99.0 , 9.42689044888325e+153 },
-        { 99.5 , 9.367802114656e+154 },
-        { 100.0 , 9.33262154439441e+155 },
+        {-19.875, 4.920331854832504e-18},
+        {-19.75, 3.879938752480031e-18},
+        {-19.625, 4.323498423815027e-18},
+        {-19.5, 5.811045977502237e-18},
+        {-19.375, 9.14330910942125e-18},
+        {-19.25, 1.735229114436739e-17},
+        {-19.125, 4.653521565668223e-17},
+        {-18.875, -9.779159561479603e-17},
+        {-18.75, -7.662879036148061e-17},
+        {-18.625, -8.484865656736991e-17},
+        {-18.5, -1.133153965612936e-16},
+        {-18.375, -1.771516139950367e-16},
+        {-18.25, -3.340316045290721e-16},
+        {-18.125, -8.899859994340475e-16},
+        {-17.875, 1.845816367229275e-15},
+        {-17.75, 1.436789819277761e-15},
+        {-17.625, 1.580306228567265e-15},
+        {-17.5, 2.096334836383932e-15},
+        {-17.375, 3.255160907158799e-15},
+        {-17.25, 6.096076782655566e-15},
+        {-17.125, 1.613099623974211e-14},
+        {-16.875, -3.29939675642233e-14},
+        {-16.75, -2.550301929218027e-14},
+        {-16.625, -2.785289727849803e-14},
+        {-16.5, -3.66858596367188e-14},
+        {-16.375, -5.655842076188414e-14},
+        {-16.25, -1.051573245008085e-13},
+        {-16.125, -2.762433106055837e-13},
+        {-15.875, 5.567732026462681e-13},
+        {-15.75, 4.271755731440195e-13},
+        {-15.625, 4.630544172550298e-13},
+        {-15.5, 6.053166840058604e-13},
+        {-15.375, 9.261441399758529e-13},
+        {-15.25, 1.708806523138138e-12},
+        {-15.125, 4.454423383515037e-12},
+        {-14.875, -8.838774592009505e-12},
+        {-14.75, -6.728015277018307e-12},
+        {-14.625, -7.235225269609841e-12},
+        {-14.5, -9.382408602090835e-12},
+        {-14.375, -1.423946615212874e-11},
+        {-14.25, -2.605929947785661e-11},
+        {-14.125, -6.737315367566492e-11},
+        {-13.875, 1.314767720561414e-10},
+        {-13.75, 9.923822533602004e-11},
+        {-13.625, 1.058151695680439e-10},
+        {-13.5, 1.360449247303171e-10},
+        {-13.375, 2.046923259368506e-10},
+        {-13.25, 3.713450175594567e-10},
+        {-13.125, 9.516457956687671e-10},
+        {-12.875, -1.8242402122789617e-9},
+        {-12.75, -1.3645255983702756e-9},
+        {-12.625, -1.4417316853645984e-9},
+        {-12.5, -1.836606483859281e-9},
+        {-12.375, -2.7377598594053765e-9},
+        {-12.25, -4.9203214826628017e-9},
+        {-12.125, -1.2490351068152569e-8},
+        {-11.875, 2.3487092733091633e-8},
+        {-11.75, 1.7397701379221012e-8},
+        {-11.625, 1.8201862527728055e-8},
+        {-11.5, 2.295758104824101e-8},
+        {-11.375, 3.3879778260141535e-8},
+        {-11.25, 6.027393816261931e-8},
+        {-11.125, 1.5144550670134987e-7},
+        {-10.875, -2.7890922620546316e-7},
+        {-10.75, -2.044229912058469e-7},
+        {-10.625, -2.1159665188483867e-7},
+        {-10.5, -2.640121820547716e-7},
+        {-10.375, -3.8538247770911e-7},
+        {-10.25, -6.780818043294673e-7},
+        {-10.125, -1.6848312620525174e-6},
+        {-9.875, 3.0331378349844124e-6},
+        {-9.75, 2.1975471554628537e-6},
+        {-9.625, 2.2482144262764103e-6},
+        {-9.5, 2.772127911575102e-6},
+        {-9.375, 3.998343206232017e-6},
+        {-9.25, 6.95033849437704e-6},
+        {-9.125, 1.7058916528281737e-5},
+        {-8.875, -2.9952236120471065e-5},
+        {-8.75, -2.1426084765762826e-5},
+        {-8.625, -2.163906385291045e-5},
+        {-8.5, -2.633521515996347e-5},
+        {-8.375, -3.748446755842515e-5},
+        {-8.25, -6.429063107298763e-5},
+        {-8.125, -1.5566261332057085e-4},
+        {-7.875, 2.658260955691807e-4},
+        {-7.75, 1.874782417004247e-4},
+        {-7.625, 1.8663692573135265e-4},
+        {-7.5, 2.238493288596895e-4},
+        {-7.375, 3.1393241580181064e-4},
+        {-7.25, 5.303977063521479e-4},
+        {-7.125, .001264758733229638},
+        {-6.875, -.002093380502607298},
+        {-6.75, -.001452956373178292},
+        {-6.625, -.001423106558701564},
+        {-6.5, -.001678869966447671},
+        {-6.375, -.002315251566538353},
+        {-6.25, -.003845383371053072},
+        {-6.125, -.009011405974261174},
+        {-5.875, .01439199095542518},
+        {-5.75, .009807455518953468},
+        {-5.625, .009428080951397862},
+        {-5.5, .01091265478190986},
+        {-5.375, 0.014759728736682},
+        {-5.25, 0.0240336460690817},
+        {-5.125, .05519486159234969},
+        {-4.875, -0.0845529468631229},
+        {-4.75, -.05639286923398244},
+        {-4.625, -.05303295535161297},
+        {-4.5, -.06001960130050425},
+        {-4.375, -.07933354195966577},
+        {-4.25, -.1261766418626789},
+        {-4.125, -.2828736656607921},
+        {-3.875, .4121956159577241},
+        {-3.75, .2678661288614166},
+        {-3.625, 0.24527741850121},
+        {-3.5, .2700882058522691},
+        {-3.375, .3470842460735378},
+        {-3.25, .5362507279163854},
+        {-3.125, 1.166853870850768},
+        {-2.875, -1.597258011836181},
+        {-2.75, -1.004497983230312},
+        {-2.625, -.8891306420668862},
+        {-2.5, -.9453087204829419},
+        {-2.375, -1.17140933049819},
+        {-2.25, -1.742814865728253},
+        {-2.125, -3.646418346408649},
+        {-1.875, 4.59211678402902},
+        {-1.75, 2.762369453883359},
+        {-1.625, 2.333967935425576},
+        {-1.5, 2.363271801207355},
+        {-1.375, 2.782097159933201},
+        {-1.25, 3.921333447888569},
+        {-1.125, 7.748638986118379},
+        {-0.875, -8.610218970054413},
+        {-0.75, -4.834146544295877},
+        {-0.625, -3.792697895066561},
+        {-0.5, -3.544907701811032},
+        {-0.375, -3.825383594908152},
+        {-0.25, -4.901666809860711},
+        {-0.125, -8.717218859383175},
+        {0.125, 7.533941598797612},
+        {0.25, 3.625609908221908},
+        {0.375, 2.370436184416601},
+        {0.5, 1.772453850905516},
+        {0.625, 1.434518848090557},
+        {0.75, 1.225416702465178},
+        {0.875, 1.089652357422897},
+        {1.0, 1.0},
+        {1.125, .9417426998497015},
+        {1.25, 0.906402477055477},
+        {1.375, .8889135691562253},
+        {1.5, 0.886226925452758},
+        {1.625, 0.896574280056598},
+        {1.75, .9190625268488832},
+        {1.875, .9534458127450348},
+        {2.0, 1.0},
+        {2.125, 1.059460537330914},
+        {2.25, 1.133003096319346},
+        {2.375, 1.22225615758981},
+        {2.5, 1.329340388179137},
+        {2.625, 1.456933205091972},
+        {2.75, 1.608359421985546},
+        {2.875, 1.78771089889694},
+        {3.0, 2.0},
+        {3.125, 2.251353641828193},
+        {3.25, 2.549256966718529},
+        {3.375, 2.902858374275799},
+        {3.5, 3.323350970447843},
+        {3.625, 3.824449663366426},
+        {3.75, 4.422988410460251},
+        {3.875, 5.139668834328703},
+        {4.0, 6.0},
+        {4.125, 7.035480130713102},
+        {4.25, 8.28508514183522},
+        {4.375, 9.797147013180819},
+        {4.5, 11.63172839656745},
+        {4.625, 13.86363002970329},
+        {4.75, 16.58620653922594},
+        {4.875, 19.91621673302373},
+        {5.0, 24.0},
+        {5.125, 29.02135553919155},
+        {5.25, 35.21161185279968},
+        {5.375, 42.86251818266609},
+        {5.5, 52.34277778455352},
+        {5.625, 64.11928888737773},
+        {5.75, 78.78448106132322},
+        {5.875, 97.09155657349066},
+        {6.0, 120.0},
+        {6.125, 148.7344471383567},
+        {6.25, 184.8609622271983},
+        {6.375, 230.3860352318302},
+        {6.5, 287.8852778150443},
+        {6.625, 360.6709999914997},
+        {6.75, 453.0107661026085},
+        {6.875, 570.4128948692577},
+        {7.0, 720.0},
+        {7.125, 910.9984887224346},
+        {7.25, 1155.38101391999},
+        {7.375, 1468.710974602918},
+        {7.5, 1871.254305797788},
+        {7.625, 2389.445374943686},
+        {7.75, 3057.822671192607},
+        {7.875, 3921.588652226146},
+        {8.0, 5040.0},
+        {8.125, 6490.864232147346},
+        {8.25, 8376.512350919926},
+        {8.375, 10831.74343769652},
+        {8.5, 14034.40729348341},
+        {8.625, 18219.5209839456},
+        {8.75, 23698.12570174271},
+        {8.875, 30882.5106362809},
+        {9.0, 40320.0},
+        {9.125, 52738.27188619719},
+        {9.25, 69106.22689508938},
+        {9.375, 90715.85129070834},
+        {9.5, 119292.461994609},
+        {9.625, 157143.3684865308},
+        {9.75, 207358.5998902487},
+        {9.875, 274082.281896993},
+        {10.0, 362880.0},
+        {10.125, 481236.7309615494},
+        {10.25, 639232.5987795768},
+        {10.375, 850461.1058503906},
+        {10.5, 1133278.388948786},
+        {10.625, 1512504.921682859},
+        {10.75, 2021746.348929925},
+        {10.875, 2706562.533732806},
+        {11.0, 3628800.0},
+        {11.125, 4872521.900985687},
+        {11.25, 6552134.137490662},
+        {11.375, 8823533.973197803},
+        {11.5, 1.1899423083962249e+7},
+        {11.625, 1.6070364792880382e+7},
+        {11.75, 2.1733773250996688e+7},
+        {11.875, 2.943386755434427e+7},
+        {12.0, 3.99168e+7},
+        {12.125, 5.420680614846578e+7},
+        {12.25, 7.371150904676994e+7},
+        {12.375, 1.0036769894512501e+8},
+        {12.5, 1.3684336546556586e+8},
+        {12.625, 1.8681799071723443e+8},
+        {12.75, 2.5537183569921107e+8},
+        {12.875, 3.4952717720783816e+8},
+        {13.0, 4.790016e+8},
+        {13.125, 6.572575245501475e+8},
+        {13.25, 9.029659858229319e+8},
+        {13.375, 1.2420502744459219e+9},
+        {13.5, 1.7105420683195732e+9},
+        {13.625, 2.3585771328050845e+9},
+        {13.75, 3.2559909051649416e+9},
+        {13.875, 4.500162406550916e+9},
+        {14.0, 6.2270208e+9},
+        {14.125, 8.626505009720685e+9},
+        {14.25, 1.196429931215385e+10},
+        {14.375, 1.66124224207142e+10},
+        {14.5, 2.309231792231424e+10},
+        {14.625, 3.213561343446927e+10},
+        {14.75, 4.476987494601794e+10},
+        {14.875, 6.243975339089396e+10},
+        {15.0, 8.71782912e+10},
+        {15.125, 1.218493832623047e+11},
+        {15.25, 1.704912651981923e+11},
+        {15.375, 2.388035722977667e+11},
+        {15.5, 3.348386098735565e+11},
+        {15.625, 4.699833464791132e+11},
+        {15.75, 6.603556554537646e+11},
+        {15.875, 9.287913316895475e+11},
+        {16.0, 1.307674368e+12},
+        {16.125, 1.842971921842358e+12},
+        {16.25, 2.599991794272433e+12},
+        {16.375, 3.671604924078163e+12},
+        {16.5, 5.189998453040126e+12},
+        {16.625, 7.343489788736144e+12},
+        {16.75, 1.040060157339679e+13},
+        {16.875, 1.474456239057157e+13},
+        {17.0, 2.0922789888e+13},
+        {17.125, 2.971792223970803e+13},
+        {17.25, 4.224986665692704e+13},
+        {17.375, 6.012253063177992e+13},
+        {17.5, 8.563497447516206e+13},
+        {17.625, 1.220855177377384e+14},
+        {17.75, 1.742100763543963e+14},
+        {17.875, 2.488144903408952e+14},
+        {18.0, 3.55687428096e+14},
+        {18.125, 5.08919418355e+14},
+        {18.25, 7.288101998319914e+14},
+        {18.375, 1.044628969727176e+15},
+        {18.5, 1.498612053315336e+15},
+        {18.625, 2.151757250127639e+15},
+        {18.75, 3.092228855290534e+15},
+        {18.875, 4.447559014843502e+15},
+        {19.0, 6.402373705728e+15},
+        {19.125, 9.224164457684374e+15},
+        {19.25, 1.330078614693384e+16},
+        {19.375, 1.919505731873686e+16},
+        {19.5, 2.772432298633372e+16},
+        {19.625, 4.007647878362728e+16},
+        {19.75, 5.797929103669752e+16},
+        {19.875, 8.39476764051711e+16},
+        {20.0, 1.21645100408832e+17},
+        {20.5, 5.406242982335075e+17},
+        {21.0, 2.43290200817664e+18},
+        {21.5, 1.10827981137869e+19},
+        {22.0, 5.109094217170944e+19},
+        {22.5, 2.382801594464184e+20},
+        {23.0, 1.124000727777608e+21},
+        {23.5, 5.361303587544415e+21},
+        {24.0, 2.585201673888498e+22},
+        {24.5, 1.259906343072938e+23},
+        {25.0, 6.204484017332395e+23},
+        {25.5, 3.086770540528697e+24},
+        {26.0, 1.551121004333099e+25},
+        {26.5, 7.871264878348176e+25},
+        {27.0, 4.032914611266056e+26},
+        {27.5, 2.085885192762267e+27},
+        {28.0, 1.088886945041835e+28},
+        {28.5, 5.736184280096234e+28},
+        {29.0, 3.048883446117139e+29},
+        {29.5, 1.634812519827427e+30},
+        {30.0, 8.841761993739702e+30},
+        {30.5, 4.822696933490909e+31},
+        {31.0, 2.65252859812191e+32},
+        {31.5, 1.470922564714727e+33},
+        {32.0, 8.222838654177922e+33},
+        {32.5, 4.633406078851391e+34},
+        {33.0, 2.631308369336935e+35},
+        {33.5, 1.505856975626702e+36},
+        {34.0, 8.683317618811885e+36},
+        {34.5, 5.044620868349451e+37},
+        {35.0, 2.952327990396041e+38},
+        {35.5, 1.740394199580561e+39},
+        {36.0, 1.033314796638614e+40},
+        {36.5, 6.178399408510991e+40},
+        {37.0, 3.719933267899013e+41},
+        {37.5, 2.255115784106512e+42},
+        {38.0, 1.376375309122634e+43},
+        {38.5, 8.456684190399419e+43},
+        {39.0, 5.230226174666011e+44},
+        {39.5, 3.255823413303776e+45},
+        {40.0, 2.039788208119745e+46},
+        {40.5, 1.286050248254992e+47},
+        {41.0, 8.159152832478976e+47},
+        {41.5, 5.208503505432716e+48},
+        {42.0, 3.345252661316381e+49},
+        {42.5, 2.161528954754577e+50},
+        {43.0, 1.40500611775288e+51},
+        {43.5, 9.186498057706953e+51},
+        {44.0, 6.041526306337383e+52},
+        {44.5, 3.996126655102524e+53},
+        {45.0, 2.658271574788449e+54},
+        {45.5, 1.778276361520623e+55},
+        {46.0, 1.196222208654802e+56},
+        {46.5, 8.091157444918836e+56},
+        {47.0, 5.502622159812088e+57},
+        {47.5, 3.762388211887259e+58},
+        {48.0, 2.586232415111682e+59},
+        {48.5, 1.787134400646448e+60},
+        {49.0, 1.241391559253607e+61},
+        {49.5, 8.667601843135273e+61},
+        {50.0, 6.082818640342675e+62},
+        {50.5, 4.290462912351959e+63},
+        {51.0, 3.041409320171338e+64},
+        {51.5, 2.16668377073774e+65},
+        {52.0, 1.551118753287382e+66},
+        {52.5, 1.115842141929936e+67},
+        {53.0, 8.065817517094388e+67},
+        {53.5, 5.858171245132164e+68},
+        {54.0, 4.274883284060025e+69},
+        {54.5, 3.134121616145708e+70},
+        {55.0, 2.308436973392413e+71},
+        {55.5, 1.70809628079941e+72},
+        {56.0, 1.269640335365828e+73},
+        {56.5, 9.479934358436728e+73},
+        {57.0, 7.109985878048635e+74},
+        {57.5, 5.356162912516752e+75},
+        {58.0, 4.052691950487721e+76},
+        {58.5, 3.079793674697132e+77},
+        {59.0, 2.350561331282878e+78},
+        {59.5, 1.801679299697822e+79},
+        {60.0, 1.386831185456898e+80},
+        {60.5, 1.071999183320204e+81},
+        {61.0, 8.320987112741391e+81},
+        {61.5, 6.485595059087236e+82},
+        {62.0, 5.075802138772249e+83},
+        {62.5, 3.98864096133865e+84},
+        {63.0, 3.146997326038794e+85},
+        {63.5, 2.492900600836656e+86},
+        {64.0, 1.98260831540444e+87},
+        {64.5, 1.582991881531277e+88},
+        {65.0, 1.268869321858841e+89},
+        {65.5, 1.021029763587673e+90},
+        {66.0, 8.247650592082472e+90},
+        {66.5, 6.687744951499262e+91},
+        {67.0, 5.443449390774431e+92},
+        {67.5, 4.447350392747009e+93},
+        {68.0, 3.647111091818868e+94},
+        {68.5, 3.001961515104231e+95},
+        {69.0, 2.48003554243683e+96},
+        {69.5, 2.056343637846398e+97},
+        {70.0, 1.711224524281413e+98},
+        {70.5, 1.429158828303247e+99},
+        {71.0, 1.19785716699699e+100},
+        {71.5, 1.00755697395379e+101},
+        {72.0, 8.50478588567862e+101},
+        {72.5, 7.20403236376959e+102},
+        {73.0, 6.12344583768861e+103},
+        {73.5, 5.22292346373295e+104},
+        {74.0, 4.47011546151268e+105},
+        {74.5, 3.83884874584372e+106},
+        {75.0, 3.30788544151939e+107},
+        {75.5, 2.85994231565357e+108},
+        {76.0, 2.48091408113954e+109},
+        {76.5, 2.15925644831845e+110},
+        {77.0, 1.88549470166605e+111},
+        {77.5, 1.65183118296361e+112},
+        {78.0, 1.45183092028286e+113},
+        {78.5, 1.2801691667968e+114},
+        {79.0, 1.13242811782063e+115},
+        {79.5, 1.00493279593549e+116},
+        {80.0, 8.94618213078298e+116},
+        {80.5, 7.98921572768712e+117},
+        {81.0, 7.15694570462638e+118},
+        {81.5, 6.43131866078814e+119},
+        {82.0, 5.79712602074737e+120},
+        {82.5, 5.24152470854233e+121},
+        {83.0, 4.75364333701284e+122},
+        {83.5, 4.32425788454742e+123},
+        {84.0, 3.94552396972066e+124},
+        {84.5, 3.6107553335971e+125},
+        {85.0, 3.31424013456535e+126},
+        {85.5, 3.05108825688955e+127},
+        {86.0, 2.81710411438055e+128},
+        {86.5, 2.60868045964056e+129},
+        {87.0, 2.42270953836727e+130},
+        {87.5, 2.25650859758909e+131},
+        {88.0, 2.10775729837953e+132},
+        {88.5, 1.97444502289045e+133},
+        {89.0, 1.85482642257398e+134},
+        {89.5, 1.74738384525805e+135},
+        {90.0, 1.65079551609085e+136},
+        {90.5, 1.56390854150595e+137},
+        {91.0, 1.48571596448176e+138},
+        {91.5, 1.41533723006289e+139},
+        {92.0, 1.3520015276784e+140},
+        {92.5, 1.29503356550754e+141},
+        {93.0, 1.24384140546413e+142},
+        {93.5, 1.19790604809448e+143},
+        {94.0, 1.15677250708164e+144},
+        {94.5, 1.12004215496834e+145},
+        {95.0, 1.08736615665674e+146},
+        {95.5, 1.05843983644508e+147},
+        {96.0, 1.03299784882391e+148},
+        {96.5, 1.01081004380505e+149},
+        {97.0, 9.9167793487095e+149},
+        {97.5, 9.75431692271873e+150},
+        {98.0, 9.61927596824821e+151},
+        {98.5, 9.51045899965076e+152},
+        {99.0, 9.42689044888325e+153},
+        {99.5, 9.367802114656e+154},
+        {100.0, 9.33262154439441e+155},
     };
 
     @Test
@@ -546,8 +546,7 @@ public class GammaTest {
         double previousGamma = Gamma.value(-18.5);
         for (double x = -19.5; x > -25; x -= 1.0) {
             double gamma = Gamma.value(x);
-            Assertions.assertEquals(  (int) Math.signum(previousGamma),
-                                - (int) Math.signum(gamma));
+            Assertions.assertEquals((int) Math.signum(previousGamma), -(int) Math.signum(gamma));
 
             previousGamma = gamma;
         }
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InvGamma1pm1Test.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InvGamma1pm1Test.java
index 328c30b..d99b316 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InvGamma1pm1Test.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InvGamma1pm1Test.java
@@ -45,23 +45,23 @@ public class InvGamma1pm1Test {
      * </pre>
      */
     private static final double[][] INV_GAMMA1P_M1_REF = {
-        { -0.5 , -.4358104164522437 },
-        { -0.375 , -.3029021533379859 },
-        { -0.25 , -0.183951060901737 },
-        { -0.125 , -.08227611018520711 },
-        { 0.0 , 0.0 },
-        { 0.125 , .06186116458306091 },
-        { 0.25 , .1032626513208373 },
-        { 0.375 , .1249687649039041 },
-        { 0.5 , .1283791670955126 },
-        { 0.625 , .1153565546592225 },
-        { 0.75 , 0.0880652521310173 },
-        { 0.875 , .04882730264547758 },
-        { 1.0 , 0.0 },
-        { 1.125 , -.05612340925950141 },
-        { 1.25 , -.1173898789433302 },
-        { 1.375 , -.1818408982517061 },
-        { 1.5 , -0.247747221936325 },
+        {-0.5, -.4358104164522437},
+        {-0.375, -.3029021533379859},
+        {-0.25, -0.183951060901737},
+        {-0.125, -.08227611018520711},
+        {0.0, 0.0},
+        {0.125, .06186116458306091},
+        {0.25, .1032626513208373},
+        {0.375, .1249687649039041},
+        {0.5, .1283791670955126},
+        {0.625, .1153565546592225},
+        {0.75, 0.0880652521310173},
+        {0.875, .04882730264547758},
+        {1.0, 0.0},
+        {1.125, -.05612340925950141},
+        {1.25, -.1173898789433302},
+        {1.375, -.1818408982517061},
+        {1.5, -0.247747221936325},
     };
 
     @Test
@@ -78,18 +78,16 @@ public class InvGamma1pm1Test {
     }
 
     @Test
-    public void testInvGamma1pm1Precondition1()
-    {
+    public void testInvGamma1pm1Precondition1() {
         Assertions.assertThrows(GammaException.class,
-                () -> InvGamma1pm1.value(-0.51)
+            () -> InvGamma1pm1.value(-0.51)
         );
     }
 
     @Test
-    public void testInvGamma1pm1Precondition2()
-    {
+    public void testInvGamma1pm1Precondition2() {
         Assertions.assertThrows(GammaException.class,
-                () -> InvGamma1pm1.value(1.51)
+            () -> InvGamma1pm1.value(1.51)
         );
     }
 }
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfcTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfcTest.java
index 991869a..a902927 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfcTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/InverseErfcTest.java
@@ -32,7 +32,7 @@ public class InverseErfcTest {
     @Test
     public void testErfcInvInfinite() {
         Assertions.assertTrue(Double.isInfinite(InverseErfc.value(-0)));
-        Assertions.assertTrue(InverseErfc.value( 0) > 0);
+        Assertions.assertTrue(InverseErfc.value(0) > 0);
         Assertions.assertTrue(Double.isInfinite(InverseErfc.value(+2)));
         Assertions.assertTrue(InverseErfc.value(+2) < 0);
     }
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogBetaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogBetaTest.java
index f6cc3bc..1dc710f 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogBetaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogBetaTest.java
@@ -27,262 +27,262 @@ import org.junit.jupiter.api.Test;
  */
 public class LogBetaTest {
     private static final double[][] LOG_BETA_REF = {
-        { 0.125 , 0.125 , 2.750814190409515 },
-        { 0.125 , 0.25 , 2.444366899981226 },
-        { 0.125 , 0.5 , 2.230953804989556 },
-        { 0.125 , 1.0 , 2.079441541679836 },
-        { 0.125 , 2.0 , 1.961658506023452 },
-        { 0.125 , 3.0 , 1.901033884207018 },
-        { 0.125 , 4.0 , 1.860211889686763 },
-        { 0.125 , 5.0 , 1.829440231020009 },
-        { 0.125 , 6.0 , 1.804747618429637 },
-        { 0.125 , 7.0 , 1.784128331226902 },
-        { 0.125 , 8.0 , 1.766428754127501 },
-        { 0.125 , 9.0 , 1.750924567591535 },
-        { 0.125 , 10.0 , 1.7371312454592 },
-        { 0.125 , 1000.0 , 1.156003642015969 },
-        { 0.125 , 1001.0 , 1.155878649827818 },
-        { 0.125 , 10000.0 , .8681312798751318 },
-        { 0.25 , 0.125 , 2.444366899981226 },
-        { 0.25 , 0.25 , 2.003680106471455 },
-        { 0.25 , 0.5 , 1.657106516191482 },
-        { 0.25 , 1.0 , 1.386294361119891 },
-        { 0.25 , 2.0 , 1.163150809805681 },
-        { 0.25 , 3.0 , 1.045367774149297 },
-        { 0.25 , 4.0 , 0.965325066475761 },
-        { 0.25 , 5.0 , .9047004446593261 },
-        { 0.25 , 6.0 , .8559102804898941 },
-        { 0.25 , 7.0 , 0.815088285969639 },
-        { 0.25 , 8.0 , .7799969661583689 },
-        { 0.25 , 9.0 , .7492253074916152 },
-        { 0.25 , 10.0 , .7218263333035008 },
-        { 0.25 , 1000.0 , - .4388225372378877 },
-        { 0.25 , 1001.0 , - .4390725059930951 },
-        { 0.25 , 10000.0 , - 1.014553193217846 },
-        { 0.5 , 0.125 , 2.230953804989556 },
-        { 0.5 , 0.25 , 1.657106516191482 },
-        { 0.5 , 0.5 , 1.1447298858494 },
-        { 0.5 , 1.0 , .6931471805599453 },
-        { 0.5 , 2.0 , .2876820724517809 },
-        { 0.5 , 3.0 , .06453852113757118 },
-//        { 0.5 , 4.0 , - .08961215868968714 },
-        { 0.5 , 5.0 , - .2073951943460706 },
-        { 0.5 , 6.0 , - .3027053741503954 },
-        { 0.5 , 7.0 , - .3827480818239319 },
-        { 0.5 , 8.0 , - .4517409533108833 },
-        { 0.5 , 9.0 , - .5123655751273182 },
-        { 0.5 , 10.0 , - .5664327963975939 },
-        { 0.5 , 1000.0 , - 2.881387696571577 },
-        { 0.5 , 1001.0 , - 2.881887571613228 },
-        { 0.5 , 10000.0 , - 4.032792743063396 },
-        { 1.0 , 0.125 , 2.079441541679836 },
-        { 1.0 , 0.25 , 1.386294361119891 },
-        { 1.0 , 0.5 , .6931471805599453 },
-        { 1.0 , 1.0 , 0.0 },
-        { 1.0 , 2.0 , - .6931471805599453 },
-        { 1.0 , 3.0 , - 1.09861228866811 },
-        { 1.0 , 4.0 , - 1.386294361119891 },
-        { 1.0 , 5.0 , - 1.6094379124341 },
-        { 1.0 , 6.0 , - 1.791759469228055 },
-        { 1.0 , 7.0 , - 1.945910149055313 },
-        { 1.0 , 8.0 , - 2.079441541679836 },
-        { 1.0 , 9.0 , - 2.19722457733622 },
-        { 1.0 , 10.0 , - 2.302585092994046 },
-        { 1.0 , 1000.0 , - 6.907755278982137 },
-        { 1.0 , 1001.0 , - 6.90875477931522 },
-        { 1.0 , 10000.0 , - 9.210340371976184 },
-        { 2.0 , 0.125 , 1.961658506023452 },
-        { 2.0 , 0.25 , 1.163150809805681 },
-        { 2.0 , 0.5 , .2876820724517809 },
-        { 2.0 , 1.0 , - .6931471805599453 },
-        { 2.0 , 2.0 , - 1.791759469228055 },
-        { 2.0 , 3.0 , - 2.484906649788 },
-        { 2.0 , 4.0 , - 2.995732273553991 },
-        { 2.0 , 5.0 , - 3.401197381662155 },
-        { 2.0 , 6.0 , - 3.737669618283368 },
-        { 2.0 , 7.0 , - 4.02535169073515 },
-        { 2.0 , 8.0 , - 4.276666119016055 },
-        { 2.0 , 9.0 , - 4.499809670330265 },
-        { 2.0 , 10.0 , - 4.700480365792417 },
-        { 2.0 , 1000.0 , - 13.81651005829736 },
-        { 2.0 , 1001.0 , - 13.81850806096003 },
-        { 2.0 , 10000.0 , - 18.4207807389527 },
-        { 3.0 , 0.125 , 1.901033884207018 },
-        { 3.0 , 0.25 , 1.045367774149297 },
-        { 3.0 , 0.5 , .06453852113757118 },
-        { 3.0 , 1.0 , - 1.09861228866811 },
-        { 3.0 , 2.0 , - 2.484906649788 },
-        { 3.0 , 3.0 , - 3.401197381662155 },
-        { 3.0 , 4.0 , - 4.0943445622221 },
-        { 3.0 , 5.0 , - 4.653960350157523 },
-        { 3.0 , 6.0 , - 5.123963979403259 },
-        { 3.0 , 7.0 , - 5.529429087511423 },
-        { 3.0 , 8.0 , - 5.886104031450156 },
-        { 3.0 , 9.0 , - 6.20455776256869 },
-        { 3.0 , 10.0 , - 6.492239835020471 },
-        { 3.0 , 1000.0 , - 20.03311615938222 },
-        { 3.0 , 1001.0 , - 20.03611166836202 },
-        { 3.0 , 10000.0 , - 26.9381739103716 },
-        { 4.0 , 0.125 , 1.860211889686763 },
-        { 4.0 , 0.25 , 0.965325066475761 },
-//        { 4.0 , 0.5 , - .08961215868968714 },
-        { 4.0 , 1.0 , - 1.386294361119891 },
-        { 4.0 , 2.0 , - 2.995732273553991 },
-        { 4.0 , 3.0 , - 4.0943445622221 },
-        { 4.0 , 4.0 , - 4.941642422609304 },
-        { 4.0 , 5.0 , - 5.634789603169249 },
-        { 4.0 , 6.0 , - 6.222576268071369 },
-        { 4.0 , 7.0 , - 6.733401891837359 },
-        { 4.0 , 8.0 , - 7.185387015580416 },
-        { 4.0 , 9.0 , - 7.590852123688581 },
-        { 4.0 , 10.0 , - 7.958576903813898 },
-        { 4.0 , 1000.0 , - 25.84525465867605 },
-        { 4.0 , 1001.0 , - 25.84924667994559 },
-        { 4.0 , 10000.0 , - 35.05020194868867 },
-        { 5.0 , 0.125 , 1.829440231020009 },
-        { 5.0 , 0.25 , .9047004446593261 },
-        { 5.0 , 0.5 , - .2073951943460706 },
-        { 5.0 , 1.0 , - 1.6094379124341 },
-        { 5.0 , 2.0 , - 3.401197381662155 },
-        { 5.0 , 3.0 , - 4.653960350157523 },
-        { 5.0 , 4.0 , - 5.634789603169249 },
-        { 5.0 , 5.0 , - 6.445719819385578 },
-        { 5.0 , 6.0 , - 7.138866999945524 },
-        { 5.0 , 7.0 , - 7.745002803515839 },
-        { 5.0 , 8.0 , - 8.283999304248526 },
-        { 5.0 , 9.0 , - 8.769507120030227 },
-        { 5.0 , 10.0 , - 9.211339872309265 },
-        { 5.0 , 1000.0 , - 31.37070759780783 },
-        { 5.0 , 1001.0 , - 31.37569513931887 },
-        { 5.0 , 10000.0 , - 42.87464787956629 },
-        { 6.0 , 0.125 , 1.804747618429637 },
-        { 6.0 , 0.25 , .8559102804898941 },
-        { 6.0 , 0.5 , - .3027053741503954 },
-        { 6.0 , 1.0 , - 1.791759469228055 },
-        { 6.0 , 2.0 , - 3.737669618283368 },
-        { 6.0 , 3.0 , - 5.123963979403259 },
-        { 6.0 , 4.0 , - 6.222576268071369 },
-        { 6.0 , 5.0 , - 7.138866999945524 },
-        { 6.0 , 6.0 , - 7.927324360309794 },
-        { 6.0 , 7.0 , - 8.620471540869739 },
-        { 6.0 , 8.0 , - 9.239510749275963 },
-        { 6.0 , 9.0 , - 9.799126537211386 },
-        { 6.0 , 10.0 , - 10.30995216097738 },
-        { 6.0 , 1000.0 , - 36.67401250586691 },
-        { 6.0 , 1001.0 , - 36.67999457754446 },
-        { 6.0 , 10000.0 , - 50.47605021415003 },
-        { 7.0 , 0.125 , 1.784128331226902 },
-        { 7.0 , 0.25 , 0.815088285969639 },
-        { 7.0 , 0.5 , - .3827480818239319 },
-        { 7.0 , 1.0 , - 1.945910149055313 },
-        { 7.0 , 2.0 , - 4.02535169073515 },
-        { 7.0 , 3.0 , - 5.529429087511423 },
-        { 7.0 , 4.0 , - 6.733401891837359 },
-        { 7.0 , 5.0 , - 7.745002803515839 },
-        { 7.0 , 6.0 , - 8.620471540869739 },
-        { 7.0 , 7.0 , - 9.39366142910322 },
-        { 7.0 , 8.0 , - 10.08680860966317 },
-        { 7.0 , 9.0 , - 10.71541726908554 },
-        { 7.0 , 10.0 , - 11.2907814139891 },
-        { 7.0 , 1000.0 , - 41.79599038729854 },
-        { 7.0 , 1001.0 , - 41.80296600103496 },
-        { 7.0 , 10000.0 , - 57.89523093697012 },
-        { 8.0 , 0.125 , 1.766428754127501 },
-        { 8.0 , 0.25 , .7799969661583689 },
-        { 8.0 , 0.5 , - .4517409533108833 },
-        { 8.0 , 1.0 , - 2.079441541679836 },
-        { 8.0 , 2.0 , - 4.276666119016055 },
-        { 8.0 , 3.0 , - 5.886104031450156 },
-        { 8.0 , 4.0 , - 7.185387015580416 },
-        { 8.0 , 5.0 , - 8.283999304248526 },
-        { 8.0 , 6.0 , - 9.239510749275963 },
-        { 8.0 , 7.0 , - 10.08680860966317 },
-        { 8.0 , 8.0 , - 10.84894866171006 },
-        { 8.0 , 9.0 , - 11.54209584227001 },
-        { 8.0 , 10.0 , - 12.17808460899001 },
-        { 8.0 , 1000.0 , - 46.76481113096179 },
-        { 8.0 , 1001.0 , - 46.77277930061096 },
-        { 8.0 , 10000.0 , - 65.16036091500527 },
-        { 9.0 , 0.125 , 1.750924567591535 },
-        { 9.0 , 0.25 , .7492253074916152 },
-        { 9.0 , 0.5 , - .5123655751273182 },
-        { 9.0 , 1.0 , - 2.19722457733622 },
-        { 9.0 , 2.0 , - 4.499809670330265 },
-        { 9.0 , 3.0 , - 6.20455776256869 },
-        { 9.0 , 4.0 , - 7.590852123688581 },
-        { 9.0 , 5.0 , - 8.769507120030227 },
-        { 9.0 , 6.0 , - 9.799126537211386 },
-        { 9.0 , 7.0 , - 10.71541726908554 },
-        { 9.0 , 8.0 , - 11.54209584227001 },
-        { 9.0 , 9.0 , - 12.29586764464639 },
-        { 9.0 , 10.0 , - 12.98901482520633 },
-        { 9.0 , 1000.0 , - 51.60109303791327 },
-        { 9.0 , 1001.0 , - 51.61005277928474 },
-        { 9.0 , 10000.0 , - 72.29205942547217 },
-        { 10.0 , 0.125 , 1.7371312454592 },
-        { 10.0 , 0.25 , .7218263333035008 },
-        { 10.0 , 0.5 , - .5664327963975939 },
-        { 10.0 , 1.0 , - 2.302585092994046 },
-        { 10.0 , 2.0 , - 4.700480365792417 },
-        { 10.0 , 3.0 , - 6.492239835020471 },
-        { 10.0 , 4.0 , - 7.958576903813898 },
-        { 10.0 , 5.0 , - 9.211339872309265 },
-        { 10.0 , 6.0 , - 10.30995216097738 },
-        { 10.0 , 7.0 , - 11.2907814139891 },
-        { 10.0 , 8.0 , - 12.17808460899001 },
-        { 10.0 , 9.0 , - 12.98901482520633 },
-        { 10.0 , 10.0 , - 13.73622922703655 },
-        { 10.0 , 1000.0 , - 56.32058348093065 },
-        { 10.0 , 1001.0 , - 56.33053381178382 },
-        { 10.0 , 10000.0 , - 79.30607481535498 },
-        { 1000.0 , 0.125 , 1.156003642015969 },
-        { 1000.0 , 0.25 , - .4388225372378877 },
-        { 1000.0 , 0.5 , - 2.881387696571577 },
-        { 1000.0 , 1.0 , - 6.907755278982137 },
-        { 1000.0 , 2.0 , - 13.81651005829736 },
-        { 1000.0 , 3.0 , - 20.03311615938222 },
-        { 1000.0 , 4.0 , - 25.84525465867605 },
-        { 1000.0 , 5.0 , - 31.37070759780783 },
-        { 1000.0 , 6.0 , - 36.67401250586691 },
-        { 1000.0 , 7.0 , - 41.79599038729854 },
-        { 1000.0 , 8.0 , - 46.76481113096179 },
-        { 1000.0 , 9.0 , - 51.60109303791327 },
-        { 1000.0 , 10.0 , - 56.32058348093065 },
-        { 1000.0 , 1000.0 , - 1388.482601635902 },
-        { 1000.0 , 1001.0 , - 1389.175748816462 },
-        { 1000.0 , 10000.0 , - 3353.484270767097 },
-        { 1001.0 , 0.125 , 1.155878649827818 },
-        { 1001.0 , 0.25 , - .4390725059930951 },
-        { 1001.0 , 0.5 , - 2.881887571613228 },
-        { 1001.0 , 1.0 , - 6.90875477931522 },
-        { 1001.0 , 2.0 , - 13.81850806096003 },
-        { 1001.0 , 3.0 , - 20.03611166836202 },
-        { 1001.0 , 4.0 , - 25.84924667994559 },
-        { 1001.0 , 5.0 , - 31.37569513931887 },
-        { 1001.0 , 6.0 , - 36.67999457754446 },
-        { 1001.0 , 7.0 , - 41.80296600103496 },
-        { 1001.0 , 8.0 , - 46.77277930061096 },
-        { 1001.0 , 9.0 , - 51.61005277928474 },
-        { 1001.0 , 10.0 , - 56.33053381178382 },
-        { 1001.0 , 1000.0 , - 1389.175748816462 },
-        { 1001.0 , 1001.0 , - 1389.869395872064 },
-        { 1001.0 , 10000.0 , - 3355.882166039895 },
-        { 10000.0 , 0.125 , .8681312798751318 },
-        { 10000.0 , 0.25 , - 1.014553193217846 },
-        { 10000.0 , 0.5 , - 4.032792743063396 },
-        { 10000.0 , 1.0 , - 9.210340371976184 },
-        { 10000.0 , 2.0 , - 18.4207807389527 },
-        { 10000.0 , 3.0 , - 26.9381739103716 },
-        { 10000.0 , 4.0 , - 35.05020194868867 },
-        { 10000.0 , 5.0 , - 42.87464787956629 },
-        { 10000.0 , 6.0 , - 50.47605021415003 },
-        { 10000.0 , 7.0 , - 57.89523093697012 },
-        { 10000.0 , 8.0 , - 65.16036091500527 },
-        { 10000.0 , 9.0 , - 72.29205942547217 },
-        { 10000.0 , 10.0 , - 79.30607481535498 },
-        { 10000.0 , 1000.0 , - 3353.484270767097 },
-        { 10000.0 , 1001.0 , - 3355.882166039895 },
-        { 10000.0 , 10000.0 , - 13866.28325676141 },
+        {0.125, 0.125, 2.750814190409515},
+        {0.125, 0.25, 2.444366899981226},
+        {0.125, 0.5, 2.230953804989556},
+        {0.125, 1.0, 2.079441541679836},
+        {0.125, 2.0, 1.961658506023452},
+        {0.125, 3.0, 1.901033884207018},
+        {0.125, 4.0, 1.860211889686763},
+        {0.125, 5.0, 1.829440231020009},
+        {0.125, 6.0, 1.804747618429637},
+        {0.125, 7.0, 1.784128331226902},
+        {0.125, 8.0, 1.766428754127501},
+        {0.125, 9.0, 1.750924567591535},
+        {0.125, 10.0, 1.7371312454592},
+        {0.125, 1000.0, 1.156003642015969},
+        {0.125, 1001.0, 1.155878649827818},
+        {0.125, 10000.0, .8681312798751318},
+        {0.25, 0.125, 2.444366899981226},
+        {0.25, 0.25, 2.003680106471455},
+        {0.25, 0.5, 1.657106516191482},
+        {0.25, 1.0, 1.386294361119891},
+        {0.25, 2.0, 1.163150809805681},
+        {0.25, 3.0, 1.045367774149297},
+        {0.25, 4.0, 0.965325066475761},
+        {0.25, 5.0, .9047004446593261},
+        {0.25, 6.0, .8559102804898941},
+        {0.25, 7.0, 0.815088285969639},
+        {0.25, 8.0, .7799969661583689},
+        {0.25, 9.0, .7492253074916152},
+        {0.25, 10.0, .7218263333035008},
+        {0.25, 1000.0, -.4388225372378877},
+        {0.25, 1001.0, -.4390725059930951},
+        {0.25, 10000.0, -1.014553193217846},
+        {0.5, 0.125, 2.230953804989556},
+        {0.5, 0.25, 1.657106516191482},
+        {0.5, 0.5, 1.1447298858494},
+        {0.5, 1.0, .6931471805599453},
+        {0.5, 2.0, .2876820724517809},
+        {0.5, 3.0, .06453852113757118},
+//        {0.5, 4.0, -.08961215868968714},
+        {0.5, 5.0, -.2073951943460706},
+        {0.5, 6.0, -.3027053741503954},
+        {0.5, 7.0, -.3827480818239319},
+        {0.5, 8.0, -.4517409533108833},
+        {0.5, 9.0, -.5123655751273182},
+        {0.5, 10.0, -.5664327963975939},
+        {0.5, 1000.0, -2.881387696571577},
+        {0.5, 1001.0, -2.881887571613228},
+        {0.5, 10000.0, -4.032792743063396},
+        {1.0, 0.125, 2.079441541679836},
+        {1.0, 0.25, 1.386294361119891},
+        {1.0, 0.5, .6931471805599453},
+        {1.0, 1.0, 0.0},
+        {1.0, 2.0, -.6931471805599453},
+        {1.0, 3.0, -1.09861228866811},
+        {1.0, 4.0, -1.386294361119891},
+        {1.0, 5.0, -1.6094379124341},
+        {1.0, 6.0, -1.791759469228055},
+        {1.0, 7.0, -1.945910149055313},
+        {1.0, 8.0, -2.079441541679836},
+        {1.0, 9.0, -2.19722457733622},
+        {1.0, 10.0, -2.302585092994046},
+        {1.0, 1000.0, -6.907755278982137},
+        {1.0, 1001.0, -6.90875477931522},
+        {1.0, 10000.0, -9.210340371976184},
+        {2.0, 0.125, 1.961658506023452},
+        {2.0, 0.25, 1.163150809805681},
+        {2.0, 0.5, .2876820724517809},
+        {2.0, 1.0, -.6931471805599453},
+        {2.0, 2.0, -1.791759469228055},
+        {2.0, 3.0, -2.484906649788},
+        {2.0, 4.0, -2.995732273553991},
+        {2.0, 5.0, -3.401197381662155},
+        {2.0, 6.0, -3.737669618283368},
+        {2.0, 7.0, -4.02535169073515},
+        {2.0, 8.0, -4.276666119016055},
+        {2.0, 9.0, -4.499809670330265},
+        {2.0, 10.0, -4.700480365792417},
+        {2.0, 1000.0, -13.81651005829736},
+        {2.0, 1001.0, -13.81850806096003},
+        {2.0, 10000.0, -18.4207807389527},
+        {3.0, 0.125, 1.901033884207018},
+        {3.0, 0.25, 1.045367774149297},
+        {3.0, 0.5, .06453852113757118},
+        {3.0, 1.0, -1.09861228866811},
+        {3.0, 2.0, -2.484906649788},
+        {3.0, 3.0, -3.401197381662155},
+        {3.0, 4.0, -4.0943445622221},
+        {3.0, 5.0, -4.653960350157523},
+        {3.0, 6.0, -5.123963979403259},
+        {3.0, 7.0, -5.529429087511423},
+        {3.0, 8.0, -5.886104031450156},
+        {3.0, 9.0, -6.20455776256869},
+        {3.0, 10.0, -6.492239835020471},
+        {3.0, 1000.0, -20.03311615938222},
+        {3.0, 1001.0, -20.03611166836202},
+        {3.0, 10000.0, -26.9381739103716},
+        {4.0, 0.125, 1.860211889686763},
+        {4.0, 0.25, 0.965325066475761},
+//        {4.0, 0.5, -.08961215868968714},
+        {4.0, 1.0, -1.386294361119891},
+        {4.0, 2.0, -2.995732273553991},
+        {4.0, 3.0, -4.0943445622221},
+        {4.0, 4.0, -4.941642422609304},
+        {4.0, 5.0, -5.634789603169249},
+        {4.0, 6.0, -6.222576268071369},
+        {4.0, 7.0, -6.733401891837359},
+        {4.0, 8.0, -7.185387015580416},
+        {4.0, 9.0, -7.590852123688581},
+        {4.0, 10.0, -7.958576903813898},
+        {4.0, 1000.0, -25.84525465867605},
+        {4.0, 1001.0, -25.84924667994559},
+        {4.0, 10000.0, -35.05020194868867},
+        {5.0, 0.125, 1.829440231020009},
+        {5.0, 0.25, .9047004446593261},
+        {5.0, 0.5, -.2073951943460706},
+        {5.0, 1.0, -1.6094379124341},
+        {5.0, 2.0, -3.401197381662155},
+        {5.0, 3.0, -4.653960350157523},
+        {5.0, 4.0, -5.634789603169249},
+        {5.0, 5.0, -6.445719819385578},
+        {5.0, 6.0, -7.138866999945524},
+        {5.0, 7.0, -7.745002803515839},
+        {5.0, 8.0, -8.283999304248526},
+        {5.0, 9.0, -8.769507120030227},
+        {5.0, 10.0, -9.211339872309265},
+        {5.0, 1000.0, -31.37070759780783},
+        {5.0, 1001.0, -31.37569513931887},
+        {5.0, 10000.0, -42.87464787956629},
+        {6.0, 0.125, 1.804747618429637},
+        {6.0, 0.25, .8559102804898941},
+        {6.0, 0.5, -.3027053741503954},
+        {6.0, 1.0, -1.791759469228055},
+        {6.0, 2.0, -3.737669618283368},
+        {6.0, 3.0, -5.123963979403259},
+        {6.0, 4.0, -6.222576268071369},
+        {6.0, 5.0, -7.138866999945524},
+        {6.0, 6.0, -7.927324360309794},
+        {6.0, 7.0, -8.620471540869739},
+        {6.0, 8.0, -9.239510749275963},
+        {6.0, 9.0, -9.799126537211386},
+        {6.0, 10.0, -10.30995216097738},
+        {6.0, 1000.0, -36.67401250586691},
+        {6.0, 1001.0, -36.67999457754446},
+        {6.0, 10000.0, -50.47605021415003},
+        {7.0, 0.125, 1.784128331226902},
+        {7.0, 0.25, 0.815088285969639},
+        {7.0, 0.5, -.3827480818239319},
+        {7.0, 1.0, -1.945910149055313},
+        {7.0, 2.0, -4.02535169073515},
+        {7.0, 3.0, -5.529429087511423},
+        {7.0, 4.0, -6.733401891837359},
+        {7.0, 5.0, -7.745002803515839},
+        {7.0, 6.0, -8.620471540869739},
+        {7.0, 7.0, -9.39366142910322},
+        {7.0, 8.0, -10.08680860966317},
+        {7.0, 9.0, -10.71541726908554},
+        {7.0, 10.0, -11.2907814139891},
+        {7.0, 1000.0, -41.79599038729854},
+        {7.0, 1001.0, -41.80296600103496},
+        {7.0, 10000.0, -57.89523093697012},
+        {8.0, 0.125, 1.766428754127501},
+        {8.0, 0.25, .7799969661583689},
+        {8.0, 0.5, -.4517409533108833},
+        {8.0, 1.0, -2.079441541679836},
+        {8.0, 2.0, -4.276666119016055},
+        {8.0, 3.0, -5.886104031450156},
+        {8.0, 4.0, -7.185387015580416},
+        {8.0, 5.0, -8.283999304248526},
+        {8.0, 6.0, -9.239510749275963},
+        {8.0, 7.0, -10.08680860966317},
+        {8.0, 8.0, -10.84894866171006},
+        {8.0, 9.0, -11.54209584227001},
+        {8.0, 10.0, -12.17808460899001},
+        {8.0, 1000.0, -46.76481113096179},
+        {8.0, 1001.0, -46.77277930061096},
+        {8.0, 10000.0, -65.16036091500527},
+        {9.0, 0.125, 1.750924567591535},
+        {9.0, 0.25, .7492253074916152},
+        {9.0, 0.5, -.5123655751273182},
+        {9.0, 1.0, -2.19722457733622},
+        {9.0, 2.0, -4.499809670330265},
+        {9.0, 3.0, -6.20455776256869},
+        {9.0, 4.0, -7.590852123688581},
+        {9.0, 5.0, -8.769507120030227},
+        {9.0, 6.0, -9.799126537211386},
+        {9.0, 7.0, -10.71541726908554},
+        {9.0, 8.0, -11.54209584227001},
+        {9.0, 9.0, -12.29586764464639},
+        {9.0, 10.0, -12.98901482520633},
+        {9.0, 1000.0, -51.60109303791327},
+        {9.0, 1001.0, -51.61005277928474},
+        {9.0, 10000.0, -72.29205942547217},
+        {10.0, 0.125, 1.7371312454592},
+        {10.0, 0.25, .7218263333035008},
+        {10.0, 0.5, -.5664327963975939},
+        {10.0, 1.0, -2.302585092994046},
+        {10.0, 2.0, -4.700480365792417},
+        {10.0, 3.0, -6.492239835020471},
+        {10.0, 4.0, -7.958576903813898},
+        {10.0, 5.0, -9.211339872309265},
+        {10.0, 6.0, -10.30995216097738},
+        {10.0, 7.0, -11.2907814139891},
+        {10.0, 8.0, -12.17808460899001},
+        {10.0, 9.0, -12.98901482520633},
+        {10.0, 10.0, -13.73622922703655},
+        {10.0, 1000.0, -56.32058348093065},
+        {10.0, 1001.0, -56.33053381178382},
+        {10.0, 10000.0, -79.30607481535498},
+        {1000.0, 0.125, 1.156003642015969},
+        {1000.0, 0.25, -.4388225372378877},
+        {1000.0, 0.5, -2.881387696571577},
+        {1000.0, 1.0, -6.907755278982137},
+        {1000.0, 2.0, -13.81651005829736},
+        {1000.0, 3.0, -20.03311615938222},
+        {1000.0, 4.0, -25.84525465867605},
+        {1000.0, 5.0, -31.37070759780783},
+        {1000.0, 6.0, -36.67401250586691},
+        {1000.0, 7.0, -41.79599038729854},
+        {1000.0, 8.0, -46.76481113096179},
+        {1000.0, 9.0, -51.60109303791327},
+        {1000.0, 10.0, -56.32058348093065},
+        {1000.0, 1000.0, -1388.482601635902},
+        {1000.0, 1001.0, -1389.175748816462},
+        {1000.0, 10000.0, -3353.484270767097},
+        {1001.0, 0.125, 1.155878649827818},
+        {1001.0, 0.25, -.4390725059930951},
+        {1001.0, 0.5, -2.881887571613228},
+        {1001.0, 1.0, -6.90875477931522},
+        {1001.0, 2.0, -13.81850806096003},
+        {1001.0, 3.0, -20.03611166836202},
+        {1001.0, 4.0, -25.84924667994559},
+        {1001.0, 5.0, -31.37569513931887},
+        {1001.0, 6.0, -36.67999457754446},
+        {1001.0, 7.0, -41.80296600103496},
+        {1001.0, 8.0, -46.77277930061096},
+        {1001.0, 9.0, -51.61005277928474},
+        {1001.0, 10.0, -56.33053381178382},
+        {1001.0, 1000.0, -1389.175748816462},
+        {1001.0, 1001.0, -1389.869395872064},
+        {1001.0, 10000.0, -3355.882166039895},
+        {10000.0, 0.125, .8681312798751318},
+        {10000.0, 0.25, -1.014553193217846},
+        {10000.0, 0.5, -4.032792743063396},
+        {10000.0, 1.0, -9.210340371976184},
+        {10000.0, 2.0, -18.4207807389527},
+        {10000.0, 3.0, -26.9381739103716},
+        {10000.0, 4.0, -35.05020194868867},
+        {10000.0, 5.0, -42.87464787956629},
+        {10000.0, 6.0, -50.47605021415003},
+        {10000.0, 7.0, -57.89523093697012},
+        {10000.0, 8.0, -65.16036091500527},
+        {10000.0, 9.0, -72.29205942547217},
+        {10000.0, 10.0, -79.30607481535498},
+        {10000.0, 1000.0, -3353.484270767097},
+        {10000.0, 1001.0, -3355.882166039895},
+        {10000.0, 10000.0, -13866.28325676141},
     };
 
     @Test
@@ -343,128 +343,129 @@ public class LogBetaTest {
         Assertions.assertEquals(expected, actual, 1e-15);
     }
 
+    // CHECKSTYLE: stop DeclarationOrder
     private static final double[][] LOG_GAMMA_MINUS_LOG_GAMMA_SUM_REF = {
 //        { 0.0 , 8.0 , 0.0 },
 //        { 0.0 , 9.0 , 0.0 },
-        { 0.0 , 10.0 , 0.0 },
-        { 0.0 , 11.0 , 0.0 },
-        { 0.0 , 12.0 , 0.0 },
-        { 0.0 , 13.0 , 0.0 },
-        { 0.0 , 14.0 , 0.0 },
-        { 0.0 , 15.0 , 0.0 },
-        { 0.0 , 16.0 , 0.0 },
-        { 0.0 , 17.0 , 0.0 },
-        { 0.0 , 18.0 , 0.0 },
-//        { 1.0 , 8.0 , - 2.079441541679836 },
-//        { 1.0 , 9.0 , - 2.19722457733622 },
-        { 1.0 , 10.0 , - 2.302585092994046 },
-        { 1.0 , 11.0 , - 2.397895272798371 },
-        { 1.0 , 12.0 , - 2.484906649788 },
-        { 1.0 , 13.0 , - 2.564949357461537 },
-        { 1.0 , 14.0 , - 2.639057329615258 },
-        { 1.0 , 15.0 , - 2.70805020110221 },
-        { 1.0 , 16.0 , - 2.772588722239781 },
-        { 1.0 , 17.0 , - 2.833213344056216 },
-        { 1.0 , 18.0 , - 2.890371757896165 },
-//        { 2.0 , 8.0 , - 4.276666119016055 },
-//        { 2.0 , 9.0 , - 4.499809670330265 },
-        { 2.0 , 10.0 , - 4.700480365792417 },
-        { 2.0 , 11.0 , - 4.882801922586371 },
-        { 2.0 , 12.0 , - 5.049856007249537 },
-        { 2.0 , 13.0 , - 5.204006687076795 },
-        { 2.0 , 14.0 , - 5.347107530717468 },
-        { 2.0 , 15.0 , - 5.480638923341991 },
-        { 2.0 , 16.0 , - 5.605802066295998 },
-        { 2.0 , 17.0 , - 5.723585101952381 },
-        { 2.0 , 18.0 , - 5.834810737062605 },
-//        { 3.0 , 8.0 , - 6.579251212010101 },
-//        { 3.0 , 9.0 , - 6.897704943128636 },
-        { 3.0 , 10.0 , - 7.185387015580416 },
-        { 3.0 , 11.0 , - 7.447751280047908 },
-        { 3.0 , 12.0 , - 7.688913336864796 },
-        { 3.0 , 13.0 , - 7.912056888179006 },
-        { 3.0 , 14.0 , - 8.11969625295725 },
-        { 3.0 , 15.0 , - 8.313852267398207 },
-        { 3.0 , 16.0 , - 8.496173824192162 },
-        { 3.0 , 17.0 , - 8.668024081118821 },
-        { 3.0 , 18.0 , - 8.830543010616596 },
-//        { 4.0 , 8.0 , - 8.977146484808472 },
-//        { 4.0 , 9.0 , - 9.382611592916636 },
-        { 4.0 , 10.0 , - 9.750336373041954 },
-        { 4.0 , 11.0 , - 10.08680860966317 },
-        { 4.0 , 12.0 , - 10.39696353796701 },
-        { 4.0 , 13.0 , - 10.68464561041879 },
-        { 4.0 , 14.0 , - 10.95290959701347 },
-        { 4.0 , 15.0 , - 11.20422402529437 },
-        { 4.0 , 16.0 , - 11.4406128033586 },
-        { 4.0 , 17.0 , - 11.66375635467281 },
-        { 4.0 , 18.0 , - 11.87506544834002 },
-//        { 5.0 , 8.0 , - 11.46205313459647 },
-//        { 5.0 , 9.0 , - 11.94756095037817 },
-        { 5.0 , 10.0 , - 12.38939370265721 },
-        { 5.0 , 11.0 , - 12.79485881076538 },
-        { 5.0 , 12.0 , - 13.16955226020679 },
-        { 5.0 , 13.0 , - 13.517858954475 },
-        { 5.0 , 14.0 , - 13.84328135490963 },
-        { 5.0 , 15.0 , - 14.14866300446081 },
-        { 5.0 , 16.0 , - 14.43634507691259 },
-        { 5.0 , 17.0 , - 14.70827879239624 },
-        { 5.0 , 18.0 , - 14.96610790169833 },
-//        { 6.0 , 8.0 , - 14.02700249205801 },
-//        { 6.0 , 9.0 , - 14.58661827999343 },
-        { 6.0 , 10.0 , - 15.09744390375942 },
-        { 6.0 , 11.0 , - 15.56744753300516 },
-        { 6.0 , 12.0 , - 16.002765604263 },
-        { 6.0 , 13.0 , - 16.40823071237117 },
-        { 6.0 , 14.0 , - 16.78772033407607 },
-        { 6.0 , 15.0 , - 17.14439527801481 },
-        { 6.0 , 16.0 , - 17.48086751463602 },
-        { 6.0 , 17.0 , - 17.79932124575455 },
-        { 6.0 , 18.0 , - 18.10160211762749 },
-//        { 7.0 , 8.0 , - 16.66605982167327 },
-//        { 7.0 , 9.0 , - 17.29466848109564 },
-        { 7.0 , 10.0 , - 17.8700326259992 },
-        { 7.0 , 11.0 , - 18.40066087706137 },
-        { 7.0 , 12.0 , - 18.89313736215917 },
-        { 7.0 , 13.0 , - 19.35266969153761 },
-        { 7.0 , 14.0 , - 19.78345260763006 },
-        { 7.0 , 15.0 , - 20.18891771573823 },
-        { 7.0 , 16.0 , - 20.57190996799433 },
-        { 7.0 , 17.0 , - 20.9348154616837 },
-        { 7.0 , 18.0 , - 21.27965594797543 },
-//        { 8.0 , 8.0 , - 19.37411002277548 },
-//        { 8.0 , 9.0 , - 20.06725720333542 },
-        { 8.0 , 10.0 , - 20.70324597005542 },
-        { 8.0 , 11.0 , - 21.29103263495754 },
-        { 8.0 , 12.0 , - 21.83757634132561 },
-        { 8.0 , 13.0 , - 22.3484019650916 },
-        { 8.0 , 14.0 , - 22.82797504535349 },
-        { 8.0 , 15.0 , - 23.27996016909654 },
-        { 8.0 , 16.0 , - 23.70740418392348 },
-        { 8.0 , 17.0 , - 24.11286929203165 },
-        { 8.0 , 18.0 , - 24.49853177284363 },
-//        { 9.0 , 8.0 , - 22.14669874501526 },
-//        { 9.0 , 9.0 , - 22.90047054739164 },
-        { 9.0 , 10.0 , - 23.59361772795159 },
-        { 9.0 , 11.0 , - 24.23547161412398 },
-        { 9.0 , 12.0 , - 24.8333086148796 },
-        { 9.0 , 13.0 , - 25.39292440281502 },
-        { 9.0 , 14.0 , - 25.9190174987118 },
-        { 9.0 , 15.0 , - 26.41545438502569 },
-        { 9.0 , 16.0 , - 26.88545801427143 },
-        { 9.0 , 17.0 , - 27.33174511689985 },
-        { 9.0 , 18.0 , - 27.75662831086511 },
-//        { 10.0 , 8.0 , - 24.97991208907148 },
-//        { 10.0 , 9.0 , - 25.7908423052878 },
-        { 10.0 , 10.0 , - 26.53805670711802 },
-        { 10.0 , 11.0 , - 27.23120388767797 },
-        { 10.0 , 12.0 , - 27.87783105260302 },
-        { 10.0 , 13.0 , - 28.48396685617334 },
-        { 10.0 , 14.0 , - 29.05451171464095 },
-        { 10.0 , 15.0 , - 29.59350821537364 },
-        { 10.0 , 16.0 , - 30.10433383913963 },
-        { 10.0 , 17.0 , - 30.58984165492133 },
-        { 10.0 , 18.0 , - 31.05246517686944 },
+        {0.0, 10.0, 0.0},
+        {0.0, 11.0, 0.0},
+        {0.0, 12.0, 0.0},
+        {0.0, 13.0, 0.0},
+        {0.0, 14.0, 0.0},
+        {0.0, 15.0, 0.0},
+        {0.0, 16.0, 0.0},
+        {0.0, 17.0, 0.0},
+        {0.0, 18.0, 0.0},
+//        {1.0, 8.0, -2.079441541679836},
+//        {1.0, 9.0, -2.19722457733622},
+        {1.0, 10.0, -2.302585092994046},
+        {1.0, 11.0, -2.397895272798371},
+        {1.0, 12.0, -2.484906649788},
+        {1.0, 13.0, -2.564949357461537},
+        {1.0, 14.0, -2.639057329615258},
+        {1.0, 15.0, -2.70805020110221},
+        {1.0, 16.0, -2.772588722239781},
+        {1.0, 17.0, -2.833213344056216},
+        {1.0, 18.0, -2.890371757896165},
+//        {2.0, 8.0, -4.276666119016055},
+//        {2.0, 9.0, -4.499809670330265},
+        {2.0, 10.0, -4.700480365792417},
+        {2.0, 11.0, -4.882801922586371},
+        {2.0, 12.0, -5.049856007249537},
+        {2.0, 13.0, -5.204006687076795},
+        {2.0, 14.0, -5.347107530717468},
+        {2.0, 15.0, -5.480638923341991},
+        {2.0, 16.0, -5.605802066295998},
+        {2.0, 17.0, -5.723585101952381},
+        {2.0, 18.0, -5.834810737062605},
+//        {3.0, 8.0, -6.579251212010101},
+//        {3.0, 9.0, -6.897704943128636},
+        {3.0, 10.0, -7.185387015580416},
+        {3.0, 11.0, -7.447751280047908},
+        {3.0, 12.0, -7.688913336864796},
+        {3.0, 13.0, -7.912056888179006},
+        {3.0, 14.0, -8.11969625295725},
+        {3.0, 15.0, -8.313852267398207},
+        {3.0, 16.0, -8.496173824192162},
+        {3.0, 17.0, -8.668024081118821},
+        {3.0, 18.0, -8.830543010616596},
+//        {4.0, 8.0, -8.977146484808472},
+//        {4.0, 9.0, -9.382611592916636},
+        {4.0, 10.0, -9.750336373041954},
+        {4.0, 11.0, -10.08680860966317},
+        {4.0, 12.0, -10.39696353796701},
+        {4.0, 13.0, -10.68464561041879},
+        {4.0, 14.0, -10.95290959701347},
+        {4.0, 15.0, -11.20422402529437},
+        {4.0, 16.0, -11.4406128033586},
+        {4.0, 17.0, -11.66375635467281},
+        {4.0, 18.0, -11.87506544834002},
+//        {5.0, 8.0, -11.46205313459647},
+//        {5.0, 9.0, -11.94756095037817},
+        {5.0, 10.0, -12.38939370265721},
+        {5.0, 11.0, -12.79485881076538},
+        {5.0, 12.0, -13.16955226020679},
+        {5.0, 13.0, -13.517858954475},
+        {5.0, 14.0, -13.84328135490963},
+        {5.0, 15.0, -14.14866300446081},
+        {5.0, 16.0, -14.43634507691259},
+        {5.0, 17.0, -14.70827879239624},
+        {5.0, 18.0, -14.96610790169833},
+//        {6.0, 8.0, -14.02700249205801},
+//        {6.0, 9.0, -14.58661827999343},
+        {6.0, 10.0, -15.09744390375942},
+        {6.0, 11.0, -15.56744753300516},
+        {6.0, 12.0, -16.002765604263},
+        {6.0, 13.0, -16.40823071237117},
+        {6.0, 14.0, -16.78772033407607},
+        {6.0, 15.0, -17.14439527801481},
+        {6.0, 16.0, -17.48086751463602},
+        {6.0, 17.0, -17.79932124575455},
+        {6.0, 18.0, -18.10160211762749},
+//        {7.0, 8.0, -16.66605982167327},
+//        {7.0, 9.0, -17.29466848109564},
+        {7.0, 10.0, -17.8700326259992},
+        {7.0, 11.0, -18.40066087706137},
+        {7.0, 12.0, -18.89313736215917},
+        {7.0, 13.0, -19.35266969153761},
+        {7.0, 14.0, -19.78345260763006},
+        {7.0, 15.0, -20.18891771573823},
+        {7.0, 16.0, -20.57190996799433},
+        {7.0, 17.0, -20.9348154616837},
+        {7.0, 18.0, -21.27965594797543},
+//        {8.0, 8.0, -19.37411002277548},
+//        {8.0, 9.0, -20.06725720333542},
+        {8.0, 10.0, -20.70324597005542},
+        {8.0, 11.0, -21.29103263495754},
+        {8.0, 12.0, -21.83757634132561},
+        {8.0, 13.0, -22.3484019650916},
+        {8.0, 14.0, -22.82797504535349},
+        {8.0, 15.0, -23.27996016909654},
+        {8.0, 16.0, -23.70740418392348},
+        {8.0, 17.0, -24.11286929203165},
+        {8.0, 18.0, -24.49853177284363},
+//        {9.0, 8.0, -22.14669874501526},
+//        {9.0, 9.0, -22.90047054739164},
+        {9.0, 10.0, -23.59361772795159},
+        {9.0, 11.0, -24.23547161412398},
+        {9.0, 12.0, -24.8333086148796},
+        {9.0, 13.0, -25.39292440281502},
+        {9.0, 14.0, -25.9190174987118},
+        {9.0, 15.0, -26.41545438502569},
+        {9.0, 16.0, -26.88545801427143},
+        {9.0, 17.0, -27.33174511689985},
+        {9.0, 18.0, -27.75662831086511},
+//        {10.0, 8.0, -24.97991208907148},
+//        {10.0, 9.0, -25.7908423052878},
+        {10.0, 10.0, -26.53805670711802},
+        {10.0, 11.0, -27.23120388767797},
+        {10.0, 12.0, -27.87783105260302},
+        {10.0, 13.0, -28.48396685617334},
+        {10.0, 14.0, -29.05451171464095},
+        {10.0, 15.0, -29.59350821537364},
+        {10.0, 16.0, -30.10433383913963},
+        {10.0, 17.0, -30.58984165492133},
+        {10.0, 18.0, -31.05246517686944},
     };
 
     private static double logGammaMinusLogGammaSum(final double a,
@@ -508,142 +509,141 @@ public class LogBetaTest {
     }
 
     @Test
-    public void testLogGammaMinusLogGammaSumPrecondition1()
-    {
+    public void testLogGammaMinusLogGammaSumPrecondition1() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> logGammaMinusLogGammaSum(-1, 8)
+            () -> logGammaMinusLogGammaSum(-1, 8)
         );
     }
 
     @Test
     public void testLogGammaMinusLogGammaSumPrecondition2() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> logGammaMinusLogGammaSum(1, 7)
+            () -> logGammaMinusLogGammaSum(1, 7)
         );
     }
 
     private static final double[][] SUM_DELTA_MINUS_DELTA_SUM_REF = {
-        { 10.0 , 10.0 , .01249480717472882 },
-        { 10.0 , 11.0 , .01193628470267385 },
-        { 10.0 , 12.0 , .01148578547212797 },
-        { 10.0 , 13.0 , .01111659739668398 },
-        { 10.0 , 14.0 , .01080991216314295 },
-        { 10.0 , 15.0 , .01055214134859758 },
-        { 10.0 , 16.0 , .01033324912491747 },
-        { 10.0 , 17.0 , .01014568069918883 },
-        { 10.0 , 18.0 , .009983653199146491 },
-        { 10.0 , 19.0 , .009842674320242729 },
-        { 10.0 , 20.0 , 0.0097192081956071 },
-        { 11.0 , 10.0 , .01193628470267385 },
-        { 11.0 , 11.0 , .01135973290745925 },
-        { 11.0 , 12.0 , .01089355537047828 },
-        { 11.0 , 13.0 , .01051064829297728 },
-        { 11.0 , 14.0 , 0.0101918899639826 },
-        { 11.0 , 15.0 , .009923438811859604 },
-        { 11.0 , 16.0 , .009695052724952705 },
-        { 11.0 , 17.0 , 0.00949900745283617 },
-        { 11.0 , 18.0 , .009329379874933402 },
-        { 11.0 , 19.0 , 0.00918156080743147 },
-        { 11.0 , 20.0 , 0.00905191635141762 },
-        { 12.0 , 10.0 , .01148578547212797 },
-        { 12.0 , 11.0 , .01089355537047828 },
-        { 12.0 , 12.0 , .01041365883144029 },
-        { 12.0 , 13.0 , .01001867865848564 },
-        { 12.0 , 14.0 , 0.00968923999191334 },
-        { 12.0 , 15.0 , .009411294976563555 },
-        { 12.0 , 16.0 , .009174432043268762 },
-        { 12.0 , 17.0 , .008970786693291802 },
-        { 12.0 , 18.0 , .008794318926790865 },
-        { 12.0 , 19.0 , .008640321527910711 },
-        { 12.0 , 20.0 , .008505077879954796 },
-        { 13.0 , 10.0 , .01111659739668398 },
-        { 13.0 , 11.0 , .01051064829297728 },
-        { 13.0 , 12.0 , .01001867865848564 },
-        { 13.0 , 13.0 , .009613018147953376 },
-        { 13.0 , 14.0 , .009274085618154277 },
-        { 13.0 , 15.0 , 0.0089876637564166 },
-        { 13.0 , 16.0 , .008743200745261382 },
-        { 13.0 , 17.0 , .008532715206686251 },
-        { 13.0 , 18.0 , .008350069108807093 },
-        { 13.0 , 19.0 , .008190472517984874 },
-        { 13.0 , 20.0 , .008050138630244345 },
-        { 14.0 , 10.0 , .01080991216314295 },
-        { 14.0 , 11.0 , 0.0101918899639826 },
-        { 14.0 , 12.0 , 0.00968923999191334 },
-        { 14.0 , 13.0 , .009274085618154277 },
-        { 14.0 , 14.0 , .008926676241967286 },
-        { 14.0 , 15.0 , .008632654302369184 },
-        { 14.0 , 16.0 , .008381351102615795 },
-        { 14.0 , 17.0 , .008164687232662443 },
-        { 14.0 , 18.0 , .007976441942841219 },
-        { 14.0 , 19.0 , .007811755112234388 },
-        { 14.0 , 20.0 , .007666780069317652 },
-        { 15.0 , 10.0 , .01055214134859758 },
-        { 15.0 , 11.0 , .009923438811859604 },
-        { 15.0 , 12.0 , .009411294976563555 },
-        { 15.0 , 13.0 , 0.0089876637564166 },
-        { 15.0 , 14.0 , .008632654302369184 },
-        { 15.0 , 15.0 , 0.00833179217417291 },
-        { 15.0 , 16.0 , .008074310643041299 },
-        { 15.0 , 17.0 , .007852047581145882 },
-        { 15.0 , 18.0 , .007658712051540045 },
-        { 15.0 , 19.0 , .007489384065757007 },
-        { 15.0 , 20.0 , .007340165635725612 },
-        { 16.0 , 10.0 , .01033324912491747 },
-        { 16.0 , 11.0 , .009695052724952705 },
-        { 16.0 , 12.0 , .009174432043268762 },
-        { 16.0 , 13.0 , .008743200745261382 },
-        { 16.0 , 14.0 , .008381351102615795 },
-        { 16.0 , 15.0 , .008074310643041299 },
-        { 16.0 , 16.0 , .007811229919967624 },
-        { 16.0 , 17.0 , .007583876618287594 },
-        { 16.0 , 18.0 , .007385899933505551 },
-        { 16.0 , 19.0 , .007212328560607852 },
-        { 16.0 , 20.0 , .007059220321091879 },
-        { 17.0 , 10.0 , .01014568069918883 },
-        { 17.0 , 11.0 , 0.00949900745283617 },
-        { 17.0 , 12.0 , .008970786693291802 },
-        { 17.0 , 13.0 , .008532715206686251 },
-        { 17.0 , 14.0 , .008164687232662443 },
-        { 17.0 , 15.0 , .007852047581145882 },
-        { 17.0 , 16.0 , .007583876618287594 },
-        { 17.0 , 17.0 , .007351882161431358 },
-        { 17.0 , 18.0 , .007149662089534654 },
-        { 17.0 , 19.0 , .006972200907152378 },
-        { 17.0 , 20.0 , .006815518216094137 },
-        { 18.0 , 10.0 , .009983653199146491 },
-        { 18.0 , 11.0 , .009329379874933402 },
-        { 18.0 , 12.0 , .008794318926790865 },
-        { 18.0 , 13.0 , .008350069108807093 },
-        { 18.0 , 14.0 , .007976441942841219 },
-        { 18.0 , 15.0 , .007658712051540045 },
-        { 18.0 , 16.0 , .007385899933505551 },
-        { 18.0 , 17.0 , .007149662089534654 },
-        { 18.0 , 18.0 , .006943552208153373 },
-        { 18.0 , 19.0 , .006762516574228829 },
-        { 18.0 , 20.0 , .006602541598043117 },
-        { 19.0 , 10.0 , .009842674320242729 },
-        { 19.0 , 11.0 , 0.00918156080743147 },
-        { 19.0 , 12.0 , .008640321527910711 },
-        { 19.0 , 13.0 , .008190472517984874 },
-        { 19.0 , 14.0 , .007811755112234388 },
-        { 19.0 , 15.0 , .007489384065757007 },
-        { 19.0 , 16.0 , .007212328560607852 },
-        { 19.0 , 17.0 , .006972200907152378 },
-        { 19.0 , 18.0 , .006762516574228829 },
-        { 19.0 , 19.0 , .006578188655176814 },
-        { 19.0 , 20.0 , .006415174623476747 },
-        { 20.0 , 10.0 , 0.0097192081956071 },
-        { 20.0 , 11.0 , 0.00905191635141762 },
-        { 20.0 , 12.0 , .008505077879954796 },
-        { 20.0 , 13.0 , .008050138630244345 },
-        { 20.0 , 14.0 , .007666780069317652 },
-        { 20.0 , 15.0 , .007340165635725612 },
-        { 20.0 , 16.0 , .007059220321091879 },
-        { 20.0 , 17.0 , .006815518216094137 },
-        { 20.0 , 18.0 , .006602541598043117 },
-        { 20.0 , 19.0 , .006415174623476747 },
-        { 20.0 , 20.0 , .006249349445691423 },
+        {10.0, 10.0, .01249480717472882},
+        {10.0, 11.0, .01193628470267385},
+        {10.0, 12.0, .01148578547212797},
+        {10.0, 13.0, .01111659739668398},
+        {10.0, 14.0, .01080991216314295},
+        {10.0, 15.0, .01055214134859758},
+        {10.0, 16.0, .01033324912491747},
+        {10.0, 17.0, .01014568069918883},
+        {10.0, 18.0, .009983653199146491},
+        {10.0, 19.0, .009842674320242729},
+        {10.0, 20.0, 0.0097192081956071},
+        {11.0, 10.0, .01193628470267385},
+        {11.0, 11.0, .01135973290745925},
+        {11.0, 12.0, .01089355537047828},
+        {11.0, 13.0, .01051064829297728},
+        {11.0, 14.0, 0.0101918899639826},
+        {11.0, 15.0, .009923438811859604},
+        {11.0, 16.0, .009695052724952705},
+        {11.0, 17.0, 0.00949900745283617},
+        {11.0, 18.0, .009329379874933402},
+        {11.0, 19.0, 0.00918156080743147},
+        {11.0, 20.0, 0.00905191635141762},
+        {12.0, 10.0, .01148578547212797},
+        {12.0, 11.0, .01089355537047828},
+        {12.0, 12.0, .01041365883144029},
+        {12.0, 13.0, .01001867865848564},
+        {12.0, 14.0, 0.00968923999191334},
+        {12.0, 15.0, .009411294976563555},
+        {12.0, 16.0, .009174432043268762},
+        {12.0, 17.0, .008970786693291802},
+        {12.0, 18.0, .008794318926790865},
+        {12.0, 19.0, .008640321527910711},
+        {12.0, 20.0, .008505077879954796},
+        {13.0, 10.0, .01111659739668398},
+        {13.0, 11.0, .01051064829297728},
+        {13.0, 12.0, .01001867865848564},
+        {13.0, 13.0, .009613018147953376},
+        {13.0, 14.0, .009274085618154277},
+        {13.0, 15.0, 0.0089876637564166},
+        {13.0, 16.0, .008743200745261382},
+        {13.0, 17.0, .008532715206686251},
+        {13.0, 18.0, .008350069108807093},
+        {13.0, 19.0, .008190472517984874},
+        {13.0, 20.0, .008050138630244345},
+        {14.0, 10.0, .01080991216314295},
+        {14.0, 11.0, 0.0101918899639826},
+        {14.0, 12.0, 0.00968923999191334},
+        {14.0, 13.0, .009274085618154277},
+        {14.0, 14.0, .008926676241967286},
+        {14.0, 15.0, .008632654302369184},
+        {14.0, 16.0, .008381351102615795},
+        {14.0, 17.0, .008164687232662443},
+        {14.0, 18.0, .007976441942841219},
+        {14.0, 19.0, .007811755112234388},
+        {14.0, 20.0, .007666780069317652},
+        {15.0, 10.0, .01055214134859758},
+        {15.0, 11.0, .009923438811859604},
+        {15.0, 12.0, .009411294976563555},
+        {15.0, 13.0, 0.0089876637564166},
+        {15.0, 14.0, .008632654302369184},
+        {15.0, 15.0, 0.00833179217417291},
+        {15.0, 16.0, .008074310643041299},
+        {15.0, 17.0, .007852047581145882},
+        {15.0, 18.0, .007658712051540045},
+        {15.0, 19.0, .007489384065757007},
+        {15.0, 20.0, .007340165635725612},
+        {16.0, 10.0, .01033324912491747},
+        {16.0, 11.0, .009695052724952705},
+        {16.0, 12.0, .009174432043268762},
+        {16.0, 13.0, .008743200745261382},
+        {16.0, 14.0, .008381351102615795},
+        {16.0, 15.0, .008074310643041299},
+        {16.0, 16.0, .007811229919967624},
+        {16.0, 17.0, .007583876618287594},
+        {16.0, 18.0, .007385899933505551},
+        {16.0, 19.0, .007212328560607852},
+        {16.0, 20.0, .007059220321091879},
+        {17.0, 10.0, .01014568069918883},
+        {17.0, 11.0, 0.00949900745283617},
+        {17.0, 12.0, .008970786693291802},
+        {17.0, 13.0, .008532715206686251},
+        {17.0, 14.0, .008164687232662443},
+        {17.0, 15.0, .007852047581145882},
+        {17.0, 16.0, .007583876618287594},
+        {17.0, 17.0, .007351882161431358},
+        {17.0, 18.0, .007149662089534654},
+        {17.0, 19.0, .006972200907152378},
+        {17.0, 20.0, .006815518216094137},
+        {18.0, 10.0, .009983653199146491},
+        {18.0, 11.0, .009329379874933402},
+        {18.0, 12.0, .008794318926790865},
+        {18.0, 13.0, .008350069108807093},
+        {18.0, 14.0, .007976441942841219},
+        {18.0, 15.0, .007658712051540045},
+        {18.0, 16.0, .007385899933505551},
+        {18.0, 17.0, .007149662089534654},
+        {18.0, 18.0, .006943552208153373},
+        {18.0, 19.0, .006762516574228829},
+        {18.0, 20.0, .006602541598043117},
+        {19.0, 10.0, .009842674320242729},
+        {19.0, 11.0, 0.00918156080743147},
+        {19.0, 12.0, .008640321527910711},
+        {19.0, 13.0, .008190472517984874},
+        {19.0, 14.0, .007811755112234388},
+        {19.0, 15.0, .007489384065757007},
+        {19.0, 16.0, .007212328560607852},
+        {19.0, 17.0, .006972200907152378},
+        {19.0, 18.0, .006762516574228829},
+        {19.0, 19.0, .006578188655176814},
+        {19.0, 20.0, .006415174623476747},
+        {20.0, 10.0, 0.0097192081956071},
+        {20.0, 11.0, 0.00905191635141762},
+        {20.0, 12.0, .008505077879954796},
+        {20.0, 13.0, .008050138630244345},
+        {20.0, 14.0, .007666780069317652},
+        {20.0, 15.0, .007340165635725612},
+        {20.0, 16.0, .007059220321091879},
+        {20.0, 17.0, .006815518216094137},
+        {20.0, 18.0, .006602541598043117},
+        {20.0, 19.0, .006415174623476747},
+        {20.0, 20.0, .006249349445691423},
     };
 
     private static double sumDeltaMinusDeltaSum(final double a,
@@ -664,9 +664,8 @@ public class LogBetaTest {
         } catch (final InvocationTargetException e) {
             if (e.getTargetException() instanceof GammaException) {
                 throw (GammaException) e.getTargetException();
-            } else {
-                Assertions.fail(e.getTargetException().getMessage());
             }
+            Assertions.fail(e.getTargetException().getMessage());
         }
 
         return Double.NaN;
@@ -696,10 +695,9 @@ public class LogBetaTest {
     }
 
     @Test
-    public void testSumDeltaMinusDeltaSumPrecondition2()
-    {
+    public void testSumDeltaMinusDeltaSumPrecondition2() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> sumDeltaMinusDeltaSum(10, 9)
+            () -> sumDeltaMinusDeltaSum(10, 9)
         );
     }
 }
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGamma1pTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGamma1pTest.java
index 5aead6d..33ac6ad 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGamma1pTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGamma1pTest.java
@@ -24,23 +24,23 @@ import org.junit.jupiter.api.Test;
  */
 public class LogGamma1pTest {
     private static final double[][] LOG_GAMMA1P_REF = {
-        { - 0.5 , .5723649429247001 },
-        { - 0.375 , .3608294954889402 },
-        { - 0.25 , .2032809514312954 },
-        { - 0.125 , .08585870722533433 },
-        { 0.0 , 0.0 },
-        { 0.125 , - .06002318412603958 },
-        { 0.25 , - .09827183642181316 },
-        { 0.375 , - .1177552707410788 },
-        { 0.5 , - .1207822376352452 },
-        { 0.625 , - .1091741337567954 },
-        { 0.75 , - .08440112102048555 },
-        { 0.875 , - 0.0476726853991883 },
-        { 1.0 , 0.0 },
-        { 1.125 , .05775985153034387 },
-        { 1.25 , .1248717148923966 },
-        { 1.375 , .2006984603774558 },
-        { 1.5 , .2846828704729192 },
+        {-0.5, .5723649429247001},
+        {-0.375, .3608294954889402},
+        {-0.25, .2032809514312954},
+        {-0.125, .08585870722533433},
+        {0.0, 0.0},
+        {0.125, -.06002318412603958},
+        {0.25, -.09827183642181316},
+        {0.375, -.1177552707410788},
+        {0.5, -.1207822376352452},
+        {0.625, -.1091741337567954},
+        {0.75, -.08440112102048555},
+        {0.875, -0.0476726853991883},
+        {1.0, 0.0},
+        {1.125, .05775985153034387},
+        {1.25, .1248717148923966},
+        {1.375, .2006984603774558},
+        {1.5, .2846828704729192},
     };
 
     @Test
@@ -59,14 +59,14 @@ public class LogGamma1pTest {
     @Test
     public void testLogGamma1pPrecondition1() {
         Assertions.assertThrows(GammaException.class,
-                () -> LogGamma1p.value(-0.51)
+            () -> LogGamma1p.value(-0.51)
         );
     }
 
     @Test
     public void testLogGamma1pPrecondition2() {
         Assertions.assertThrows(GammaException.class,
-                () -> LogGamma1p.value(1.51)
+            () -> LogGamma1p.value(1.51)
         );
     }
 }
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaSumTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaSumTest.java
index 0e6eb9d..9bba2b0 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaSumTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaSumTest.java
@@ -45,87 +45,87 @@ public class LogGammaSumTest {
      * </pre>
      */
     private static final double[][] LOG_GAMMA_SUM_REF = {
-        { 1.0 , 1.0 , 0.0 },
-        { 1.0 , 1.125 , .05775985153034387 },
-        { 1.0 , 1.25 , .1248717148923966 },
-        { 1.0 , 1.375 , .2006984603774558 },
-        { 1.0 , 1.5 , .2846828704729192 },
-        { 1.0 , 1.625 , .3763336820249054 },
-        { 1.0 , 1.75 , .4752146669149371 },
-        { 1.0 , 1.875 , .5809359740231859 },
-        { 1.0 , 2.0 , .6931471805599453 },
-        { 1.125 , 1.0 , .05775985153034387 },
-        { 1.125 , 1.125 , .1248717148923966 },
-        { 1.125 , 1.25 , .2006984603774558 },
-        { 1.125 , 1.375 , .2846828704729192 },
-        { 1.125 , 1.5 , .3763336820249054 },
-        { 1.125 , 1.625 , .4752146669149371 },
-        { 1.125 , 1.75 , .5809359740231859 },
-        { 1.125 , 1.875 , .6931471805599453 },
-        { 1.125 , 2.0 , 0.811531653906724 },
-        { 1.25 , 1.0 , .1248717148923966 },
-        { 1.25 , 1.125 , .2006984603774558 },
-        { 1.25 , 1.25 , .2846828704729192 },
-        { 1.25 , 1.375 , .3763336820249054 },
-        { 1.25 , 1.5 , .4752146669149371 },
-        { 1.25 , 1.625 , .5809359740231859 },
-        { 1.25 , 1.75 , .6931471805599453 },
-        { 1.25 , 1.875 , 0.811531653906724 },
-        { 1.25 , 2.0 , .9358019311087253 },
-        { 1.375 , 1.0 , .2006984603774558 },
-        { 1.375 , 1.125 , .2846828704729192 },
-        { 1.375 , 1.25 , .3763336820249054 },
-        { 1.375 , 1.375 , .4752146669149371 },
-        { 1.375 , 1.5 , .5809359740231859 },
-        { 1.375 , 1.625 , .6931471805599453 },
-        { 1.375 , 1.75 , 0.811531653906724 },
-        { 1.375 , 1.875 , .9358019311087253 },
-        { 1.375 , 2.0 , 1.06569589786406 },
-        { 1.5 , 1.0 , .2846828704729192 },
-        { 1.5 , 1.125 , .3763336820249054 },
-        { 1.5 , 1.25 , .4752146669149371 },
-        { 1.5 , 1.375 , .5809359740231859 },
-        { 1.5 , 1.5 , .6931471805599453 },
-        { 1.5 , 1.625 , 0.811531653906724 },
-        { 1.5 , 1.75 , .9358019311087253 },
-        { 1.5 , 1.875 , 1.06569589786406 },
-        { 1.5 , 2.0 , 1.200973602347074 },
-        { 1.625 , 1.0 , .3763336820249054 },
-        { 1.625 , 1.125 , .4752146669149371 },
-        { 1.625 , 1.25 , .5809359740231859 },
-        { 1.625 , 1.375 , .6931471805599453 },
-        { 1.625 , 1.5 , 0.811531653906724 },
-        { 1.625 , 1.625 , .9358019311087253 },
-        { 1.625 , 1.75 , 1.06569589786406 },
-        { 1.625 , 1.875 , 1.200973602347074 },
-        { 1.625 , 2.0 , 1.341414578068493 },
-        { 1.75 , 1.0 , .4752146669149371 },
-        { 1.75 , 1.125 , .5809359740231859 },
-        { 1.75 , 1.25 , .6931471805599453 },
-        { 1.75 , 1.375 , 0.811531653906724 },
-        { 1.75 , 1.5 , .9358019311087253 },
-        { 1.75 , 1.625 , 1.06569589786406 },
-        { 1.75 , 1.75 , 1.200973602347074 },
-        { 1.75 , 1.875 , 1.341414578068493 },
-        { 1.75 , 2.0 , 1.486815578593417 },
-        { 1.875 , 1.0 , .5809359740231859 },
-        { 1.875 , 1.125 , .6931471805599453 },
-        { 1.875 , 1.25 , 0.811531653906724 },
-        { 1.875 , 1.375 , .9358019311087253 },
-        { 1.875 , 1.5 , 1.06569589786406 },
-        { 1.875 , 1.625 , 1.200973602347074 },
-        { 1.875 , 1.75 , 1.341414578068493 },
-        { 1.875 , 1.875 , 1.486815578593417 },
-        { 1.875 , 2.0 , 1.6369886482725 },
-        { 2.0 , 1.0 , .6931471805599453 },
-        { 2.0 , 1.125 , 0.811531653906724 },
-        { 2.0 , 1.25 , .9358019311087253 },
-        { 2.0 , 1.375 , 1.06569589786406 },
-        { 2.0 , 1.5 , 1.200973602347074 },
-        { 2.0 , 1.625 , 1.341414578068493 },
-        { 2.0 , 1.75 , 1.486815578593417 },
-        { 2.0 , 1.875 , 1.6369886482725 },
-        { 2.0 , 2.0 , 1.791759469228055 },
+        {1.0, 1.0, 0.0},
+        {1.0, 1.125, .05775985153034387},
+        {1.0, 1.25, .1248717148923966},
+        {1.0, 1.375, .2006984603774558},
+        {1.0, 1.5, .2846828704729192},
+        {1.0, 1.625, .3763336820249054},
+        {1.0, 1.75, .4752146669149371},
+        {1.0, 1.875, .5809359740231859},
+        {1.0, 2.0, .6931471805599453},
+        {1.125, 1.0, .05775985153034387},
+        {1.125, 1.125, .1248717148923966},
+        {1.125, 1.25, .2006984603774558},
+        {1.125, 1.375, .2846828704729192},
+        {1.125, 1.5, .3763336820249054},
+        {1.125, 1.625, .4752146669149371},
+        {1.125, 1.75, .5809359740231859},
+        {1.125, 1.875, .6931471805599453},
+        {1.125, 2.0, 0.811531653906724},
+        {1.25, 1.0, .1248717148923966},
+        {1.25, 1.125, .2006984603774558},
+        {1.25, 1.25, .2846828704729192},
+        {1.25, 1.375, .3763336820249054},
+        {1.25, 1.5, .4752146669149371},
+        {1.25, 1.625, .5809359740231859},
+        {1.25, 1.75, .6931471805599453},
+        {1.25, 1.875, 0.811531653906724},
+        {1.25, 2.0, .9358019311087253},
+        {1.375, 1.0, .2006984603774558},
+        {1.375, 1.125, .2846828704729192},
+        {1.375, 1.25, .3763336820249054},
+        {1.375, 1.375, .4752146669149371},
+        {1.375, 1.5, .5809359740231859},
+        {1.375, 1.625, .6931471805599453},
+        {1.375, 1.75, 0.811531653906724},
+        {1.375, 1.875, .9358019311087253},
+        {1.375, 2.0, 1.06569589786406},
+        {1.5, 1.0, .2846828704729192},
+        {1.5, 1.125, .3763336820249054},
+        {1.5, 1.25, .4752146669149371},
+        {1.5, 1.375, .5809359740231859},
+        {1.5, 1.5, .6931471805599453},
+        {1.5, 1.625, 0.811531653906724},
+        {1.5, 1.75, .9358019311087253},
+        {1.5, 1.875, 1.06569589786406},
+        {1.5, 2.0, 1.200973602347074},
+        {1.625, 1.0, .3763336820249054},
+        {1.625, 1.125, .4752146669149371},
+        {1.625, 1.25, .5809359740231859},
+        {1.625, 1.375, .6931471805599453},
+        {1.625, 1.5, 0.811531653906724},
+        {1.625, 1.625, .9358019311087253},
+        {1.625, 1.75, 1.06569589786406},
+        {1.625, 1.875, 1.200973602347074},
+        {1.625, 2.0, 1.341414578068493},
+        {1.75, 1.0, .4752146669149371},
+        {1.75, 1.125, .5809359740231859},
+        {1.75, 1.25, .6931471805599453},
+        {1.75, 1.375, 0.811531653906724},
+        {1.75, 1.5, .9358019311087253},
+        {1.75, 1.625, 1.06569589786406},
+        {1.75, 1.75, 1.200973602347074},
+        {1.75, 1.875, 1.341414578068493},
+        {1.75, 2.0, 1.486815578593417},
+        {1.875, 1.0, .5809359740231859},
+        {1.875, 1.125, .6931471805599453},
+        {1.875, 1.25, 0.811531653906724},
+        {1.875, 1.375, .9358019311087253},
+        {1.875, 1.5, 1.06569589786406},
+        {1.875, 1.625, 1.200973602347074},
+        {1.875, 1.75, 1.341414578068493},
+        {1.875, 1.875, 1.486815578593417},
+        {1.875, 2.0, 1.6369886482725},
+        {2.0, 1.0, .6931471805599453},
+        {2.0, 1.125, 0.811531653906724},
+        {2.0, 1.25, .9358019311087253},
+        {2.0, 1.375, 1.06569589786406},
+        {2.0, 1.5, 1.200973602347074},
+        {2.0, 1.625, 1.341414578068493},
+        {2.0, 1.75, 1.486815578593417},
+        {2.0, 1.875, 1.6369886482725},
+        {2.0, 2.0, 1.791759469228055},
     };
 
     @Test
@@ -154,21 +154,21 @@ public class LogGammaSumTest {
     @Test
     public void testLogGammaSumPrecondition2() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> LogGammaSum.value(3, 1)
+            () -> LogGammaSum.value(3, 1)
         );
     }
 
     @Test
     public void testLogGammaSumPrecondition3() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> LogGammaSum.value(1, 0)
+            () -> LogGammaSum.value(1, 0)
         );
     }
 
     @Test
     public void testLogGammaSumPrecondition4() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> LogGammaSum.value(1, 3)
+            () -> LogGammaSum.value(1, 3)
         );
     }
 }
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaTest.java
index be6496e..698d8e8 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/LogGammaTest.java
@@ -23,26 +23,6 @@ import org.junit.jupiter.api.Test;
  * Tests for {@link LogGamma}.
  */
 public class LogGammaTest {
-    @Test
-    public void testLogGammaNan() {
-        testLogGamma(Double.NaN, Double.NaN);
-    }
-
-    @Test
-    public void testLogGammaNegative() {
-        testLogGamma(Double.NaN, -1.0);
-    }
-
-    @Test
-    public void testLogGammaZero() {
-        testLogGamma(Double.NaN, 0.0);
-    }
-
-    @Test
-    public void testLogGammaPositive() {
-        testLogGamma(0.6931471805599457, 3.0);
-    }
-
     /**
      * Reference data for the {@link Gamma#logGamma(double)} function. This data
      * was generated with the following <a
@@ -61,141 +41,161 @@ public class LogGammaTest {
      * </pre>
      */
     private static final double[][] LOG_GAMMA_REF = {
-        { 0.125 , 2.019418357553796 },
-        { 0.25 , 1.288022524698077 },
-        { 0.375 , .8630739822706475 },
-        { 0.5 , .5723649429247001 },
-        { 0.625 , .3608294954889402 },
-        { 0.75 , .2032809514312954 },
-        { 0.875 , .08585870722533433 },
-        { 0.890625 , .07353860936979656 },
-        { 0.90625 , .06169536624059108 },
-        { 0.921875 , .05031670080005688 },
-        { 0.9375 , 0.0393909017345823 },
-        { 0.953125 , .02890678734595923 },
-        { 0.96875 , .01885367233441289 },
-        { 0.984375 , .009221337197578781 },
-        { 1.0 , 0.0 },
-        { 1.015625 , - 0.00881970970573307 },
-        { 1.03125 , - .01724677500176807 },
-        { 1.046875 , - .02528981394675729 },
-        { 1.0625 , - .03295710029357782 },
-        { 1.078125 , - .04025658272400143 },
-        { 1.09375 , - .04719590272716985 },
-        { 1.109375 , - .05378241123619192 },
-        { 1.125 , - .06002318412603958 },
-        { 1.25 , - .09827183642181316 },
-        { 1.375 , - .1177552707410788 },
-        { 1.5 , - .1207822376352452 },
-        { 1.625 , - .1091741337567954 },
-        { 1.75 , - .08440112102048555 },
-        { 1.875 , - 0.0476726853991883 },
-        { 1.890625 , - .04229320615532515 },
-        { 1.90625 , - .03674470657266143 },
-        { 1.921875 , - .03102893865389552 },
-        { 1.9375 , - .02514761940298887 },
-        { 1.953125 , - .01910243184040138 },
-        { 1.96875 , - .01289502598016741 },
-        { 1.984375 , - .006527019770560387 },
-        { 2.0 , 0.0 },
-        { 2.015625 , .006684476830232185 },
-        { 2.03125 , .01352488366498562 },
-        { 2.046875 , .02051972208453692 },
-        { 2.0625 , .02766752152285702 },
-        { 2.078125 , 0.0349668385135861 },
-        { 2.09375 , .04241625596251728 },
-        { 2.109375 , .05001438244545164 },
-        { 2.125 , .05775985153034387 },
-        { 2.25 , .1248717148923966 },
-        { 2.375 , .2006984603774558 },
-        { 2.5 , .2846828704729192 },
-        { 2.625 , .3763336820249054 },
-        { 2.75 , .4752146669149371 },
-        { 2.875 , .5809359740231859 },
-        { 2.890625 , .5946142560817441 },
-        { 2.90625 , .6083932548009232 },
-        { 2.921875 , .6222723333588501 },
-        { 2.9375 , .6362508628423761 },
-        { 2.953125 , .6503282221022278 },
-        { 2.96875 , .6645037976116387 },
-        { 2.984375 , 0.678776983328359 },
-        { 3.0 , .6931471805599453 },
-        { 3.015625 , .7076137978322324 },
-        { 3.03125 , .7221762507608962 },
-        { 3.046875 , .7368339619260166 },
-        { 3.0625 , 0.751586360749556 },
-        { 3.078125 , .7664328833756681 },
-        { 3.09375 , .7813729725537568 },
-        { 3.109375 , .7964060775242092 },
-        { 3.125 , 0.811531653906724 },
-        { 3.25 , .9358019311087253 },
-        { 3.375 , 1.06569589786406 },
-        { 3.5 , 1.200973602347074 },
-        { 3.625 , 1.341414578068493 },
-        { 3.75 , 1.486815578593417 },
-        { 3.875 , 1.6369886482725 },
-        { 4.0 , 1.791759469228055 },
-        { 4.125 , 1.950965937095089 },
-        { 4.25 , 2.114456927450371 },
-        { 4.375 , 2.282091222188554 },
-        { 4.5 , 2.453736570842442 },
-        { 4.625 , 2.62926886637513 },
-        { 4.75 , 2.808571418575736 },
-        { 4.875 , 2.99153431107781 },
-        { 5.0 , 3.178053830347946 },
-        { 5.125 , 3.368031956881733 },
-        { 5.25 , 3.561375910386697 },
-        { 5.375 , 3.757997741998131 },
-        { 5.5 , 3.957813967618717 },
-        { 5.625 , 4.160745237339519 },
-        { 5.75 , 4.366716036622286 },
-        { 5.875 , 4.57565441552762 },
-        { 6.0 , 4.787491742782046 },
-        { 6.125 , 5.002162481906205 },
-        { 6.25 , 5.219603986990229 },
-        { 6.375 , 5.439756316011858 },
-        { 6.5 , 5.662562059857142 },
-        { 6.625 , 5.887966185430003 },
-        { 6.75 , 6.115915891431546 },
-        { 6.875 , 6.346360475557843 },
-        { 7.0 , 6.579251212010101 },
-        { 7.125 , 6.814541238336996 },
-        { 7.25 , 7.05218545073854 },
-        { 7.375 , 7.292140407056348 },
-        { 7.5 , 7.534364236758733 },
-        { 7.625 , 7.778816557302289 },
-        { 7.75 , 8.025458396315983 },
-        { 7.875 , 8.274252119110479 },
-        { 8.0 , 8.525161361065415 },
-        { 8.125 , 8.77815096449171 },
-        { 8.25 , 9.033186919605123 },
-        { 8.375 , 9.290236309282232 },
-        { 8.5 , 9.549267257300997 },
-        { 8.625 , 9.810248879795765 },
-        { 8.75 , 10.07315123968124 },
-        { 8.875 , 10.33794530382217 },
-        { 9.0 , 10.60460290274525 },
-        { 9.125 , 10.87309669270751 },
-        { 9.25 , 11.14340011995171 },
-        { 9.375 , 11.41548738699336 },
-        { 9.5 , 11.68933342079727 },
-        { 9.625 , 11.96491384271319 },
-        { 9.75 , 12.24220494005076 },
-        { 9.875 , 12.52118363918365 },
-        { 10.0 , 12.80182748008147 },
-        { 0.8 , .1520596783998376 },
-        { 100.0 , 359.1342053695754 },
-        { 1000.0 , 5905.220423209181 },
-        { 10000.0 , 82099.71749644238 },
-        { 100000.0 , 1051287.708973657 },
-        { 1000000.0 , 1.2815504569147612e+7 },
-        { 10000000.0 , 1.511809493694739e+8 },
-        { 1.e+8 , 1.7420680661038346e+9 },
-        { 1.e+9 , 1.972326582750371e+10 },
-        { 1.e+10 , 2.202585092888106e+11 },
+        {0.125, 2.019418357553796},
+        {0.25, 1.288022524698077},
+        {0.375, .8630739822706475},
+        {0.5, .5723649429247001},
+        {0.625, .3608294954889402},
+        {0.75, .2032809514312954},
+        {0.875, .08585870722533433},
+        {0.890625, .07353860936979656},
+        {0.90625, .06169536624059108},
+        {0.921875, .05031670080005688},
+        {0.9375, 0.0393909017345823},
+        {0.953125, .02890678734595923},
+        {0.96875, .01885367233441289},
+        {0.984375, .009221337197578781},
+        {1.0, 0.0},
+        {1.015625, -0.00881970970573307},
+        {1.03125, -.01724677500176807},
+        {1.046875, -.02528981394675729},
+        {1.0625, -.03295710029357782},
+        {1.078125, -.04025658272400143},
+        {1.09375, -.04719590272716985},
+        {1.109375, -.05378241123619192},
+        {1.125, -.06002318412603958},
+        {1.25, -.09827183642181316},
+        {1.375, -.1177552707410788},
+        {1.5, -.1207822376352452},
+        {1.625, -.1091741337567954},
+        {1.75, -.08440112102048555},
+        {1.875, -0.0476726853991883},
+        {1.890625, -.04229320615532515},
+        {1.90625, -.03674470657266143},
+        {1.921875, -.03102893865389552},
+        {1.9375, -.02514761940298887},
+        {1.953125, -.01910243184040138},
+        {1.96875, -.01289502598016741},
+        {1.984375, -.006527019770560387},
+        {2.0, 0.0},
+        {2.015625, .006684476830232185},
+        {2.03125, .01352488366498562},
+        {2.046875, .02051972208453692},
+        {2.0625, .02766752152285702},
+        {2.078125, 0.0349668385135861},
+        {2.09375, .04241625596251728},
+        {2.109375, .05001438244545164},
+        {2.125, .05775985153034387},
+        {2.25, .1248717148923966},
+        {2.375, .2006984603774558},
+        {2.5, .2846828704729192},
+        {2.625, .3763336820249054},
+        {2.75, .4752146669149371},
+        {2.875, .5809359740231859},
+        {2.890625, .5946142560817441},
+        {2.90625, .6083932548009232},
+        {2.921875, .6222723333588501},
+        {2.9375, .6362508628423761},
+        {2.953125, .6503282221022278},
+        {2.96875, .6645037976116387},
+        {2.984375, 0.678776983328359},
+        {3.0, .6931471805599453},
+        {3.015625, .7076137978322324},
+        {3.03125, .7221762507608962},
+        {3.046875, .7368339619260166},
+        {3.0625, 0.751586360749556},
+        {3.078125, .7664328833756681},
+        {3.09375, .7813729725537568},
+        {3.109375, .7964060775242092},
+        {3.125, 0.811531653906724},
+        {3.25, .9358019311087253},
+        {3.375, 1.06569589786406},
+        {3.5, 1.200973602347074},
+        {3.625, 1.341414578068493},
+        {3.75, 1.486815578593417},
+        {3.875, 1.6369886482725},
+        {4.0, 1.791759469228055},
+        {4.125, 1.950965937095089},
+        {4.25, 2.114456927450371},
+        {4.375, 2.282091222188554},
+        {4.5, 2.453736570842442},
+        {4.625, 2.62926886637513},
+        {4.75, 2.808571418575736},
+        {4.875, 2.99153431107781},
+        {5.0, 3.178053830347946},
+        {5.125, 3.368031956881733},
+        {5.25, 3.561375910386697},
+        {5.375, 3.757997741998131},
+        {5.5, 3.957813967618717},
+        {5.625, 4.160745237339519},
+        {5.75, 4.366716036622286},
+        {5.875, 4.57565441552762},
+        {6.0, 4.787491742782046},
+        {6.125, 5.002162481906205},
+        {6.25, 5.219603986990229},
+        {6.375, 5.439756316011858},
+        {6.5, 5.662562059857142},
+        {6.625, 5.887966185430003},
+        {6.75, 6.115915891431546},
+        {6.875, 6.346360475557843},
+        {7.0, 6.579251212010101},
+        {7.125, 6.814541238336996},
+        {7.25, 7.05218545073854},
+        {7.375, 7.292140407056348},
+        {7.5, 7.534364236758733},
+        {7.625, 7.778816557302289},
+        {7.75, 8.025458396315983},
+        {7.875, 8.274252119110479},
+        {8.0, 8.525161361065415},
+        {8.125, 8.77815096449171},
+        {8.25, 9.033186919605123},
+        {8.375, 9.290236309282232},
+        {8.5, 9.549267257300997},
+        {8.625, 9.810248879795765},
+        {8.75, 10.07315123968124},
+        {8.875, 10.33794530382217},
+        {9.0, 10.60460290274525},
+        {9.125, 10.87309669270751},
+        {9.25, 11.14340011995171},
+        {9.375, 11.41548738699336},
+        {9.5, 11.68933342079727},
+        {9.625, 11.96491384271319},
+        {9.75, 12.24220494005076},
+        {9.875, 12.52118363918365},
+        {10.0, 12.80182748008147},
+        {0.8, .1520596783998376},
+        {100.0, 359.1342053695754},
+        {1000.0, 5905.220423209181},
+        {10000.0, 82099.71749644238},
+        {100000.0, 1051287.708973657},
+        {1000000.0, 1.2815504569147612e+7},
+        {10000000.0, 1.511809493694739e+8},
+        {1.e+8, 1.7420680661038346e+9},
+        {1.e+9, 1.972326582750371e+10},
+        {1.e+10, 2.202585092888106e+11},
     };
 
     @Test
+    public void testLogGammaNan() {
+        testLogGamma(Double.NaN, Double.NaN);
+    }
+
+    @Test
+    public void testLogGammaNegative() {
+        testLogGamma(Double.NaN, -1.0);
+    }
+
+    @Test
+    public void testLogGammaZero() {
+        testLogGamma(Double.NaN, 0.0);
+    }
+
+    @Test
+    public void testLogGammaPositive() {
+        testLogGamma(0.6931471805599457, 3.0);
+    }
+
+    @Test
     public void testLogGamma() {
         final int ulps = 3;
         for (int i = 0; i < LOG_GAMMA_REF.length; i++) {
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java
index bd7284f..f14fe78 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java
@@ -30,19 +30,19 @@ public class TrigammaTest {
         //
         // http://functions.wolfram.com/webMathematica/Evaluated.jsp?name=PolyGamma2&plottype=0&vars={%221%22,%22$i%22}&digits=20
         double[] data = {
-                1e-4, 1.0000000164469368793e8,
-                1e-3, 1.0000016425331958690e6,
-                1e-2, 10001.621213528313220,
-                1e-1, 101.43329915079275882,
-                1, 1.6449340668482264365,
-                2, 0.64493406684822643647,
-                3, 0.39493406684822643647,
-                4, 0.28382295573711532536,
-                5, 0.22132295573711532536,
-                10, 0.10516633568168574612,
-                20, 0.051270822935203119832,
-                50, 0.020201333226697125806,
-                100, 0.010050166663333571395
+            1e-4, 1.0000000164469368793e8,
+            1e-3, 1.0000016425331958690e6,
+            1e-2, 10001.621213528313220,
+            1e-1, 101.43329915079275882,
+            1, 1.6449340668482264365,
+            2, 0.64493406684822643647,
+            3, 0.39493406684822643647,
+            4, 0.28382295573711532536,
+            5, 0.22132295573711532536,
+            10, 0.10516633568168574612,
+            20, 0.051270822935203119832,
+            50, 0.020201333226697125806,
+            100, 0.010050166663333571395
         };
         for (int i = data.length - 2; i >= 0; i -= 2) {
             Assertions.assertEquals(data[i + 1], Trigamma.value(data[i]), eps, String.format("trigamma %.0f", data[i]));


[commons-numbers] 29/32: Fixed checkstyle in fraction.

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

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

commit 59428784a8533c1b05fc430c5c763b25f9ee44f5
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 18:17:38 2019 +0000

    Fixed checkstyle in fraction.
---
 .../commons/numbers/fraction/BigFraction.java      |   2 +-
 .../apache/commons/numbers/fraction/Fraction.java  |   6 +-
 .../commons/numbers/fraction/BigFractionTest.java  | 130 +++++++---------
 .../commons/numbers/fraction/CommonTestCases.java  | 102 +++++++------
 .../commons/numbers/fraction/FractionTest.java     | 168 ++++++++++-----------
 5 files changed, 191 insertions(+), 217 deletions(-)

diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
index 22cb6e3..fea4759 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
@@ -120,7 +120,7 @@ public final class BigFraction
         long a0 = (long) Math.floor(r0);
 
         if (Math.abs(a0) > overflow) {
-            throw new FractionException(FractionException.ERROR_CONVERSION_OVERFLOW, value, a0, 1l);
+            throw new FractionException(FractionException.ERROR_CONVERSION_OVERFLOW, value, a0, 1L);
         }
 
         // check for (almost) integer arguments, which should not go
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
index c4393ce..07fbe7a 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
@@ -32,7 +32,7 @@ public final class Fraction
     public static final Fraction ONE = new Fraction(1, 1);
     /** A fraction representing "0". */
     public static final Fraction ZERO = new Fraction(0, 1);
-    /** Serializable version identifier */
+    /** Serializable version identifier. */
     private static final long serialVersionUID = 20190701L;
     /** Parameter name for fraction (to satisfy checkstyle). */
     private static final String PARAM_NAME_FRACTION = "fraction";
@@ -78,7 +78,7 @@ public final class Fraction
         double r0 = value;
         long a0 = (long)Math.floor(r0);
         if (Math.abs(a0) > overflow) {
-            throw new FractionException(FractionException.ERROR_CONVERSION, value, a0, 1l);
+            throw new FractionException(FractionException.ERROR_CONVERSION, value, a0, 1L);
         }
 
         // check for (almost) integer arguments, which should not go to iterations.
@@ -232,7 +232,7 @@ public final class Fraction
      * @return a new instance.
      */
     public static Fraction from(double value, int maxDenominator) {
-       return new Fraction(value, 0, maxDenominator, 100);
+        return new Fraction(value, 0, maxDenominator, 100);
     }
 
     /**
diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java
index 82ee513..a90ecd3 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java
@@ -56,16 +56,16 @@ public class BigFractionTest {
             );
         }
 
-        assertFraction(0, 1, BigFraction.of(0l, 2l));
-        assertFraction(11, 1, BigFraction.of(11));
-        assertFraction(11, 1, BigFraction.of(11l));
+        assertFraction(0, 1, BigFraction.of(0L, 2L));
+        assertFraction(1L, 1, BigFraction.of(1L));
+        assertFraction(11, 1, BigFraction.of(11L));
         assertFraction(11, 1, BigFraction.of(new BigInteger("11")));
 
         Assertions.assertEquals(0.00000000000001, BigFraction.from(0.00000000000001).doubleValue(), 0.0);
         Assertions.assertEquals(0.40000000000001, BigFraction.from(0.40000000000001).doubleValue(), 0.0);
         Assertions.assertEquals(15.0000000000001, BigFraction.from(15.0000000000001).doubleValue(), 0.0);
-        assertFraction(3602879701896487l, 9007199254740992l, BigFraction.from(0.40000000000001));
-        assertFraction(1055531162664967l, 70368744177664l, BigFraction.from(15.0000000000001));
+        assertFraction(3602879701896487L, 9007199254740992L, BigFraction.from(0.40000000000001));
+        assertFraction(1055531162664967L, 70368744177664L, BigFraction.from(15.0000000000001));
         try {
             BigFraction.of(null, BigInteger.ONE);
             Assertions.fail("Expecting NullPointerException");
@@ -96,7 +96,7 @@ public class BigFractionTest {
     public void testGoldenRatio() {
         // the golden ratio is notoriously a difficult number for continuous fraction
         Assertions.assertThrows(FractionException.class,
-                () -> BigFraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
+            () -> BigFraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
         );
     }
 
@@ -132,7 +132,7 @@ public class BigFractionTest {
     @Test
     public void testPositiveValueOverflow() {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> assertFraction((long) 1e10, 1, BigFraction.from(1e10, 1000))
+            () -> assertFraction((long) 1e10, 1, BigFraction.from(1e10, 1000))
         );
     }
 
@@ -140,7 +140,7 @@ public class BigFractionTest {
     @Test
     public void testNegativeValueOverflow() {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> assertFraction((long) -1e10, 1, BigFraction.from(-1e10, 1000))
+            () -> assertFraction((long) -1e10, 1, BigFraction.from(-1e10, 1000))
         );
     }
 
@@ -180,7 +180,7 @@ public class BigFractionTest {
         // the first  one is approximately PI - 3.07e-18
         // the second one is approximately PI + 1.936e-17
         final BigFraction pi1 = BigFraction.of(1068966896, 340262731);
-        final BigFraction pi2 = BigFraction.of( 411557987, 131002976);
+        final BigFraction pi2 = BigFraction.of(411557987, 131002976);
         Assertions.assertEquals(-1, pi1.compareTo(pi2));
         Assertions.assertEquals(1, pi2.compareTo(pi1));
         Assertions.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
@@ -217,7 +217,8 @@ public class BigFractionTest {
 
     @Test
     public void testDoubleValueForSubnormalNumbers() {
-        assertDoubleValue( //Double.MIN_VALUE * 2/3
+        assertDoubleValue(
+                //Double.MIN_VALUE * 2/3
                 Double.MIN_VALUE,
                 BigInteger.ONE,
                 BigInteger.ONE.shiftLeft(1073).multiply(BigInteger.valueOf(3L))
@@ -304,14 +305,12 @@ public class BigFractionTest {
     @Test
     public void testDoubleValueForLargeNumeratorAndSmallDenominator() {
         // NUMBERS-15
-        {
-            final BigInteger pow300 = BigInteger.TEN.pow(300);
-            final BigInteger pow330 = BigInteger.TEN.pow(330);
-            final BigFraction large = BigFraction.of(pow330.add(BigInteger.ONE),
-                    pow300);
+        final BigInteger pow300 = BigInteger.TEN.pow(300);
+        final BigInteger pow330 = BigInteger.TEN.pow(330);
+        final BigFraction large = BigFraction.of(pow330.add(BigInteger.ONE),
+                pow300);
 
-            Assertions.assertEquals(1e30, large.doubleValue(), 1e-15);
-        }
+        Assertions.assertEquals(1e30, large.doubleValue(), 1e-15);
 
         // NUMBERS-120
         assertDoubleValue(
@@ -387,14 +386,14 @@ public class BigFractionTest {
     @Test
     public void testConstructorDouble() {
         assertFraction(1, 2, BigFraction.from(0.5));
-        assertFraction(6004799503160661l, 18014398509481984l, BigFraction.from(1.0 / 3.0));
-        assertFraction(6124895493223875l, 36028797018963968l, BigFraction.from(17.0 / 100.0));
-        assertFraction(1784551352345559l, 562949953421312l, BigFraction.from(317.0 / 100.0));
+        assertFraction(6004799503160661L, 18014398509481984L, BigFraction.from(1.0 / 3.0));
+        assertFraction(6124895493223875L, 36028797018963968L, BigFraction.from(17.0 / 100.0));
+        assertFraction(1784551352345559L, 562949953421312L, BigFraction.from(317.0 / 100.0));
         assertFraction(-1, 2, BigFraction.from(-0.5));
-        assertFraction(-6004799503160661l, 18014398509481984l, BigFraction.from(-1.0 / 3.0));
-        assertFraction(-6124895493223875l, 36028797018963968l, BigFraction.from(17.0 / -100.0));
-        assertFraction(-1784551352345559l, 562949953421312l, BigFraction.from(-317.0 / 100.0));
-        for (double v : new double[] { Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}) {
+        assertFraction(-6004799503160661L, 18014398509481984L, BigFraction.from(-1.0 / 3.0));
+        assertFraction(-6124895493223875L, 36028797018963968L, BigFraction.from(17.0 / -100.0));
+        assertFraction(-1784551352345559L, 562949953421312L, BigFraction.from(-317.0 / 100.0));
+        for (double v : new double[] {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}) {
             try {
                 BigFraction.from(v);
                 Assertions.fail("Expecting IllegalArgumentException");
@@ -402,8 +401,8 @@ public class BigFractionTest {
                 // expected
             }
         }
-        Assertions.assertEquals(1l, BigFraction.from(Double.MAX_VALUE).getDenominatorAsLong());
-        Assertions.assertEquals(1l, BigFraction.from(Double.longBitsToDouble(0x0010000000000000L)).getNumeratorAsLong());
+        Assertions.assertEquals(1L, BigFraction.from(Double.MAX_VALUE).getDenominatorAsLong());
+        Assertions.assertEquals(1L, BigFraction.from(Double.longBitsToDouble(0x0010000000000000L)).getNumeratorAsLong());
         assertFraction(BigInteger.ONE, BigInteger.ONE.shiftLeft(1074), BigFraction.from(Double.MIN_VALUE));
     }
 
@@ -446,12 +445,10 @@ public class BigFractionTest {
             assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f1.add(f2));
         }
 
-        {
-            final BigFraction f = BigFraction.of(-17 - 2*13*2, 13*13*17*2*2);
-            Assertions.assertThrows(NullPointerException.class,
-                    () -> f.add((BigFraction) null)
-            );
-        }
+        final BigFraction f0 = BigFraction.of(-17 - 2 * 13 * 2, 13 * 13 * 17 * 2 * 2);
+        Assertions.assertThrows(NullPointerException.class,
+            () -> f0.add((BigFraction) null)
+        );
 
         BigFraction f1 = BigFraction.of(Integer.MAX_VALUE - 1, 1);
         BigFraction f = f1.add(BigInteger.ONE);
@@ -472,11 +469,11 @@ public class BigFractionTest {
         Assertions.assertEquals(1, f.getDenominatorAsInt());
 
         f1 = BigFraction.of(Integer.MAX_VALUE - 1, 1);
-        f = f1.add(1l);
+        f = f1.add(1L);
         Assertions.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
         Assertions.assertEquals(1, f.getDenominatorAsInt());
 
-        f = f.add(0l);
+        f = f.add(0L);
         Assertions.assertEquals(Integer.MAX_VALUE, f.getNumeratorAsInt());
         Assertions.assertEquals(1, f.getDenominatorAsInt());
 
@@ -490,10 +487,7 @@ public class BigFractionTest {
             assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f1.divide(f2));
         }
 
-        {
-            Assertions.assertThrows(FractionException.class,
-                                    () -> BigFraction.of(1, 2).divide(BigInteger.ZERO));
-        }
+        Assertions.assertThrows(FractionException.class, () -> BigFraction.of(1, 2).divide(BigInteger.ZERO));
 
         BigFraction f1;
         BigFraction f2;
@@ -503,12 +497,10 @@ public class BigFractionTest {
         BigFraction f = f1.divide(f2);
         Assertions.assertSame(BigFraction.ZERO, f);
 
-        {
-            final BigFraction f3 = BigFraction.of(Integer.MIN_VALUE, 1);
-            Assertions.assertThrows(NullPointerException.class,
-                    () -> f3.divide((BigFraction) null)
-            );
-        }
+        final BigFraction f3 = BigFraction.of(Integer.MIN_VALUE, 1);
+        Assertions.assertThrows(NullPointerException.class,
+            () -> f3.divide((BigFraction) null)
+        );
 
         f1 = BigFraction.of(Integer.MIN_VALUE, Integer.MAX_VALUE);
         f = f1.divide(BigInteger.valueOf(Integer.MIN_VALUE));
@@ -545,10 +537,7 @@ public class BigFractionTest {
         Assertions.assertEquals(Integer.MIN_VALUE, f.getNumeratorAsInt());
         Assertions.assertEquals(1, f.getDenominatorAsInt());
 
-        {
-            Assertions.assertThrows(NullPointerException.class,
-                                    () -> BigFraction.ONE.multiply((BigFraction) null));
-        }
+        Assertions.assertThrows(NullPointerException.class, () -> BigFraction.ONE.multiply((BigFraction) null));
 
         Assertions.assertEquals(BigFraction.ZERO, BigFraction.ZERO.multiply(BigInteger.ONE));
         Assertions.assertEquals(BigFraction.ZERO, BigFraction.ONE.multiply(BigInteger.ZERO));
@@ -567,10 +556,7 @@ public class BigFractionTest {
         }
 
         BigFraction f = BigFraction.of(1, 1);
-        {
-            Assertions.assertThrows(NullPointerException.class,
-                                    () -> f.subtract((BigFraction) null));
-        }
+        Assertions.assertThrows(NullPointerException.class, () -> f.subtract((BigFraction) null));
 
         Assertions.assertEquals(BigFraction.ONE, BigFraction.ONE.subtract(BigInteger.ZERO));
         Assertions.assertEquals(BigFraction.of(-1), BigFraction.ZERO.subtract(BigInteger.ONE));
@@ -614,14 +600,14 @@ public class BigFractionTest {
     @Test
     public void testPow() {
         Assertions.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(13));
-        Assertions.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(13l));
-        Assertions.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(BigInteger.valueOf(13l)));
+        Assertions.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(13L));
+        Assertions.assertEquals(BigFraction.of(8192, 1594323), BigFraction.of(2, 3).pow(BigInteger.valueOf(13L)));
         Assertions.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(0));
-        Assertions.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(0l));
-        Assertions.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(BigInteger.valueOf(0l)));
+        Assertions.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(0L));
+        Assertions.assertEquals(BigFraction.ONE, BigFraction.of(2, 3).pow(BigInteger.valueOf(0L)));
         Assertions.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(-13));
-        Assertions.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(-13l));
-        Assertions.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(BigInteger.valueOf(-13l)));
+        Assertions.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(-13L));
+        Assertions.assertEquals(BigFraction.of(1594323, 8192), BigFraction.of(2, 3).pow(BigInteger.valueOf(-13L)));
         Assertions.assertEquals(BigFraction.ZERO, BigFraction.of(0, 5).pow(123));
         Assertions.assertEquals(BigFraction.ZERO, BigFraction.of(0, 5).pow(123L));
         Assertions.assertEquals(BigFraction.ZERO, BigFraction.of(0, 5).pow(new BigInteger("112233445566778899")));
@@ -671,13 +657,13 @@ public class BigFractionTest {
     @Test
     public void testParse() {
         String[] validExpressions = new String[] {
-                "3",
-                "1 / 2",
-                "-1 / 2",
-                "1 / -2",
-                "-1 / -2",
-                "2147,483,647 / 2,147,483,648", //over largest int value
-                "9,223,372,036,854,775,807 / 9,223,372,036,854,775,808" //over largest long value
+            "3",
+            "1 / 2",
+            "-1 / 2",
+            "1 / -2",
+            "-1 / -2",
+            "2147,483,647 / 2,147,483,648", //over largest int value
+            "9,223,372,036,854,775,807 / 9,223,372,036,854,775,808" //over largest long value
         };
         BigFraction[] fractions = {
                 BigFraction.of(3),
@@ -696,15 +682,9 @@ public class BigFractionTest {
             inc++;
         }
 
-        {
-            Assertions.assertThrows(NumberFormatException.class,
-                                    () -> BigFraction.parse("1 // 2"));
-            Assertions.assertThrows(NumberFormatException.class,
-                                    () -> BigFraction.parse("1 / z"));
-            Assertions.assertThrows(NumberFormatException.class,
-                                    () -> BigFraction.parse("1 / --2"));
-            Assertions.assertThrows(NumberFormatException.class,
-                                    () -> BigFraction.parse("x"));
-        }
+        Assertions.assertThrows(NumberFormatException.class, () -> BigFraction.parse("1 // 2"));
+        Assertions.assertThrows(NumberFormatException.class, () -> BigFraction.parse("1 / z"));
+        Assertions.assertThrows(NumberFormatException.class, () -> BigFraction.parse("1 / --2"));
+        Assertions.assertThrows(NumberFormatException.class, () -> BigFraction.parse("x"));
     }
 }
diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
index a2bcdeb..193da38 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
@@ -25,7 +25,10 @@ import java.util.List;
  * and {@link BigFraction}, e.g. for operations and expected results that
  * involve numerators and denominators in the {@code int} range.
  */
-class CommonTestCases {
+final class CommonTestCases {
+
+    // CHECKSTYLE: stop ConstantName
+
     /**
      * See {@link #numDenConstructorTestCases()}
      */
@@ -71,6 +74,8 @@ class CommonTestCases {
      */
     private static final List<BinaryOperatorTestCase> subtractFractionTestCasesList;
 
+    // CHECKSTYLE: resume ConstantName
+
     static {
         numDenConstructorTestCasesList = collectNumDenConstructorTestCases();
         doubleConstructorTestCasesList = collectDoubleConstructorTestCases();
@@ -83,6 +88,8 @@ class CommonTestCases {
         subtractFractionTestCasesList = collectSubtractFractionTestCases();
     }
 
+    private CommonTestCases() {}
+
     /**
      * Defines test cases as described in
      * {@link #numDenConstructorTestCases()} and collects them into a {@code
@@ -116,47 +123,47 @@ class CommonTestCases {
     private static List<DoubleToFractionTestCase> collectDoubleConstructorTestCases() {
         List<DoubleToFractionTestCase> testCases = new ArrayList<>();
 
-        testCases.add(new DoubleToFractionTestCase(1d/2d, 1, 2));
-        testCases.add(new DoubleToFractionTestCase(1d/3d, 1, 3));
-        testCases.add(new DoubleToFractionTestCase(2d/3d, 2, 3));
-        testCases.add(new DoubleToFractionTestCase(1d/4d, 1, 4));
-        testCases.add(new DoubleToFractionTestCase(3d/4d, 3, 4));
-        testCases.add(new DoubleToFractionTestCase(1d/5d, 1, 5));
-        testCases.add(new DoubleToFractionTestCase(2d/5d, 2, 5));
-        testCases.add(new DoubleToFractionTestCase(3d/5d, 3, 5));
-        testCases.add(new DoubleToFractionTestCase(4d/5d, 4, 5));
-        testCases.add(new DoubleToFractionTestCase(1d/6d, 1, 6));
-        testCases.add(new DoubleToFractionTestCase(5d/6d, 5, 6));
-        testCases.add(new DoubleToFractionTestCase(1d/7d, 1, 7));
-        testCases.add(new DoubleToFractionTestCase(2d/7d, 2, 7));
-        testCases.add(new DoubleToFractionTestCase(3d/7d, 3, 7));
-        testCases.add(new DoubleToFractionTestCase(4d/7d, 4, 7));
-        testCases.add(new DoubleToFractionTestCase(5d/7d, 5, 7));
-        testCases.add(new DoubleToFractionTestCase(6d/7d, 6, 7));
-        testCases.add(new DoubleToFractionTestCase(1d/8d, 1, 8));
-        testCases.add(new DoubleToFractionTestCase(3d/8d, 3, 8));
-        testCases.add(new DoubleToFractionTestCase(5d/8d, 5, 8));
-        testCases.add(new DoubleToFractionTestCase(7d/8d, 7, 8));
-        testCases.add(new DoubleToFractionTestCase(1d/9d, 1, 9));
-        testCases.add(new DoubleToFractionTestCase(2d/9d, 2, 9));
-        testCases.add(new DoubleToFractionTestCase(4d/9d, 4, 9));
-        testCases.add(new DoubleToFractionTestCase(5d/9d, 5, 9));
-        testCases.add(new DoubleToFractionTestCase(7d/9d, 7, 9));
-        testCases.add(new DoubleToFractionTestCase(8d/9d, 8, 9));
-        testCases.add(new DoubleToFractionTestCase(1d/10d, 1, 10));
-        testCases.add(new DoubleToFractionTestCase(3d/10d, 3, 10));
-        testCases.add(new DoubleToFractionTestCase(7d/10d, 7, 10));
-        testCases.add(new DoubleToFractionTestCase(9d/10d, 9, 10));
-        testCases.add(new DoubleToFractionTestCase(1d/11d, 1, 11));
-        testCases.add(new DoubleToFractionTestCase(2d/11d, 2, 11));
-        testCases.add(new DoubleToFractionTestCase(3d/11d, 3, 11));
-        testCases.add(new DoubleToFractionTestCase(4d/11d, 4, 11));
-        testCases.add(new DoubleToFractionTestCase(5d/11d, 5, 11));
-        testCases.add(new DoubleToFractionTestCase(6d/11d, 6, 11));
-        testCases.add(new DoubleToFractionTestCase(7d/11d, 7, 11));
-        testCases.add(new DoubleToFractionTestCase(8d/11d, 8, 11));
-        testCases.add(new DoubleToFractionTestCase(9d/11d, 9, 11));
-        testCases.add(new DoubleToFractionTestCase(10d/11d, 10, 11));
+        testCases.add(new DoubleToFractionTestCase(1d / 2d, 1, 2));
+        testCases.add(new DoubleToFractionTestCase(1d / 3d, 1, 3));
+        testCases.add(new DoubleToFractionTestCase(2d / 3d, 2, 3));
+        testCases.add(new DoubleToFractionTestCase(1d / 4d, 1, 4));
+        testCases.add(new DoubleToFractionTestCase(3d / 4d, 3, 4));
+        testCases.add(new DoubleToFractionTestCase(1d / 5d, 1, 5));
+        testCases.add(new DoubleToFractionTestCase(2d / 5d, 2, 5));
+        testCases.add(new DoubleToFractionTestCase(3d / 5d, 3, 5));
+        testCases.add(new DoubleToFractionTestCase(4d / 5d, 4, 5));
+        testCases.add(new DoubleToFractionTestCase(1d / 6d, 1, 6));
+        testCases.add(new DoubleToFractionTestCase(5d / 6d, 5, 6));
+        testCases.add(new DoubleToFractionTestCase(1d / 7d, 1, 7));
+        testCases.add(new DoubleToFractionTestCase(2d / 7d, 2, 7));
+        testCases.add(new DoubleToFractionTestCase(3d / 7d, 3, 7));
+        testCases.add(new DoubleToFractionTestCase(4d / 7d, 4, 7));
+        testCases.add(new DoubleToFractionTestCase(5d / 7d, 5, 7));
+        testCases.add(new DoubleToFractionTestCase(6d / 7d, 6, 7));
+        testCases.add(new DoubleToFractionTestCase(1d / 8d, 1, 8));
+        testCases.add(new DoubleToFractionTestCase(3d / 8d, 3, 8));
+        testCases.add(new DoubleToFractionTestCase(5d / 8d, 5, 8));
+        testCases.add(new DoubleToFractionTestCase(7d / 8d, 7, 8));
+        testCases.add(new DoubleToFractionTestCase(1d / 9d, 1, 9));
+        testCases.add(new DoubleToFractionTestCase(2d / 9d, 2, 9));
+        testCases.add(new DoubleToFractionTestCase(4d / 9d, 4, 9));
+        testCases.add(new DoubleToFractionTestCase(5d / 9d, 5, 9));
+        testCases.add(new DoubleToFractionTestCase(7d / 9d, 7, 9));
+        testCases.add(new DoubleToFractionTestCase(8d / 9d, 8, 9));
+        testCases.add(new DoubleToFractionTestCase(1d / 10d, 1, 10));
+        testCases.add(new DoubleToFractionTestCase(3d / 10d, 3, 10));
+        testCases.add(new DoubleToFractionTestCase(7d / 10d, 7, 10));
+        testCases.add(new DoubleToFractionTestCase(9d / 10d, 9, 10));
+        testCases.add(new DoubleToFractionTestCase(1d / 11d, 1, 11));
+        testCases.add(new DoubleToFractionTestCase(2d / 11d, 2, 11));
+        testCases.add(new DoubleToFractionTestCase(3d / 11d, 3, 11));
+        testCases.add(new DoubleToFractionTestCase(4d / 11d, 4, 11));
+        testCases.add(new DoubleToFractionTestCase(5d / 11d, 5, 11));
+        testCases.add(new DoubleToFractionTestCase(6d / 11d, 6, 11));
+        testCases.add(new DoubleToFractionTestCase(7d / 11d, 7, 11));
+        testCases.add(new DoubleToFractionTestCase(8d / 11d, 8, 11));
+        testCases.add(new DoubleToFractionTestCase(9d / 11d, 9, 11));
+        testCases.add(new DoubleToFractionTestCase(10d / 11d, 10, 11));
 
         testCases.add(new DoubleToFractionTestCase(0.00000000000001, 0, 1));
         testCases.add(new DoubleToFractionTestCase(0.40000000000001, 2, 5));
@@ -233,9 +240,10 @@ class CommonTestCases {
         testCases.add(new BinaryOperatorTestCase(2, 3, -2, 3, 0, 1));
 
         testCases.add(new BinaryOperatorTestCase(
-                -1, 13*13*2*2,
-                -2, 13*17*2,
-                -17 - 2*13*2, 13*13*17*2*2));
+                -1, 13 * 13 * 2 * 2,
+                -2, 13 * 17 * 2,
+                -17 - 2 * 13 * 2,
+                13 * 13 * 17 * 2 * 2));
 
         // if this fraction is added naively, it will overflow the int range.
         // check that it doesn't.
@@ -347,7 +355,7 @@ class CommonTestCases {
         testCases.add(new BinaryOperatorTestCase(
                 Integer.MAX_VALUE, 1,
                 1, 1,
-                Integer.MAX_VALUE-1, 1
+                Integer.MAX_VALUE - 1, 1
         ));
 
         return testCases;
@@ -467,6 +475,8 @@ class CommonTestCases {
         return Collections.unmodifiableList(subtractFractionTestCasesList);
     }
 
+    // CHECKSTYLE: stop VisibilityModifier
+
     /**
      * Represents a test case where a unary operation should be performed on
      * a specified combination of numerator and denominator, both in the
diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionTest.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionTest.java
index 33ca53e..a26d378 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionTest.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionTest.java
@@ -51,7 +51,7 @@ public class FractionTest {
     public void testGoldenRatio() {
         // the golden ratio is notoriously a difficult number for continuous fraction
         Assertions.assertThrows(ArithmeticException.class,
-                () -> Fraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
+            () -> Fraction.from((1 + Math.sqrt(5)) / 2, 1.0e-12, 25)
         );
     }
 
@@ -93,7 +93,7 @@ public class FractionTest {
 
     private void checkIntegerOverflow(final double a) {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> Fraction.from(a, 1.0e-12, 1000)
+            () -> Fraction.from(a, 1.0e-12, 1000)
         );
     }
 
@@ -111,27 +111,23 @@ public class FractionTest {
 
     @Test
     public void testCompareTo() {
-        {
-            Fraction first = Fraction.of(1, 2);
-            Fraction second = Fraction.of(1, 3);
-            Fraction third = Fraction.of(1, 2);
-
-            Assertions.assertEquals(0, first.compareTo(first));
-            Assertions.assertEquals(0, first.compareTo(third));
-            Assertions.assertEquals(1, first.compareTo(second));
-            Assertions.assertEquals(-1, second.compareTo(first));
-        }
-
-        {
-            // these two values are different approximations of PI
-            // the first  one is approximately PI - 3.07e-18
-            // the second one is approximately PI + 1.936e-17
-            Fraction pi1 = Fraction.of(1068966896, 340262731);
-            Fraction pi2 = Fraction.of( 411557987, 131002976);
-            Assertions.assertEquals(-1, pi1.compareTo(pi2));
-            Assertions.assertEquals( 1, pi2.compareTo(pi1));
-            Assertions.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
-        }
+        Fraction first = Fraction.of(1, 2);
+        Fraction second = Fraction.of(1, 3);
+        Fraction third = Fraction.of(1, 2);
+
+        Assertions.assertEquals(0, first.compareTo(first));
+        Assertions.assertEquals(0, first.compareTo(third));
+        Assertions.assertEquals(1, first.compareTo(second));
+        Assertions.assertEquals(-1, second.compareTo(first));
+
+        // these two values are different approximations of PI
+        // the first  one is approximately PI - 3.07e-18
+        // the second one is approximately PI + 1.936e-17
+        Fraction pi1 = Fraction.of(1068966896, 340262731);
+        Fraction pi2 = Fraction.of(411557987, 131002976);
+        Assertions.assertEquals(-1, pi1.compareTo(pi2));
+        Assertions.assertEquals(1, pi2.compareTo(pi1));
+        Assertions.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20);
     }
 
     @Test
@@ -192,17 +188,13 @@ public class FractionTest {
 
     @Test
     public void testMath1261() {
-        {
-            final Fraction a = Fraction.of(Integer.MAX_VALUE, 2);
-            final Fraction b = a.multiply(2);
-            Assertions.assertTrue(b.equals(Fraction.of(Integer.MAX_VALUE)));
-        }
+        final Fraction a = Fraction.of(Integer.MAX_VALUE, 2);
+        final Fraction b = a.multiply(2);
+        Assertions.assertTrue(b.equals(Fraction.of(Integer.MAX_VALUE)));
 
-        {
-            final Fraction c = Fraction.of(2, Integer.MAX_VALUE);
-            final Fraction d = c.divide(2);
-            Assertions.assertTrue(d.equals(Fraction.of(1, Integer.MAX_VALUE)));
-        }
+        final Fraction c = Fraction.of(2, Integer.MAX_VALUE);
+        final Fraction d = c.divide(2);
+        Assertions.assertTrue(d.equals(Fraction.of(1, Integer.MAX_VALUE)));
     }
 
     @Test
@@ -212,12 +204,10 @@ public class FractionTest {
             assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f.reciprocal());
         }
 
-        {
-            final Fraction f = Fraction.of(0, 3);
-            Assertions.assertThrows(ArithmeticException.class,
-                    f::reciprocal
-            );
-        }
+        final Fraction f = Fraction.of(0, 3);
+        Assertions.assertThrows(ArithmeticException.class,
+                f::reciprocal
+        );
     }
 
     @Test
@@ -236,6 +226,8 @@ public class FractionTest {
             assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f1.add(f2));
         }
 
+        // CHECKSTYLE: stop AvoidNestedBlocks
+
         {
             Fraction f1 = Fraction.of(Integer.MAX_VALUE - 1, 1);
             Fraction f = f1.add(1);
@@ -243,19 +235,19 @@ public class FractionTest {
         }
 
         {
-            final Fraction f = Fraction.of(-17 - 2*13*2, 13*13*17*2*2);
+            final Fraction f = Fraction.of(-17 - 2 * 13 * 2, 13 * 13 * 17 * 2 * 2);
             Assertions.assertThrows(NullPointerException.class,
-                    () -> f.add(null)
+                () -> f.add(null)
             );
         }
 
         {
             final Fraction f1 = Fraction.of(Integer.MAX_VALUE, 1);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> {
-                        Fraction f = f1.add(Fraction.ONE); // should overflow
-                        Assertions.fail("expecting ArithmeticException but got: " + f.toString());
-                    }
+                () -> {
+                    Fraction f = f1.add(Fraction.ONE); // should overflow
+                    Assertions.fail("expecting ArithmeticException but got: " + f.toString());
+                }
             );
         }
 
@@ -264,17 +256,17 @@ public class FractionTest {
             final Fraction f1 = Fraction.of(Integer.MIN_VALUE, 5);
             final Fraction f2 = Fraction.of(-1, 5);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> {
-                        Fraction f = f1.add(f2); // should overflow
-                        Assertions.fail("expecting ArithmeticException but got: " + f.toString());
-                    }
+                () -> {
+                    Fraction f = f1.add(f2); // should overflow
+                    Assertions.fail("expecting ArithmeticException but got: " + f.toString());
+                }
             );
         }
 
         {
             final Fraction f = Fraction.of(-Integer.MAX_VALUE, 1);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> f.add(f)
+                () -> f.add(f)
             );
         }
 
@@ -282,10 +274,10 @@ public class FractionTest {
             final Fraction f1 = Fraction.of(3, 327680);
             final Fraction f2 = Fraction.of(2, 59049);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> {
-                        Fraction f = f1.add(f2); // should overflow
-                        Assertions.fail("expecting ArithmeticException but got: " + f.toString());
-                    }
+                () -> {
+                    Fraction f = f1.add(f2); // should overflow
+                    Assertions.fail("expecting ArithmeticException but got: " + f.toString());
+                }
             );
         }
     }
@@ -302,7 +294,7 @@ public class FractionTest {
             final Fraction f1 = Fraction.of(3, 5);
             final Fraction f2 = Fraction.ZERO;
             Assertions.assertThrows(FractionException.class,
-                    () -> f1.divide(f2)
+                () -> f1.divide(f2)
             );
         }
 
@@ -316,21 +308,21 @@ public class FractionTest {
         {
             final Fraction f = Fraction.of(Integer.MIN_VALUE, 1);
             Assertions.assertThrows(NullPointerException.class,
-                    () -> f.divide(null)
+                () -> f.divide(null)
             );
         }
 
         {
             final Fraction f1 = Fraction.of(1, Integer.MAX_VALUE);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> f1.divide(f1.reciprocal())  // should overflow
+                () -> f1.divide(f1.reciprocal())  // should overflow
             );
         }
 
         {
             final Fraction f1 = Fraction.of(1, -Integer.MAX_VALUE);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> f1.divide(f1.reciprocal())  // should overflow
+                () -> f1.divide(f1.reciprocal())  // should overflow
             );
         }
 
@@ -349,18 +341,14 @@ public class FractionTest {
             assertFraction(testCase.expectedNumerator, testCase.expectedDenominator, f1.multiply(f2));
         }
 
-        {
-            final Fraction f = Fraction.of(Integer.MIN_VALUE, 1);
-            Assertions.assertThrows(NullPointerException.class,
-                    () -> f.multiply(null)
-            );
-        }
+        final Fraction f0 = Fraction.of(Integer.MIN_VALUE, 1);
+        Assertions.assertThrows(NullPointerException.class,
+            () -> f0.multiply(null)
+        );
 
-        {
-            Fraction f1 = Fraction.of(6, 35);
-            Fraction f = f1.multiply(15);
-            assertFraction(18, 7, f);
-        }
+        Fraction f1 = Fraction.of(6, 35);
+        Fraction f = f1.multiply(15);
+        assertFraction(18, 7, f);
     }
 
     @Test
@@ -400,21 +388,22 @@ public class FractionTest {
         {
             final Fraction f = Fraction.of(1, 1);
             Assertions.assertThrows(NullPointerException.class,
-                    () -> f.subtract(null)
+                () -> f.subtract(null)
             );
         }
 
+        // CHECKSTYLE: stop AvoidNestedBlocks
         {
             Fraction f1 = Fraction.of(Integer.MAX_VALUE, 1);
             Fraction f = f1.subtract(1);
-            assertFraction(Integer.MAX_VALUE-1, 1, f);
+            assertFraction(Integer.MAX_VALUE - 1, 1, f);
         }
 
         {
             final Fraction f1 = Fraction.of(1, Integer.MAX_VALUE);
             final Fraction f2 = Fraction.of(1, Integer.MAX_VALUE - 1);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> f1.subtract(f2)  //should overflow
+                () -> f1.subtract(f2)  //should overflow
             );
         }
 
@@ -423,24 +412,24 @@ public class FractionTest {
             final Fraction f1 = Fraction.of(Integer.MIN_VALUE, 5);
             final Fraction f2 = Fraction.of(1, 5);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> {
-                        Fraction f = f1.subtract(f2); // should overflow
-                        Assertions.fail("expecting ArithmeticException but got: " + f.toString());
-                    }
+                () -> {
+                    Fraction f = f1.subtract(f2); // should overflow
+                    Assertions.fail("expecting ArithmeticException but got: " + f.toString());
+                }
             );
         }
 
         {
             final Fraction f = Fraction.of(Integer.MIN_VALUE, 1);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> f.subtract(Fraction.ONE)
+                () -> f.subtract(Fraction.ONE)
             );
         }
 
         {
             final Fraction f = Fraction.of(Integer.MAX_VALUE, 1);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> f.subtract(Fraction.ONE.negate())
+                () -> f.subtract(Fraction.ONE.negate())
             );
         }
 
@@ -448,12 +437,13 @@ public class FractionTest {
             final Fraction f1 = Fraction.of(3, 327680);
             final Fraction f2 = Fraction.of(2, 59049);
             Assertions.assertThrows(ArithmeticException.class,
-                    () -> {
-                        Fraction f = f1.subtract(f2); // should overflow
-                        Assertions.fail("expecting ArithmeticException but got: " + f.toString());
-                    }
+                () -> {
+                    Fraction f = f1.subtract(f2); // should overflow
+                    Assertions.fail("expecting ArithmeticException but got: " + f.toString());
+                }
             );
         }
+        // CHECKSTYLE: resume AvoidNestedBlocks
     }
 
     @Test
@@ -551,15 +541,9 @@ public class FractionTest {
             inc++;
         }
 
-        {
-            Assertions.assertThrows(NumberFormatException.class,
-                                    () -> Fraction.parse("1 // 2"));
-            Assertions.assertThrows(NumberFormatException.class,
-                                    () -> Fraction.parse("1 / z"));
-            Assertions.assertThrows(NumberFormatException.class,
-                                    () -> Fraction.parse("1 / --2"));
-            Assertions.assertThrows(NumberFormatException.class,
-                                    () -> Fraction.parse("x"));
-        }
+        Assertions.assertThrows(NumberFormatException.class, () -> Fraction.parse("1 // 2"));
+        Assertions.assertThrows(NumberFormatException.class, () -> Fraction.parse("1 / z"));
+        Assertions.assertThrows(NumberFormatException.class, () -> Fraction.parse("1 / --2"));
+        Assertions.assertThrows(NumberFormatException.class, () -> Fraction.parse("x"));
     }
 }


[commons-numbers] 24/32: Fixed checkstyle in complex-streams.

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

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

commit 2d0ef91daf9fe0509d9f7b68a0debf6d280ad62c
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 17:43:34 2019 +0000

    Fixed checkstyle in complex-streams.
---
 .../numbers/complex/streams/ComplexUtils.java      | 30 ++++----
 .../numbers/complex/streams/ComplexUtilsTest.java  | 88 +++++++++++-----------
 .../commons/numbers/complex/streams/TestUtils.java | 26 ++++---
 3 files changed, 74 insertions(+), 70 deletions(-)

diff --git a/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/ComplexUtils.java b/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/ComplexUtils.java
index 66d72b5..304f9db 100644
--- a/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/ComplexUtils.java
+++ b/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/ComplexUtils.java
@@ -22,7 +22,7 @@ import org.apache.commons.numbers.complex.Complex;
 /**
  * Static implementations of common {@link Complex} utilities functions.
  */
-public class ComplexUtils {
+public final class ComplexUtils {
 
     /**
      * Utility class.
@@ -33,7 +33,7 @@ public class ComplexUtils {
      * Creates a complex number from the given polar representation.
      * <p>
      * If either {@code r} or {@code theta} is NaN, or {@code theta} is
-     * infinite, {@link Complex#NAN} is returned.
+     * infinite, {@code Complex(NaN, NaN)} is returned.
      * <p>
      * If {@code r} is infinite and {@code theta} is finite, infinite or NaN
      * values may be returned in parts of the result, following the rules for
@@ -242,7 +242,7 @@ public class ComplexUtils {
      * @return size 2 array.
      */
     public static double[] extractInterleavedFromComplexArray(Complex[] complex, int index) {
-        return new double[] { complex[index].getReal(), complex[index].getImaginary() };
+        return new double[] {complex[index].getReal(), complex[index].getImaginary()};
     }
 
     /**
@@ -254,7 +254,7 @@ public class ComplexUtils {
      * @return size 2 {@code float[]}.
      */
     public static float[] extractInterleavedFloatFromComplexArray(Complex[] complex, int index) {
-        return new float[] { (float) complex[index].getReal(), (float) complex[index].getImaginary() };
+        return new float[] {(float) complex[index].getReal(), (float) complex[index].getImaginary()};
     }
 
     /**
@@ -714,7 +714,7 @@ public class ComplexUtils {
 
     /**
      * Converts a complex interleaved {@code double[]} array to a
-     * {@code Complex[]} array
+     * {@code Complex[]} array.
      *
      * @param interleaved array of numbers to be converted to their {@code Complex} equivalent
      * @return {@code Complex} array
@@ -730,7 +730,7 @@ public class ComplexUtils {
 
     /**
      * Converts a complex interleaved {@code float[]} array to a
-     * {@code Complex[]} array
+     * {@code Complex[]} array.
      *
      * @param interleaved float[] array of numbers to be converted to their {@code Complex} equivalent
      * @return {@code Complex} array
@@ -746,7 +746,7 @@ public class ComplexUtils {
 
     /**
      * Converts a {@code Complex[]} array to an interleaved complex
-     * {@code double[]} array
+     * {@code double[]} array.
      *
      * @param c Complex array
      * @return complex interleaved array alternating real and
@@ -767,7 +767,7 @@ public class ComplexUtils {
 
     /**
      * Converts a {@code Complex[]} array to an interleaved complex
-     * {@code float[]} array
+     * {@code float[]} array.
      *
      * @param c Complex array
      * @return complex interleaved {@code float[]} alternating real and
@@ -934,8 +934,8 @@ public class ComplexUtils {
                 for (int y = 0; y < h; y++) {
                     for (int z = 0; z < d; z++) {
                         for (int t = 0; t < v; t++) {
-                        i[x][y][z * 2][t] = c[x][y][z][t].getReal();
-                        i[x][y][z * 2 + 1][t] = c[x][y][z][t].getImaginary();
+                            i[x][y][z * 2][t] = c[x][y][z][t].getReal();
+                            i[x][y][z * 2 + 1][t] = c[x][y][z][t].getImaginary();
                         }
                     }
                 }
@@ -946,8 +946,8 @@ public class ComplexUtils {
                 for (int y = 0; y < h; y++) {
                     for (int z = 0; z < d; z++) {
                         for (int t = 0; t < v; t++) {
-                        i[x][y][z][t * 2] = c[x][y][z][t].getReal();
-                        i[x][y][z][t * 2 + 1] = c[x][y][z][t].getImaginary();
+                            i[x][y][z][t * 2] = c[x][y][z][t].getReal();
+                            i[x][y][z][t * 2 + 1] = c[x][y][z][t].getImaginary();
                         }
                     }
                 }
@@ -1329,7 +1329,7 @@ public class ComplexUtils {
         Complex[][][] c;
         if (interleavedDim == 0) {
             c = new Complex[w / 2][h][d];
-            for (int x = 0; x < w/2; x ++) {
+            for (int x = 0; x < w / 2; x++) {
                 for (int y = 0; y < h; y++) {
                     for (int z = 0; z < d; z++) {
                         c[x][y][z] = Complex.ofCartesian(i[x * 2][y][z], i[x * 2 + 1][y][z]);
@@ -1339,7 +1339,7 @@ public class ComplexUtils {
         } else if (interleavedDim == 1) {
             c = new Complex[w][h / 2][d];
             for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h/2; y ++) {
+                for (int y = 0; y < h / 2; y++) {
                     for (int z = 0; z < d; z++) {
                         c[x][y][z] = Complex.ofCartesian(i[x][y * 2][z], i[x][y * 2 + 1][z]);
                     }
@@ -1349,7 +1349,7 @@ public class ComplexUtils {
             c = new Complex[w][h][d / 2];
             for (int x = 0; x < w; x++) {
                 for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d/2; z++) {
+                    for (int z = 0; z < d / 2; z++) {
                         c[x][y][z] = Complex.ofCartesian(i[x][y][z * 2], i[x][y][z * 2 + 1]);
                     }
                 }
diff --git a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
index daaa2e5..07b7a88 100644
--- a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
+++ b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test;
  */
 public class ComplexUtilsTest {
 
+    // CHECKSTYLE: stop ConstantName
     private static final double inf = Double.POSITIVE_INFINITY;
     private static final double negInf = Double.NEGATIVE_INFINITY;
     private static final double nan = Double.NaN;
@@ -54,6 +55,7 @@ public class ComplexUtilsTest {
     private static float[] sfr; // real component of split array, float, evens
     private static float[] sfi; // imag component of split array, float, odds
     private static String msg; // error message for AssertEquals
+    // CHECKSTYLE: stop MultipleVariableDeclarations
     private static Complex[][] c2d, cr2d, ci2d; // for 2d methods
     private static Complex[][][] c3d, cr3d, ci3d; // for 3d methods
     private static Complex[][][][] c4d, cr4d, ci4d; // for 3d methods
@@ -63,7 +65,10 @@ public class ComplexUtilsTest {
     private static float[][] fi2d0, fi2d1, sfr2d, sfi2d;
     private static float[][][] fi3d0, fi3d1, fi3d2, sfr3d, sfi3d;
     private static float[][][][] sfr4d, sfi4d;
+    // CHECKSTYLE: resume MultipleVariableDeclarations
+    // CHECKSTYLE: resume ConstantName
 
+    // CHECKSTYLE: stop MethodLength
     private static void setArrays() { // initial setup method
         c = new Complex[10];
         cr = new Complex[10];
@@ -231,6 +236,7 @@ public class ComplexUtilsTest {
         }
         msg = "";
     }
+    // CHECKSTYLE: resume MethodLength
 
     @Test
     public void testPolar2Complex() {
@@ -261,8 +267,8 @@ public class ComplexUtilsTest {
         }
         theta1D[5] = 0;
         for (int i = 1; i < 5; i++) {
-            theta1D[5+i] = theta1D[5 + i - 1] + pi/6;
-            theta1D[5-i] = theta1D[5 + i + 1] - pi/6;
+            theta1D[5 + i] = theta1D[5 + i - 1] + pi / 6;
+            theta1D[5 - i] = theta1D[5 + i + 1] - pi / 6;
         }
         Complex[] observed1D = ComplexUtils.polar2Complex(r1D, theta1D);
         Assertions.assertEquals(r1D.length, observed1D.length);
@@ -310,28 +316,28 @@ public class ComplexUtilsTest {
     @Test
     public void testPolar2ComplexIllegalModulus() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.polar2Complex(-1, 0)
+            () -> ComplexUtils.polar2Complex(-1, 0)
         );
     }
 
     @Test
     public void testPolar2ComplexIllegalModulus1D() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.polar2Complex(new double[]{0, -1, 2}, new double[]{0, 1, 2})
+            () -> ComplexUtils.polar2Complex(new double[]{0, -1, 2}, new double[]{0, 1, 2})
         );
     }
 
     @Test
     public void testPolar2ComplexIllegalModulus2D() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.polar2Complex(new double[][]{{0, 2, 2}, {0, -1, 2}}, new double[][]{{0, 1, 2}, {0, 1, 2}})
+            () -> ComplexUtils.polar2Complex(new double[][]{{0, 2, 2}, {0, -1, 2}}, new double[][]{{0, 1, 2}, {0, 1, 2}})
         );
     }
 
     @Test
     public void testPolar2ComplexIllegalModulus3D() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.polar2Complex(new double[][][]{{{0, 2, 2}}, {{0, -1, 2}}}, new double[][][]{{{0, 1, 2}}, {{0, 1, 2}}})
+            () -> ComplexUtils.polar2Complex(new double[][][]{{{0, 2, 2}}, {{0, -1, 2}}}, new double[][][]{{{0, 1, 2}}, {{0, 1, 2}}})
         );
     }
 
@@ -357,7 +363,7 @@ public class ComplexUtilsTest {
 
     @Test
     public void testCExtract() {
-        final double[] real = new double[] { negInf, -123.45, 0, 1, 234.56, pi, inf };
+        final double[] real = new double[] {negInf, -123.45, 0, 1, 234.56, pi, inf};
         final Complex[] complex = ComplexUtils.real2Complex(real);
 
         for (int i = 0; i < real.length; i++) {
@@ -395,10 +401,10 @@ public class ComplexUtilsTest {
         // Extract complex from interleaved float array, index 3
         TestUtils.assertSame(Complex.ofCartesian(6, 7), ComplexUtils.extractComplexFromInterleavedArray(f, 3));
         // Extract interleaved double from complex array, index 3
-        Assertions.assertArrayEquals(new double[] { 6, 7 }, ComplexUtils.extractInterleavedFromComplexArray(c, 3),
+        Assertions.assertArrayEquals(new double[] {6, 7}, ComplexUtils.extractInterleavedFromComplexArray(c, 3),
                 Math.ulp(1), msg);
         // Extract interleaved float from complex array, index 3
-        Assertions.assertArrayEquals(new double[] { 6, 7 }, ComplexUtils.extractInterleavedFromComplexArray(c, 3),
+        Assertions.assertArrayEquals(new double[] {6, 7}, ComplexUtils.extractInterleavedFromComplexArray(c, 3),
                 Math.ulp(1), msg);
     }
     // REAL <-> COMPLEX
@@ -504,101 +510,98 @@ public class ComplexUtilsTest {
     @Test
     public void testComplex2InterleavedIllegalIndex3Dmin() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.complex2Interleaved(c3d, -1)
+            () -> ComplexUtils.complex2Interleaved(c3d, -1)
         );
     }
 
     @Test
     public void testComplex2InterleavedIllegalIndex3Dmax() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.complex2Interleaved(c3d, 3)
+            () -> ComplexUtils.complex2Interleaved(c3d, 3)
         );
     }
 
     @Test
     public void testComplex2InterleavedIllegalIndex4Dmin() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.complex2Interleaved(c4d, -1)
+            () -> ComplexUtils.complex2Interleaved(c4d, -1)
         );
     }
 
     @Test
     public void testComplex2InterleavedIllegalIndex4Dmax() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.complex2Interleaved(c4d, 4)
+            () -> ComplexUtils.complex2Interleaved(c4d, 4)
         );
     }
 
     @Test
     public void testComplex2InterleavedFloatIllegalIndex2Dmin() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.complex2InterleavedFloat(c2d, -1)
+            () -> ComplexUtils.complex2InterleavedFloat(c2d, -1)
         );
     }
 
     @Test
     public void testComplex2InterleavedFloatIllegalIndex2Dmax() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.complex2InterleavedFloat(c2d, 2)
+            () -> ComplexUtils.complex2InterleavedFloat(c2d, 2)
         );
     }
 
     @Test
-    public void testComplex2InterleavedFloatIllegalIndex3Dmin()
-    {
+    public void testComplex2InterleavedFloatIllegalIndex3Dmin() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.complex2InterleavedFloat(c3d,-1)
+            () -> ComplexUtils.complex2InterleavedFloat(c3d, -1)
         );
     }
 
     @Test
-    public void testComplex2InterleavedFloatIllegalIndex3Dmax()
-    {
+    public void testComplex2InterleavedFloatIllegalIndex3Dmax() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.complex2InterleavedFloat(c3d, 3)
+            () -> ComplexUtils.complex2InterleavedFloat(c3d, 3)
         );
     }
 
     @Test
     public void testInterleaved2ComplexIllegalIndex2Dmin() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.interleaved2Complex(di2d0, -1)
+            () -> ComplexUtils.interleaved2Complex(di2d0, -1)
         );
     }
 
     @Test
     public void testInterleaved2ComplexIllegalIndex2Dmax() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.interleaved2Complex(di2d0, 2)
+            () -> ComplexUtils.interleaved2Complex(di2d0, 2)
         );
     }
 
     @Test
     public void testInterleaved2ComplexIllegalIndex3Dmin() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.interleaved2Complex(di3d0, -1)
+            () -> ComplexUtils.interleaved2Complex(di3d0, -1)
         );
     }
 
     @Test
-    public void testInterleaved2ComplexIllegalIndex3Dmax()
-    {
+    public void testInterleaved2ComplexIllegalIndex3Dmax() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.interleaved2Complex(di3d0, 3)
+            () -> ComplexUtils.interleaved2Complex(di3d0, 3)
         );
     }
 
     @Test
     public void testInterleaved2ComplexIllegalIndex4Dmin() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.interleaved2Complex(di4d0, -1)
+            () -> ComplexUtils.interleaved2Complex(di4d0, -1)
         );
     }
 
     @Test
     public void testInterleaved2ComplexIllegalIndex4Dmax() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.interleaved2Complex(di4d0, 4)
+            () -> ComplexUtils.interleaved2Complex(di4d0, 4)
         );
     }
 
@@ -612,22 +615,21 @@ public class ComplexUtilsTest {
     @Test
     public void testInterleaved2ComplexFloatIllegalIndex2Dmax() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.interleaved2Complex(fi2d0, 2)
+            () -> ComplexUtils.interleaved2Complex(fi2d0, 2)
         );
     }
 
     @Test
     public void testInterleaved2ComplexFloatIllegalIndex3Dmin() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.interleaved2Complex(fi3d0, -1)
+            () -> ComplexUtils.interleaved2Complex(fi3d0, -1)
         );
     }
 
     @Test
-    public void testInterleaved2ComplexFloatIllegalIndex3Dmax()
-    {
+    public void testInterleaved2ComplexFloatIllegalIndex3Dmax() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> ComplexUtils.interleaved2Complex(fi3d0, 3)
+            () -> ComplexUtils.interleaved2Complex(fi3d0, 3)
         );
     }
 
@@ -719,18 +721,18 @@ public class ComplexUtilsTest {
 
     @Test
     public void testInitialize() {
-        Complex[] c = new Complex[10];
-        ComplexUtils.initialize(c);
-        for (Complex cc : c) {
+        Complex[] complexes = new Complex[10];
+        ComplexUtils.initialize(complexes);
+        for (Complex cc : complexes) {
             TestUtils.assertEquals(Complex.ofCartesian(0, 0), cc, Math.ulp(0));
         }
     }
 
     @Test
     public void testInitialize2d() {
-        Complex[][] c = new Complex[10][10];
-        ComplexUtils.initialize(c);
-        for (Complex[] c1 : c) {
+        Complex[][] complexes = new Complex[10][10];
+        ComplexUtils.initialize(complexes);
+        for (Complex[] c1 : complexes) {
             for (Complex c0 : c1) {
                 TestUtils.assertEquals(Complex.ofCartesian(0, 0), c0, Math.ulp(0));
             }
@@ -739,9 +741,9 @@ public class ComplexUtilsTest {
 
     @Test
     public void testInitialize3d() {
-        Complex[][][] c = new Complex[10][10][10];
-        ComplexUtils.initialize(c);
-        for (Complex[][] c2 : c) {
+        Complex[][][] complexes = new Complex[10][10][10];
+        ComplexUtils.initialize(complexes);
+        for (Complex[][] c2 : complexes) {
             for (Complex[] c1 : c2) {
                 for (Complex c0 : c1) {
                     TestUtils.assertEquals(Complex.ofCartesian(0, 0), c0, Math.ulp(0));
diff --git a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java
index 30de90e..0b3ff66 100644
--- a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java
+++ b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Assertions;
  * Test utilities.
  */
 @SuppressWarnings("WeakerAccess")
-class TestUtils {
+final class TestUtils {
     /**
      * Collection of static methods used in math unit tests.
      */
@@ -87,7 +87,7 @@ class TestUtils {
     /** verifies that two 2D arrays are close (sup norm) */
     public static void assertEquals(String msg, double[][] expected, double[][] observed, double tolerance) {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             Assertions.assertArrayEquals(expected[i], observed[i], tolerance, msg + "[" + i + "]");
         }
     }
@@ -95,7 +95,7 @@ class TestUtils {
     /** verifies that two 3D arrays are close (sup norm) */
     public static void assertEquals(String msg, double[][][] expected, double[][][] observed, double tolerance) {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance);
         }
     }
@@ -103,7 +103,7 @@ class TestUtils {
     /** verifies that two 4D arrays are close (sup norm) */
     public static void assertEquals(String msg, double[][][][] expected, double[][][][] observed, double tolerance) {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance);
         }
     }
@@ -111,7 +111,7 @@ class TestUtils {
     /** verifies that two 4D arrays are close (sup norm) */
     public static void assertEquals(String msg, float[][][][] expected, float[][][][] observed, float tolerance) {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance);
         }
     }
@@ -119,7 +119,7 @@ class TestUtils {
     /** verifies that two 2D arrays are close (sup norm) */
     public static void assertEquals(String msg, float[][] expected, float[][] observed, float tolerance) {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             Assertions.assertArrayEquals(expected[i], observed[i], tolerance, msg + "[" + i + "]");
         }
     }
@@ -127,7 +127,7 @@ class TestUtils {
     /** verifies that two 3D arrays are close (sup norm) */
     public static void assertEquals(String msg, float[][][] expected, float[][][] observed, float tolerance) {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance);
         }
     }
@@ -137,7 +137,7 @@ class TestUtils {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
         StringBuilder out = new StringBuilder(msg);
         boolean failure = false;
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             if (!Precision.equalsIncludingNaN(expected[i].getReal(), observed[i].getReal(), tolerance)) {
                 failure = true;
                 out.append("\n[").append(i).append("] ");
@@ -165,7 +165,7 @@ class TestUtils {
     /** verifies that two 2D arrays are close (sup norm) */
     public static void assertEquals(String msg, Complex[][] expected, Complex[][] observed, double tolerance) {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance);
         }
     }
@@ -173,7 +173,7 @@ class TestUtils {
     /** verifies that two 3D arrays are close (sup norm) */
     public static void assertEquals(String msg, Complex[][][] expected, Complex[][][] observed, double tolerance) {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance);
         }
     }
@@ -181,7 +181,7 @@ class TestUtils {
     /** verifies that two 4D arrays are close (sup norm) */
     public static void assertEquals(String msg, Complex[][][][] expected, Complex[][][][] observed, double tolerance) {
         assertArrayLengthsEqual(msg, expected.length, observed.length);
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance);
         }
     }
@@ -195,7 +195,9 @@ class TestUtils {
     private static void assertArrayLengthsEqual(String msg, int expectedLength, int observedLength) {
         if (expectedLength != observedLength) {
             StringBuilder out = new StringBuilder(msg);
-            if (msg != null && msg.length()>0) out.append("\n");
+            if (msg != null && msg.length() > 0) {
+                out.append("\n");
+            }
             out.append("Arrays not same length. \n");
             out.append("expected has length ").append(expectedLength);
             out.append(" observed has length = ").append(observedLength);


[commons-numbers] 03/32: Reference conjugate from conj method javadoc.

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

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

commit aec4ea5378f577f32d0b9faa58916ad6fd5ca7a8
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 21:54:10 2019 +0000

    Reference conjugate from conj method javadoc.
---
 .../src/main/java/org/apache/commons/numbers/complex/Complex.java        | 1 +
 1 file changed, 1 insertion(+)

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 c6c5224..aa23ed5 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
@@ -291,6 +291,7 @@ public final class Complex implements Serializable  {
      * Returns the conjugate of this complex number.
      * C++11 grammar.
      * @return the conjugate of this complex object.
+     * @see #conjugate()
      */
     public Complex conj() {
         return conjugate();


[commons-numbers] 25/32: Fixed checkstyle in primes.

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

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

commit d803bf596a20bc45e1943e269497e23cd3b47c76
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 17:52:26 2019 +0000

    Fixed checkstyle in primes.
---
 .../org/apache/commons/numbers/primes/Primes.java  |  7 +-
 .../apache/commons/numbers/primes/SmallPrimes.java | 63 +++++++-------
 .../apache/commons/numbers/primes/PrimesTest.java  | 96 ++++++++++++----------
 .../commons/numbers/primes/SmallPrimesTest.java    | 34 ++++----
 4 files changed, 106 insertions(+), 94 deletions(-)

diff --git a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/Primes.java b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/Primes.java
index 320b411..a971372 100644
--- a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/Primes.java
+++ b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/Primes.java
@@ -19,16 +19,15 @@ package org.apache.commons.numbers.primes;
 import java.text.MessageFormat;
 import java.util.List;
 
-
 /**
- * Methods related to prime numbers in the range of <code>int</code>:
+ * Methods related to prime numbers in the range of <code>int</code>.
  * <ul>
  * <li>primality test</li>
  * <li>prime number generation</li>
  * <li>factorization</li>
  * </ul>
  */
-public class Primes {
+public final class Primes {
     /** Exception message format when an argument is too small. */
     static final String NUMBER_TOO_SMALL = "{0} is smaller than the minimum ({1})";
 
@@ -105,7 +104,7 @@ public class Primes {
     }
 
     /**
-     * Prime factors decomposition
+     * Prime factors decomposition.
      *
      * @param n Number to factorize: must be &ge; 2.
      * @return the list of prime factors of {@code n}.
diff --git a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java
index badc11c..4097f32 100644
--- a/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java
+++ b/commons-numbers-primes/src/main/java/org/apache/commons/numbers/primes/SmallPrimes.java
@@ -29,7 +29,7 @@ import java.util.Set;
 /**
  * Utility methods to work on primes within the <code>int</code> range.
  */
-class SmallPrimes {
+final class SmallPrimes {
     /**
      * The first 512 prime numbers.
      * <p>
@@ -37,33 +37,34 @@ class SmallPrimes {
      * As a result, <code>int</code> numbers which are not reduced by those primes are guaranteed
      * to be either prime or semi prime.
      */
-    static final int[] PRIMES = {2,
-            3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
-            79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179,
-            181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283,
-            293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419,
-            421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547,
-            557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661,
-            673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811,
-            821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947,
-            953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087,
-            1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229,
-            1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381,
-            1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523,
-            1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663,
-            1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823,
-            1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993,
-            1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131,
-            2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293,
-            2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437,
-            2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621,
-            2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749,
-            2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909,
-            2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083,
-            3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259,
-            3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433,
-            3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581,
-            3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671};
+    static final int[] PRIMES = {
+        2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,
+        109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
+        233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359,
+        367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491,
+        499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641,
+        643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787,
+        797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
+        947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069,
+        1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213,
+        1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321,
+        1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481,
+        1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601,
+        1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733,
+        1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877,
+        1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017,
+        2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143,
+        2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297,
+        2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423,
+        2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593,
+        2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713,
+        2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851,
+        2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011,
+        3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181,
+        3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323,
+        3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467,
+        3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607,
+        3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671};
 
     /** The last number in {@link #PRIMES}. */
     static final int PRIMES_LAST = PRIMES[PRIMES.length - 1];
@@ -179,7 +180,8 @@ class SmallPrimes {
         as prime factors, and c is an integer undivisible by all of those
         prime numbers; in other words, skipping multiples of these primes
          */
-        int m = PRIME_NUMBERS_AND_COPRIME_EQUIVALENCE_CLASSES.getValue()[PRIME_NUMBERS_AND_COPRIME_EQUIVALENCE_CLASSES.getValue().length - 1] + 1;
+        int m = PRIME_NUMBERS_AND_COPRIME_EQUIVALENCE_CLASSES.getValue()
+            [PRIME_NUMBERS_AND_COPRIME_EQUIVALENCE_CLASSES.getValue().length - 1] + 1;
         int km = m * (minFactor / m);
         int currentEquivalenceClassIndex = Arrays.binarySearch(
                 PRIME_NUMBERS_AND_COPRIME_EQUIVALENCE_CLASSES.getValue(),
@@ -202,7 +204,8 @@ class SmallPrimes {
                 factors.add(f);
                 done = true;
             } else {
-                if (currentEquivalenceClassIndex == PRIME_NUMBERS_AND_COPRIME_EQUIVALENCE_CLASSES.getValue().length - 1) {
+                if (currentEquivalenceClassIndex ==
+                    PRIME_NUMBERS_AND_COPRIME_EQUIVALENCE_CLASSES.getValue().length - 1) {
                     km += m;
                     currentEquivalenceClassIndex = 0;
                 } else {
diff --git a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/PrimesTest.java b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/PrimesTest.java
index 0ca314a..9667a16 100644
--- a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/PrimesTest.java
+++ b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/PrimesTest.java
@@ -26,36 +26,45 @@ import org.junit.jupiter.api.Test;
 
 public class PrimesTest {
 
-    public static final int[] PRIMES = {//primes here have been verified one by one using Dario Alejandro Alpern's tool, see http://www.alpertron.com.ar/ECM.HTM
-            2,3,5,7,11,13,17,19,23,29,31,43,47,53,71,73,79,89,97,
-            107,137,151,157,271,293,331,409,607,617,683,829,
-            1049,1103,1229,1657,
-            2039,2053,//around first boundary in miller-rabin
-            2251,2389,2473,2699,3271,3389,3449,5653,6449,6869,9067,9091,
-            11251,12433,12959,22961,41047,46337,65413,80803,91577,92693,
-            118423,656519,795659,
-            1373639,1373677,//around second boundary in miller-rabin
-            588977,952381,
-            1013041,1205999,2814001,
-            22605091,
-            25325981,25326023,//around third boundary in miller-rabin
-            100000007,715827881,
-            2147483647//Integer.MAX_VALUE
-            };
-
-    public static final int[] NOT_PRIMES = {//composite chosen at random + particular values used in algorithms such as boundaries for millerRabin
-            4,6,8,9,10,12,14,15,16,18,20,21,22,24,25,
-            275,
-            2037,2041,2045,2046,2047,2048,2049,2051,2055,//around first boundary in miller-rabin
-            9095,
-            463465,
-            1373637,1373641,1373651,1373652,1373653,1373654,1373655,1373673,1373675,1373679,//around second boundary in miller-rabin
-            25325979,25325983,25325993,25325997,25325999,25326001,25326003,25326007,25326009,25326011,25326021,25326025,//around third boundary in miller-rabin
-            100000005,
-            1073741341,1073741823,2147473649,2147483641,2147483643,2147483645,2147483646};
-
-    public static final int[] BELOW_2 = {
-            Integer.MIN_VALUE,-1,0,1};
+    static final int[] PRIMES = {
+        //primes here have been verified one by one using Dario Alejandro Alpern's tool.
+        //see http://www.alpertron.com.ar/ECM.HTM
+        2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 43, 47, 53, 71, 73, 79, 89, 97,
+        107, 137, 151, 157, 271, 293, 331, 409, 607, 617, 683, 829,
+        1049, 1103, 1229, 1657,
+        2039, 2053, //around first boundary in miller-rabin
+        2251, 2389, 2473, 2699, 3271, 3389, 3449, 5653, 6449, 6869, 9067, 9091,
+        11251, 12433, 12959, 22961, 41047, 46337, 65413, 80803, 91577, 92693,
+        118423, 656519, 795659,
+        1373639, 1373677, //around second boundary in miller-rabin
+        588977, 952381,
+        1013041, 1205999, 2814001,
+        22605091,
+        25325981, 25326023, //around third boundary in miller-rabin
+        100000007, 715827881,
+        2147483647//Integer.MAX_VALUE
+        };
+
+    static final int[] NOT_PRIMES = {
+        //composite chosen at random + particular values used in algorithms such as boundaries for millerRabin
+        4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25,
+        275,
+        2037, 2041, 2045, 2046, 2047, 2048, 2049, 2051, 2055, //around first boundary in miller-rabin
+        9095,
+        463465,
+        1373637, 1373641, 1373651, 1373652, 1373653, 1373654, 1373655, 1373673, 1373675, 1373679, //around second boundary in miller-rabin
+        25325979, 25325983, 25325993, 25325997, 25325999, 25326001, 25326003, 25326007, 25326009, 25326011, 25326021, 25326025, //around third boundary in miller-rabin
+        100000005,
+        1073741341, 1073741823, 2147473649, 2147483641, 2147483643, 2147483645, 2147483646};
+
+    static final int[] BELOW_2 = {Integer.MIN_VALUE, -1, 0, 1};
+
+    static final HashSet<Integer> PRIMES_SET = new HashSet<>();
+    static {
+        for (int p : PRIMES) {
+            PRIMES_SET.add(p);
+        }
+    }
 
     void assertPrimeFactorsException(int n, String expected) {
         try {
@@ -65,11 +74,12 @@ public class PrimesTest {
             Assertions.assertEquals(expected, e.getMessage());
         }
     }
-    void assertNextPrimeException(int n, String expected){
+
+    void assertNextPrimeException(int n, String expected) {
         try {
             Primes.nextPrime(n);
             Assertions.fail("Exception not thrown");
-        } catch(IllegalArgumentException e) {
+        } catch (IllegalArgumentException e) {
             Assertions.assertEquals(expected, e.getMessage());
         }
     }
@@ -86,7 +96,7 @@ public class PrimesTest {
 
         for (int i = 0; i < SmallPrimes.PRIMES.length - 1; i++) {
             for (int j = SmallPrimes.PRIMES[i] + 1; j <= SmallPrimes.PRIMES[i + 1]; j++) {
-                Assertions.assertEquals(SmallPrimes.PRIMES[i+1], Primes.nextPrime(j));
+                Assertions.assertEquals(SmallPrimes.PRIMES[i + 1], Primes.nextPrime(j));
             }
         }
 
@@ -99,9 +109,9 @@ public class PrimesTest {
         Assertions.assertEquals(Integer.MAX_VALUE, Primes.nextPrime(Integer.MAX_VALUE - 1));
         Assertions.assertEquals(Integer.MAX_VALUE, Primes.nextPrime(Integer.MAX_VALUE));
 
-        assertNextPrimeException(Integer.MIN_VALUE, MessageFormat.format(Primes.NUMBER_TOO_SMALL,Integer.MIN_VALUE,0));
-        assertNextPrimeException(-1, MessageFormat.format(Primes.NUMBER_TOO_SMALL,-1,0));
-        assertNextPrimeException(-13, MessageFormat.format(Primes.NUMBER_TOO_SMALL,-13,0));
+        assertNextPrimeException(Integer.MIN_VALUE, MessageFormat.format(Primes.NUMBER_TOO_SMALL, Integer.MIN_VALUE, 0));
+        assertNextPrimeException(-1, MessageFormat.format(Primes.NUMBER_TOO_SMALL, -1, 0));
+        assertNextPrimeException(-13, MessageFormat.format(Primes.NUMBER_TOO_SMALL, -13, 0));
     }
 
     @Test
@@ -117,13 +127,14 @@ public class PrimesTest {
         }
     }
 
-    static int sum(List<Integer> numbers){
+    static int sum(List<Integer> numbers) {
         int out = 0;
         for (int i:numbers) {
             out += i;
         }
         return out;
     }
+
     static int product(List<Integer> numbers) {
         int out = 1;
         for (int i : numbers) {
@@ -131,13 +142,8 @@ public class PrimesTest {
         }
         return out;
     }
-    static final HashSet<Integer> PRIMES_SET = new HashSet<Integer>();
-    static {
-        for (int p : PRIMES) {
-            PRIMES_SET.add(p);
-        }
-    }
-    static void checkPrimeFactors(List<Integer> factors){
+
+    static void checkPrimeFactors(List<Integer> factors) {
         for (int p : factors) {
             if (!PRIMES_SET.contains(p)) {
                 Assertions.fail("Not found in primes list: " + p);
@@ -148,7 +154,7 @@ public class PrimesTest {
     @Test
     public void testPrimeFactors() throws Exception {
         for (int i : BELOW_2) {
-            assertPrimeFactorsException(i, MessageFormat.format(Primes.NUMBER_TOO_SMALL,i,2));
+            assertPrimeFactorsException(i, MessageFormat.format(Primes.NUMBER_TOO_SMALL, i, 2));
         }
         for (int i : NOT_PRIMES) {
             List<Integer> factors = Primes.primeFactors(i);
diff --git a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java
index 06023c5..19263d5 100644
--- a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java
+++ b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java
@@ -26,13 +26,15 @@ import org.junit.jupiter.api.Test;
 
 public class SmallPrimesTest {
 
+    // CHECKSTYLE: stop MethodName
+
     // Primes larger than the small PRIMES array in SmallPrimes
     private static final int[] LARGE_PRIME = {3673, 3677};
 
     @Test
     public void smallTrialDivision_smallComposite() {
         final List<Integer> factors = new ArrayList<Integer>();
-        final int result = SmallPrimes.smallTrialDivision(3*7*23, factors);
+        final int result = SmallPrimes.smallTrialDivision(3 * 7 * 23, factors);
         Assertions.assertEquals(1, result);
         Assertions.assertEquals(Arrays.asList(3, 7, 23), factors);
     }
@@ -40,7 +42,7 @@ public class SmallPrimesTest {
     @Test
     public void smallTrialDivision_repeatedFactors() {
         final List<Integer> factors = new ArrayList<Integer>();
-        final int result = SmallPrimes.smallTrialDivision(2*2*3*3*3, factors);
+        final int result = SmallPrimes.smallTrialDivision(2 * 2 * 3 * 3 * 3, factors);
         Assertions.assertEquals(1, result);
         Assertions.assertEquals(Arrays.asList(2, 2, 3, 3, 3), factors);
     }
@@ -56,8 +58,8 @@ public class SmallPrimesTest {
     @Test
     public void smallTrialDivision_BoundaryPrimes() {
         final List<Integer> factors = new ArrayList<Integer>();
-        final int penultimatePrime = SmallPrimes.PRIMES[SmallPrimes.PRIMES.length-2];
-        final int result = SmallPrimes.smallTrialDivision(penultimatePrime*SmallPrimes.PRIMES_LAST, factors);
+        final int penultimatePrime = SmallPrimes.PRIMES[SmallPrimes.PRIMES.length - 2];
+        final int result = SmallPrimes.smallTrialDivision(penultimatePrime * SmallPrimes.PRIMES_LAST, factors);
         Assertions.assertEquals(1, result);
         Assertions.assertEquals(Arrays.asList(penultimatePrime, SmallPrimes.PRIMES_LAST), factors);
     }
@@ -65,7 +67,7 @@ public class SmallPrimesTest {
     @Test
     public void smallTrialDivision_largeComposite() {
         final List<Integer> factors = new ArrayList<Integer>();
-        final int result = SmallPrimes.smallTrialDivision(2*5*LARGE_PRIME[0], factors);
+        final int result = SmallPrimes.smallTrialDivision(2 * 5 * LARGE_PRIME[0], factors);
         Assertions.assertEquals(LARGE_PRIME[0], result);
         Assertions.assertEquals(Arrays.asList(2, 5), factors);
     }
@@ -73,15 +75,16 @@ public class SmallPrimesTest {
     @Test
     public void smallTrialDivision_noSmallPrimeFactors() {
         final List<Integer> factors = new ArrayList<Integer>();
-        final int result = SmallPrimes.smallTrialDivision(LARGE_PRIME[0]*LARGE_PRIME[1], factors);
-        Assertions.assertEquals(LARGE_PRIME[0]*LARGE_PRIME[1], result);
+        final int result = SmallPrimes.smallTrialDivision(LARGE_PRIME[0] * LARGE_PRIME[1], factors);
+        Assertions.assertEquals(LARGE_PRIME[0] * LARGE_PRIME[1], result);
         Assertions.assertEquals(Collections.<Integer>emptyList(), factors);
     }
-    
+
     @Test
     public void boundedTrialDivision_twoDifferentFactors() {
         final List<Integer> factors = new ArrayList<Integer>();
-        final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0]*LARGE_PRIME[1], Integer.MAX_VALUE, factors);
+        final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0] * LARGE_PRIME[1], Integer.MAX_VALUE,
+            factors);
         Assertions.assertEquals(LARGE_PRIME[1], result);
         Assertions.assertEquals(Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[1]), factors);
     }
@@ -89,20 +92,21 @@ public class SmallPrimesTest {
     @Test
     public void boundedTrialDivision_square() {
         final List<Integer> factors = new ArrayList<Integer>();
-        final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0]*LARGE_PRIME[0], Integer.MAX_VALUE, factors);
+        final int result = SmallPrimes.boundedTrialDivision(LARGE_PRIME[0] * LARGE_PRIME[0], Integer.MAX_VALUE,
+            factors);
         Assertions.assertEquals(LARGE_PRIME[0], result);
         Assertions.assertEquals(Arrays.asList(LARGE_PRIME[0], LARGE_PRIME[0]), factors);
     }
 
     @Test
     public void trialDivision_smallComposite() {
-        final List<Integer> factors = SmallPrimes.trialDivision(5*11*29*103);
+        final List<Integer> factors = SmallPrimes.trialDivision(5 * 11 * 29 * 103);
         Assertions.assertEquals(Arrays.asList(5, 11, 29, 103), factors);
     }
 
     @Test
     public void trialDivision_repeatedFactors() {
-        final List<Integer> factors = SmallPrimes.trialDivision(2*2*2*2*5*5);
+        final List<Integer> factors = SmallPrimes.trialDivision(2 * 2 * 2 * 2 * 5 * 5);
         Assertions.assertEquals(Arrays.asList(2, 2, 2, 2, 5, 5), factors);
     }
 
@@ -114,13 +118,13 @@ public class SmallPrimesTest {
 
     @Test
     public void trialDivision_largeComposite() {
-        final List<Integer> factors = SmallPrimes.trialDivision(2*3*LARGE_PRIME[0]);
+        final List<Integer> factors = SmallPrimes.trialDivision(2 * 3 * LARGE_PRIME[0]);
         Assertions.assertEquals(Arrays.asList(2, 3, LARGE_PRIME[0]), factors);
     }
 
     @Test
     public void trialDivision_veryLargeComposite() {
-        final List<Integer> factors = SmallPrimes.trialDivision(2*LARGE_PRIME[0]*LARGE_PRIME[1]);
+        final List<Integer> factors = SmallPrimes.trialDivision(2 * LARGE_PRIME[0] * LARGE_PRIME[1]);
         Assertions.assertEquals(Arrays.asList(2, LARGE_PRIME[0], LARGE_PRIME[1]), factors);
     }
 
@@ -136,7 +140,7 @@ public class SmallPrimesTest {
     @Test
     public void millerRabinPrimeTest_composites() {
         for (final int n : PrimesTest.NOT_PRIMES) {
-            if (n %2 == 1) {
+            if (n % 2 == 1) {
                 Assertions.assertFalse(SmallPrimes.millerRabinPrimeTest(n));
             }
         }


[commons-numbers] 05/32: Javadoc requires period at end of first line.

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

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

commit a3d48c746d7a8c96bdcd460218ed903d5dfd77c8
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 22:09:49 2019 +0000

    Javadoc requires period at end of first line.
---
 .../main/java/org/apache/commons/numbers/complex/Complex.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 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 238abf2..c47b510 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
@@ -135,7 +135,7 @@ public final class Complex implements Serializable  {
 
     /**
      * For a real constructor argument x, returns a new Complex object c
-     * where {@code c = cos(x) + i sin (x)}
+     * where {@code c = cos(x) + i sin (x)}.
      *
      * @param x {@code double} to build the cis number
      * @return {@code Complex}
@@ -288,8 +288,8 @@ public final class Complex implements Serializable  {
     }
 
      /**
-     * Returns the conjugate of this complex number.
-     * C++11 grammar.
+     * Returns the conjugate of this complex number
+     * (C++11 grammar).
      * @return the conjugate of this complex object.
      * @see #conjugate()
      */
@@ -537,7 +537,7 @@ public final class Complex implements Serializable  {
         return imaginary;
     }
     /**
-     * Access the imaginary part (C++ grammar)
+     * Access the imaginary part (C++ grammar).
      *
      * @return the imaginary part.
      */
@@ -555,7 +555,7 @@ public final class Complex implements Serializable  {
     }
 
      /**
-     * Access the real part (C++ grammar)
+     * Access the real part (C++ grammar).
      *
      * @return the real part.
      */


[commons-numbers] 14/32: Added default goal.

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

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

commit 1bfd5f35da1f1d19db50b163fd4c18f715edb499
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 23:47:47 2019 +0000

    Added default goal.
---
 pom.xml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pom.xml b/pom.xml
index 55097c2..97c61c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -188,6 +188,8 @@
   </dependencies>
 
   <build>
+    <!--  TODO: Add binary compatibility check when released. -->
+    <defaultGoal>clean verify apache-rat:check checkstyle:check pmd:check spotbugs:check javadoc:javadoc</defaultGoal>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>


[commons-numbers] 02/32: Use Math.ulp(double) not Math.ulp(float) for Complex test.

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

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

commit 0f02bbab29b07323970fb24714ea40b49c986684
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 21:50:13 2019 +0000

    Use Math.ulp(double) not Math.ulp(float) for Complex test.
---
 .../test/java/org/apache/commons/numbers/complex/CStandardTest.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 92da022..d1e5a9c 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
@@ -92,7 +92,7 @@ public class CStandardTest {
         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));
+        assertComplex(z1.atan(), negI.multiply(z2.atanh()), Math.ulp(1.0), Math.ulp(1.0));
         assertComplex(z1.cos(), z2.cosh());
         assertComplex(z1.sin(), negI.multiply(z2.sinh()));
         assertComplex(z1.tan(), negI.multiply(z2.tanh()));
@@ -103,7 +103,7 @@ public class CStandardTest {
      */
     @Test
     public void testAcos() {
-        assertComplex(oneOne.acos().conj(), oneOne.conj().acos(), Math.ulp(1), Math.ulp(1));
+        assertComplex(oneOne.acos().conj(), oneOne.conj().acos(), Math.ulp(1.0), Math.ulp(1.0));
         assertComplex(Complex.ZERO.acos(), piTwoNegZero);
         assertComplex(negZeroZero.acos(), piTwoNegZero);
         assertComplex(zeroNaN.acos(), piTwoNaN);


[commons-numbers] 22/32: Code style and javadoc.

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

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

commit ce3b6d5a4cc0de9d406c9337cae95cbad0225735
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 17:26:41 2019 +0000

    Code style and javadoc.
---
 .../apache/commons/numbers/complex/Complex.java    | 86 ++++++++--------------
 1 file changed, 32 insertions(+), 54 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 ce2c5e4..4cfc306 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
@@ -255,8 +255,6 @@ public final class Complex implements Serializable  {
      * project onto real infinity, as described in the
      * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/cproj.html">
      * IEEE and ISO C standards</a>.
-     * <p>
-     *
      *
      * @return {@code Complex} projected onto the Riemann sphere.
      */
@@ -279,25 +277,15 @@ public final class Complex implements Serializable  {
     public double abs() {
         // Delegate
         return Math.hypot(real, imaginary);
-
-        //if (Math.abs(real) < Math.abs(imaginary)) {
-        //    final double q = real / imaginary;
-        //    return Math.abs(imaginary) * Math.sqrt(1 + q * q);
-        //}
-        //if (real == 0) {
-        //    return Math.abs(imaginary);
-        //}
-        //final double q = imaginary / real;
-        //return Math.abs(real) * Math.sqrt(1 + q * q);
     }
 
     /**
      * Returns a {@code Complex} whose value is
      * {@code (this + addend)}.
      * Uses the definitional formula
-     * <p>
-     *   {@code (a + bi) + (c + di) = (a+c) + (b+d)i}
-     * </p>
+     * <pre>
+     *   (a + bi) + (c + di) = (a+c) + (b+d)i
+     * </pre>
      *
      * @param  addend Value to be added to this {@code Complex}.
      * @return {@code this + addend}.
@@ -329,7 +317,7 @@ public final class Complex implements Serializable  {
         return new Complex(real, -imaginary);
     }
 
-     /**
+    /**
      * Returns the conjugate of this complex number
      * (C++11 grammar).
      *
@@ -340,23 +328,19 @@ public final class Complex implements Serializable  {
         return conjugate();
     }
 
-
     /**
      * Returns a {@code Complex} whose value is
      * {@code (this / divisor)}.
      * Implements the definitional formula
      * <pre>
-     *  <code>
-     *    a + bi          ac + bd + (bc - ad)i
-     *    ----------- = -------------------------
-     *    c + di         c<sup>2</sup> + d<sup>2</sup>
-     *  </code>
+     *   a + bi     ac + bd + (bc - ad)i
+     *   ------  =  --------------------
+     *   c + di           c<sup>2</sup> + d<sup>2</sup>
      * </pre>
      *
-     *
-     * Recalculates to recover infinities as specified in C.99
+     * <p>Recalculates to recover infinities as specified in C.99
      * standard G.5.1. Method is fully in accordance with
-     * C++11 standards for complex numbers.
+     * C++11 standards for complex numbers.</p>
      *
      * @param divisor Value by which this {@code Complex} is to be divided.
      * @return {@code this / divisor}.
@@ -614,6 +598,7 @@ public final class Complex implements Serializable  {
      */
     @Override
     public int hashCode() {
+        // TODO: Infinity can contain NaNs. This would get the same hashcode.
         if (Double.isNaN(real) ||
             Double.isNaN(imaginary)) {
             return 7;
@@ -629,6 +614,7 @@ public final class Complex implements Serializable  {
     public double getImaginary() {
         return imaginary;
     }
+
     /**
      * Access the imaginary part (C++ grammar).
      *
@@ -659,12 +645,13 @@ public final class Complex implements Serializable  {
     /**
      * Returns a {@code Complex} whose value is {@code this * factor}.
      * Implements the definitional formula:
+     * <pre>
+     *   (a + bi)(c + di) = (ac - bd) + (ad + bc)i
+     * </pre>
      *
-     *   {@code (a + bi)(c + di) = (ac - bd) + (ad + bc)i}
-     *
-     * Recalculates to recover infinities as specified in C.99
+     * <p>Recalculates to recover infinities as specified in C.99
      * standard G.5.1. Method is fully in accordance with
-     * C++11 standards for complex numbers.
+     * C++11 standards for complex numbers.</p>
      *
      * @param  factor value to be multiplied by this {@code Complex}.
      * @return {@code this * factor}.
@@ -844,9 +831,9 @@ public final class Complex implements Serializable  {
      * <a href="http://mathworld.wolfram.com/InverseCosine.html">
      * inverse cosine</a> of this complex number.
      * Implements the formula:
-     * <p>
-     *  {@code acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))}
-     * </p>
+     * <pre>
+     *   acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))
+     * </pre>
      *
      * @return the inverse cosine of this complex number.
      */
@@ -884,7 +871,7 @@ public final class Complex implements Serializable  {
      * <a href="http://mathworld.wolfram.com/InverseSine.html">
      * inverse sine</a> of this complex number.
      * <pre>
-     *  asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))
+     *   asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))
      * </pre>
      *
      * <p>As per the C.99 standard this function is computed using the trigonomic identity:</p>
@@ -906,7 +893,7 @@ public final class Complex implements Serializable  {
      * inverse tangent</a> of this complex number.
      * Implements the formula:
      * <pre>
-     *  atan(z) = (i/2) log((i + z)/(i - z))
+     *   atan(z) = (i/2) log((i + z)/(i - z))
      * </pre>
      *
      * <p>As per the C.99 standard this function is computed using the trigonomic identity:</p>
@@ -1159,9 +1146,7 @@ public final class Complex implements Serializable  {
      * exponential function</a> of this complex number.
      * Implements the formula:
      * <pre>
-     *  <code>
      *   exp(a + bi) = exp(a)cos(b) + exp(a)sin(b)i
-     *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
      * {@link Math#exp}, {@link Math#cos}, and
@@ -1197,9 +1182,7 @@ public final class Complex implements Serializable  {
      * natural logarithm</a> of this complex number.
      * Implements the formula:
      * <pre>
-     *  <code>
      *   log(a + bi) = ln(|a + bi|) + arg(a + bi)i
-     *  </code>
      * </pre>
      * where ln on the right hand side is {@link Math#log},
      * {@code |a + bi|} is the modulus, {@link Complex#abs},  and
@@ -1227,8 +1210,8 @@ public final class Complex implements Serializable  {
      * <a href="http://mathworld.wolfram.com/CommonLogarithm.html">
      * common logarithm</a> of this complex number.
      *
-     *  @return the base 10 logarithm of <code>this</code>.
-    */
+     * @return the base 10 logarithm of <code>this</code>.
+     */
     public Complex log10() {
         // Same edge cases as log()
         if (real == Double.POSITIVE_INFINITY &&
@@ -1248,15 +1231,13 @@ public final class Complex implements Serializable  {
      * Returns of value of this complex number raised to the power of {@code x}.
      * Implements the formula:
      * <pre>
-     *  <code>
      *   y<sup>x</sup> = exp(x&middot;log(y))
-     *  </code>
      * </pre>
      * where {@code exp} and {@code log} are {@link #exp} and
      * {@link #log}, respectively.
      *
      * @param  x exponent to which this {@code Complex} is to be raised.
-     * @return <code> this<sup>x</sup></code>.
+     * @return <code>this<sup>x</sup></code>.
      */
     public Complex pow(Complex x) {
         if (real == 0 &&
@@ -1327,9 +1308,7 @@ public final class Complex implements Serializable  {
      * hyperbolic sine</a> of this complex number.
      * Implements the formula:
      * <pre>
-     *  <code>
      *   sinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)i
-     *  </code>
      * </pre>
      * where the (real) functions on the right-hand side are
      * {@link Math#sin}, {@link Math#cos},
@@ -1430,8 +1409,9 @@ public final class Complex implements Serializable  {
      * <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
-     * {@code sqrt(ONE.subtract(z.multiply(z)))}.
+     *
+     * <p>Computes the result directly as
+     * {@code sqrt(ONE.subtract(z.multiply(z)))}.</p>
      *
      * @return the square root of <code>1 - this<sup>2</sup></code>.
      */
@@ -1495,7 +1475,7 @@ public final class Complex implements Serializable  {
      * @return the hyperbolic tangent of this complex number
      */
     private static Complex tanh(double real, double imaginary, ComplexConstructor constructor) {
-        // TODO - should these checks be made on real2 and imaginary2?
+        // TODO: Should these checks be made on real2 and imaginary2?
         // Compare to other library implementations.
         //
         // Math.cos and Math.sin return NaN for infinity.
@@ -1524,13 +1504,13 @@ public final class Complex implements Serializable  {
      * The value returned is between -PI (not inclusive)
      * and PI (inclusive), with negative values returned for numbers with
      * negative imaginary parts.
-     * <p>
-     * If either real or imaginary part (or both) is NaN, NaN is returned.
+     *
+     * <p>If either real or imaginary part (or both) is NaN, NaN is returned.
      * Infinite parts are handled as {@code Math.atan2} handles them,
      * essentially treating finite parts as zero in the presence of an
      * infinite coordinate and returning a multiple of pi/4 depending on
      * the signs of the infinite parts.
-     * See the javadoc for {@code Math.atan2} for full details.
+     * See the javadoc for {@code Math.atan2} for full details.</p>
      *
      * @return the argument of {@code this}.
      */
@@ -1554,9 +1534,7 @@ public final class Complex implements Serializable  {
      * Computes the n-th roots of this complex number.
      * The nth roots are defined by the formula:
      * <pre>
-     *  <code>
      *   z<sub>k</sub> = abs<sup>1/n</sup> (cos(phi + 2&pi;k/n) + i (sin(phi + 2&pi;k/n))
-     *  </code>
      * </pre>
      * for <i>{@code k=0, 1, ..., n-1}</i>, where {@code abs} and {@code phi}
      * are respectively the {@link #abs() modulus} and
@@ -1658,7 +1636,7 @@ public final class Complex implements Serializable  {
      * equivalent of:
      *
      * <pre>
-     *  z = new Complex(real, imaginary).multiply(new Complex(0, -1));
+     *   z = new Complex(real, imaginary).multiply(new Complex(0, -1));
      * </pre>
      *
      * @param real Real part.


[commons-numbers] 10/32: Fixed javadoc plugin configuration for default target 1.8.

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

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

commit e9ac506af281402b42a5f9d73822d26b10e575e4
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 23:13:42 2019 +0000

    Fixed javadoc plugin configuration for default target 1.8.
---
 pom.xml | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/pom.xml b/pom.xml
index e6c9358..360ce39 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,10 +97,9 @@
         Temporary workaround?
     -->
     <commons.release.name>commons-numbers-${project.version}</commons.release.name>
-    <!-- Java8+ requires additional Javadoc qualifier for MathJax (default to empty). -->
-    <allowscript.javadoc.qualifier></allowscript.javadoc.qualifier>
-    <!-- Invalid flag for old javadoc versions (default to empty). -->
-    <doclint.javadoc.qualifier></doclint.javadoc.qualifier>
+    <!-- Java8+ requires additional Javadoc qualifier for scripts such as MathJax -->
+    <allowscript.javadoc.qualifier>--allow-script-in-comments</allowscript.javadoc.qualifier>
+    <doclint.javadoc.qualifier>-Xdoclint:all</doclint.javadoc.qualifier>
   </properties>
 
   <modules>
@@ -649,23 +648,6 @@
         </plugins>
       </build>
     </profile>
-
-    <profile>
-      <id>javadoc8</id>
-      <activation><jdk>[1.8,)</jdk></activation>
-      <properties>
-        <!-- Java8+ requires additional Javadoc qualifier for scripts such as MathJax -->
-        <allowscript.javadoc.qualifier>--allow-script-in-comments</allowscript.javadoc.qualifier>
-      </properties>
-    </profile>
-    <profile>
-      <id>javadoc7</id>
-      <activation><jdk>[1.7,)</jdk></activation>
-      <properties>
-        <!-- Invalid flag in earlier versions of javadoc -->
-        <doclint.javadoc.qualifier>-Xdoclint:all</doclint.javadoc.qualifier>
-      </properties>
-    </profile>
   </profiles>
 
   <developers>


[commons-numbers] 11/32: Added license header.

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

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

commit 9067e4d9d17f5dca0ec7dd73c3ac05e382e462f1
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 23:15:32 2019 +0000

    Added license header.
---
 .../apache/commons/numbers/fraction/CommonTestCases.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
index d359550..a2bcdeb 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.commons.numbers.fraction;
 
 import java.util.ArrayList;


[commons-numbers] 04/32: Use Double.hashCode from JDK 1.8.

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

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

commit 5d289a73786ab4ca10bdbd251bacad62c3f5c52b
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 21:56:22 2019 +0000

    Use Double.hashCode from JDK 1.8.
    
    The JDK implementation matches the removed private method hash(double)
    that probably was a backport from Java 8.
---
 .../java/org/apache/commons/numbers/complex/Complex.java     | 12 +-----------
 1 file changed, 1 insertion(+), 11 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 aa23ed5..238abf2 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
@@ -525,17 +525,7 @@ public final class Complex implements Serializable  {
             Double.isNaN(imaginary)) {
             return 7;
         }
-        return 37 * (17 * hash(imaginary) + hash(real));
-    }
-
-    /**
-     * @param d Value.
-     * @return a hash code for the given value.
-     */
-    private int hash(double d) {
-        final long v = Double.doubleToLongBits(d);
-        return (int) (v ^ (v >>> 32));
-        //return new Double(d).hashCode();
+        return 37 * (17 * Double.hashCode(imaginary) + Double.hashCode(real));
     }
 
     /**


[commons-numbers] 32/32: Suppression of ConstantName is in the global checkstyle configuration.

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

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

commit e47e31ddcd394372dec26ba8da556b16be1a2bf0
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 18:45:23 2019 +0000

    Suppression of ConstantName is in the global checkstyle configuration.
---
 .../org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java  | 2 --
 .../test/java/org/apache/commons/numbers/complex/CStandardTest.java   | 2 --
 .../src/test/java/org/apache/commons/numbers/complex/ComplexTest.java | 2 --
 .../java/org/apache/commons/numbers/fraction/CommonTestCases.java     | 4 ----
 4 files changed, 10 deletions(-)

diff --git a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
index 07b7a88..cd31e1f 100644
--- a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
+++ b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
  */
 public class ComplexUtilsTest {
 
-    // CHECKSTYLE: stop ConstantName
     private static final double inf = Double.POSITIVE_INFINITY;
     private static final double negInf = Double.NEGATIVE_INFINITY;
     private static final double nan = Double.NaN;
@@ -66,7 +65,6 @@ public class ComplexUtilsTest {
     private static float[][][] fi3d0, fi3d1, fi3d2, sfr3d, sfi3d;
     private static float[][][][] sfr4d, sfi4d;
     // CHECKSTYLE: resume MultipleVariableDeclarations
-    // CHECKSTYLE: resume ConstantName
 
     // CHECKSTYLE: stop MethodLength
     private static void setArrays() { // initial setup method
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 4a8fe97..269ab74 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
@@ -36,7 +36,6 @@ import java.util.function.Predicate;
  */
 public class CStandardTest {
 
-    // CHECKSTYLE: stop ConstantName
     private static final double inf = Double.POSITIVE_INFINITY;
     private static final double negInf = Double.NEGATIVE_INFINITY;
     private static final double nan = Double.NaN;
@@ -82,7 +81,6 @@ public class CStandardTest {
     private static final Complex maxMax = complex(max, max);
     private static final Complex maxNan = complex(max, nan);
     private static final Complex nanMax = complex(nan, max);
-    // CHECKSTYLE: resume ConstantName
 
     /**
      * Assert the two complex numbers have their real and imaginary components within
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 8078da8..e28b1ce 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.jupiter.api.Test;
  */
 public class ComplexTest {
 
-    // CHECKSTYLE: stop ConstantName
     private static final double inf = Double.POSITIVE_INFINITY;
     private static final double neginf = Double.NEGATIVE_INFINITY;
     private static final double nan = Double.NaN;
@@ -55,7 +54,6 @@ public class ComplexTest {
     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);
-    // CHECKSTYLE: resume ConstantName
 
     /**
      * Used to test the number category of a Complex.
diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
index 193da38..3e23798 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/CommonTestCases.java
@@ -27,8 +27,6 @@ import java.util.List;
  */
 final class CommonTestCases {
 
-    // CHECKSTYLE: stop ConstantName
-
     /**
      * See {@link #numDenConstructorTestCases()}
      */
@@ -74,8 +72,6 @@ final class CommonTestCases {
      */
     private static final List<BinaryOperatorTestCase> subtractFractionTestCasesList;
 
-    // CHECKSTYLE: resume ConstantName
-
     static {
         numDenConstructorTestCasesList = collectNumDenConstructorTestCases();
         doubleConstructorTestCasesList = collectDoubleConstructorTestCases();


[commons-numbers] 01/32: Numbers requires Java 8 (not 6).

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

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

commit 9b22dde78ba82fa4ddbe11768c8067315469afe4
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 21:48:51 2019 +0000

    Numbers requires Java 8 (not 6).
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index abe5f84..34a1f04 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,7 +47,7 @@
     <commons.osgi.export>org.apache.commons.numbers</commons.osgi.export>
     <!-- do not use snapshot suffix here -->
     <commons.release.version>1.0</commons.release.version>
-    <commons.release.desc>(requires Java 6+)</commons.release.desc>
+    <commons.release.desc>(requires Java 8+)</commons.release.desc>
     <!-- <commons.rc.version>RC1</commons.rc.version> -->
     <commons.binary.suffix>-bin</commons.binary.suffix>
 


[commons-numbers] 31/32: Fixed checkstyle in combinatorics.

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

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

commit c4bf150ab646328f666754713f1647774a8457b4
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 18:44:52 2019 +0000

    Fixed checkstyle in combinatorics.
---
 .../numbers/combinatorics/BinomialCoefficient.java |  2 +-
 .../combinatorics/BinomialCoefficientDouble.java   |  2 +-
 .../numbers/combinatorics/Combinations.java        | 10 ++++----
 .../commons/numbers/combinatorics/Factorial.java   |  5 ++--
 .../numbers/combinatorics/FactorialDouble.java     |  6 ++---
 .../combinatorics/LogBinomialCoefficient.java      |  2 +-
 .../numbers/combinatorics/LogFactorial.java        |  2 +-
 .../BinomialCoefficientDoubleTest.java             | 12 ++++-----
 .../combinatorics/BinomialCoefficientTest.java     | 30 ++++++++++------------
 .../numbers/combinatorics/CombinationsTest.java    | 22 ++++++++--------
 .../numbers/combinatorics/FactorialDoubleTest.java |  4 +--
 .../combinatorics/LogBinomialCoefficientTest.java  | 10 ++++----
 .../numbers/combinatorics/LogFactorialTest.java    |  2 +-
 .../checkstyle/checkstyle-suppressions.xml         |  3 +++
 14 files changed, 55 insertions(+), 57 deletions(-)

diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/BinomialCoefficient.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/BinomialCoefficient.java
index 0f4929f..801669e 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/BinomialCoefficient.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/BinomialCoefficient.java
@@ -25,7 +25,7 @@ import org.apache.commons.numbers.core.ArithmeticUtils;
  * It is "{@code n choose k}", the number of {@code k}-element subsets that
  * can be selected from an {@code n}-element set.
  */
-public class BinomialCoefficient {
+public final class BinomialCoefficient {
 
     /** Private constructor. */
     private BinomialCoefficient() {
diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDouble.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDouble.java
index af543b2..b0b276e 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDouble.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDouble.java
@@ -23,7 +23,7 @@ package org.apache.commons.numbers.combinatorics;
  * It is "{@code n choose k}", the number of {@code k}-element subsets that
  * can be selected from an {@code n}-element set.
  */
-public class BinomialCoefficientDouble {
+public final class BinomialCoefficientDouble {
 
     /** Private constructor. */
     private BinomialCoefficientDouble() {
diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Combinations.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Combinations.java
index b779e34..3db4ae7 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Combinations.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Combinations.java
@@ -30,7 +30,7 @@ import org.apache.commons.numbers.core.ArithmeticUtils;
  * combinations</a> {@code (n, k)} of {@code k} elements in a set of
  * {@code n} elements.
  */
-public class Combinations implements Iterable<int[]> {
+public final class Combinations implements Iterable<int[]> {
     /** Size of the set from which combinations are drawn. */
     private final int n;
     /** Number of elements in each combination. */
@@ -120,7 +120,7 @@ public class Combinations implements Iterable<int[]> {
      * <p>
      * Implementation follows Algorithm T in <i>The Art of Computer Programming</i>
      * Internet Draft (PRE-FASCICLE 3A), "A Draft of Section 7.2.1.3 Generating All
-     * Combinations</a>, D. Knuth, 2004.</p>
+     * Combinations, D. Knuth, 2004.</p>
      * <p>
      * The degenerate cases {@code k == 0} and {@code k == n} are NOT handled by this
      * implementation.  If constructor arguments satisfy {@code k == 0}
@@ -141,7 +141,7 @@ public class Combinations implements Iterable<int[]> {
          */
         private final int[] c;
 
-        /** Return value for {@link #hasNext()} */
+        /** Return value for {@link #hasNext()}. */
         private boolean more = true;
 
         /** Marker: smallest index such that {@code c[j + 1] > j}. */
@@ -249,7 +249,7 @@ public class Combinations implements Iterable<int[]> {
     private static class SingletonIterator implements Iterator<int[]> {
         /** Number of elements of the singleton array. */
         private final int n;
-        /** True on initialization, false after first call to next */
+        /** True on initialization, false after first call to next. */
         private boolean more = true;
         /**
          * Create a singleton iterator providing the given array.
@@ -288,7 +288,7 @@ public class Combinations implements Iterable<int[]> {
         /**
          * Unsupported.
          *
-         * @throws UnsupportedOperationException
+         * @throws UnsupportedOperationException Remove is not supported.
          */
         @Override
         public void remove() {
diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Factorial.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Factorial.java
index 40f2332..553652d 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Factorial.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Factorial.java
@@ -20,9 +20,9 @@ package org.apache.commons.numbers.combinatorics;
 /**
  * <a href="http://mathworld.wolfram.com/Factorial.html">Factorial of a number</a>.
  */
-public class Factorial {
+public final class Factorial {
 
-    /** All long-representable factorials */
+    /** All long-representable factorials. */
     static final long[] FACTORIALS = new long[] {
                        1L,                  1L,                   2L,
                        6L,                 24L,                 120L,
@@ -56,5 +56,4 @@ public class Factorial {
 
         return FACTORIALS[n];
     }
-
 }
diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/FactorialDouble.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/FactorialDouble.java
index df6942f..154be52 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/FactorialDouble.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/FactorialDouble.java
@@ -22,7 +22,7 @@ package org.apache.commons.numbers.combinatorics;
  * <a href="http://mathworld.wolfram.com/Factorial.html">factorial of a number</a>.
  * It allows to allocate a cache of precomputed values.
  */
-public class FactorialDouble {
+public final class FactorialDouble {
     /**
      * Size of precomputed factorials.
      * @see Factorial
@@ -50,7 +50,7 @@ public class FactorialDouble {
         // Initialize first two entries.
         for (int i = 0, max = numValues < 2 ? numValues : 2;
              i < max; i++) {
-            factorialsDouble [i] = 1;
+            factorialsDouble[i] = 1;
         }
 
         final int beginCopy = 2;
@@ -130,5 +130,5 @@ public class FactorialDouble {
             result *= i;
         }
         return result;
-     }
+    }
 }
diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficient.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficient.java
index 2b016df..d8464e4 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficient.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficient.java
@@ -23,7 +23,7 @@ package org.apache.commons.numbers.combinatorics;
  * It is "{@code n choose k}", the number of {@code k}-element subsets that
  * can be selected from an {@code n}-element set.
  */
-public class LogBinomialCoefficient {
+public final class LogBinomialCoefficient {
 
     /** Private constructor. */
     private LogBinomialCoefficient() {
diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogFactorial.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogFactorial.java
index db2c1dd..b1012c1 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogFactorial.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/LogFactorial.java
@@ -25,7 +25,7 @@ import org.apache.commons.numbers.gamma.LogGamma;
  * In case of cache miss, computation is performed by a call to
  * {@link LogGamma#value(double)}.
  */
-public class LogFactorial {
+public final class LogFactorial {
     /**
      * Size of precomputed factorials.
      * @see Factorial
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDoubleTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDoubleTest.java
index fd38458..1a17721 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDoubleTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientDoubleTest.java
@@ -31,8 +31,8 @@ public class BinomialCoefficientDoubleTest {
 
     @Test
     public void testBinomialCoefficient() {
-        final long[] bcoef5 = { 1, 5, 10, 10, 5, 1 };
-        final long[] bcoef6 = { 1, 6, 15, 20, 15, 6, 1 };
+        final long[] bcoef5 = {1, 5, 10, 10, 5, 1};
+        final long[] bcoef6 = {1, 6, 15, 20, 15, 6, 1};
 
         for (int n = 1; n < 10; n++) {
             for (int k = 0; k <= n; k++) {
@@ -45,8 +45,8 @@ public class BinomialCoefficientDoubleTest {
             }
         }
 
-        final int[] n = { 34, 66, 100, 1500, 1500 };
-        final int[] k = { 17, 33, 10, 1500 - 4, 4 };
+        final int[] n = {34, 66, 100, 1500, 1500};
+        final int[] k = {17, 33, 10, 1500 - 4, 4};
         for (int i = 0; i < n.length; i++) {
             final long expected = BinomialCoefficientTest.binomialCoefficient(n[i], k[i]);
             Assertions.assertEquals(
@@ -61,14 +61,14 @@ public class BinomialCoefficientDoubleTest {
     @Test
     public void testBinomialCoefficientFail1() {
         Assertions.assertThrows(CombinatoricsException.class,
-                () -> BinomialCoefficientDouble.value(4, 5)
+            () -> BinomialCoefficientDouble.value(4, 5)
         );
     }
 
     @Test
     public void testBinomialCoefficientFail2() {
         Assertions.assertThrows(CombinatoricsException.class,
-                () -> BinomialCoefficientDouble.value(-1, -2)
+            () -> BinomialCoefficientDouble.value(-1, -2)
         );
     }
 
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientTest.java
index 71d26eb..b266930 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/BinomialCoefficientTest.java
@@ -24,15 +24,12 @@ import java.util.HashMap;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-import org.apache.commons.numbers.core.ArithmeticUtils;
-
 /**
  * Test cases for the {@link BinomialCoefficient} class.
  */
 public class BinomialCoefficientTest {
     /** Cached binomial coefficients. */
-    private static final List<Map<Integer, Long>> binomialCache =
-        new ArrayList<Map<Integer, Long>>();
+    private static final List<Map<Integer, Long>> binomialCache = new ArrayList<>();
 
     /** Verify that b(0,0) = 1 */
     @Test
@@ -42,8 +39,8 @@ public class BinomialCoefficientTest {
 
     @Test
     public void testBinomialCoefficient() {
-        final long[] bcoef5 = { 1, 5, 10, 10, 5, 1 };
-        final long[] bcoef6 = { 1, 6, 15, 20, 15, 6, 1 };
+        final long[] bcoef5 = {1, 5, 10, 10, 5, 1};
+        final long[] bcoef6 = {1, 6, 15, 20, 15, 6, 1};
 
         for (int i = 0; i < 6; i++) {
             Assertions.assertEquals(bcoef5[i], BinomialCoefficient.value(5, i), "5 choose " + i);
@@ -62,8 +59,8 @@ public class BinomialCoefficientTest {
             }
         }
 
-        final int[] n = { 34, 66, 100, 1500, 1500 };
-        final int[] k = { 17, 33, 10, 1500 - 4, 4 };
+        final int[] n = {34, 66, 100, 1500, 1500};
+        final int[] k = {17, 33, 10, 1500 - 4, 4};
         for (int i = 0; i < n.length; i++) {
             final long expected = binomialCoefficient(n[i], k[i]);
             Assertions.assertEquals(
@@ -84,29 +81,28 @@ public class BinomialCoefficientTest {
     @Test
     public void testBinomialCoefficientFail2() {
         Assertions.assertThrows(CombinatoricsException.class,
-                () -> BinomialCoefficient.value(-1, -2)
+            () -> BinomialCoefficient.value(-1, -2)
         );
     }
 
     @Test
-    public void testBinomialCoefficientFail3()
-    {
+    public void testBinomialCoefficientFail3() {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> BinomialCoefficient.value(67, 30)
+            () -> BinomialCoefficient.value(67, 30)
         );
     }
 
     @Test
     public void testBinomialCoefficientFail4() {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> BinomialCoefficient.value(67, 34)
+            () -> BinomialCoefficient.value(67, 34)
         );
     }
 
     @Test
     public void testBinomialCoefficientFail5() {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> BinomialCoefficient.value(700, 300)
+            () -> BinomialCoefficient.value(700, 300)
         );
     }
 
@@ -135,7 +131,7 @@ public class BinomialCoefficientTest {
                 }
                 Assertions.assertEquals(exactResult, ourResult, n + " choose " + k);
                 Assertions.assertEquals(shouldThrow, didThrow, n + " choose " + k);
-                Assertions.assertTrue((n > 66 || !didThrow), n + " choose " + k);
+                Assertions.assertTrue(n > 66 || !didThrow, n + " choose " + k);
             }
         }
 
@@ -157,14 +153,14 @@ public class BinomialCoefficientTest {
     @Test
     public void checkNLessThanOne() {
         Assertions.assertThrows(CombinatoricsException.class,
-                () -> BinomialCoefficient.checkBinomial(-1, -2)
+            () -> BinomialCoefficient.checkBinomial(-1, -2)
         );
     }
 
     @Test
     public void checkKGreaterThanN() {
         Assertions.assertThrows(CombinatoricsException.class,
-                () -> BinomialCoefficient.checkBinomial(4, 5)
+            () -> BinomialCoefficient.checkBinomial(4, 5)
         );
     }
 
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/CombinationsTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/CombinationsTest.java
index 3e5febf..fba85bb 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/CombinationsTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/CombinationsTest.java
@@ -60,8 +60,8 @@ public class CombinationsTest {
         final int k = 3;
         final Comparator<int[]> comp = Combinations.of(n, k).comparator();
         Assertions.assertThrows(IllegalArgumentException.class,
-                                () -> comp.compare(new int[] {1},
-                                                   new int[] {0, 1, 2}));
+            () -> comp.compare(new int[] {1},
+                               new int[] {0, 1, 2}));
     }
 
     @Test
@@ -70,18 +70,18 @@ public class CombinationsTest {
         final int k = 3;
         final Comparator<int[]> comp = Combinations.of(n, k).comparator();
         Assertions.assertThrows(IllegalArgumentException.class,
-                                () -> comp.compare(new int[] {0, 1, 2},
-                                                   new int[] {0, 1, 2, 3}));
+            () -> comp.compare(new int[] {0, 1, 2},
+                               new int[] {0, 1, 2, 3}));
     }
 
     @Test
     public void testLexicographicComparatorWrongIterate3() {
         final int n = 5;
         final int k = 3;
-           final Comparator<int[]> comp = Combinations.of(n, k).comparator();
+        final Comparator<int[]> comp = Combinations.of(n, k).comparator();
         Assertions.assertThrows(IllegalArgumentException.class,
-                                () -> comp.compare(new int[] {1, 2, 5},
-                                                   new int[] {0, 1, 2}));
+            () -> comp.compare(new int[] {1, 2, 5},
+                               new int[] {0, 1, 2}));
     }
 
     @Test
@@ -90,8 +90,8 @@ public class CombinationsTest {
         final int k = 3;
         final Comparator<int[]> comp = Combinations.of(n, k).comparator();
         Assertions.assertThrows(IllegalArgumentException.class,
-                                () -> comp.compare(new int[] {1, 2, 4},
-                                                   new int[] {-1, 1, 2}));
+            () -> comp.compare(new int[] {1, 2, 4},
+                               new int[] {-1, 1, 2}));
     }
 
     @Test
@@ -185,11 +185,11 @@ public class CombinationsTest {
     @Test
     public void testCombinationsPrecondition1() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                                () -> Combinations.of(4, 5));
+            () -> Combinations.of(4, 5));
     }
     @Test
     public void testCombinationsPrecondition2() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                                () -> Combinations.of(-1, -2));
+            () -> Combinations.of(-1, -2));
     }
 }
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java
index 19d7b76..7dc1b9a 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/FactorialDoubleTest.java
@@ -35,7 +35,7 @@ public class FactorialDoubleTest {
                     factorialDirect(i), FactorialDouble.create().value(i), 0d, i + "!");
         }
     }
-    
+
     @Test
     public void testLargestFactorialDouble() {
         final int n = 170;
@@ -53,7 +53,7 @@ public class FactorialDoubleTest {
     @Test
     public void testNonPositiveArgument() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> FactorialDouble.create().value(-1)
+            () -> FactorialDouble.create().value(-1)
         );
     }
 
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficientTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficientTest.java
index 8a3af5a..e8c20b6 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficientTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogBinomialCoefficientTest.java
@@ -31,8 +31,8 @@ public class LogBinomialCoefficientTest {
 
     @Test
     public void testBinomialCoefficient() {
-        final long[] bcoef5 = { 1, 5, 10, 10, 5, 1 };
-        final long[] bcoef6 = { 1, 6, 15, 20, 15, 6, 1 };
+        final long[] bcoef5 = {1, 5, 10, 10, 5, 1};
+        final long[] bcoef6 = {1, 6, 15, 20, 15, 6, 1};
 
         for (int n = 1; n < 10; n++) {
             for (int k = 0; k <= n; k++) {
@@ -42,8 +42,8 @@ public class LogBinomialCoefficientTest {
             }
         }
 
-        final int[] n = { 34, 66, 100, 1500, 1500 };
-        final int[] k = { 17, 33, 10, 1500 - 4, 4 };
+        final int[] n = {34, 66, 100, 1500, 1500};
+        final int[] k = {17, 33, 10, 1500 - 4, 4};
         for (int i = 0; i < n.length; i++) {
             final long expected = BinomialCoefficientTest.binomialCoefficient(n[i], k[i]);
             Assertions.assertEquals(
@@ -63,7 +63,7 @@ public class LogBinomialCoefficientTest {
     @Test
     public void testBinomialCoefficientFail2() {
         Assertions.assertThrows(CombinatoricsException.class,
-                () -> LogBinomialCoefficient.value(-1, -2)
+            () -> LogBinomialCoefficient.value(-1, -2)
         );
     }
 
diff --git a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogFactorialTest.java b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogFactorialTest.java
index 7970869..0a4beae 100644
--- a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogFactorialTest.java
+++ b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/LogFactorialTest.java
@@ -28,7 +28,7 @@ public class LogFactorialTest {
     @Test
     public void testNonPositiveArgument() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> LogFactorial.create().withCache(-1)
+            () -> LogFactorial.create().withCache(-1)
         );
     }
 
diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml
index 9234fae..958bc9f 100644
--- a/src/main/resources/checkstyle/checkstyle-suppressions.xml
+++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -19,6 +19,8 @@
     "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
     "https://checkstyle.org/dtds/suppressions_1_2.dtd">
 <suppressions>
+  <suppress checks="Indentation" files=".*/combinatorics/Factorial" />
+
   <!-- Be more lenient on tests. -->
   <suppress checks="Javadoc" files=".*[/\\]test[/\\].*" />
   <suppress checks="MultipleStringLiterals" files=".*[/\\]test[/\\].*" />
@@ -26,4 +28,5 @@
   <suppress checks="LineLength" files=".*[/\\]test[/\\].*" />
   <suppress checks="IllegalCatch" files=".*[/\\]test[/\\].*" />
   <suppress checks="MethodName" files=".*[/\\]test[/\\].*" />
+  <suppress checks="ConstantName" files=".*[/\\]test[/\\].*" />
 </suppressions>


[commons-numbers] 12/32: Upgrade to parent 49. Allows build on Java 11.

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

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

commit 7357e4b9d9ea18e3ad093636d0847c709c410e9c
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 23:31:50 2019 +0000

    Upgrade to parent 49. Allows build on Java 11.
    
    Parent 49 adds a <source> tag to the javadoc plugin allowing building
    using JDK 11 with older sources.
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 360ce39..55097c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <groupId>org.apache.commons</groupId>
     <artifactId>commons-parent</artifactId>
-    <version>47</version>
+    <version>49</version>
   </parent>
 
   <groupId>org.apache.commons</groupId>


[commons-numbers] 26/32: Suppress MethodName rule in checkstyle for tests.

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

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

commit a7066567b1b11f8ba337ecbe0303659adc13a946
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 17:57:00 2019 +0000

    Suppress MethodName rule in checkstyle for tests.
---
 .../test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java    | 2 --
 src/main/resources/checkstyle/checkstyle-suppressions.xml               | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java
index 19263d5..4305109 100644
--- a/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java
+++ b/commons-numbers-primes/src/test/java/org/apache/commons/numbers/primes/SmallPrimesTest.java
@@ -26,8 +26,6 @@ import org.junit.jupiter.api.Test;
 
 public class SmallPrimesTest {
 
-    // CHECKSTYLE: stop MethodName
-
     // Primes larger than the small PRIMES array in SmallPrimes
     private static final int[] LARGE_PRIME = {3673, 3677};
 
diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml
index 89acf69..9234fae 100644
--- a/src/main/resources/checkstyle/checkstyle-suppressions.xml
+++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -25,4 +25,5 @@
   <suppress checks="DesignForExtension" files=".*[/\\]test[/\\].*" />
   <suppress checks="LineLength" files=".*[/\\]test[/\\].*" />
   <suppress checks="IllegalCatch" files=".*[/\\]test[/\\].*" />
+  <suppress checks="MethodName" files=".*[/\\]test[/\\].*" />
 </suppressions>


[commons-numbers] 09/32: Ignore checkstyle failures.

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

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

commit 1e1e4087854c00740e7b6028bc59309f478390a7
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 23:06:21 2019 +0000

    Ignore checkstyle failures.
---
 pom.xml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 242d77b..e6c9358 100644
--- a/pom.xml
+++ b/pom.xml
@@ -248,7 +248,8 @@
           <suppressionsLocation>${numbers.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
           <enableRulesSummary>false</enableRulesSummary>
           <logViolationsToConsole>false</logViolationsToConsole>
-          <failOnViolation>true</failOnViolation>
+          <!-- TODO: Set to true when Checkstyle has been fixed. -->
+          <failOnViolation>false</failOnViolation>
           <resourceExcludes>NOTICE.txt,LICENSE.txt,**/maven-archiver/pom.properties,**/resolver-status.properties</resourceExcludes>
           <excludes>**/generated/**.java</excludes>
         </configuration>


[commons-numbers] 27/32: Fixed checkstyle in quaternion.

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

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

commit 5326c6a95c2309a44645b6a185c3b8bafff39726
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 17:58:58 2019 +0000

    Fixed checkstyle in quaternion.
---
 .../commons/numbers/quaternion/Quaternion.java     | 12 ++---
 .../commons/numbers/quaternion/QuaternionTest.java | 18 ++++----
 .../commons/numbers/quaternion/SlerpTest.java      | 54 +++++++++++-----------
 3 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/commons-numbers-quaternion/src/main/java/org/apache/commons/numbers/quaternion/Quaternion.java b/commons-numbers-quaternion/src/main/java/org/apache/commons/numbers/quaternion/Quaternion.java
index bb93755..020b746 100644
--- a/commons-numbers-quaternion/src/main/java/org/apache/commons/numbers/quaternion/Quaternion.java
+++ b/commons-numbers-quaternion/src/main/java/org/apache/commons/numbers/quaternion/Quaternion.java
@@ -38,11 +38,11 @@ public final class Quaternion implements Serializable {
     public static final Quaternion ZERO = of(0, 0, 0, 0);
     /** Identity quaternion. */
     public static final Quaternion ONE = new Quaternion(Type.POSITIVE_POLAR_FORM, 1, 0, 0, 0);
-    /** i */
+    /** i. */
     public static final Quaternion I = new Quaternion(Type.POSITIVE_POLAR_FORM, 0, 1, 0, 0);
-    /** j */
+    /** j. */
     public static final Quaternion J = new Quaternion(Type.POSITIVE_POLAR_FORM, 0, 0, 1, 0);
-    /** k */
+    /** k. */
     public static final Quaternion K = new Quaternion(Type.POSITIVE_POLAR_FORM, 0, 0, 0, 1);
 
     /** Serializable version identifier. */
@@ -103,7 +103,7 @@ public final class Quaternion implements Serializable {
         private static final class Normalized {
             /** {@link Quaternion#norm()} returns 1. */
             static final ToDoubleFunction<Quaternion> NORM = q -> 1;
-            /** {@link Quaternion#isUnit()} returns 1. */
+            /** {@link Quaternion#isUnit(double)} returns 1. */
             static final BiPredicate<Quaternion, Double> IS_UNIT = (q, eps) -> true;
         }
 
@@ -432,7 +432,7 @@ public final class Quaternion implements Serializable {
      */
     @Override
     public int hashCode() {
-        return Arrays.hashCode(new double[] { w, x, y, z });
+        return Arrays.hashCode(new double[] {w, x, y, z});
     }
 
     /**
@@ -604,7 +604,7 @@ public final class Quaternion implements Serializable {
      * @see #getZ()
      */
     public double[] getVectorPart() {
-        return new double[] { x, y, z };
+        return new double[] {x, y, z};
     }
 
     /**
diff --git a/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/QuaternionTest.java b/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/QuaternionTest.java
index 7a787dc..aede102 100644
--- a/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/QuaternionTest.java
+++ b/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/QuaternionTest.java
@@ -84,7 +84,7 @@ public class QuaternionTest {
         final double q1 = 5.4;
         final double q2 = 17;
         final double q3 = 0.0005;
-        final Quaternion q = Quaternion.of(q0, new double[] { q1, q2, q3 });
+        final Quaternion q = Quaternion.of(q0, new double[] {q1, q2, q3});
 
         final double sP = q.getScalarPart();
         final double[] vP = q.getVectorPart();
@@ -98,7 +98,7 @@ public class QuaternionTest {
     @Test
     public void testWrongDimension() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Quaternion.of(new double[] { 1, 2 })
+            () -> Quaternion.of(new double[] {1, 2})
         );
     }
 
@@ -297,7 +297,7 @@ public class QuaternionTest {
         Assertions.assertEquals(x, qb.getX(), EPS);
         Assertions.assertEquals(y, qb.getY(), EPS);
         Assertions.assertEquals(z, qb.getZ(), EPS);
-}
+    }
 
     @Test
     public final void testNorm() {
@@ -692,42 +692,42 @@ public class QuaternionTest {
     @Test
     public final void testParseMissingEnd() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Quaternion.parse("[1.0 2.0 3.0 4.0")
+            () -> Quaternion.parse("[1.0 2.0 3.0 4.0")
         );
     }
 
     @Test
     public final void testParseMissingPart() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Quaternion.parse("[1.0 2.0 3.0 ]")
+            () -> Quaternion.parse("[1.0 2.0 3.0 ]")
         );
     }
 
     @Test
     public final void testParseInvalidScalar() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Quaternion.parse("[1.x 2.0 3.0 4.0]")
+            () -> Quaternion.parse("[1.x 2.0 3.0 4.0]")
         );
     }
 
     @Test
     public final void testParseInvalidI() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Quaternion.parse("[1.0 2.0x 3.0 4.0]")
+            () -> Quaternion.parse("[1.0 2.0x 3.0 4.0]")
         );
     }
 
     @Test
     public final void testParseInvalidJ() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Quaternion.parse("[1.0 2.0 3.0x 4.0]")
+            () -> Quaternion.parse("[1.0 2.0 3.0x 4.0]")
         );
     }
 
     @Test
     public final void testParseInvalidK() {
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Quaternion.parse("[1.0 2.0 3.0 4.0x]")
+            () -> Quaternion.parse("[1.0 2.0 3.0 4.0x]")
         );
     }
 
diff --git a/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/SlerpTest.java b/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/SlerpTest.java
index e6b7719..71ebb5e 100644
--- a/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/SlerpTest.java
+++ b/commons-numbers-quaternion/src/test/java/org/apache/commons/numbers/quaternion/SlerpTest.java
@@ -182,23 +182,23 @@ public class SlerpTest {
 
         Slerp slerp = new Slerp(q0, q1);
 
-        double[] vec = { 2, 0, 1 };
+        double[] vec = {2, 0, 1};
 
         // act/assert
-        Assertions.assertArrayEquals(new double[] { 2, 0, 1 },
-                transformVector(slerp.apply(0), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {2, 0, 1},
+            transformVector(slerp.apply(0), vec), EPS);
 
-        Assertions.assertArrayEquals(new double[] { SQRT_2, SQRT_2, 1 },
-                transformVector(slerp.apply(0.25), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {SQRT_2, SQRT_2, 1},
+            transformVector(slerp.apply(0.25), vec), EPS);
 
-        Assertions.assertArrayEquals(new double[] { 0, 2, 1 },
-                transformVector(slerp.apply(0.5), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {0, 2, 1},
+            transformVector(slerp.apply(0.5), vec), EPS);
 
-        Assertions.assertArrayEquals(new double[] { -SQRT_2, SQRT_2, 1 },
-                transformVector(slerp.apply(0.75), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {-SQRT_2, SQRT_2, 1},
+            transformVector(slerp.apply(0.75), vec), EPS);
 
-        Assertions.assertArrayEquals(new double[] { -2, 0, 1 },
-                transformVector(slerp.apply(1), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {-2, 0, 1},
+            transformVector(slerp.apply(1), vec), EPS);
     }
 
     @Test
@@ -238,8 +238,8 @@ public class SlerpTest {
 
         // act/assert
         // test each quaternion against all of the others (including itself)
-        for (int i=0; i<quaternions.length; ++i) {
-            for (int j=0; j<quaternions.length; ++j) {
+        for (int i = 0; i < quaternions.length; ++i) {
+            for (int j = 0; j < quaternions.length; ++j) {
                 checkSlerpCombination(quaternions[i], quaternions[j]);
             }
         }
@@ -248,7 +248,7 @@ public class SlerpTest {
     private void checkSlerpCombination(Quaternion start, Quaternion end) {
         Slerp slerp = new Slerp(start, end);
 
-        double[] vec = { 1, 2, 3 };
+        double[] vec = {1, 2, 3};
         double vecNorm = norm(vec);
 
         double[] startVec = transformVector(start, vec);
@@ -263,7 +263,7 @@ public class SlerpTest {
         final int numSteps = 100;
         final double delta = 1.0 / numSteps;
         for (int step = 0; step <= numSteps; ++step) {
-            final double t= step * delta;
+            final double t = step * delta;
             Quaternion result = slerp.apply(t);
 
             double[] slerpVec = transformVector(result, vec);
@@ -291,20 +291,20 @@ public class SlerpTest {
         Quaternion q1 = Quaternion.of(Math.cos(halfAngle1), 0, 0, Math.sin(halfAngle1)); // pi/4 around +z
         Quaternion q2 = Quaternion.of(Math.cos(halfAngle2), 0, 0, Math.sin(halfAngle2)); // 3pi/4 around +z
 
-        double[] vec = new double[] { 1, 0, 0 };
+        double[] vec = new double[] {1, 0, 0};
 
         // act/assert
         Slerp slerp12 = new Slerp(q1, q2);
-        Assertions.assertArrayEquals(new double[] { 1, 0, 0 }, transformVector(slerp12.apply(-4.5), vec), EPS);
-        Assertions.assertArrayEquals(new double[] { 1, 0, 0 }, transformVector(slerp12.apply(-0.5), vec), EPS);
-        Assertions.assertArrayEquals(new double[] { -1, 0, 0 }, transformVector(slerp12.apply(1.5), vec), EPS);
-        Assertions.assertArrayEquals(new double[] { -1, 0, 0 }, transformVector(slerp12.apply(5.5), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {1, 0, 0}, transformVector(slerp12.apply(-4.5), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {1, 0, 0}, transformVector(slerp12.apply(-0.5), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {-1, 0, 0}, transformVector(slerp12.apply(1.5), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {-1, 0, 0}, transformVector(slerp12.apply(5.5), vec), EPS);
 
         Slerp slerp21 = new Slerp(q2, q1);
-        Assertions.assertArrayEquals(new double[] { -1, 0, 0 }, transformVector(slerp21.apply(-4.5), vec), EPS);
-        Assertions.assertArrayEquals(new double[] { -1, 0, 0 }, transformVector(slerp21.apply(-0.5), vec), EPS);
-        Assertions.assertArrayEquals(new double[] { 1, 0, 0 }, transformVector(slerp21.apply(1.5), vec), EPS);
-        Assertions.assertArrayEquals(new double[] { 1, 0, 0 }, transformVector(slerp21.apply(5.5), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {-1, 0, 0}, transformVector(slerp21.apply(-4.5), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {-1, 0, 0}, transformVector(slerp21.apply(-0.5), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {1, 0, 0}, transformVector(slerp21.apply(1.5), vec), EPS);
+        Assertions.assertArrayEquals(new double[] {1, 0, 0}, transformVector(slerp21.apply(5.5), vec), EPS);
     }
 
     /**
@@ -325,7 +325,7 @@ public class SlerpTest {
      */
     private static double norm(double[] vec) {
         double sum = 0.0;
-        for (int i=0; i<vec.length; ++i) {
+        for (int i = 0; i < vec.length; ++i) {
             sum += vec[i] * vec[i];
         }
         return Math.sqrt(sum);
@@ -351,7 +351,7 @@ public class SlerpTest {
      */
     private static double dot(double[] a, double[] b) {
         double result = 0.0;
-        for (int i=0; i<a.length; ++i) {
+        for (int i = 0; i < a.length; ++i) {
             result += a[i] * b[i];
         }
         return result;
@@ -371,7 +371,7 @@ public class SlerpTest {
 
         Quaternion result = q.multiply(qVec).multiply(qConj);
 
-        return new double[] { result.getX(), result.getY(), result.getZ() };
+        return new double[] {result.getX(), result.getY(), result.getZ()};
     }
 
     /**


[commons-numbers] 20/32: [NUMBERS-78] Increase test coverage of divide/multiply.

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

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

commit 594ffaddb28b553558138c2606924b2182b84d91
Author: aherbert <ah...@apache.org>
AuthorDate: Thu Nov 7 18:21:07 2019 +0000

    [NUMBERS-78] Increase test coverage of divide/multiply.
    
    This involves fixing the edge case correction algorithm.
    
    Multiply has been updated to explicitly detect infinities multiplied by
    zero and not correct the NaN,NaN result.
    
    Divide algorithm has been updated to handle overflow in infinite/finite
    and finite/infinite correction.
---
 .../apache/commons/numbers/complex/Complex.java    | 210 +++++++++++++-----
 .../commons/numbers/complex/CStandardTest.java     | 234 +++++++++++++++++++++
 2 files changed, 391 insertions(+), 53 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 083f774..3a86fd3 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
@@ -354,7 +354,7 @@ public final class Complex implements Serializable  {
         double d = divisor.getImaginary();
         int ilogbw = 0;
         final double logbw = Math.log(Math.max(Math.abs(c), Math.abs(d))) / Math.log(2);
-        if (!Double.isInfinite(logbw)) {
+        if (Double.isFinite(logbw)) {
             ilogbw = (int)logbw;
             c = Math.scalb(c, -ilogbw);
             d = Math.scalb(d, -ilogbw);
@@ -362,29 +362,83 @@ public final class Complex implements Serializable  {
         final double denom = c * c + d * d;
         double x = Math.scalb((a * c + b * d) / denom, -ilogbw);
         double y = Math.scalb((b * c - a * d) / denom, -ilogbw);
+        // Recover infinities and zeros that computed as NaN+iNaN
+        // the only cases are nonzero/zero, infinite/finite, and finite/infinite, ...
+        // --------------
+        // Modification from the listing in ISO C.99 G.5.1 (8):
+        // Prevent overflow in (a * c + b * d) and (b * c - a * d).
+        // It is only the sign that is important. not the magnitude.
+        // --------------
         if (Double.isNaN(x) && Double.isNaN(y)) {
             if ((denom == 0.0) &&
                     (!Double.isNaN(a) || !Double.isNaN(b))) {
+                // nonzero/zero
                 x = Math.copySign(Double.POSITIVE_INFINITY, c) * a;
                 y = Math.copySign(Double.POSITIVE_INFINITY, c) * b;
-            } else if ((Double.isInfinite(a) && Double.isInfinite(b)) &&
-                    !Double.isInfinite(c) && !Double.isInfinite(d)) {
-                a = Math.copySign(Double.isInfinite(a) ? 1.0 : 0.0, a);
-                b = Math.copySign(Double.isInfinite(b) ? 1.0 : 0.0, b);
-                x = Double.POSITIVE_INFINITY * (a * c + b * d);
-                y = Double.POSITIVE_INFINITY * (b * c - a * d);
-            } else if (Double.isInfinite(logbw) &&
-                    !Double.isInfinite(a) && !Double.isInfinite(b)) {
-                c = Math.copySign(Double.isInfinite(c) ? 1.0 : 0.0, c);
-                d = Math.copySign(Double.isInfinite(d) ? 1.0 : 0.0, d);
-                x = 0.0 * (a * c + b * d);
-                y = 0.0 * (b * c - a * d);
+            } else if ((Double.isInfinite(a) || Double.isInfinite(b)) &&
+                    Double.isFinite(c) && Double.isFinite(d)) {
+                // infinite/finite
+                a = boxInfinity(a);
+                b = boxInfinity(b);
+                x = Double.POSITIVE_INFINITY * computeACplusBD(a, b, c, d);
+                y = Double.POSITIVE_INFINITY * computeBCminusAD(a, b, c, d);
+            } else if (divisor.isInfinite() &&
+                    Double.isFinite(a) && Double.isFinite(b)) {
+                // finite/infinite
+                c = boxInfinity(c);
+                d = boxInfinity(d);
+                x = 0.0 * computeACplusBD(a, b, c, d);
+                y = 0.0 * computeBCminusAD(a, b, c, d);
             }
         }
         return new Complex(x, y);
     }
 
     /**
+     * Compute {@code a*c + b*d} without overflow.
+     * It is assumed: either {@code a} and {@code b} or {@code c} and {@code d} are
+     * either zero or one (i.e. a boxed infinity); and the sign of the result is important,
+     * not the value.
+     *
+     * @param a the a
+     * @param b the b
+     * @param c the c
+     * @param d the d
+     * @return the result
+     */
+    private static double computeACplusBD(double a, double b, double c, double d) {
+        final double ac = a * c;
+        final double bd = b * d;
+        double result = ac + bd;
+        return Double.isFinite(result) ?
+            result :
+            // Overflow. Just divide by 2 as it is the sign of the result that matters.
+            ac * 0.5 + bd * 0.5;
+    }
+
+    /**
+     * Compute {@code b*c - a*d} without overflow.
+     * It is assumed: either {@code a} and {@code b} or {@code c} and {@code d} are
+     * either zero or one (i.e. a boxed infinity); and the sign of the result is important,
+     * not the value.
+     *
+     * @param a the a
+     * @param b the b
+     * @param c the c
+     * @param d the d
+     * @return the result
+     */
+    private static double computeBCminusAD(double a, double b, double c, double d) {
+        final double bc = b * c;
+        final double ad = a * d;
+        final double result = bc - ad;
+        return Double.isFinite(result) ?
+            result :
+            // Overflow. Just divide by 2 as it is the sign of the result that matters.
+            bc * 0.5 + ad * 0.5;
+    }
+
+    /**
      * Returns a {@code Complex} whose value is {@code (this / divisor)},
      * with {@code divisor} interpreted as a real number.
      *
@@ -612,44 +666,51 @@ public final class Complex implements Serializable  {
         final double bc = b * c;
         double x = ac - bd;
         double y = ad + bc;
-        if (Double.isNaN(a) && Double.isNaN(b)) {
+
+        // --------------
+        // NaN can occur if:
+        // - any of (a,b,c,d) are NaN (for NaN or Infinite complex numbers)
+        // - a multiplication of infinity by zero (ac,bd,ad,bc).
+        // - a subtraction of infinity from infinity (e.g. ac - bd)
+        //   Note that (ac,bd,ad,bc) can be infinite due to overflow.
+        //
+        // Detect a NaN result and perform correction.
+        //
+        // Modification from the listing in ISO C.99 G.5.1 (6)
+        // Do not correct infinity multiplied by zero. This is left as NaN.
+        // --------------
+
+        if (Double.isNaN(x) && Double.isNaN(y)) {
+            // Recover infinities that computed as NaN+iNaN ...
             boolean recalc = false;
-            if (Double.isInfinite(a) || Double.isInfinite(b)) {
-                a = Math.copySign(Double.isInfinite(a) ? 1.0 : 0.0, a);
-                b = Math.copySign(Double.isInfinite(a) ? 1.0 : 0.0, a);
-                if (Double.isNaN(c)) {
-                    c = Math.copySign(0.0,  c);
-                }
-                if (Double.isNaN(d)) {
-                    d = Math.copySign(0.0,  d);
-                }
+            if (isInfinite() && isNotZero(c, d)) {
+                // This complex is infinite.
+                // "Box" the infinity and change NaNs in the other factor to 0.
+                a = boxInfinity(a);
+                b = boxInfinity(b);
+                c = changeNaNtoZero(c);
+                d = changeNaNtoZero(d);
                 recalc = true;
             }
-            if (Double.isInfinite(c) || Double.isInfinite(d)) {
-                c = Math.copySign(Double.isInfinite(c) ? 1.0 : 0.0, c);
-                d = Math.copySign(Double.isInfinite(d) ? 1.0 : 0.0, d);
-                if (Double.isNaN(a)) {
-                    a = Math.copySign(0.0,  a);
-                }
-                if (Double.isNaN(b)) {
-                    b = Math.copySign(0.0,  b);
-                }
+            // (c, d) may have been corrected so do not use factor.isInfinite().
+            if ((Double.isInfinite(c) || Double.isInfinite(d)) &&
+                isNotZero(a, b)) {
+                // This other complex is infinite.
+                // "Box" the infinity and change NaNs in the other factor to 0.
+                c = boxInfinity(c);
+                d = boxInfinity(d);
+                a = changeNaNtoZero(a);
+                b = changeNaNtoZero(b);
                 recalc = true;
             }
             if (!recalc && (Double.isInfinite(ac) || Double.isInfinite(bd) ||
-                    Double.isInfinite(ad) || Double.isInfinite(bc))) {
-                if (Double.isNaN(a)) {
-                    a = Math.copySign(0.0,  a);
-                }
-                if (Double.isNaN(b)) {
-                    b = Math.copySign(0.0,  b);
-                }
-                if (Double.isNaN(c)) {
-                    c = Math.copySign(0.0,  c);
-                }
-                if (Double.isNaN(d)) {
-                    d = Math.copySign(0.0,  d);
-                }
+                            Double.isInfinite(ad) || Double.isInfinite(bc))) {
+                // The result overflowed to infinity.
+                // Recover infinities from overflow by changing NaNs to 0 ...
+                a = changeNaNtoZero(a);
+                b = changeNaNtoZero(b);
+                c = changeNaNtoZero(c);
+                d = changeNaNtoZero(d);
                 recalc = true;
             }
             if (recalc) {
@@ -661,6 +722,49 @@ public final class Complex implements Serializable  {
     }
 
     /**
+     * Box values for the real or imaginary component of an infinite complex number.
+     * Any infinite value will be returned as one. Non-infinite values will be returned as zero.
+     * The sign is maintained.
+     *
+     * <pre>
+     *  inf  =  1
+     * -inf  = -1
+     *  x    =  0
+     * -x    = -0
+     * </pre>
+     *
+     * @param component the component
+     * @return the boxed value
+     */
+    private static double boxInfinity(double component) {
+        return Math.copySign(Double.isInfinite(component) ? 1.0 : 0.0, component);
+    }
+
+    /**
+     * Checks if the complex number is not zero.
+     *
+     * @param real the real component
+     * @param imaginary the imaginary component
+     * @return true if the complex is zero
+     */
+    private static boolean isNotZero(double real, double imaginary) {
+        // The use of equals is deliberate.
+        // This method must distinguish NaN from zero thus ruling out:
+        // (real != 0.0 || imaginary != 0.0)
+        return !(real == 0.0 && imaginary == 0.0);
+    }
+
+    /**
+     * Change NaN to zero preserving the sign; otherwise return the value.
+     *
+     * @param value the value
+     * @return the new value
+     */
+    private static double changeNaNtoZero(double value) {
+        return Double.isNaN(value) ? Math.copySign(0.0, value) : value;
+    }
+
+    /**
      * Returns a {@code Complex} whose value is {@code this * factor}, with {@code factor}
      * interpreted as a integer number.
      *
@@ -830,7 +934,7 @@ public final class Complex implements Serializable  {
             imaginary == Double.POSITIVE_INFINITY) {
             return new Complex(Double.POSITIVE_INFINITY, PI_OVER_2);
         } else if (real == Double.POSITIVE_INFINITY &&
-                   !Double.isInfinite(imaginary) && !Double.isNaN(imaginary)) {
+                   Double.isFinite(imaginary)) {
             return new Complex(Double.POSITIVE_INFINITY, 0);
         } else if (real == Double.POSITIVE_INFINITY &&
                    imaginary == Double.POSITIVE_INFINITY) {
@@ -1073,8 +1177,8 @@ public final class Complex implements Serializable  {
             return new Complex(Double.POSITIVE_INFINITY, PI_OVER_4);
         } else if ((real == Double.POSITIVE_INFINITY &&
                     Double.isNaN(imaginary)) ||
-                   ((Double.isNaN(real) &&
-                    imaginary == Double.POSITIVE_INFINITY))) {
+                   (Double.isNaN(real) &&
+                    imaginary == Double.POSITIVE_INFINITY)) {
             return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
         }
         return new Complex(Math.log(abs()),
@@ -1095,8 +1199,8 @@ public final class Complex implements Serializable  {
             return new Complex(Double.POSITIVE_INFINITY, PI_OVER_4);
         } else if ((real == Double.POSITIVE_INFINITY &&
                     Double.isNaN(imaginary)) ||
-                   ((Double.isNaN(real) &&
-                    imaginary == Double.POSITIVE_INFINITY))) {
+                   (Double.isNaN(real) &&
+                    imaginary == Double.POSITIVE_INFINITY)) {
             return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
         }
         return new Complex(Math.log(abs()) / Math.log(10),
@@ -1479,15 +1583,15 @@ public final class Complex implements Serializable  {
      *  <li>it is not infinite,</li>
      *  <li>it is positive signed,</li>
      * </ul>
-     * 
-     * <p>Note: This is true for negative zero.</p>
+     *
+     * <p>Note: This is false for negative zero.</p>
      *
      * @param d Value.
      * @return {@code true} if {@code d} meets all the conditions and
      * {@code false} otherwise.
      */
     private static boolean positiveSignedFinite(double d) {
-        return Double.isFinite(d) && d >= 0;
+        return (Double.isFinite(d) && d > 0) || Double.doubleToLongBits(d) == 0;
     }
 
     /** See {@link #parse(String)}. */
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 e336b0c..4a8fe97 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
@@ -23,6 +23,10 @@ import org.apache.commons.rng.simple.RandomSource;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
+import java.util.ArrayList;
+import java.util.function.BiFunction;
+import java.util.function.Predicate;
+
 /**
  * Tests the standards defined by the C.99 standard for complex numbers
  * defined in ISO/IEC 9899, Annex G.
@@ -36,6 +40,7 @@ public class CStandardTest {
     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 max = Double.MAX_VALUE;
     private static final double piOverFour = Math.PI / 4.0;
     private static final double piOverTwo = Math.PI / 2.0;
     private static final double threePiOverFour = 3.0 * Math.PI / 4.0;
@@ -74,6 +79,9 @@ public class CStandardTest {
     private static final Complex threePiFourNegInf = complex(threePiOverFour, negInf);
     private static final Complex piFourNegInf = complex(piOverFour, negInf);
     private static final Complex NAN = complex(nan, nan);
+    private static final Complex maxMax = complex(max, max);
+    private static final Complex maxNan = complex(max, nan);
+    private static final Complex nanMax = complex(nan, max);
     // CHECKSTYLE: resume ConstantName
 
     /**
@@ -107,6 +115,24 @@ public class CStandardTest {
     }
 
     /**
+     * Assert the operation on the two complex numbers.
+     *
+     * @param c1 the first complex
+     * @param c2 the second complex
+     * @param operation the operation
+     * @param operationName the operation name
+     * @param expected the expected
+     * @param expectedName the expected name
+     */
+    private static void assertOperation(Complex c1, Complex c2,
+            BiFunction<Complex, Complex, Complex> operation, String operationName,
+            Predicate<Complex> expected, String expectedName) {
+        final Complex z = operation.apply(c1, c2);
+        Assertions.assertTrue(expected.test(z),
+            () -> String.format("%s expected: %s %s %s = %s", expectedName, c1, operationName, c2, z));
+    }
+
+    /**
      * Utility to create a Complex.
      *
      * @param real the real
@@ -118,6 +144,203 @@ public class CStandardTest {
     }
 
     /**
+     * Creates a list of Complex infinites.
+     *
+     * @return the list
+     */
+    private static ArrayList<Complex> createInfinites() {
+        final double[] values = {0, 1, inf, negInf, nan};
+        return createCombinations(values, Complex::isInfinite);
+    }
+
+    /**
+     * Creates a list of Complex finites that are not zero.
+     *
+     * @return the list
+     */
+    private static ArrayList<Complex> createNonZeroFinites() {
+        final double[] values = {-1, -0, 0, 1, Double.MAX_VALUE};
+        return createCombinations(values, c -> !CStandardTest.isZero(c));
+    }
+
+    /**
+     * Creates a list of Complex finites that are zero: [0,0], [-0,0], [0,-0], [-0,-0].
+     *
+     * @return the list
+     */
+    private static ArrayList<Complex> createZeroFinites() {
+        final double[] values = {-0, 0};
+        return createCombinations(values, c -> true);
+    }
+
+    /**
+     * Creates a list of Complex NaNs.
+     *
+     * @return the list
+     */
+    private static ArrayList<Complex> createNaNs() {
+        final double[] values = {0, 1, nan};
+        return createCombinations(values, Complex::isNaN);
+    }
+
+    /**
+     * Creates a list of Complex numbers as an all-vs-all combinations that pass the
+     * condition.
+     *
+     * @param values the values
+     * @param condition the condition
+     * @return the list
+     */
+    private static ArrayList<Complex> createCombinations(final double[] values, Predicate<Complex> condition) {
+        final ArrayList<Complex> list = new ArrayList<>();
+        for (double re : values) {
+            for (double im : values) {
+                final Complex z = complex(re, im);
+                if (condition.test(z)) {
+                    list.add(z);
+                }
+            }
+        }
+        return list;
+    }
+
+    /**
+     * Checks if the complex is zero.
+     *
+     * @param c the complex
+     * @return true if zero
+     */
+    private static boolean isZero(Complex c) {
+        return Complex.equals(c, Complex.ZERO, 0);
+    }
+
+    /**
+     * ISO C Standard G.5 (4).
+     */
+    @Test
+    public void testMultiply() {
+        final ArrayList<Complex> infinites = createInfinites();
+        final ArrayList<Complex> nonZeroFinites = createNonZeroFinites();
+        final ArrayList<Complex> zeroFinites = createZeroFinites();
+
+        // C.99 refers to non-zero finites.
+        // Standard multiplication of zero with infinites is not defined.
+        Assertions.assertEquals(nan, 0.0 * inf, "0 * inf");
+        Assertions.assertEquals(nan, 0.0 * negInf, "0 * -inf");
+        Assertions.assertEquals(nan, -0.0 * inf, "-0 * inf");
+        Assertions.assertEquals(nan, -0.0 * negInf, "-0 * -inf");
+
+        // "if one operand is an infinity and the other operand is a nonzero finite number or an
+        // infinity, then the result of the * operator is an infinity;"
+        for (Complex z : infinites) {
+            for (Complex w : infinites) {
+                assertOperation(z, w, Complex::multiply, "*", Complex::isInfinite, "Inf");
+                assertOperation(w, z, Complex::multiply, "*", Complex::isInfinite, "Inf");
+            }
+            for (Complex w : nonZeroFinites) {
+                assertOperation(z, w, Complex::multiply, "*", Complex::isInfinite, "Inf");
+                assertOperation(w, z, Complex::multiply, "*", Complex::isInfinite, "Inf");
+            }
+            // C.99 refers to non-zero finites.
+            // Infer that Complex multiplication of zero with infinites is not defined.
+            for (Complex w : zeroFinites) {
+                assertOperation(z, w, Complex::multiply, "*", Complex::isNaN, "NaN");
+                assertOperation(w, z, Complex::multiply, "*", Complex::isNaN, "NaN");
+            }
+        }
+
+        // ISO C Standard in Annex G is missing an explicit definition of how to handle NaNs.
+        // We will assume multiplication by (nan,nan) is not allowed.
+        // It is undefined how to multiply when a complex has only one NaN component.
+        // The reference implementation allows it.
+
+        // The GNU g++ compiler computes:
+        // (1e300 + i 1e300) * (1e30 + i NAN) = inf + i inf
+        // Thus this is allowing some computations with NaN.
+
+        // Check multiply with (NaN,NaN) is not corrected
+        final double[] values = {0, 1, inf, negInf, nan};
+        for (Complex z : createCombinations(values, c -> true)) {
+            assertOperation(z, NAN, Complex::multiply, "*", Complex::isNaN, "NaN");
+            assertOperation(NAN, z, Complex::multiply, "*", Complex::isNaN, "NaN");
+        }
+
+        // Test multiply cases which result in overflow are corrected to infinity
+        assertOperation(maxMax, maxMax, Complex::multiply, "*", Complex::isInfinite, "Inf");
+        assertOperation(maxNan, maxNan, Complex::multiply, "*", Complex::isInfinite, "Inf");
+        assertOperation(nanMax, maxNan, Complex::multiply, "*", Complex::isInfinite, "Inf");
+        assertOperation(maxNan, nanMax, Complex::multiply, "*", Complex::isInfinite, "Inf");
+        assertOperation(nanMax, nanMax, Complex::multiply, "*", Complex::isInfinite, "Inf");
+    }
+
+    /**
+     * ISO C Standard G.5 (4).
+     */
+    @Test
+    public void testDivide() {
+        final ArrayList<Complex> infinites = createInfinites();
+        final ArrayList<Complex> nonZeroFinites = createNonZeroFinites();
+        final ArrayList<Complex> zeroFinites = createZeroFinites();
+        final ArrayList<Complex> nans = createNaNs();
+        final ArrayList<Complex> finites = new ArrayList<>(nonZeroFinites);
+        finites.addAll(zeroFinites);
+
+        // "if the first operand is an infinity and the second operand is a finite number, then the
+        // result of the / operator is an infinity;"
+        for (Complex z : infinites) {
+            for (Complex w : nonZeroFinites) {
+                assertOperation(z, w, Complex::divide, "/", Complex::isInfinite, "Inf");
+            }
+            for (Complex w : zeroFinites) {
+                assertOperation(z, w, Complex::divide, "/", Complex::isInfinite, "Inf");
+            }
+            // Check inf/inf cannot be done
+            for (Complex w : infinites) {
+                assertOperation(z, w, Complex::divide, "/", Complex::isNaN, "NaN");
+            }
+        }
+
+        // "if the first operand is a finite number and the second operand is an infinity, then the
+        // result of the / operator is a zero;"
+        for (Complex z : finites) {
+            for (Complex w : infinites) {
+                assertOperation(z, w, Complex::divide, "/", CStandardTest::isZero, "Zero");
+            }
+        }
+
+        // "if the first operand is a nonzero finite number or an infinity and the second operand is
+        // a zero, then the result of the / operator is an infinity."
+        for (Complex w : zeroFinites) {
+            for (Complex z : nonZeroFinites) {
+                assertOperation(z, w, Complex::divide, "/", Complex::isInfinite, "Inf");
+            }
+            for (Complex z : infinites) {
+                assertOperation(z, w, Complex::divide, "/", Complex::isInfinite, "Inf");
+            }
+        }
+
+        // ISO C Standard in Annex G is missing an explicit definition of how to handle NaNs.
+        // The reference implementation does not correct for divide by NaN components unless
+        // infinite.
+        for (Complex w : nans) {
+            for (Complex z : finites) {
+                assertOperation(z, w, Complex::divide, "/", c -> NAN.equals(c), "(NaN,NaN)");
+            }
+            for (Complex z : infinites) {
+                assertOperation(z, w, Complex::divide, "/", c -> NAN.equals(c), "(NaN,NaN)");
+            }
+        }
+
+        // Check (NaN,NaN) divide is not corrected for the edge case of divide by zero or infinite
+        for (Complex w : zeroFinites) {
+            assertOperation(NAN, w, Complex::divide, "/", Complex::isNaN, "NaN");
+        }
+        for (Complex w : infinites) {
+            assertOperation(NAN, w, Complex::divide, "/", Complex::isNaN, "NaN");
+        }
+    }
+
+    /**
      * ISO C Standard G.6 (3).
      */
     @Test
@@ -210,7 +433,9 @@ public class CStandardTest {
         assertComplex(zeroNaN.acosh(), NAN);
         assertComplex(oneNaN.acosh(), NAN);
         assertComplex(negInfOne.acosh(), infPi);
+        assertComplex(negInfZero.acosh(), infPi);
         assertComplex(infOne.acosh(), infZero);
+        assertComplex(infZero.acosh(), infZero);
         assertComplex(negInfPosInf.acosh(), infThreePiFour);
         assertComplex(infInf.acosh(), infPiFour);
         assertComplex(infNaN.acosh(), infNaN);
@@ -218,6 +443,15 @@ public class CStandardTest {
         assertComplex(nanOne.acosh(), NAN);
         assertComplex(nanInf.acosh(), infNaN);
         assertComplex(NAN.acosh(), NAN);
+        // The standard mentions positive-signed y
+        Assertions.assertThrows(AssertionError.class, () -> {
+            // Not −∞ + iy, positive signed y
+            assertComplex(complex(negInf, -0.0).acosh(), infPi);
+        });
+        Assertions.assertThrows(AssertionError.class, () -> {
+            // Not ∞ + iy, positive signed y
+            assertComplex(complex(inf, -0.0).acosh(), infPi);
+        });
     }
 
     /**


[commons-numbers] 18/32: Add commons-rng-simple to dependency management.

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

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

commit 5caefb152c6705e11539573434425b102b13c45c
Author: aherbert <ah...@apache.org>
AuthorDate: Thu Nov 7 11:08:41 2019 +0000

    Add commons-rng-simple to dependency management.
    
    This is used in tests.
---
 commons-numbers-arrays/pom.xml  | 2 --
 commons-numbers-complex/pom.xml | 5 +++++
 pom.xml                         | 6 ++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/commons-numbers-arrays/pom.xml b/commons-numbers-arrays/pom.xml
index c8b514e..21a3d0b 100644
--- a/commons-numbers-arrays/pom.xml
+++ b/commons-numbers-arrays/pom.xml
@@ -46,14 +46,12 @@
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-rng-simple</artifactId>
-      <version>1.0</version>
       <scope>test</scope>
     </dependency>
 
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-numbers-fraction</artifactId>
-      <version>${project.version}</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
diff --git a/commons-numbers-complex/pom.xml b/commons-numbers-complex/pom.xml
index ef979ca..29b0872 100644
--- a/commons-numbers-complex/pom.xml
+++ b/commons-numbers-complex/pom.xml
@@ -54,6 +54,11 @@
       <scope>test</scope>
     </dependency>
 
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-rng-simple</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>
diff --git a/pom.xml b/pom.xml
index 97c61c9..7d676eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,6 +63,7 @@
     <numbers.mathjax.version>2.7.2</numbers.mathjax.version>
     <numbers.junit.bom.version>5.4.2</numbers.junit.bom.version>
     <numbers.commons.math3.version>3.6.1</numbers.commons.math3.version>
+    <numbers.commons.rng.version>1.2</numbers.commons.rng.version>
     <!-- Workaround to avoid duplicating config files. -->
     <numbers.parent.dir>${basedir}</numbers.parent.dir>
 
@@ -171,6 +172,11 @@
         <scope>import</scope>
         <type>pom</type>
       </dependency>
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-rng-simple</artifactId>
+        <version>${numbers.commons.rng.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 


[commons-numbers] 08/32: Update PMD version from 3.9.0 to 3.12.0.

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

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

commit 2b03836a70178585f80c1c0ec01fd6530073a6af
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 23:05:55 2019 +0000

    Update PMD version from 3.9.0 to 3.12.0.
    
    Update dependency version to v6.19.0.
---
 pom.xml | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index f44a230..242d77b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,7 +56,8 @@
     <commons.encoding>UTF-8</commons.encoding>
     <maven.compiler.source>1.8</maven.compiler.source>
     <maven.compiler.target>1.8</maven.compiler.target>
-    <numbers.pmd.version>3.9.0</numbers.pmd.version>
+    <numbers.pmd.version>3.12.0</numbers.pmd.version>
+    <numbers.pmd.dep.version>6.19.0</numbers.pmd.dep.version>
     <numbers.checkstyle.version>3.0.0</numbers.checkstyle.version>
     <numbers.checkstyle.dep.version>8.20</numbers.checkstyle.dep.version>
     <numbers.mathjax.version>2.7.2</numbers.mathjax.version>
@@ -272,6 +273,32 @@
         </configuration>
       </plugin>
       <plugin>
+        <artifactId>maven-pmd-plugin</artifactId>
+        <version>${numbers.pmd.version}</version>
+        <dependencies>
+          <dependency>
+            <groupId>net.sourceforge.pmd</groupId>
+            <artifactId>pmd-core</artifactId>
+            <version>${numbers.pmd.dep.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>net.sourceforge.pmd</groupId>
+            <artifactId>pmd-java</artifactId>
+            <version>${numbers.pmd.dep.version}</version>
+          </dependency>
+        </dependencies>
+        <configuration>
+          <!-- TODO: remove this when PMD has been fixed. -->
+          <failOnViolation>false</failOnViolation>
+          <targetJdk>${maven.compiler.target}</targetJdk>
+          <skipEmptyReport>false</skipEmptyReport>
+          <analysisCache>true</analysisCache>
+          <rulesets>
+            <ruleset>${numbers.parent.dir}/src/main/resources/pmd/pmd-ruleset.xml</ruleset>
+          </rulesets>
+        </configuration>
+      </plugin>
+      <plugin>
         <groupId>org.apache.rat</groupId>
         <artifactId>apache-rat-plugin</artifactId>
         <version>${commons.rat.version}</version>


[commons-numbers] 19/32: [NUMBERS-78] Increase test coverage.

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

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

commit 7775ba7b3188906c077be853bebaa01274565bd0
Author: aherbert <ah...@apache.org>
AuthorDate: Thu Nov 7 11:04:57 2019 +0000

    [NUMBERS-78] Increase test coverage.
    
    Added more tests using the C.99 standard.
    
    Fixed checkstyle.
    
    Use final.
---
 .../apache/commons/numbers/complex/Complex.java    | 391 ++++++++++-----
 .../commons/numbers/complex/CStandardTest.java     | 250 +++++++---
 .../commons/numbers/complex/ComplexTest.java       | 547 +++++++++++++--------
 .../apache/commons/numbers/complex/TestUtils.java  |  53 +-
 4 files changed, 822 insertions(+), 419 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 c47b510..083f774 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
@@ -25,18 +25,19 @@ import org.apache.commons.numbers.core.Precision;
 /**
  * Representation of a Complex number, i.e. a number which has both a
  * real and imaginary part.
- * <p>
- * Implementations of arithmetic operations handle {@code NaN} and
+ *
+ * <p>Implementations of arithmetic operations handle {@code NaN} and
  * infinite values according to the rules for {@link java.lang.Double}, i.e.
  * {@link #equals} is an equivalence relation for all instances that have
  * a {@code NaN} in either real or imaginary part, e.g. the following are
- * considered equal:
+ * considered equal:</p>
  * <ul>
  *  <li>{@code 1 + NaNi}</li>
  *  <li>{@code NaN + i}</li>
  *  <li>{@code NaN + NaNi}</li>
- * </ul><p>
- * Note that this contradicts the IEEE-754 standard for floating
+ * </ul>
+ *
+ * <p>Note that this contradicts the IEEE-754 standard for floating
  * point numbers (according to which the test {@code x == x} must fail if
  * {@code x} is {@code NaN}). The method
  * {@link org.apache.commons.numbers.core.Precision#equals(double,double,int)
@@ -44,6 +45,11 @@ import org.apache.commons.numbers.core.Precision;
  * IEEE-754 while this class conforms with the standard behavior for Java
  * object types.</p>
  *
+ * <p>Arithmetic in this class conforms to the C.99 standard for complex numbers
+ * defined in ISO/IEC 9899, Annex G.<p>
+ *
+ * @see <a href="http://www.open-std.org/JTC1/SC22/WG14/www/standards">
+ *    ISO/IEC 9899 - Programming languages - C</a>
  */
 public final class Complex implements Serializable  {
     /** The square root of -1, a.k.a. "i". */
@@ -52,8 +58,10 @@ public final class Complex implements Serializable  {
     public static final Complex ONE = new Complex(1, 0);
     /** A complex number representing zero. */
     public static final Complex ZERO = new Complex(0, 0);
-    /** A complex number representing "NaN + NaN i" */
+    /** A complex number representing "NaN + NaN i". */
     private static final Complex NAN = new Complex(Double.NaN, Double.NaN);
+    /** 3*&pi;/4. */
+    private static final double PI_3_OVER_4 = 0.75 * Math.PI;
     /** &pi;/2. */
     private static final double PI_OVER_2 = 0.5 * Math.PI;
     /** &pi;/4. */
@@ -111,9 +119,9 @@ public final class Complex implements Serializable  {
     /**
      * Creates a Complex from its polar representation.
      *
-     * If {@code r} is infinite and {@code theta} is finite, infinite or NaN
+     * <p>If {@code r} is infinite and {@code theta} is finite, infinite or NaN
      * values may be returned in parts of the result, following the rules for
-     * double arithmetic.
+     * double arithmetic.</p>
      *
      * <pre>
      * Examples:
@@ -127,9 +135,12 @@ public final class Complex implements Serializable  {
      * @param r the modulus of the complex number to create
      * @param theta the argument of the complex number to create
      * @return {@code Complex}
+     * @throws IllegalArgumentException if {@code r} is non-positive
      */
     public static Complex ofPolar(double r, double theta) {
-        checkNotNegative(r);
+        if (r <= 0) {
+            throw new IllegalArgumentException("Non-positive polar modulus argument: " + r);
+        }
         return new Complex(r * Math.cos(theta), r * Math.sin(theta));
     }
 
@@ -173,13 +184,13 @@ public final class Complex implements Serializable  {
         final double re;
         try {
             re = Double.parseDouble(elements[0]);
-        } catch (NumberFormatException ex) {
+        } catch (final NumberFormatException ex) {
             throw new ComplexParsingException("Could not parse real part" + elements[0]);
         }
         final double im;
         try {
             im = Double.parseDouble(elements[1]);
-        } catch (NumberFormatException ex) {
+        } catch (final NumberFormatException ex) {
             throw new ComplexParsingException("Could not parse imaginary part" + elements[1]);
         }
 
@@ -187,25 +198,41 @@ public final class Complex implements Serializable  {
     }
 
     /**
-     * Returns true if either real or imaginary component of the Complex
-     * is NaN.
+     * Returns true if either real or imaginary component of the Complex is NaN and the
+     * Complex is not infinite.
      *
-     * @return {@code true} is this instance contains NaN.
+     * @return {@code true} if this instance contains NaN and no infinite parts.
+     * @see Double#isNaN(double)
+     * @see #isInfinite()
      */
     public boolean isNaN() {
-        return Double.isNaN(real) ||
-            Double.isNaN(imaginary);
+        if (Double.isNaN(real) || Double.isNaN(imaginary)) {
+            return !isInfinite();
+        }
+        return false;
     }
 
     /**
-     * Returns true if either real or imaginary component of the Complex
-     * is infinite.
+     * Returns true if either real or imaginary component of the Complex is infinite.
+     *
+     * <p>Note: A complex or imaginary value with at least one infinite part is regarded
+     * as an infinity (even if its other part is a NaN).</p>
      *
      * @return {@code true} if this instance contains an infinite value.
+     * @see Double#isInfinite(double)
      */
     public boolean isInfinite() {
-        return Double.isInfinite(real) ||
-            Double.isInfinite(imaginary);
+        return Double.isInfinite(real) || Double.isInfinite(imaginary);
+    }
+
+    /**
+     * Returns true if both real and imaginary component of the Complex are finite.
+     *
+     * @return {@code true} if this instance contains finite values.
+     * @see Double#isFinite(double)
+     */
+    public boolean isFinite() {
+        return Double.isFinite(real) && Double.isFinite(imaginary);
     }
 
     /**
@@ -223,9 +250,8 @@ public final class Complex implements Serializable  {
         if (Double.isInfinite(real) ||
             Double.isInfinite(imaginary)) {
             return new Complex(Double.POSITIVE_INFINITY, 0);
-        } else {
-            return this;
         }
+        return this;
     }
 
      /**
@@ -237,16 +263,18 @@ public final class Complex implements Serializable  {
      * @return the absolute value.
      */
     public double abs() {
-        if (Math.abs(real) < Math.abs(imaginary)) {
-            final double q = real / imaginary;
-            return Math.abs(imaginary) * Math.sqrt(1 + q * q);
-        } else {
-            if (real == 0) {
-                return Math.abs(imaginary);
-            }
-            final double q = imaginary / real;
-            return Math.abs(real) * Math.sqrt(1 + q * q);
-        }
+        // Delegate
+        return Math.hypot(real, imaginary);
+
+        //if (Math.abs(real) < Math.abs(imaginary)) {
+        //    final double q = real / imaginary;
+        //    return Math.abs(imaginary) * Math.sqrt(1 + q * q);
+        //}
+        //if (real == 0) {
+        //    return Math.abs(imaginary);
+        //}
+        //final double q = imaginary / real;
+        //return Math.abs(real) * Math.sqrt(1 + q * q);
     }
 
     /**
@@ -290,6 +318,7 @@ public final class Complex implements Serializable  {
      /**
      * Returns the conjugate of this complex number
      * (C++11 grammar).
+     *
      * @return the conjugate of this complex object.
      * @see #conjugate()
      */
@@ -319,21 +348,20 @@ public final class Complex implements Serializable  {
      * @return {@code this / divisor}.
      */
     public Complex divide(Complex divisor) {
-
         double a = real;
         double b = imaginary;
         double c = divisor.getReal();
         double d = divisor.getImaginary();
         int ilogbw = 0;
-        double logbw = Math.log(Math.max(Math.abs(c), Math.abs(d))) / Math.log(2);
+        final double logbw = Math.log(Math.max(Math.abs(c), Math.abs(d))) / Math.log(2);
         if (!Double.isInfinite(logbw)) {
             ilogbw = (int)logbw;
             c = Math.scalb(c, -ilogbw);
             d = Math.scalb(d, -ilogbw);
         }
-        double denom = c*c + d*d;
-        double x = Math.scalb( (a*c + b*d) / denom, -ilogbw);
-        double y = Math.scalb( (b*c - a*d) / denom, -ilogbw);
+        final double denom = c * c + d * d;
+        double x = Math.scalb((a * c + b * d) / denom, -ilogbw);
+        double y = Math.scalb((b * c - a * d) / denom, -ilogbw);
         if (Double.isNaN(x) && Double.isNaN(y)) {
             if ((denom == 0.0) &&
                     (!Double.isNaN(a) || !Double.isNaN(b))) {
@@ -343,19 +371,17 @@ public final class Complex implements Serializable  {
                     !Double.isInfinite(c) && !Double.isInfinite(d)) {
                 a = Math.copySign(Double.isInfinite(a) ? 1.0 : 0.0, a);
                 b = Math.copySign(Double.isInfinite(b) ? 1.0 : 0.0, b);
-                x = Double.POSITIVE_INFINITY * (a*c + b*d);
-                y = Double.POSITIVE_INFINITY * (b*c - a*d);
+                x = Double.POSITIVE_INFINITY * (a * c + b * d);
+                y = Double.POSITIVE_INFINITY * (b * c - a * d);
             } else if (Double.isInfinite(logbw) &&
                     !Double.isInfinite(a) && !Double.isInfinite(b)) {
                 c = Math.copySign(Double.isInfinite(c) ? 1.0 : 0.0, c);
                 d = Math.copySign(Double.isInfinite(d) ? 1.0 : 0.0, d);
-                x = 0.0 * (a*c + b*d);
-                y = 0.0 * (b*c - a*d);
+                x = 0.0 * (a * c + b * d);
+                y = 0.0 * (b * c - a * d);
             }
         }
         return new Complex(x, y);
-
-
     }
 
     /**
@@ -386,16 +412,15 @@ public final class Complex implements Serializable  {
                 scaleQ = scale * q;
             }
             return new Complex(scaleQ, -scale);
-        } else {
-            final double q = imaginary / real;
-            final double scale = 1. / (imaginary * q + real);
-            double scaleQ = 0;
-            if (q != 0 &&
-                scale != 0) {
-                scaleQ = scale * q;
-            }
-            return new Complex(scale, -scaleQ);
         }
+        final double q = imaginary / real;
+        final double scale = 1. / (imaginary * q + real);
+        double scaleQ = 0;
+        if (q != 0 &&
+            scale != 0) {
+            scaleQ = scale * q;
+        }
+        return new Complex(scale, -scaleQ);
     }
 
     /**
@@ -427,8 +452,8 @@ public final class Complex implements Serializable  {
         if (this == other) {
             return true;
         }
-        if (other instanceof Complex){
-            Complex c = (Complex) other;
+        if (other instanceof Complex) {
+            final Complex c = (Complex) other;
             return equals(real, c.real) &&
                 equals(imaginary, c.imaginary);
         }
@@ -581,10 +606,10 @@ public final class Complex implements Serializable  {
         double b = imaginary;
         double c = factor.getReal();
         double d = factor.getImaginary();
-        final double ac = a*c;
-        final double bd = b*d;
-        final double ad = a*d;
-        final double bc = b*c;
+        final double ac = a * c;
+        final double bd = b * d;
+        final double ad = a * d;
+        final double bc = b * c;
         double x = ac - bd;
         double y = ad + bc;
         if (Double.isNaN(a) && Double.isNaN(b)) {
@@ -628,8 +653,8 @@ public final class Complex implements Serializable  {
                 recalc = true;
             }
             if (recalc) {
-                x = Double.POSITIVE_INFINITY * (a*c - b*d);
-                y = Double.POSITIVE_INFINITY * (a*d + b*c);
+                x = Double.POSITIVE_INFINITY * (a * c - b * d);
+                y = Double.POSITIVE_INFINITY * (a * d + b * c);
             }
         }
         return new Complex(x, y);
@@ -722,16 +747,14 @@ public final class Complex implements Serializable  {
             return new Complex(0, Double.NEGATIVE_INFINITY);
         } else if (real == Double.NEGATIVE_INFINITY &&
                    imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Math.PI * 0.75, Double.NEGATIVE_INFINITY);
+            return new Complex(PI_3_OVER_4, Double.NEGATIVE_INFINITY);
         } else if (real == Double.POSITIVE_INFINITY &&
                    imaginary == Double.POSITIVE_INFINITY) {
             return new Complex(PI_OVER_4, Double.NEGATIVE_INFINITY);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.NaN , Double.POSITIVE_INFINITY);
-        } else if (real == Double.NEGATIVE_INFINITY &&
+        } else if (Double.isInfinite(real) &&
                    Double.isNaN(imaginary)) {
-            return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
+            // Swap real and imaginary
+            return new Complex(Double.NaN, real);
         } else if (Double.isNaN(real) &&
                    imaginary == Double.POSITIVE_INFINITY) {
             return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
@@ -748,8 +771,13 @@ public final class Complex implements Serializable  {
      * @return the inverse sine of this complex number
      */
     public Complex asin() {
-        return sqrt1z().add(multiply(I)).log().multiply(I.negate());
+        // Define in terms of asinh
+        // asin(z) = -i asinh(iz)
+        return multiplyByI().asinh().multiplyByNegI();
+
+        //return sqrt1z().add(multiply(I)).log().multiply(I.negate());
     }
+
     /**
      * Compute the
      * <a href="http://mathworld.wolfram.com/InverseTangent.html">
@@ -761,7 +789,30 @@ public final class Complex implements Serializable  {
      * @return the inverse tangent of this complex number
      */
     public Complex atan() {
-        return add(I).divide(I.subtract(this)).log().multiply(I.multiply(0.5));
+        // Define in terms of atanh
+        // atan(z) = -i atanh(iz)
+        return multiplyByI().atanh().multiplyByNegI();
+
+        // This is not exact to 1 ulp
+        //return add(I).divide(I.subtract(this)).log().multiply(I.multiply(0.5));
+    }
+
+    /**
+     * Multiply the Complex by I.
+     *
+     * @return the result (iz)
+     */
+    private Complex multiplyByI() {
+        return new Complex(-imaginary, real);
+    }
+
+    /**
+     * Multiply the Complex by -I.
+     *
+     * @return the result (-iz)
+     */
+    private Complex multiplyByNegI() {
+        return new Complex(imaginary, -real);
     }
 
     /**
@@ -774,7 +825,7 @@ public final class Complex implements Serializable  {
      * </p><p>
      * @return the inverse hyperbolic cosine of this complex number
      */
-    public Complex asinh(){
+    public Complex asinh() {
         if (neitherInfiniteNorZeroNorNaN(real) &&
             imaginary == Double.POSITIVE_INFINITY) {
             return new Complex(Double.POSITIVE_INFINITY, PI_OVER_2);
@@ -807,7 +858,7 @@ public final class Complex implements Serializable  {
      * </p><p>
      * @return the inverse hyperbolic cosine of this complex number
      */
-    public Complex atanh(){
+    public Complex atanh() {
         if (real == 0 &&
             Double.isNaN(imaginary)) {
             return new Complex(0, Double.NaN);
@@ -832,17 +883,60 @@ public final class Complex implements Serializable  {
         }
         return add(ONE).divide(ONE.subtract(this)).log().multiply(0.5);
     }
-   /**
+
+    /**
      * Compute the
      * <a href="http://mathworld.wolfram.com/InverseHyperbolicCosine.html">
      * inverse hyperbolic cosine</a> of this complex number.
      * Implements the formula:
      * <p>
      * {@code acosh(z) = log(z+sqrt(z^2-1))}
-     * </p><p>
+     * </p>
+     *
      * @return the inverse hyperbolic cosine of this complex number
      */
     public Complex acosh() {
+        if (Double.isFinite(real)) {
+            if (real == 0 &&
+                imaginary == 0) {
+                return new Complex(0, PI_OVER_2);
+            }
+            if (imaginary == Double.POSITIVE_INFINITY) {
+                return new Complex(Double.POSITIVE_INFINITY, PI_OVER_2);
+            }
+            if (Double.isNaN(imaginary)) {
+                return NAN;
+            }
+        } else if (Double.isInfinite(real)) {
+            if (real == Double.NEGATIVE_INFINITY &&
+                positiveSignedFinite(imaginary)) {
+                return new Complex(Double.POSITIVE_INFINITY, Math.PI);
+            }
+            if (real == Double.POSITIVE_INFINITY &&
+                positiveSignedFinite(imaginary)) {
+                return new Complex(Double.POSITIVE_INFINITY, 0);
+            }
+            if (real == Double.NEGATIVE_INFINITY &&
+                imaginary == Double.POSITIVE_INFINITY) {
+                return new Complex(Double.POSITIVE_INFINITY, PI_3_OVER_4);
+            }
+            if (real == Double.POSITIVE_INFINITY &&
+                imaginary == Double.POSITIVE_INFINITY) {
+                return new Complex(Double.POSITIVE_INFINITY, PI_OVER_4);
+            }
+            if (Double.isNaN(imaginary)) {
+                return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+            }
+        } else if (Double.isNaN(real)) {
+            if (imaginary == Double.POSITIVE_INFINITY) {
+                return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+            }
+            if (Double.isFinite(imaginary) || Double.isNaN(imaginary)) {
+                // optionally raises the ‘‘invalid’’ floating-point exception, for finite y.
+                // No condition for imaginary as negative infinity
+                return NAN;
+            }
+        }
         return square().subtract(ONE).sqrt().add(this).log();
     }
 
@@ -861,7 +955,7 @@ public final class Complex implements Serializable  {
      * cosine</a> of this complex number.
      * Implements the formula:
      * <p>
-     *  {@code cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i}
+     * {@code cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i}
      * </p><p>
      * where the (real) functions on the right-hand side are
      * {@link Math#sin}, {@link Math#cos},
@@ -871,8 +965,12 @@ public final class Complex implements Serializable  {
      * @return the cosine of this complex number.
      */
     public Complex cos() {
-        return new Complex(Math.cos(real) * Math.cosh(imaginary),
-                           -Math.sin(real) * Math.sinh(imaginary));
+        // Define in terms of cosh
+        // cos(z) = cosh(iz)
+        return multiplyByI().cosh();
+
+        //return new Complex(Math.cos(real) * Math.cosh(imaginary),
+        //                  -Math.sin(real) * Math.sinh(imaginary));
     }
 
     /**
@@ -903,10 +1001,7 @@ public final class Complex implements Serializable  {
                    imaginary == 0) {
             return new Complex(Double.POSITIVE_INFINITY, 0);
         } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
+                   (imaginary == Double.POSITIVE_INFINITY || Double.isNaN(imaginary))) {
             return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
         } else if (Double.isNaN(real) &&
                    imaginary == 0) {
@@ -941,19 +1036,16 @@ public final class Complex implements Serializable  {
                    imaginary == Double.POSITIVE_INFINITY) {
             return Complex.ZERO;
         } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
+                   (imaginary == Double.POSITIVE_INFINITY || Double.isNaN(imaginary))) {
             return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
         } else if (real == Double.NEGATIVE_INFINITY &&
                    Double.isNaN(imaginary)) {
             return Complex.ZERO;
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
         } else if (Double.isNaN(real) &&
                    imaginary == 0) {
             return new Complex(Double.NaN, 0);
         }
-        double expReal = Math.exp(real);
+        final double expReal = Math.exp(real);
         return new Complex(expReal *  Math.cos(imaginary),
                            expReal * Math.sin(imaginary));
     }
@@ -979,11 +1071,10 @@ public final class Complex implements Serializable  {
         if (real == Double.POSITIVE_INFINITY &&
             imaginary == Double.POSITIVE_INFINITY) {
             return new Complex(Double.POSITIVE_INFINITY, PI_OVER_4);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        } else if (Double.isNaN(real) &&
-                   imaginary == Double.POSITIVE_INFINITY) {
+        } else if ((real == Double.POSITIVE_INFINITY &&
+                    Double.isNaN(imaginary)) ||
+                   ((Double.isNaN(real) &&
+                    imaginary == Double.POSITIVE_INFINITY))) {
             return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
         }
         return new Complex(Math.log(abs()),
@@ -998,6 +1089,16 @@ public final class Complex implements Serializable  {
      *  @return the base 10 logarithm of <code>this</code>.
     */
     public Complex log10() {
+        // Same edge cases as log()
+        if (real == Double.POSITIVE_INFINITY &&
+            imaginary == Double.POSITIVE_INFINITY) {
+            return new Complex(Double.POSITIVE_INFINITY, PI_OVER_4);
+        } else if ((real == Double.POSITIVE_INFINITY &&
+                    Double.isNaN(imaginary)) ||
+                   ((Double.isNaN(real) &&
+                    imaginary == Double.POSITIVE_INFINITY))) {
+            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+        }
         return new Complex(Math.log(abs()) / Math.log(10),
                            Math.atan2(imaginary, real));
     }
@@ -1019,14 +1120,14 @@ public final class Complex implements Serializable  {
     public Complex pow(Complex x) {
         if (real == 0 &&
             imaginary == 0) {
+            // This value is zero. Test the other.
             if (x.real > 0 &&
                 x.imaginary == 0) {
                 // 0 raised to positive number is 0
                 return ZERO;
-            } else {
-                // 0 raised to anything else is NaN
-                return NAN;
             }
+            // 0 raised to anything else is NaN
+            return NAN;
         }
         return log().multiply(x).exp();
     }
@@ -1038,16 +1139,16 @@ public final class Complex implements Serializable  {
      * @return <code>this<sup>x</sup></code>.
      * @see #pow(Complex)
      */
-     public Complex pow(double x) {
+    public Complex pow(double x) {
         if (real == 0 &&
             imaginary == 0) {
+            // This value is zero. Test the other.
             if (x > 0) {
                 // 0 raised to positive number is 0
                 return ZERO;
-            } else {
-                // 0 raised to anything else is NaN
-                return NAN;
             }
+            // 0 raised to anything else is NaN
+            return NAN;
         }
         return log().multiply(x).exp();
     }
@@ -1070,8 +1171,12 @@ public final class Complex implements Serializable  {
      * @return the sine of this complex number.
      */
     public Complex sin() {
-        return new Complex(Math.sin(real) * Math.cosh(imaginary),
-                           Math.cos(real) * Math.sinh(imaginary));
+        // Define in terms of sinh
+        // sin(z) = -i sinh(iz)
+        return multiplyByI().sinh().multiplyByNegI();
+
+        //return new Complex(Math.sin(real) * Math.cosh(imaginary),
+        //                   Math.cos(real) * Math.sinh(imaginary));
     }
 
     /**
@@ -1155,10 +1260,9 @@ public final class Complex implements Serializable  {
         final double t = Math.sqrt((Math.abs(real) + abs()) / 2);
         if (real >= 0) {
             return new Complex(t, imaginary / (2 * t));
-        } else {
-            return new Complex(Math.abs(imaginary) / (2 * t),
-                               Math.copySign(1d, imaginary) * t);
         }
+        return new Complex(Math.abs(imaginary) / (2 * t),
+                           Math.copySign(1d, imaginary) * t);
     }
 
     /**
@@ -1192,19 +1296,23 @@ public final class Complex implements Serializable  {
      * @return the tangent of {@code this}.
      */
     public Complex tan() {
-        if (imaginary > 20) {
-            return ONE;
-        }
-        if (imaginary < -20) {
-            return MINUS_I;
-        }
-
-        final double real2 = 2 * real;
-        final double imaginary2 = 2 * imaginary;
-        final double d = Math.cos(real2) + Math.cosh(imaginary2);
-
-        return new Complex(Math.sin(real2) / d,
-                           Math.sinh(imaginary2) / d);
+        // Define in terms of tanh
+        // tan(z) = -i tanh(iz)
+        return multiplyByI().tanh().multiplyByNegI();
+
+        //if (imaginary > 20) {
+        //    return ONE;
+        //}
+        //if (imaginary < -20) {
+        //    return MINUS_I;
+        //}
+        //
+        //final double real2 = 2 * real;
+        //final double imaginary2 = 2 * imaginary;
+        //final double d = Math.cos(real2) + Math.cosh(imaginary2);
+        //
+        //return new Complex(Math.sin(real2) / d,
+        //                   Math.sinh(imaginary2) / d);
     }
 
     /**
@@ -1224,6 +1332,11 @@ public final class Complex implements Serializable  {
      * @return the hyperbolic tangent of {@code this}.
      */
     public Complex tanh() {
+        // TODO - should these checks be made on real2 and imaginary2?
+        // Math.cos and Math.sin return NaN for infinity.
+        // Math.cosh returns positive infinity for infinity.
+        // Math.sinh returns the input infinity for infinity.
+
         if (real == Double.POSITIVE_INFINITY &&
             imaginary == Double.POSITIVE_INFINITY) {
             return ONE;
@@ -1260,14 +1373,16 @@ public final class Complex implements Serializable  {
      * @return the argument of {@code this}.
      */
     public double getArgument() {
+        // Delegate
         return Math.atan2(imaginary, real);
     }
 
     /**
-     * Compute the argument of this complex number.
-     * C++11 syntax
+     * Compute the argument of this complex number
+     * (C++11 grammar).
      *
      * @return the argument of {@code this}.
+     * @see #getArgument()
      */
     public double arg() {
         return getArgument();
@@ -1284,12 +1399,13 @@ public final class Complex implements Serializable  {
      * for <i>{@code k=0, 1, ..., n-1}</i>, where {@code abs} and {@code phi}
      * 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 all
-     * all elements set to {@code NaN + NaN i} is returned.
+     *
+     * <p>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.</p>
      *
      * @param n Degree of root.
      * @return a List of all {@code n}-th roots of {@code this}.
+     * @throws IllegalArgumentException if {@code n} is zero.
      */
     public List<Complex> nthRoot(int n) {
         if (n == 0) {
@@ -1305,7 +1421,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 < Math.abs(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);
@@ -1329,17 +1445,6 @@ public final class Complex implements Serializable  {
     }
 
     /**
-     * Check that the argument is positive and throw a RuntimeException
-     * if it is not.
-     * @param arg {@code double} to check
-     */
-    private static void checkNotNegative(double arg) {
-        if (arg <= 0) {
-            throw new IllegalArgumentException("Complex: Non-positive argument");
-        }
-    }
-
-    /**
      * Returns {@code true} if the values are equal according to semantics of
      * {@link Double#equals(Object)}.
      *
@@ -1352,7 +1457,7 @@ public final class Complex implements Serializable  {
     }
 
     /**
-     * Check that a value meets all the following conditions:
+     * Check that a value meets all the following conditions.
      * <ul>
      *  <li>it is not {@code NaN},</li>
      *  <li>it is not infinite,</li>
@@ -1364,9 +1469,25 @@ public final class Complex implements Serializable  {
      * {@code false} otherwise.
      */
     private static boolean neitherInfiniteNorZeroNorNaN(double d) {
-        return !Double.isNaN(d) &&
-            !Double.isInfinite(d) &&
-            d != 0;
+        return Double.isFinite(d) && d != 0;
+    }
+
+    /**
+     * Check that a value meets all the following conditions.
+     * <ul>
+     *  <li>it is not {@code NaN},</li>
+     *  <li>it is not infinite,</li>
+     *  <li>it is positive signed,</li>
+     * </ul>
+     * 
+     * <p>Note: This is true for negative zero.</p>
+     *
+     * @param d Value.
+     * @return {@code true} if {@code d} meets all the conditions and
+     * {@code false} otherwise.
+     */
+    private static boolean positiveSignedFinite(double d) {
+        return Double.isFinite(d) && d >= 0;
     }
 
     /** See {@link #parse(String)}. */
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 d1e5a9c..e336b0c 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
@@ -17,93 +17,171 @@
 
 package org.apache.commons.numbers.complex;
 
+import org.apache.commons.numbers.core.Precision;
+import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.simple.RandomSource;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
+/**
+ * Tests the standards defined by the C.99 standard for complex numbers
+ * defined in ISO/IEC 9899, Annex G.
+ *
+ * @see <a href="http://www.open-std.org/JTC1/SC22/WG14/www/standards">
+ *    ISO/IEC 9899 - Programming languages - C</a>
+ */
 public class CStandardTest {
 
+    // CHECKSTYLE: stop ConstantName
     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 piOverFour = Math.PI / 4.0;
     private static final double piOverTwo = Math.PI / 2.0;
-    private static final double threePiOverFour = 3.0*Math.PI/4.0;
-    private static final Complex oneOne = Complex.ofCartesian(1, 1);
-    private static final Complex oneZero = Complex.ofCartesian(1, 0);
-    private static final Complex oneInf = Complex.ofCartesian(1, inf);
-    private static final Complex oneNaN = Complex.ofCartesian(1, nan);
-    private static final Complex zeroInf = Complex.ofCartesian(0, inf);
-    private static final Complex zeroNegInf = Complex.ofCartesian(0,negInf);
-    private static final Complex zeroNaN = Complex.ofCartesian(0, nan);
-    private static final Complex zeroPiTwo = Complex.ofCartesian(0.0, piOverTwo);
-    private static final Complex negZeroZero = Complex.ofCartesian(-0.0, 0);
-    private static final Complex negI = Complex.ofCartesian(0.0, -1.0);
-    private static final Complex infOne = Complex.ofCartesian(inf, 1);
-    private static final Complex infZero = Complex.ofCartesian(inf, 0);
-    private static final Complex infNaN = Complex.ofCartesian(inf, nan);
-    private static final Complex infInf = Complex.ofCartesian(inf, inf);
-    private static final Complex infPiTwo = Complex.ofCartesian(inf, piOverTwo);
-    private static final Complex infPiFour = Complex.ofCartesian(inf, piOverFour);
-    private static final Complex infPi = Complex.ofCartesian(inf, Math.PI);
-    private static final Complex negInfInf = Complex.ofCartesian(negInf, inf);
-    private static final Complex negInfZero = Complex.ofCartesian(negInf, 0);
-    private static final Complex negInfOne = Complex.ofCartesian(negInf, 1);
-    private static final Complex negInfNaN = Complex.ofCartesian(negInf, nan);
-    private static final Complex negInfPosInf = Complex.ofCartesian(negInf, inf);
-    private static final Complex negInfPi = Complex.ofCartesian(negInf, Math.PI);
-    private static final Complex nanInf = Complex.ofCartesian(nan, inf);
-    private static final Complex nanNegInf = Complex.ofCartesian(nan, negInf);
-    private static final Complex nanZero = Complex.ofCartesian(nan, 0);
-    private static final Complex nanOne = Complex.ofCartesian(nan, 1);
-    private static final Complex piTwoNaN = Complex.ofCartesian(piOverTwo, nan);
-    private static final Complex piNegInf = Complex.ofCartesian(Math.PI, negInf);
-    private static final Complex piTwoNegInf = Complex.ofCartesian(piOverTwo, negInf);
-    private static final Complex piTwoNegZero = Complex.ofCartesian(piOverTwo, -0.0);
-    private static final Complex threePiFourNegInf = Complex.ofCartesian(threePiOverFour,negInf);
-    private static final Complex piFourNegInf = Complex.ofCartesian(piOverFour, negInf);
-    private static final Complex NAN = Complex.ofCartesian(nan, nan);
+    private static final double threePiOverFour = 3.0 * Math.PI / 4.0;
+    private static final Complex oneOne = complex(1, 1);
+    private static final Complex oneZero = complex(1, 0);
+    private static final Complex oneInf = complex(1, inf);
+    private static final Complex oneNaN = complex(1, nan);
+    private static final Complex zeroInf = complex(0, inf);
+    private static final Complex zeroNegInf = complex(0, negInf);
+    private static final Complex zeroNaN = complex(0, nan);
+    private static final Complex zeroPiTwo = complex(0.0, piOverTwo);
+    private static final Complex negZeroZero = complex(-0.0, 0);
+    private static final Complex negI = complex(0.0, -1.0);
+    private static final Complex infOne = complex(inf, 1);
+    private static final Complex infZero = complex(inf, 0);
+    private static final Complex infNaN = complex(inf, nan);
+    private static final Complex infInf = complex(inf, inf);
+    private static final Complex infPiTwo = complex(inf, piOverTwo);
+    private static final Complex infThreePiFour = complex(inf, threePiOverFour);
+    private static final Complex infPiFour = complex(inf, piOverFour);
+    private static final Complex infPi = complex(inf, Math.PI);
+    private static final Complex negInfInf = complex(negInf, inf);
+    private static final Complex negInfZero = complex(negInf, 0);
+    private static final Complex negInfOne = complex(negInf, 1);
+    private static final Complex negInfNaN = complex(negInf, nan);
+    private static final Complex negInfPosInf = complex(negInf, inf);
+    private static final Complex negInfPi = complex(negInf, Math.PI);
+    private static final Complex nanInf = complex(nan, inf);
+    private static final Complex nanNegInf = complex(nan, negInf);
+    private static final Complex nanZero = complex(nan, 0);
+    private static final Complex nanOne = complex(nan, 1);
+    private static final Complex piTwoNaN = complex(piOverTwo, nan);
+    private static final Complex piNegInf = complex(Math.PI, negInf);
+    private static final Complex piTwoNegInf = complex(piOverTwo, negInf);
+    private static final Complex piTwoNegZero = complex(piOverTwo, -0.0);
+    private static final Complex threePiFourNegInf = complex(threePiOverFour, negInf);
+    private static final Complex piFourNegInf = complex(piOverFour, negInf);
+    private static final Complex NAN = complex(nan, nan);
+    // CHECKSTYLE: resume ConstantName
 
-    public void assertComplex(Complex c1, Complex c2, double realTol, double imagTol) {
-        Assertions.assertEquals(c1.getReal(), c2.getReal(), realTol);
-        Assertions.assertEquals(c1.getImaginary(), c2.getImaginary(), imagTol);
+    /**
+     * Assert the two complex numbers have their real and imaginary components within
+     * the given tolerance.
+     *
+     * @param c1 the first complex
+     * @param c2 the second complex
+     * @param maxUlps {@code (maxUlps - 1)} is the number of floating point
+     * values between the real (resp. imaginary) parts of {@code x} and
+     * {@code y}.
+     */
+    public void assertComplex(Complex c1, Complex c2, int maxUlps) {
+        if (!Precision.equals(c1.getReal(), c2.getReal(), maxUlps) ||
+            !Precision.equals(c1.getImaginary(), c2.getImaginary(), maxUlps)) {
+            Assertions.fail(c1 + " != " + c2);
+        }
     }
 
+    /**
+     * Assert the two complex numbers have equivalent real and imaginary components as
+     * defined by the {@code ==} operator.
+     *
+     * @param c1 the first complex
+     * @param c2 the second complex
+     */
     public void assertComplex(Complex c1, Complex c2) {
-        Assertions.assertEquals(c1.getReal(), c2.getReal(),0.0);
-        Assertions.assertEquals(c1.getImaginary(), c2.getImaginary(), 0.0);
+        // Use a delta of zero to allow comparison of -0.0 to 0.0
+        Assertions.assertEquals(c1.getReal(), c2.getReal(), 0.0, "real");
+        Assertions.assertEquals(c1.getImaginary(), c2.getImaginary(), 0.0, "imaginary");
     }
 
+    /**
+     * Utility to create a Complex.
+     *
+     * @param real the real
+     * @param imaginary the imaginary
+     * @return the complex
+     */
+    private static Complex complex(double real, double imaginary) {
+        return Complex.ofCartesian(real, imaginary);
+    }
 
     /**
-     * ISO C Standard G.6.3
+     * ISO C Standard G.6 (3).
      */
     @Test
     public void testSqrt1() {
-        Complex z1 = Complex.ofCartesian(-2.0, 0.0);
-        Complex z2 = Complex.ofCartesian(0.0, Math.sqrt(2));
-        assertComplex(z1.sqrt(), z2);
-        z1 = Complex.ofCartesian(-2.0, -0.0);
-        z2 = Complex.ofCartesian(0.0, -Math.sqrt(2));
-        assertComplex(z1.sqrt(), z2);
+        assertComplex(complex(-2.0, 0.0).sqrt(), complex(0.0, Math.sqrt(2)));
+        assertComplex(complex(-2.0, -0.0).sqrt(), complex(0.0, -Math.sqrt(2)));
     }
 
+    /**
+     * ISO C Standard G.6 (7).
+     */
     @Test
     public void testImplicitTrig() {
-        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.0), Math.ulp(1.0));
-        assertComplex(z1.cos(), z2.cosh());
-        assertComplex(z1.sin(), negI.multiply(z2.sinh()));
-        assertComplex(z1.tan(), negI.multiply(z2.tanh()));
+        final UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64);
+        for (int i = 0; i < 100; i++) {
+            final double re = next(rng);
+            final double im = next(rng);
+            final Complex z = complex(re, im);
+            final Complex iz = Complex.I.multiply(z);
+            assertComplex(z.asin(), negI.multiply(iz.asinh()));
+            assertComplex(z.atan(), negI.multiply(iz.atanh()));
+            assertComplex(z.cos(), iz.cosh());
+            assertComplex(z.sin(), negI.multiply(iz.sinh()));
+            assertComplex(z.tan(), negI.multiply(iz.tanh()));
+        }
+    }
+
+    /**
+     * Create a number in the range {@code (-1,1)}.
+     *
+     * @param rng the random generator
+     * @return the number
+     */
+    private static double next(UniformRandomProvider rng) {
+        return rng.nextDouble() * (rng.nextBoolean() ? -1 : 1);
     }
 
     /**
-     * ISO C Standard G.6.1.1
+     * ISO C Standard G.6 (6) for abs().
+     * Defined by ISO C Standard F.9.4.3 hypot function.
+     */
+    @Test
+    public void testAbs() {
+        Assertions.assertEquals(inf, complex(inf, nan).abs());
+        Assertions.assertEquals(inf, complex(negInf, nan).abs());
+        final UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64);
+        for (int i = 0; i < 100; i++) {
+            final double x = next(rng);
+            final double y = next(rng);
+            Assertions.assertEquals(complex(x, y).abs(), complex(y, x).abs());
+            Assertions.assertEquals(complex(x, y).abs(), complex(x, -y).abs());
+            Assertions.assertEquals(Math.abs(x), complex(x, 0.0).abs());
+            Assertions.assertEquals(Math.abs(x), complex(x, -0.0).abs());
+            Assertions.assertEquals(inf, complex(inf, y).abs());
+            Assertions.assertEquals(inf, complex(negInf, y).abs());
+        }
+    }
+
+    /**
+     * ISO C Standard G.6.1.1.
      */
     @Test
     public void testAcos() {
-        assertComplex(oneOne.acos().conj(), oneOne.conj().acos(), Math.ulp(1.0), Math.ulp(1.0));
+        assertComplex(oneOne.acos().conj(), oneOne.conj().acos(), 1);
         assertComplex(Complex.ZERO.acos(), piTwoNegZero);
         assertComplex(negZeroZero.acos(), piTwoNegZero);
         assertComplex(zeroNaN.acos(), piTwoNaN);
@@ -121,7 +199,29 @@ public class CStandardTest {
     }
 
     /**
-     * ISO C Standard G.6.2.2
+     * ISO C Standard G.6.2.1.
+     */
+    @Test
+    public void testAcosh() {
+        assertComplex(oneOne.acosh().conj(), oneOne.conj().acosh(), 1);
+        assertComplex(Complex.ZERO.acosh(), zeroPiTwo);
+        assertComplex(negZeroZero.acosh(), zeroPiTwo);
+        assertComplex(oneInf.acosh(), infPiTwo);
+        assertComplex(zeroNaN.acosh(), NAN);
+        assertComplex(oneNaN.acosh(), NAN);
+        assertComplex(negInfOne.acosh(), infPi);
+        assertComplex(infOne.acosh(), infZero);
+        assertComplex(negInfPosInf.acosh(), infThreePiFour);
+        assertComplex(infInf.acosh(), infPiFour);
+        assertComplex(infNaN.acosh(), infNaN);
+        assertComplex(negInfNaN.acosh(), infNaN);
+        assertComplex(nanOne.acosh(), NAN);
+        assertComplex(nanInf.acosh(), infNaN);
+        assertComplex(NAN.acosh(), NAN);
+    }
+
+    /**
+     * ISO C Standard G.6.2.2.
      */
     @Test
     public void testAsinh() {
@@ -140,7 +240,7 @@ public class CStandardTest {
     }
 
     /**
-     * ISO C Standard G.6.2.3
+     * ISO C Standard G.6.2.3.
      */
     @Test
     public void testAtanh() {
@@ -148,7 +248,7 @@ public class CStandardTest {
         assertComplex(Complex.ZERO.atanh(), Complex.ZERO);
         assertComplex(zeroNaN.atanh(), zeroNaN);
         assertComplex(oneZero.atanh(), infZero);
-        assertComplex(oneInf.atanh(),zeroPiTwo);
+        assertComplex(oneInf.atanh(), zeroPiTwo);
         assertComplex(oneNaN.atanh(), NAN);
         assertComplex(infOne.atanh(), zeroPiTwo);
         assertComplex(infInf.atanh(), zeroPiTwo);
@@ -159,7 +259,7 @@ public class CStandardTest {
     }
 
     /**
-     * ISO C Standard G.6.2.4
+     * ISO C Standard G.6.2.4.
      */
     @Test
     public void testCosh() {
@@ -181,7 +281,7 @@ public class CStandardTest {
     }
 
     /**
-     * ISO C Standard G.6.2.5
+     * ISO C Standard G.6.2.5.
      */
     @Test
     public void testSinh() {
@@ -201,7 +301,7 @@ public class CStandardTest {
     }
 
     /**
-     * ISO C Standard G.6.2.6
+     * ISO C Standard G.6.2.6.
      */
     @Test
     public void testTanh() {
@@ -218,7 +318,7 @@ public class CStandardTest {
     }
 
     /**
-     * ISO C Standard G.6.3.1
+     * ISO C Standard G.6.3.1.
      */
     @Test
     public void testExp() {
@@ -239,7 +339,7 @@ public class CStandardTest {
     }
 
     /**
-     * ISO C Standard G.6.3.2
+     * ISO C Standard G.6.3.2.
      */
     @Test
     public void testLog() {
@@ -258,7 +358,27 @@ public class CStandardTest {
     }
 
     /**
-     * ISO C Standard G.6.4.2
+     * Same edge cases as log() since the real component is divided by Math.log(10) whic
+     * has no effect on infinite or nan.
+     */
+    @Test
+    public void testLog10() {
+        assertComplex(oneOne.log10().conj(), oneOne.conj().log10());
+        assertComplex(negZeroZero.log10(), negInfPi);
+        assertComplex(Complex.ZERO.log10(), negInfZero);
+        assertComplex(oneInf.log10(), infPiTwo);
+        assertComplex(oneNaN.log10(), NAN);
+        assertComplex(negInfOne.log10(), infPi);
+        assertComplex(infOne.log10(), infZero);
+        assertComplex(infInf.log10(), infPiFour);
+        assertComplex(infNaN.log10(), infNaN);
+        assertComplex(nanOne.log10(), NAN);
+        assertComplex(nanInf.log10(), infNaN);
+        assertComplex(NAN.log10(), NAN);
+    }
+
+    /**
+     * ISO C Standard G.6.4.2.
      */
     @Test
     public void testSqrt2() {
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 e8128dd..8078da8 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
@@ -18,15 +18,19 @@
 package org.apache.commons.numbers.complex;
 
 import java.util.List;
+
+import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.simple.RandomSource;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
-
 /**
+ * Tests for {@link Complex}.
  */
 public class ComplexTest {
 
+    // CHECKSTYLE: stop ConstantName
     private static final double inf = Double.POSITIVE_INFINITY;
     private static final double neginf = Double.NEGATIVE_INFINITY;
     private static final double nan = Double.NaN;
@@ -51,44 +55,137 @@ public class ComplexTest {
     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);
+    // CHECKSTYLE: resume ConstantName
+
+    /**
+     * Used to test the number category of a Complex.
+     */
+    private enum NumberType {
+        NAN,
+        INFINITE,
+        FINITE
+    }
 
     @Test
-    public void testConstructor() {
-        Complex z = Complex.ofCartesian(3.0, 4.0);
-        Assertions.assertEquals(3.0, z.getReal(), 1.0e-5);
-        Assertions.assertEquals(4.0, z.getImaginary(), 1.0e-5);
+    public void testCartesianConstructor() {
+        final Complex z = Complex.ofCartesian(3.0, 4.0);
+        Assertions.assertEquals(3.0, z.getReal());
+        Assertions.assertEquals(4.0, z.getImaginary());
     }
 
     @Test
-    public void testConstructorNaN() {
-        Complex z = Complex.ofCartesian(3.0, Double.NaN);
-        Assertions.assertTrue(z.isNaN());
+    public void testRealConstructor() {
+        final Complex z = Complex.ofReal(3.0);
+        Assertions.assertEquals(3.0, z.getReal());
+        Assertions.assertEquals(0.0, z.getImaginary());
+    }
 
-        z = Complex.ofCartesian(nan, 4.0);
-        Assertions.assertTrue(z.isNaN());
+    @Test
+    public void testPolarConstructor() {
+        final double r = 98765;
+        final double theta = 0.12345;
+        final Complex z = Complex.ofPolar(r, theta);
+        final Complex y = Complex.ofCis(theta);
+        Assertions.assertEquals(r * y.getReal(), z.getReal());
+        Assertions.assertEquals(r * y.getImaginary(), z.getImaginary());
 
-        z = Complex.ofCartesian(3.0, 4.0);
-        Assertions.assertFalse(z.isNaN());
+        Assertions.assertThrows(IllegalArgumentException.class, () -> Complex.ofPolar(-1, 0),
+            "negative modulus should not be allowed");
+    }
+
+    @Test
+    public void testCisConstructor() {
+        final double x = 0.12345;
+        final Complex z = Complex.ofCis(x);
+        Assertions.assertEquals(Math.cos(x), z.getReal());
+        Assertions.assertEquals(Math.sin(x), z.getImaginary());
+    }
+
+    @Test
+    public void testNumberType() {
+        assertNumberType(0, 0, NumberType.FINITE);
+        assertNumberType(1, 0, NumberType.FINITE);
+        assertNumberType(0, 1, NumberType.FINITE);
+
+        assertNumberType(inf, 0, NumberType.INFINITE);
+        assertNumberType(-inf, 0, NumberType.INFINITE);
+        assertNumberType(0, inf, NumberType.INFINITE);
+        assertNumberType(0, -inf, NumberType.INFINITE);
+        // A complex or imaginary value with at least one infinite part is regarded as an infinity
+        // (even if its other part is a NaN).
+        assertNumberType(inf, nan, NumberType.INFINITE);
+        assertNumberType(-inf, nan, NumberType.INFINITE);
+        assertNumberType(nan, inf, NumberType.INFINITE);
+        assertNumberType(nan, -inf, NumberType.INFINITE);
+
+        assertNumberType(nan, 0, NumberType.NAN);
+        assertNumberType(0, nan, NumberType.NAN);
+        assertNumberType(nan, nan, NumberType.NAN);
+    }
+
+    /**
+     * Assert the number type of the Complex created from the real and imaginary
+     * components.
+     *
+     * @param real the real component
+     * @param imaginary the imaginary component
+     * @param type the type
+     */
+    private static void assertNumberType(double real, double imaginary, NumberType type) {
+        final Complex z = Complex.ofCartesian(real, imaginary);
+        final boolean isNaN = z.isNaN();
+        final boolean isInfinite = z.isInfinite();
+        final boolean isFinite = z.isFinite();
+        // A number can be only one
+        int count = isNaN ? 1 : 0;
+        count += isInfinite ? 1 : 0;
+        count += isFinite ? 1 : 0;
+        Assertions.assertEquals(1, count,
+            () -> String.format("Complex can be only one type: isNaN=%s, isInfinite=%s, isFinite=%s: %s",
+                                isNaN, isInfinite, isFinite, z));
+        switch (type) {
+        case FINITE:
+            Assertions.assertTrue(isFinite, () -> "not finite: " + z);
+            break;
+        case INFINITE:
+            Assertions.assertTrue(isInfinite, () -> "not infinite: " + z);
+            break;
+        case NAN:
+            Assertions.assertTrue(isNaN, () -> "not nan: " + z);
+            break;
+        default:
+            Assertions.fail("Unknown number type");
+        }
+    }
+
+
+    @Test
+    public void testProj() {
+        final Complex z = Complex.ofCartesian(3.0, 4.0);
+        Assertions.assertSame(z, z.proj());
+        TestUtils.assertSame(infZero, Complex.ofCartesian(inf, 4.0).proj());
+        TestUtils.assertSame(infZero, Complex.ofCartesian(3.0, inf).proj());
     }
 
     @Test
     public void testAbs() {
-        Complex z = Complex.ofCartesian(3.0, 4.0);
+        final Complex z = Complex.ofCartesian(3.0, 4.0);
         Assertions.assertEquals(5.0, z.abs(), 1.0e-5);
     }
 
     @Test
     public void testAbsNaN() {
         Assertions.assertTrue(Double.isNaN(NAN.abs()));
-        Complex z = Complex.ofCartesian(inf, nan);
-        Assertions.assertTrue(Double.isNaN(z.abs()));
+        // The result is infinite if either argument is infinite
+        Assertions.assertEquals(inf, Complex.ofCartesian(inf, nan).abs());
+        Assertions.assertEquals(inf, Complex.ofCartesian(nan, inf).abs());
     }
 
     @Test
     public void testAdd() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        Complex y = Complex.ofCartesian(5.0, 6.0);
-        Complex z = x.add(y);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex y = Complex.ofCartesian(5.0, 6.0);
+        final Complex z = x.add(y);
         Assertions.assertEquals(8.0, z.getReal(), 1.0e-5);
         Assertions.assertEquals(10.0, z.getImaginary(), 1.0e-5);
     }
@@ -96,8 +193,8 @@ public class ComplexTest {
     @Test
     public void testAddInf() {
         Complex x = Complex.ofCartesian(1, 1);
-        Complex z = Complex.ofCartesian(inf, 0);
-        Complex w = x.add(z);
+        final Complex z = Complex.ofCartesian(inf, 0);
+        final Complex w = x.add(z);
         Assertions.assertEquals(1, w.getImaginary(), 0);
         Assertions.assertEquals(inf, w.getReal(), 0);
 
@@ -108,26 +205,26 @@ public class ComplexTest {
 
     @Test
     public void testScalarAdd() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        double yDouble = 2.0;
-        Complex yComplex = Complex.ofReal(yDouble);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final double yDouble = 2.0;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.add(yComplex), x.add(yDouble));
     }
 
     @Test
     public void testScalarAddNaN() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        double yDouble = Double.NaN;
-        Complex yComplex = Complex.ofReal(yDouble);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final double yDouble = Double.NaN;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.add(yComplex), x.add(yDouble));
     }
 
     @Test
     public void testScalarAddInf() {
         Complex x = Complex.ofCartesian(1, 1);
-        double yDouble = Double.POSITIVE_INFINITY;
+        final double yDouble = Double.POSITIVE_INFINITY;
 
-        Complex yComplex = Complex.ofReal(yDouble);
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.add(yComplex), x.add(yDouble));
 
         x = Complex.ofCartesian(neginf, 0);
@@ -136,15 +233,15 @@ public class ComplexTest {
 
     @Test
     public void testConjugate() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        Complex z = x.conjugate();
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex z = x.conjugate();
         Assertions.assertEquals(3.0, z.getReal(), 1.0e-5);
         Assertions.assertEquals(-4.0, z.getImaginary(), 1.0e-5);
     }
 
     @Test
     public void testConjugateNaN() {
-        Complex z = NAN.conjugate();
+        final Complex z = NAN.conjugate();
         Assertions.assertTrue(z.isNaN());
     }
 
@@ -158,100 +255,100 @@ public class ComplexTest {
 
     @Test
     public void testDivide() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        Complex y = Complex.ofCartesian(5.0, 6.0);
-        Complex z = x.divide(y);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex y = Complex.ofCartesian(5.0, 6.0);
+        final Complex z = x.divide(y);
         Assertions.assertEquals(39.0 / 61.0, z.getReal(), 1.0e-5);
         Assertions.assertEquals(2.0 / 61.0, z.getImaginary(), 1.0e-5);
     }
 
     @Test
     public void testDivideReal() {
-        Complex x = Complex.ofCartesian(2d, 3d);
-        Complex y = Complex.ofCartesian(2d, 0d);
+        final Complex x = Complex.ofCartesian(2d, 3d);
+        final Complex y = Complex.ofCartesian(2d, 0d);
         Assertions.assertEquals(Complex.ofCartesian(1d, 1.5), x.divide(y));
 
     }
 
     @Test
     public void testDivideImaginary() {
-        Complex x = Complex.ofCartesian(2d, 3d);
-        Complex y = Complex.ofCartesian(0d, 2d);
+        final Complex x = Complex.ofCartesian(2d, 3d);
+        final Complex y = Complex.ofCartesian(0d, 2d);
         Assertions.assertEquals(Complex.ofCartesian(1.5d, -1d), x.divide(y));
     }
 
     @Test
     public void testDivideZero() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        Complex z = x.divide(Complex.ZERO);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex z = x.divide(Complex.ZERO);
         Assertions.assertEquals(INF, z);
     }
 
     @Test
     public void testDivideZeroZero() {
-        Complex x = Complex.ofCartesian(0.0, 0.0);
-        Complex z = x.divide(Complex.ZERO);
+        final Complex x = Complex.ofCartesian(0.0, 0.0);
+        final Complex z = x.divide(Complex.ZERO);
         Assertions.assertEquals(NAN, z);
     }
 
     @Test
     public void testDivideNaN() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        Complex z = x.divide(NAN);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex z = x.divide(NAN);
         Assertions.assertTrue(z.isNaN());
     }
 
     @Test
     public void testDivideNanInf() {
-       Complex z = oneInf.divide(Complex.ONE);
-       Assertions.assertTrue(Double.isNaN(z.getReal()));
-       Assertions.assertEquals(inf, z.getImaginary(), 0);
+        Complex z = oneInf.divide(Complex.ONE);
+        Assertions.assertTrue(Double.isNaN(z.getReal()));
+        Assertions.assertEquals(inf, z.getImaginary(), 0);
 
-       z = negInfNegInf.divide(oneNan);
-       Assertions.assertTrue(Double.isNaN(z.getReal()));
-       Assertions.assertTrue(Double.isNaN(z.getImaginary()));
+        z = negInfNegInf.divide(oneNan);
+        Assertions.assertTrue(Double.isNaN(z.getReal()));
+        Assertions.assertTrue(Double.isNaN(z.getImaginary()));
 
-       z = negInfInf.divide(Complex.ONE);
-       Assertions.assertTrue(Double.isInfinite(z.getReal()));
-       Assertions.assertTrue(Double.isInfinite(z.getImaginary()));
+        z = negInfInf.divide(Complex.ONE);
+        Assertions.assertTrue(Double.isInfinite(z.getReal()));
+        Assertions.assertTrue(Double.isInfinite(z.getImaginary()));
     }
 
     @Test
     public void testScalarDivide() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        double yDouble = 2.0;
-        Complex yComplex = Complex.ofReal(yDouble);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final double yDouble = 2.0;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.divide(yComplex), x.divide(yDouble));
     }
 
     @Test
     public void testScalarDivideNaN() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        double yDouble = Double.NaN;
-        Complex yComplex = Complex.ofReal(yDouble);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final double yDouble = Double.NaN;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.divide(yComplex), x.divide(yDouble));
     }
 
     @Test
     public void testScalarDivideZero() {
-        Complex x = Complex.ofCartesian(1,1);
+        final Complex x = Complex.ofCartesian(1, 1);
         TestUtils.assertEquals(x.divide(Complex.ZERO), x.divide(0), 0);
     }
 
     @Test
     public void testReciprocal() {
-        Complex z = Complex.ofCartesian(5.0, 6.0);
-        Complex act = z.reciprocal();
-        double expRe = 5.0 / 61.0;
-        double expIm = -6.0 / 61.0;
+        final Complex z = Complex.ofCartesian(5.0, 6.0);
+        final Complex act = z.reciprocal();
+        final double expRe = 5.0 / 61.0;
+        final double expIm = -6.0 / 61.0;
         Assertions.assertEquals(expRe, act.getReal(), Math.ulp(expRe));
         Assertions.assertEquals(expIm, act.getImaginary(), Math.ulp(expIm));
     }
 
     @Test
     public void testReciprocalReciprocal() {
-        Complex z = Complex.ofCartesian(5.0, 6.0);
-        Complex zRR = z.reciprocal().reciprocal();
+        final Complex z = Complex.ofCartesian(5.0, 6.0);
+        final Complex zRR = z.reciprocal().reciprocal();
         final double tol = 1e-14;
         Assertions.assertEquals(zRR.getReal(), z.getReal(), tol);
         Assertions.assertEquals(zRR.getImaginary(), z.getImaginary(), tol);
@@ -259,13 +356,13 @@ public class ComplexTest {
 
     @Test
     public void testReciprocalReal() {
-        Complex z = Complex.ofCartesian(-2.0, 0.0);
+        final Complex z = Complex.ofCartesian(-2.0, 0.0);
         Assertions.assertTrue(Complex.equals(Complex.ofCartesian(-0.5, 0.0), z.reciprocal()));
     }
 
     @Test
     public void testReciprocalImaginary() {
-        Complex z = Complex.ofCartesian(0.0, -2.0);
+        final Complex z = Complex.ofCartesian(0.0, -2.0);
         Assertions.assertEquals(Complex.ofCartesian(0.0, 0.5), z.reciprocal());
     }
 
@@ -276,9 +373,9 @@ public class ComplexTest {
 
     @Test
     public void testMultiply() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        Complex y = Complex.ofCartesian(5.0, 6.0);
-        Complex z = x.multiply(y);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex y = Complex.ofCartesian(5.0, 6.0);
+        final Complex z = x.multiply(y);
         Assertions.assertEquals(-9.0, z.getReal(), 1.0e-5);
         Assertions.assertEquals(38.0, z.getImaginary(), 1.0e-5);
     }
@@ -291,26 +388,26 @@ public class ComplexTest {
 
     @Test
     public void testScalarMultiply() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        double yDouble = 2.0;
-        Complex yComplex = Complex.ofReal(yDouble);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final double yDouble = 2.0;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.multiply(yComplex), x.multiply(yDouble));
-        int zInt = -5;
-        Complex zComplex = Complex.ofReal(zInt);
+        final int zInt = -5;
+        final Complex zComplex = Complex.ofReal(zInt);
         Assertions.assertEquals(x.multiply(zComplex), x.multiply(zInt));
     }
 
     @Test
     public void testScalarMultiplyNaN() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        double yDouble = Double.NaN;
-        Complex yComplex = Complex.ofReal(yDouble);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final double yDouble = Double.NaN;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.multiply(yComplex), x.multiply(yDouble));
     }
 
     @Test
     public void testScalarMultiplyInf() {
-        Complex x = Complex.ofCartesian(1, 1);
+        final Complex x = Complex.ofCartesian(1, 1);
         double yDouble = Double.POSITIVE_INFINITY;
         Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.multiply(yComplex), x.multiply(yDouble));
@@ -322,23 +419,23 @@ public class ComplexTest {
 
     @Test
     public void testNegate() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        Complex z = x.negate();
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex z = x.negate();
         Assertions.assertEquals(-3.0, z.getReal(), 1.0e-5);
         Assertions.assertEquals(-4.0, z.getImaginary(), 1.0e-5);
     }
 
     @Test
     public void testNegateNaN() {
-        Complex z = NAN.negate();
+        final Complex z = NAN.negate();
         Assertions.assertTrue(z.isNaN());
     }
 
     @Test
     public void testSubtract() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        Complex y = Complex.ofCartesian(5.0, 6.0);
-        Complex z = x.subtract(y);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex y = Complex.ofCartesian(5.0, 6.0);
+        final Complex z = x.subtract(y);
         Assertions.assertEquals(-2.0, z.getReal(), 1.0e-5);
         Assertions.assertEquals(-2.0, z.getImaginary(), 1.0e-5);
     }
@@ -346,8 +443,8 @@ public class ComplexTest {
     @Test
     public void testSubtractInf() {
         Complex x = Complex.ofCartesian(1, 1);
-        Complex z = Complex.ofCartesian(neginf, 0);
-        Complex w = x.subtract(z);
+        final Complex z = Complex.ofCartesian(neginf, 0);
+        final Complex w = x.subtract(z);
         Assertions.assertEquals(1, w.getImaginary(), 0);
         Assertions.assertEquals(inf, w.getReal(), 0);
 
@@ -357,25 +454,25 @@ public class ComplexTest {
 
     @Test
     public void testScalarSubtract() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        double yDouble = 2.0;
-        Complex yComplex = Complex.ofReal(yDouble);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final double yDouble = 2.0;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.subtract(yComplex), x.subtract(yDouble));
     }
 
     @Test
     public void testScalarSubtractNaN() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        double yDouble = Double.NaN;
-        Complex yComplex = Complex.ofReal(yDouble);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final double yDouble = Double.NaN;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.subtract(yComplex), x.subtract(yDouble));
     }
 
     @Test
     public void testScalarSubtractInf() {
         Complex x = Complex.ofCartesian(1, 1);
-        double yDouble = Double.POSITIVE_INFINITY;
-        Complex yComplex = Complex.ofReal(yDouble);
+        final double yDouble = Double.POSITIVE_INFINITY;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.subtract(yComplex), x.subtract(yDouble));
 
         x = Complex.ofCartesian(neginf, 0);
@@ -385,33 +482,33 @@ public class ComplexTest {
 
     @Test
     public void testEqualsNull() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
         Assertions.assertNotEquals(null, x);
     }
 
     @Test
     public void testFloatingPointEqualsPrecondition1() {
         Assertions.assertThrows(NullPointerException.class,
-                () -> Complex.equals(Complex.ofCartesian(3.0, 4.0), null, 3)
+            () -> Complex.equals(Complex.ofCartesian(3.0, 4.0), null, 3)
         );
-
     }
+
     @Test
     public void testFloatingPointEqualsPrecondition2() {
         Assertions.assertThrows(NullPointerException.class,
-                () -> Complex.equals(null, Complex.ofCartesian(3.0, 4.0), 3)
+            () -> Complex.equals(null, Complex.ofCartesian(3.0, 4.0), 3)
         );
     }
 
     @Test
     public void testEqualsClass() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
         Assertions.assertFalse(x.equals(this));
     }
 
     @Test
     public void testEqualsSame() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
         Assertions.assertEquals(x, x);
     }
 
@@ -494,22 +591,22 @@ public class ComplexTest {
 
     @Test
     public void testEqualsTrue() {
-        Complex x = Complex.ofCartesian(3.0, 4.0);
-        Complex y = Complex.ofCartesian(3.0, 4.0);
+        final Complex x = Complex.ofCartesian(3.0, 4.0);
+        final Complex y = Complex.ofCartesian(3.0, 4.0);
         Assertions.assertEquals(x, y);
     }
 
     @Test
     public void testEqualsRealDifference() {
-        Complex x = Complex.ofCartesian(0.0, 0.0);
-        Complex y = Complex.ofCartesian(0.0 + Double.MIN_VALUE, 0.0);
+        final Complex x = Complex.ofCartesian(0.0, 0.0);
+        final Complex y = Complex.ofCartesian(0.0 + Double.MIN_VALUE, 0.0);
         Assertions.assertNotEquals(x, y);
     }
 
     @Test
     public void testEqualsImaginaryDifference() {
-        Complex x = Complex.ofCartesian(0.0, 0.0);
-        Complex y = Complex.ofCartesian(0.0, 0.0 + Double.MIN_VALUE);
+        final Complex x = Complex.ofCartesian(0.0, 0.0);
+        final Complex y = Complex.ofCartesian(0.0, 0.0 + Double.MIN_VALUE);
         Assertions.assertNotEquals(x, y);
     }
 
@@ -520,8 +617,8 @@ public class ComplexTest {
         Assertions.assertNotEquals(x.hashCode(), y.hashCode());
         y = Complex.ofCartesian(0.0 + Double.MIN_VALUE, 0.0);
         Assertions.assertNotEquals(x.hashCode(), y.hashCode());
-        Complex realNan = Complex.ofCartesian(Double.NaN, 0.0);
-        Complex imaginaryNan = Complex.ofCartesian(0.0, Double.NaN);
+        final Complex realNan = Complex.ofCartesian(Double.NaN, 0.0);
+        final Complex imaginaryNan = Complex.ofCartesian(0.0, Double.NaN);
         Assertions.assertEquals(realNan.hashCode(), imaginaryNan.hashCode());
         Assertions.assertEquals(imaginaryNan.hashCode(), NAN.hashCode());
 
@@ -542,74 +639,86 @@ public class ComplexTest {
     }
 
     @Test
-    @Disabled
-    public void testJava() {// TODO more debug
+    @Disabled("Used to output the java environment")
+    public void testJava() {
+        // CHECKSTYLE: stop Regexp
         System.out.println(">>testJava()");
         // MathTest#testExpSpecialCases() checks the following:
         // Assert.assertEquals("exp of -infinity should be 0.0", 0.0, Math.exp(Double.NEGATIVE_INFINITY), Precision.EPSILON);
         // Let's check how well Math works:
-        System.out.println("Math.exp="+Math.exp(Double.NEGATIVE_INFINITY));
-        String props[] = {
-        "java.version", //    Java Runtime Environment version
-        "java.vendor", // Java Runtime Environment vendor
-        "java.vm.specification.version", //   Java Virtual Machine specification version
-        "java.vm.specification.vendor", //    Java Virtual Machine specification vendor
-        "java.vm.specification.name", //  Java Virtual Machine specification name
-        "java.vm.version", // Java Virtual Machine implementation version
-        "java.vm.vendor", //  Java Virtual Machine implementation vendor
-        "java.vm.name", //    Java Virtual Machine implementation name
-        "java.specification.version", //  Java Runtime Environment specification version
-        "java.specification.vendor", //   Java Runtime Environment specification vendor
-        "java.specification.name", // Java Runtime Environment specification name
-        "java.class.version", //  Java class format version number
+        System.out.println("Math.exp=" + Math.exp(Double.NEGATIVE_INFINITY));
+        final String[] props = {
+            "java.version", //    Java Runtime Environment version
+            "java.vendor", // Java Runtime Environment vendor
+            "java.vm.specification.version", //   Java Virtual Machine specification version
+            "java.vm.specification.vendor", //    Java Virtual Machine specification vendor
+            "java.vm.specification.name", //  Java Virtual Machine specification name
+            "java.vm.version", // Java Virtual Machine implementation version
+            "java.vm.vendor", //  Java Virtual Machine implementation vendor
+            "java.vm.name", //    Java Virtual Machine implementation name
+            "java.specification.version", //  Java Runtime Environment specification version
+            "java.specification.vendor", //   Java Runtime Environment specification vendor
+            "java.specification.name", // Java Runtime Environment specification name
+            "java.class.version", //  Java class format version number
         };
-        for(String t : props) {
+        for (final String t : props) {
             System.out.println(t + "=" + System.getProperty(t));
         }
         System.out.println("<<testJava()");
+        // CHECKSTYLE: resume Regexp
     }
 
-
     @Test
-    public void testScalarPow() {
-        Complex x = Complex.ofCartesian(3, 4);
-        double yDouble = 5.0;
-        Complex yComplex = Complex.ofReal(yDouble);
+    public void testPow() {
+        final Complex x = Complex.ofCartesian(3, 4);
+        final double yDouble = 5.0;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.pow(yComplex), x.pow(yDouble));
     }
 
     @Test
-    public void testScalarPowNanBase() {
-        Complex x = NAN;
-        double yDouble = 5.0;
-        Complex yComplex = Complex.ofReal(yDouble);
-        Assertions.assertEquals(x.pow(yComplex), x.pow(yDouble));
+    public void testPowComplexZeroBase() {
+        final double x = Double.MIN_VALUE;
+        assertPowComplexZeroBase(0, 0, NAN);
+        assertPowComplexZeroBase(0, x, NAN);
+        assertPowComplexZeroBase(x, x, NAN);
+        assertPowComplexZeroBase(x, 0, Complex.ZERO);
+    }
+
+    private static void assertPowComplexZeroBase(double re, double im, Complex expected) {
+        final Complex z = Complex.ofCartesian(re, im);
+        final Complex c = Complex.ZERO.pow(z);
+        Assertions.assertEquals(expected, c);
     }
 
     @Test
-    public void testScalarPowZeroBaseZeroExponent() {
-        Complex x = Complex.ZERO;
-        double yDouble = 0;
-        Assertions.assertEquals(NAN, x.pow(yDouble));
-        Complex yComplex = Complex.ofReal(yDouble);
-        Assertions.assertEquals(NAN, x.pow(yComplex));
+    public void testPowScalarZeroBase() {
+        final double x = Double.MIN_VALUE;
+        assertPowScalarZeroBase(0, NAN);
+        assertPowScalarZeroBase(x, Complex.ZERO);
     }
+
+    private static void assertPowScalarZeroBase(double exp, Complex expected) {
+        final Complex c = Complex.ZERO.pow(exp);
+        Assertions.assertEquals(expected, c);
+    }
+
     @Test
-    public void testScalarPowZeroBasePositiveExponent() {
-        Complex x = Complex.ZERO;
-        double yDouble = Double.MIN_VALUE;
-        Assertions.assertEquals(Complex.ZERO, x.pow(yDouble));
-        Complex yComplex = Complex.ofReal(yDouble);
-        Assertions.assertEquals(Complex.ZERO, x.pow(yComplex));
+    public void testPowNanBase() {
+        final Complex x = NAN;
+        final double yDouble = 5.0;
+        final Complex yComplex = Complex.ofReal(yDouble);
+        Assertions.assertEquals(x.pow(yComplex), x.pow(yDouble));
     }
 
     @Test
-    public void testScalarPowNanExponent() {
-        Complex x = Complex.ofCartesian(3, 4);
-        double yDouble = Double.NaN;
-        Complex yComplex = Complex.ofReal(yDouble);
+    public void testPowNanExponent() {
+        final Complex x = Complex.ofCartesian(3, 4);
+        final double yDouble = Double.NaN;
+        final Complex yComplex = Complex.ofReal(yDouble);
         Assertions.assertEquals(x.pow(yComplex), x.pow(yDouble));
     }
+
     @Test
     public void testSqrtPolar() {
         final double tol = 1e-12;
@@ -619,13 +728,20 @@ public class ComplexTest {
             double theta = 0;
             for (int j = 0; j < 11; j++) {
                 theta += pi / 12;
-                Complex z = Complex.ofPolar(r, theta);
-                Complex sqrtz = Complex.ofPolar(Math.sqrt(r), theta / 2);
+                final Complex z = Complex.ofPolar(r, theta);
+                final Complex sqrtz = Complex.ofPolar(Math.sqrt(r), theta / 2);
                 TestUtils.assertEquals(sqrtz, z.sqrt(), tol);
             }
         }
     }
 
+    @Test
+    public void testZerothRootThrows() {
+        final Complex c = Complex.ofCartesian(1, 1);
+        Assertions.assertThrows(IllegalArgumentException.class, () -> c.nthRoot(0),
+            "zeroth root should not be allowed");
+    }
+
     /**
      * Test: computing <b>third roots</b> of z.
      * <pre>
@@ -640,9 +756,9 @@ public class ComplexTest {
     @Test
     public void testNthRootNormalThirdRoot() {
         // The complex number we want to compute all third-roots for.
-        Complex z = Complex.ofCartesian(-2,2);
+        final Complex z = Complex.ofCartesian(-2, 2);
         // The List holding all third roots
-        Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]);
+        final Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]);
         // Returned Collection must not be empty!
         Assertions.assertEquals(3, thirdRootsOfZ.length);
         // test z_0
@@ -656,7 +772,6 @@ public class ComplexTest {
         Assertions.assertEquals(-1.3660254037844384,  thirdRootsOfZ[2].getImaginary(), 1.0e-5);
     }
 
-
     /**
      * Test: computing <b>fourth roots</b> of z.
      * <pre>
@@ -672,9 +787,9 @@ public class ComplexTest {
     @Test
     public void testNthRootNormalFourthRoot() {
         // The complex number we want to compute all third-roots for.
-        Complex z = Complex.ofCartesian(5,-2);
+        final Complex z = Complex.ofCartesian(5, -2);
         // The List holding all fourth roots
-        Complex[] fourthRootsOfZ = z.nthRoot(4).toArray(new Complex[0]);
+        final Complex[] fourthRootsOfZ = z.nthRoot(4).toArray(new Complex[0]);
         // Returned Collection must not be empty!
         Assertions.assertEquals(4, fourthRootsOfZ.length);
         // test z_0
@@ -706,9 +821,9 @@ public class ComplexTest {
     public void testNthRootCornercaseThirdRootImaginaryPartEmpty() {
         // The number 8 has three third roots. One we all already know is the number 2.
         // But there are two more complex roots.
-        Complex z = Complex.ofCartesian(8,0);
+        final Complex z = Complex.ofCartesian(8, 0);
         // The List holding all third roots
-        Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]);
+        final Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]);
         // Returned Collection must not be empty!
         Assertions.assertEquals(3, thirdRootsOfZ.length);
         // test z_0
@@ -737,9 +852,9 @@ public class ComplexTest {
     @Test
     public void testNthRootCornercaseThirdRootRealPartZero() {
         // complex number with only imaginary part
-        Complex z = Complex.ofCartesian(0,2);
+        final Complex z = Complex.ofCartesian(0, 2);
         // The List holding all third roots
-        Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]);
+        final Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]);
         // Returned Collection must not be empty!
         Assertions.assertEquals(3, thirdRootsOfZ.length);
         // test z_0
@@ -771,13 +886,13 @@ public class ComplexTest {
     @Test
     public void testNthRootNegativeArg() {
         // The complex number we want to compute all third-roots for.
-        Complex z = Complex.ofCartesian(1, 0);
+        final Complex z = Complex.ofCartesian(1, 0);
         // The List holding all fourth roots
         Complex[] fourthRootsOfZ = z.nthRoot(4).toArray(new Complex[0]);
         // test z_0
         Assertions.assertEquals(1,     fourthRootsOfZ[0].getReal(),      1.0e-5);
         Assertions.assertEquals(0,   fourthRootsOfZ[0].getImaginary(), 1.0e-5);
-//         test z_1
+        // test z_1
         Assertions.assertEquals(0,    fourthRootsOfZ[1].getReal(),      1.0e-5);
         Assertions.assertEquals(1,     fourthRootsOfZ[1].getImaginary(), 1.0e-5);
         // test z_2
@@ -791,7 +906,7 @@ public class ComplexTest {
         // test z_0
         Assertions.assertEquals(1,     fourthRootsOfZ[0].getReal(),      1.0e-5);
         Assertions.assertEquals(0,   fourthRootsOfZ[0].getImaginary(), 1.0e-5);
-//         test z_1
+        // test z_1
         Assertions.assertEquals(0,    fourthRootsOfZ[1].getReal(),      1.0e-5);
         Assertions.assertEquals(-1,     fourthRootsOfZ[1].getImaginary(), 1.0e-5);
         // test z_2
@@ -808,9 +923,9 @@ public class ComplexTest {
         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()));
+        for (final Complex c : r) {
+            Assertions.assertTrue(Double.isNaN(c.getReal()));
+            Assertions.assertTrue(Double.isNaN(c.getImaginary()));
         }
     }
     @Test
@@ -827,29 +942,28 @@ public class ComplexTest {
     @Test
     public void testGetArgument() {
         Complex z = Complex.ofCartesian(1, 0);
-        Assertions.assertEquals(0.0, z.getArgument(), 1.0e-12);
+        assertGetArgument(0.0, z, 1.0e-12);
 
         z = Complex.ofCartesian(1, 1);
-        Assertions.assertEquals(Math.PI/4, z.getArgument(), 1.0e-12);
+        assertGetArgument(Math.PI / 4, z, 1.0e-12);
 
         z = Complex.ofCartesian(0, 1);
-        Assertions.assertEquals(Math.PI/2, z.getArgument(), 1.0e-12);
+        assertGetArgument(Math.PI / 2, z, 1.0e-12);
 
         z = Complex.ofCartesian(-1, 1);
-        Assertions.assertEquals(3 * Math.PI/4, z.getArgument(), 1.0e-12);
+        assertGetArgument(3 * Math.PI / 4, z, 1.0e-12);
 
         z = Complex.ofCartesian(-1, 0);
-        Assertions.assertEquals(Math.PI, z.getArgument(), 1.0e-12);
+        assertGetArgument(Math.PI, z, 1.0e-12);
 
         z = Complex.ofCartesian(-1, -1);
-        Assertions.assertEquals(-3 * Math.PI/4, z.getArgument(), 1.0e-12);
+        assertGetArgument(-3 * Math.PI / 4, z, 1.0e-12);
 
         z = Complex.ofCartesian(0, -1);
-        Assertions.assertEquals(-Math.PI/2, z.getArgument(), 1.0e-12);
+        assertGetArgument(-Math.PI / 2, z, 1.0e-12);
 
         z = Complex.ofCartesian(1, -1);
-        Assertions.assertEquals(-Math.PI/4, z.getArgument(), 1.0e-12);
-
+        assertGetArgument(-Math.PI / 4, z, 1.0e-12);
     }
 
     /**
@@ -857,14 +971,14 @@ public class ComplexTest {
      */
     @Test
     public void testGetArgumentInf() {
-        Assertions.assertEquals(Math.PI/4, infInf.getArgument(), 1.0e-12);
-        Assertions.assertEquals(Math.PI/2, oneInf.getArgument(), 1.0e-12);
-        Assertions.assertEquals(0.0, infOne.getArgument(), 1.0e-12);
-        Assertions.assertEquals(Math.PI/2, zeroInf.getArgument(), 1.0e-12);
-        Assertions.assertEquals(0.0, infZero.getArgument(), 1.0e-12);
-        Assertions.assertEquals(Math.PI, negInfOne.getArgument(), 1.0e-12);
-        Assertions.assertEquals(-3.0*Math.PI/4, negInfNegInf.getArgument(), 1.0e-12);
-        Assertions.assertEquals(-Math.PI/2, oneNegInf.getArgument(), 1.0e-12);
+        assertGetArgument(Math.PI / 4, infInf, 1.0e-12);
+        assertGetArgument(Math.PI / 2, oneInf, 1.0e-12);
+        assertGetArgument(0.0, infOne, 1.0e-12);
+        assertGetArgument(Math.PI / 2, zeroInf, 1.0e-12);
+        assertGetArgument(0.0, infZero, 1.0e-12);
+        assertGetArgument(Math.PI, negInfOne, 1.0e-12);
+        assertGetArgument(-3.0 * Math.PI / 4, negInfNegInf, 1.0e-12);
+        assertGetArgument(-Math.PI / 2, oneNegInf, 1.0e-12);
     }
 
     /**
@@ -872,9 +986,15 @@ public class ComplexTest {
      */
     @Test
     public void testGetArgumentNaN() {
-        Assertions.assertTrue(Double.isNaN(nanZero.getArgument()));
-        Assertions.assertTrue(Double.isNaN(zeroNan.getArgument()));
-        Assertions.assertTrue(Double.isNaN(NAN.getArgument()));
+        assertGetArgument(Double.NaN, nanZero, 0);
+        assertGetArgument(Double.NaN, zeroNan, 0);
+        assertGetArgument(Double.NaN, NAN, 0);
+    }
+
+    private static void assertGetArgument(double expected, Complex complex, double delta) {
+        final double actual = complex.getArgument();
+        Assertions.assertEquals(expected, actual, delta);
+        Assertions.assertEquals(actual, complex.arg(), delta);
     }
 
     @Test
@@ -896,35 +1016,37 @@ public class ComplexTest {
         final String re = "1.234";
         final String im = "5.678";
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Complex.parse( re + "," + im + ")")
+            () -> Complex.parse(re + "," + im + ")")
         );
-
     }
+
     @Test
     public void testParseWrongEnd() {
         final String re = "1.234";
         final String im = "5.678";
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Complex.parse("(" + re + "," + im)
+            () -> Complex.parse("(" + re + "," + im)
         );
-
     }
+
     @Test
     public void testParseMissingSeparator() {
         final String re = "1.234";
         final String im = "5.678";
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Complex.parse("(" + re + " " + im + ")")
+            () -> Complex.parse("(" + re + " " + im + ")")
         );
     }
+
     @Test
     public void testParseInvalidRe() {
         final String re = "I.234";
         final String im = "5.678";
         Assertions.assertThrows(IllegalArgumentException.class,
-                () -> Complex.parse("(" + re + "," + im + ")")
+            () -> Complex.parse("(" + re + "," + im + ")")
         );
     }
+
     @Test
     public void testParseInvalidIm() {
         final String re = "1.234";
@@ -941,4 +1063,37 @@ public class ComplexTest {
         final String str = "(  " + re + "  , " + im + "     )";
         Assertions.assertEquals(Complex.ofCartesian(re, im), Complex.parse(str));
     }
+
+    @Test
+    public void testCGrammar() {
+        final UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64);
+        for (int i = 0; i < 10; i++) {
+            final Complex z = Complex.ofCartesian(rng.nextDouble(), rng.nextDouble());
+            Assertions.assertEquals(z.getReal(), z.real(), "real");
+            Assertions.assertEquals(z.getImaginary(), z.imag(), "imag");
+            Assertions.assertEquals(z.conjugate(), z.conj(), "conj");
+            Assertions.assertEquals(z.getArgument(), z.arg(), "arg");
+        }
+    }
+
+    @Test
+    public void testLog10() {
+        final double ln10 = Math.log(10.0);
+        final UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64);
+        for (int i = 0; i < 10; i++) {
+            final Complex z = Complex.ofCartesian(rng.nextDouble(), rng.nextDouble());
+            final Complex lnz = z.log();
+            final Complex log10z = z.log10();
+            Assertions.assertEquals(lnz.getReal() / ln10, log10z.getReal(), "real");
+            Assertions.assertEquals(lnz.getImaginary(), log10z.getImaginary(), "imag");
+        }
+    }
+
+    @Test
+    @Disabled("Required if not implemented in terms of tanh")
+    public void testTan() {
+        // Check the conditions on the imaginary component that create special results.
+        TestUtils.assertEquals(Complex.ONE, Complex.ofCartesian(0, 25).tan(), 0);
+        TestUtils.assertEquals(Complex.ofCartesian(0, -1), Complex.ofCartesian(0, -25).tan(), 0);
+    }
 }
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java
index 3fae6c5..17d7ac8 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import org.apache.commons.numbers.complex.Complex;
 import org.apache.commons.numbers.core.Precision;
 
 import org.junit.jupiter.api.Assertions;
@@ -32,7 +31,7 @@ import org.junit.jupiter.api.Assertions;
  * Test utilities.
  * TODO: Cleanup (remove unused and obsolete methods).
  */
-public class TestUtils {
+public final class TestUtils {
     /**
      * Collection of static methods used in math unit tests.
      */
@@ -41,8 +40,12 @@ public class TestUtils {
     }
 
     /**
-     * Verifies that real and imaginary parts of the two complex arguments
-     * are exactly the same.  Also ensures that NaN / infinite components match.
+     * Verifies that real and imaginary parts of the two complex arguments are exactly the
+     * same as defined by {@link Double#compare(double, double)}. Also ensures that NaN /
+     * infinite components match.
+     *
+     * @param expected the expected value
+     * @param actual the actual value
      */
     public static void assertSame(Complex expected, Complex actual) {
         Assertions.assertEquals(expected.getReal(), actual.getReal());
@@ -50,8 +53,12 @@ public class TestUtils {
     }
 
     /**
-     * Verifies that real and imaginary parts of the two complex arguments
-     * differ by at most delta.  Also ensures that NaN / infinite components match.
+     * Verifies that real and imaginary parts of the two complex arguments differ by at
+     * most delta. Also ensures that NaN / infinite components match.
+     *
+     * @param expected the expected value
+     * @param actual the actual value
+     * @param delta the delta
      */
     public static void assertEquals(Complex expected, Complex actual, double delta) {
         Assertions.assertEquals(expected.getReal(), actual.getReal(), delta);
@@ -68,17 +75,17 @@ public class TestUtils {
     public static Object serializeAndRecover(Object o) {
         try {
             // serialize the Object
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
-            ObjectOutputStream so = new ObjectOutputStream(bos);
+            final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            final ObjectOutputStream so = new ObjectOutputStream(bos);
             so.writeObject(o);
 
             // deserialize the Object
-            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-            ObjectInputStream si = new ObjectInputStream(bis);
+            final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+            final ObjectInputStream si = new ObjectInputStream(bis);
             return si.readObject();
-        } catch (IOException ioe) {
+        } catch (final IOException ioe) {
             return null;
-        } catch (ClassNotFoundException cnfe) {
+        } catch (final ClassNotFoundException cnfe) {
             return null;
         }
     }
@@ -90,7 +97,7 @@ public class TestUtils {
      * @param object  the object to serialize and recover
      */
     public static void checkSerializedEquality(Object object) {
-        Object object2 = serializeAndRecover(object);
+        final Object object2 = serializeAndRecover(object);
         Assertions.assertEquals(object, object2, "Equals check");
         Assertions.assertEquals(object.hashCode(), object2.hashCode(), "HashCode check");
     }
@@ -130,7 +137,7 @@ public class TestUtils {
         } else if (expected == 0.0) {
             Assertions.assertEquals(actual, expected, relativeError, msg);
         } else {
-            double absError = Math.abs(expected) * relativeError;
+            final double absError = Math.abs(expected) * relativeError;
             Assertions.assertEquals(expected, actual, absError, msg);
         }
     }
@@ -145,7 +152,7 @@ public class TestUtils {
      */
     public static void assertContains(String msg, Complex[] values,
                                       Complex z, double epsilon) {
-        for (Complex value : values) {
+        for (final Complex value : values) {
             if (Precision.equals(value.getReal(), z.getReal(), epsilon) &&
                 Precision.equals(value.getImaginary(), z.getImaginary(), epsilon)) {
                 return;
@@ -176,7 +183,7 @@ public class TestUtils {
      */
     public static void assertContains(String msg, double[] values,
             double x, double epsilon) {
-        for (double value : values) {
+        for (final double value : values) {
             if (Precision.equals(value, x, epsilon)) {
                 return;
             }
@@ -193,12 +200,12 @@ public class TestUtils {
      */
     public static void assertContains(double[] values, double x,
             double epsilon) {
-       assertContains(null, values, x, epsilon);
+        assertContains(null, values, x, epsilon);
     }
 
     /** verifies that two arrays are close (sup norm) */
     public static void assertEquals(String msg, Complex[] expected, Complex[] observed, double tolerance) {
-        StringBuilder out = new StringBuilder(msg);
+        final StringBuilder out = new StringBuilder(msg);
         if (expected.length != observed.length) {
             out.append("\n Arrays not same length. \n");
             out.append("expected has length ");
@@ -208,7 +215,7 @@ public class TestUtils {
             Assertions.fail(out.toString());
         }
         boolean failure = false;
-        for (int i=0; i < expected.length; i++) {
+        for (int i = 0; i < expected.length; i++) {
             if (!Precision.equalsIncludingNaN(expected[i].getReal(), observed[i].getReal(), tolerance)) {
                 failure = true;
                 out.append("\n Real elements at index ");
@@ -265,8 +272,8 @@ public class TestUtils {
             }
         }
         if (positiveMassCount < densityValues.length) {
-            int[] newPoints = new int[positiveMassCount];
-            double[] newValues = new double[positiveMassCount];
+            final int[] newPoints = new int[positiveMassCount];
+            final double[] newValues = new double[positiveMassCount];
             int j = 0;
             for (int i = 0; i < densityValues.length; i++) {
                 if (densityValues[i] > 0) {
@@ -275,8 +282,8 @@ public class TestUtils {
                     j++;
                 }
             }
-            System.arraycopy(newPoints,0,densityPoints,0,positiveMassCount);
-            System.arraycopy(newValues,0,densityValues,0,positiveMassCount);
+            System.arraycopy(newPoints, 0, densityPoints, 0, positiveMassCount);
+            System.arraycopy(newValues, 0, densityValues, 0, positiveMassCount);
         }
         return positiveMassCount;
     }


[commons-numbers] 23/32: Fixed checkstyle in core.

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

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

commit 90c8689425db98f5a36be803982e51269aa5b5e0
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 17:35:22 2019 +0000

    Fixed checkstyle in core.
---
 .../commons/numbers/core/ArithmeticUtils.java      | 21 +++----
 .../org/apache/commons/numbers/core/Precision.java | 17 +++---
 .../commons/numbers/core/ArithmeticUtilsTest.java  | 71 +++++++++++-----------
 .../apache/commons/numbers/core/PrecisionTest.java | 25 +++++---
 .../org/apache/commons/numbers/core/TestUtils.java |  8 +--
 5 files changed, 69 insertions(+), 73 deletions(-)

diff --git a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
index af72311..abb0aed 100644
--- a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
+++ b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
@@ -29,9 +29,9 @@ public final class ArithmeticUtils {
     /** Overflow gcd exception message for 2^63. */
     private static final String OVERFLOW_GCD_MESSAGE_2_POWER_63 = "overflow: gcd({0}, {1}) is 2^63";
 
-    /** Negative exponent exception message part 1 */
+    /** Negative exponent exception message part 1. */
     private static final String NEGATIVE_EXPONENT_1 = "negative exponent ({";
-    /** Negative exponent exception message part 2 */
+    /** Negative exponent exception message part 2. */
     private static final String NEGATIVE_EXPONENT_2 = "})";
 
     /** Private constructor. */
@@ -143,7 +143,7 @@ public final class ArithmeticUtils {
         long u = p;
         long v = q;
         if ((u == 0) || (v == 0)) {
-            if ((u == Long.MIN_VALUE) || (v == Long.MIN_VALUE)){
+            if ((u == Long.MIN_VALUE) || (v == Long.MIN_VALUE)) {
                 throw new NumbersArithmeticException(OVERFLOW_GCD_MESSAGE_2_POWER_63,
                                                   p, q);
             }
@@ -219,7 +219,7 @@ public final class ArithmeticUtils {
      * a non-negative {@code int} value.
      */
     public static int lcm(int a, int b) {
-        if (a == 0 || b == 0){
+        if (a == 0 || b == 0) {
             return 0;
         }
         int lcm = Math.abs(Math.multiplyExact(a / gcd(a, b), b));
@@ -252,11 +252,11 @@ public final class ArithmeticUtils {
      * as a non-negative {@code long} value.
      */
     public static long lcm(long a, long b) {
-        if (a == 0 || b == 0){
+        if (a == 0 || b == 0) {
             return 0;
         }
         long lcm = Math.abs(Math.multiplyExact(a / gcd(a, b), b));
-        if (lcm == Long.MIN_VALUE){
+        if (lcm == Long.MIN_VALUE) {
             throw new NumbersArithmeticException("overflow: lcm({0}, {1}) is 2^63",
                                               a, b);
         }
@@ -540,20 +540,13 @@ public final class ArithmeticUtils {
         private static final long serialVersionUID = 20180130L;
 
         /**
-         * Default constructor.
-         */
-        NumbersArithmeticException() {
-            this("arithmetic exception");
-        }
-
-        /**
          * Constructor with a specific message.
          *
          * @param message Message pattern providing the specific context of
          * the error.
          * @param args Arguments.
          */
-        NumbersArithmeticException(String message, Object ... args) {
+        NumbersArithmeticException(String message, Object... args) {
             super(MessageFormat.format(message, args));
         }
     }
diff --git a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
index 69c0f01..9a3ecb2 100644
--- a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
+++ b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
@@ -23,7 +23,7 @@ import java.math.RoundingMode;
 /**
  * Utilities for comparing numbers.
  */
-public class Precision {
+public final class Precision {
     /**
      * <p>
      * Largest double-precision floating-point number such that
@@ -47,7 +47,7 @@ public class Precision {
     public static final double SAFE_MIN;
 
     /** Exponent offset in IEEE754 representation. */
-    private static final long EXPONENT_OFFSET = 1023l;
+    private static final long EXPONENT_OFFSET = 1023L;
 
     /** Offset to order signed double numbers lexicographically. */
     private static final long SGN_MASK = 0x8000000000000000L;
@@ -66,18 +66,18 @@ public class Precision {
 
     static {
         /*
-         *  This was previously expressed as = 0x1.0p-53;
+         *  This was previously expressed as = 0x1.0p-53
          *  However, OpenJDK (Sparc Solaris) cannot handle such small
          *  constants: MATH-721
          */
-        EPSILON = Double.longBitsToDouble((EXPONENT_OFFSET - 53l) << 52);
+        EPSILON = Double.longBitsToDouble((EXPONENT_OFFSET - 53L) << 52);
 
         /*
-         * This was previously expressed as = 0x1.0p-1022;
+         * This was previously expressed as = 0x1.0p-1022
          * However, OpenJDK (Sparc Solaris) cannot handle such small
          * constants: MATH-721
          */
-        SAFE_MIN = Double.longBitsToDouble((EXPONENT_OFFSET - 1022l) << 52);
+        SAFE_MIN = Double.longBitsToDouble((EXPONENT_OFFSET - 1022L) << 52);
     }
 
     /**
@@ -387,7 +387,7 @@ public class Precision {
         final long yInt = Double.doubleToRawLongBits(y);
 
         final boolean isEqual;
-        if (((xInt ^ yInt) & SGN_MASK) == 0l) {
+        if (((xInt ^ yInt) & SGN_MASK) == 0L) {
             // number have same sign, there is no risk of overflow
             isEqual = Math.abs(xInt - yInt) <= maxUlps;
         } else {
@@ -472,9 +472,8 @@ public class Precision {
         } catch (NumberFormatException ex) {
             if (Double.isInfinite(x)) {
                 return x;
-            } else {
-                return Double.NaN;
             }
+            return Double.NaN;
         }
     }
 
diff --git a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
index fe0ce08..fbeb78e 100644
--- a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
+++ b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
@@ -52,11 +52,11 @@ public class ArithmeticUtilsTest {
         Assertions.assertEquals(1, ArithmeticUtils.gcd(a, -c));
         Assertions.assertEquals(1, ArithmeticUtils.gcd(-a, -c));
 
-        Assertions.assertEquals(3 * (1<<15), ArithmeticUtils.gcd(3 * (1<<20), 9 * (1<<15)));
+        Assertions.assertEquals(3 * (1 << 15), ArithmeticUtils.gcd(3 * (1 << 20), 9 * (1 << 15)));
 
         Assertions.assertEquals(Integer.MAX_VALUE, ArithmeticUtils.gcd(Integer.MAX_VALUE, 0));
         Assertions.assertEquals(Integer.MAX_VALUE, ArithmeticUtils.gcd(-Integer.MAX_VALUE, 0));
-        Assertions.assertEquals(1<<30, ArithmeticUtils.gcd(1<<30, -Integer.MIN_VALUE));
+        Assertions.assertEquals(1 << 30, ArithmeticUtils.gcd(1 << 30, -Integer.MIN_VALUE));
         try {
             // gcd(Integer.MIN_VALUE, 0) > Integer.MAX_VALUE
             ArithmeticUtils.gcd(Integer.MIN_VALUE, 0);
@@ -102,7 +102,7 @@ public class ArithmeticUtilsTest {
     }
 
     @Test
-    public void  testGcdLong(){
+    public void  testGcdLong() {
         long a = 30;
         long b = 50;
         long c = 77;
@@ -124,9 +124,9 @@ public class ArithmeticUtilsTest {
         Assertions.assertEquals(1, ArithmeticUtils.gcd(a, -c));
         Assertions.assertEquals(1, ArithmeticUtils.gcd(-a, -c));
 
-        Assertions.assertEquals(3L * (1L<<45), ArithmeticUtils.gcd(3L * (1L<<50), 9L * (1L<<45)));
+        Assertions.assertEquals(3L * (1L << 45), ArithmeticUtils.gcd(3L * (1L << 50), 9L * (1L << 45)));
 
-        Assertions.assertEquals(1L<<45, ArithmeticUtils.gcd(1L<<45, Long.MIN_VALUE));
+        Assertions.assertEquals(1L << 45, ArithmeticUtils.gcd(1L << 45, Long.MIN_VALUE));
 
         Assertions.assertEquals(Long.MAX_VALUE, ArithmeticUtils.gcd(Long.MAX_VALUE, 0L));
         Assertions.assertEquals(Long.MAX_VALUE, ArithmeticUtils.gcd(-Long.MAX_VALUE, 0L));
@@ -173,7 +173,7 @@ public class ArithmeticUtilsTest {
 
         // Assert that no intermediate value overflows:
         // The naive implementation of lcm(a,b) would be (a*b)/gcd(a,b)
-        Assertions.assertEquals((1<<20)*15, ArithmeticUtils.lcm((1<<20)*3, (1<<20)*5));
+        Assertions.assertEquals((1 << 20) * 15, ArithmeticUtils.lcm((1 << 20) * 3, (1 << 20) * 5));
 
         // Special case
         Assertions.assertEquals(0, ArithmeticUtils.lcm(0, 0));
@@ -188,7 +188,7 @@ public class ArithmeticUtilsTest {
 
         try {
             // lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int
-            ArithmeticUtils.lcm(Integer.MIN_VALUE, 1<<20);
+            ArithmeticUtils.lcm(Integer.MIN_VALUE, 1 << 20);
             Assertions.fail("Expecting ArithmeticException");
         } catch (ArithmeticException expected) {
             // expected
@@ -222,7 +222,7 @@ public class ArithmeticUtilsTest {
 
         // Assert that no intermediate value overflows:
         // The naive implementation of lcm(a,b) would be (a*b)/gcd(a,b)
-        Assertions.assertEquals((1L<<50)*15, ArithmeticUtils.lcm((1L<<45)*3, (1L<<50)*5));
+        Assertions.assertEquals((1L << 50) * 15, ArithmeticUtils.lcm((1L << 45) * 3, (1L << 50) * 5));
 
         // Special case
         Assertions.assertEquals(0L, ArithmeticUtils.lcm(0L, 0L));
@@ -237,7 +237,7 @@ public class ArithmeticUtilsTest {
 
         try {
             // lcm == abs(MIN_VALUE) cannot be represented as a nonnegative int
-            ArithmeticUtils.lcm(Long.MIN_VALUE, 1<<20);
+            ArithmeticUtils.lcm(Long.MIN_VALUE, 1 << 20);
             Assertions.fail("Expecting ArithmeticException");
         } catch (ArithmeticException expected) {
             // expected
@@ -274,17 +274,17 @@ public class ArithmeticUtilsTest {
             // expected behavior
         }
 
-        Assertions.assertEquals(1801088541l, ArithmeticUtils.pow(21l, 7));
-        Assertions.assertEquals(1l, ArithmeticUtils.pow(21l, 0));
+        Assertions.assertEquals(1801088541L, ArithmeticUtils.pow(21L, 7));
+        Assertions.assertEquals(1L, ArithmeticUtils.pow(21L, 0));
         try {
-            ArithmeticUtils.pow(21l, -7);
+            ArithmeticUtils.pow(21L, -7);
             Assertions.fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // expected behavior
         }
 
-        BigInteger twentyOne = BigInteger.valueOf(21l);
-        Assertions.assertEquals(BigInteger.valueOf(1801088541l), ArithmeticUtils.pow(twentyOne, 7));
+        BigInteger twentyOne = BigInteger.valueOf(21L);
+        Assertions.assertEquals(BigInteger.valueOf(1801088541L), ArithmeticUtils.pow(twentyOne, 7));
         Assertions.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, 0));
         try {
             ArithmeticUtils.pow(twentyOne, -7);
@@ -293,19 +293,19 @@ public class ArithmeticUtilsTest {
             // expected behavior
         }
 
-        Assertions.assertEquals(BigInteger.valueOf(1801088541l), ArithmeticUtils.pow(twentyOne, 7l));
-        Assertions.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, 0l));
+        Assertions.assertEquals(BigInteger.valueOf(1801088541L), ArithmeticUtils.pow(twentyOne, 7L));
+        Assertions.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, 0L));
         try {
-            ArithmeticUtils.pow(twentyOne, -7l);
+            ArithmeticUtils.pow(twentyOne, -7L);
             Assertions.fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // expected behavior
         }
 
-        Assertions.assertEquals(BigInteger.valueOf(1801088541l), ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(7l)));
+        Assertions.assertEquals(BigInteger.valueOf(1801088541L), ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(7L)));
         Assertions.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, BigInteger.ZERO));
         try {
-            ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(-7l));
+            ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(-7L));
             Assertions.fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // expected behavior
@@ -316,15 +316,15 @@ public class ArithmeticUtilsTest {
                            "4763915343722775611762713982220306372888519211" +
                            "560905579993523402015636025177602059044911261");
         Assertions.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, 103));
-        Assertions.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, 103l));
-        Assertions.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(103l)));
+        Assertions.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, 103L));
+        Assertions.assertEquals(bigOne, ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(103L)));
 
     }
 
     @Test
     public void testPowIntOverflow() {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> ArithmeticUtils.pow(21, 8)
+            () -> ArithmeticUtils.pow(21, 8)
         );
     }
 
@@ -341,7 +341,7 @@ public class ArithmeticUtilsTest {
     @Test
     public void testPowNegativeIntOverflow() {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> ArithmeticUtils.pow(-21, 8)
+            () -> ArithmeticUtils.pow(-21, 8)
         );
     }
 
@@ -374,10 +374,9 @@ public class ArithmeticUtilsTest {
     }
 
     @Test
-    public void testPowLongOverflow()
-    {
+    public void testPowLongOverflow() {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> ArithmeticUtils.pow(21, 15)
+            () -> ArithmeticUtils.pow(21, 15)
         );
     }
 
@@ -394,7 +393,7 @@ public class ArithmeticUtilsTest {
     @Test
     public void testPowNegativeLongOverflow() {
         Assertions.assertThrows(ArithmeticException.class,
-                () -> ArithmeticUtils.pow(-21L, 15)
+            () -> ArithmeticUtils.pow(-21L, 15)
         );
     }
 
@@ -450,7 +449,7 @@ public class ArithmeticUtilsTest {
      * </ul>
      */
     private static int[] getIntSpecialCases() {
-        int ints[] = new int[100];
+        int[] ints = new int[100];
         int i = 0;
         ints[i++] = Integer.MAX_VALUE;
         ints[i++] = Integer.MAX_VALUE - 1;
@@ -484,7 +483,7 @@ public class ArithmeticUtilsTest {
      * </ul>
      */
     private static long[] getLongSpecialCases() {
-        long longs[] = new long[100];
+        long[] longs = new long[100];
         int i = 0;
         longs[i++] = Long.MAX_VALUE;
         longs[i++] = Long.MAX_VALUE - 1L;
@@ -541,12 +540,12 @@ public class ArithmeticUtilsTest {
 
     @Test
     public void testRemainderUnsignedIntSpecialCases() {
-        int ints[] = getIntSpecialCases();
+        int[] ints = getIntSpecialCases();
         for (int dividend : ints) {
             for (int divisor : ints) {
                 if (divisor == 0) {
                     Assertions.assertThrows(ArithmeticException.class,
-                            () -> ArithmeticUtils.remainderUnsigned(dividend, divisor)
+                        () -> ArithmeticUtils.remainderUnsigned(dividend, divisor)
                     );
                 } else {
                     Assertions.assertEquals(remainderUnsignedExpected(dividend, divisor), ArithmeticUtils.remainderUnsigned(dividend, divisor));
@@ -562,7 +561,7 @@ public class ArithmeticUtilsTest {
 
     @Test
     public void testRemainderUnsignedLongSpecialCases() {
-        long longs[] = getLongSpecialCases();
+        long[] longs = getLongSpecialCases();
         for (long dividend : longs) {
             for (long divisor : longs) {
                 if (divisor == 0L) {
@@ -595,12 +594,12 @@ public class ArithmeticUtilsTest {
 
     @Test
     public void testDivideUnsignedIntSpecialCases() {
-        int ints[] = getIntSpecialCases();
+        int[] ints = getIntSpecialCases();
         for (int dividend : ints) {
             for (int divisor : ints) {
                 if (divisor == 0) {
                     Assertions.assertThrows(ArithmeticException.class,
-                            () -> ArithmeticUtils.divideUnsigned(dividend, divisor)
+                        () -> ArithmeticUtils.divideUnsigned(dividend, divisor)
                     );
                 } else {
                     Assertions.assertEquals(divideUnsignedExpected(dividend, divisor), ArithmeticUtils.divideUnsigned(dividend, divisor));
@@ -616,12 +615,12 @@ public class ArithmeticUtilsTest {
 
     @Test
     public void testDivideUnsignedLongSpecialCases() {
-        long longs[] = getLongSpecialCases();
+        long[] longs = getLongSpecialCases();
         for (long dividend : longs) {
             for (long divisor : longs) {
                 if (divisor == 0L) {
                     Assertions.assertThrows(ArithmeticException.class,
-                            () -> ArithmeticUtils.divideUnsigned(dividend, divisor)
+                        () -> ArithmeticUtils.divideUnsigned(dividend, divisor)
                     );
                 } else {
                     Assertions.assertEquals(divideUnsignedExpected(dividend, divisor), ArithmeticUtils.divideUnsigned(dividend, divisor));
diff --git a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
index dc231bf..288f3c4 100644
--- a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
+++ b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
@@ -1,15 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
- * or agreed to in writing, software distributed under the License is
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.commons.numbers.core;
 
@@ -247,6 +250,7 @@ public class PrecisionTest {
 
     @Test
     public void testCompareToMaxUlps() {
+        // CHECKSTYLE: stop ParenPad
         double a     = 152.32;
         double delta = Math.ulp(a);
         for (int i = 0; i <= 10; ++i) {
@@ -280,6 +284,7 @@ public class PrecisionTest {
 
         Assertions.assertEquals(+1, Precision.compareTo(Double.MAX_VALUE, Double.NaN, Integer.MAX_VALUE));
         Assertions.assertEquals(+1, Precision.compareTo(Double.NaN, Double.MAX_VALUE, Integer.MAX_VALUE));
+        // CHECKSTYLE: resume ParenPad
     }
 
     @Test
diff --git a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/TestUtils.java b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/TestUtils.java
index b343f36..2d01f9c 100644
--- a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/TestUtils.java
+++ b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/TestUtils.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Assertions;
  * Test utilities.
  * TODO: Cleanup (remove unused and obsolete methods).
  */
-public class TestUtils {
+public final class TestUtils {
     /**
      * Collection of static methods used in math unit tests.
      */
@@ -141,7 +141,7 @@ public class TestUtils {
      */
     public static void assertContains(double[] values, double x,
             double epsilon) {
-       assertContains(null, values, x, epsilon);
+        assertContains(null, values, x, epsilon);
     }
 
     /**
@@ -184,8 +184,8 @@ public class TestUtils {
                     j++;
                 }
             }
-            System.arraycopy(newPoints,0,densityPoints,0,positiveMassCount);
-            System.arraycopy(newValues,0,densityValues,0,positiveMassCount);
+            System.arraycopy(newPoints, 0, densityPoints, 0, positiveMassCount);
+            System.arraycopy(newValues, 0, densityValues, 0, positiveMassCount);
         }
         return positiveMassCount;
     }


[commons-numbers] 06/32: Update checkstyle configuration.

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

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

commit 397d1a3e040a99a517aad8f4f57c593f02730edc
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Nov 6 22:39:30 2019 +0000

    Update checkstyle configuration.
---
 pom.xml                                            |  22 ++
 .../checkstyle/checkstyle-suppressions.xml         |  28 ++
 src/main/resources/checkstyle/checkstyle.xml       | 291 +++++++++++++--------
 3 files changed, 226 insertions(+), 115 deletions(-)

diff --git a/pom.xml b/pom.xml
index 34a1f04..9958e8c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,7 @@
     <maven.compiler.target>1.8</maven.compiler.target>
     <numbers.pmd.version>3.9.0</numbers.pmd.version>
     <numbers.checkstyle.version>3.0.0</numbers.checkstyle.version>
+    <numbers.checkstyle.dep.version>8.20</numbers.checkstyle.dep.version>
     <numbers.mathjax.version>2.7.2</numbers.mathjax.version>
     <numbers.junit.bom.version>5.4.2</numbers.junit.bom.version>
     <numbers.commons.math3.version>3.6.1</numbers.commons.math3.version>
@@ -231,6 +232,25 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${numbers.checkstyle.version}</version>
+        <dependencies>
+          <dependency>
+            <groupId>com.puppycrawl.tools</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>${numbers.checkstyle.dep.version}</version>
+          </dependency>
+        </dependencies>
+        <configuration>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <configLocation>${numbers.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation>
+          <headerLocation>${numbers.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation>
+          <suppressionsLocation>${numbers.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
+          <enableRulesSummary>false</enableRulesSummary>
+          <logViolationsToConsole>false</logViolationsToConsole>
+          <failOnViolation>true</failOnViolation>
+          <resourceExcludes>NOTICE.txt,LICENSE.txt,**/maven-archiver/pom.properties,**/resolver-status.properties</resourceExcludes>
+          <excludes>**/generated/**.java</excludes>
+        </configuration>
         <executions>
           <execution>
             <id>validate</id>
@@ -369,8 +389,10 @@
         <configuration>
           <configLocation>${numbers.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation>
           <headerLocation>${numbers.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation>
+          <suppressionsLocation>${numbers.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
           <enableRulesSummary>false</enableRulesSummary>
           <includeResources>false</includeResources>
+          <excludes>**/generated/**.java</excludes>
         </configuration>
         <reportSets>
           <reportSet>
diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml
new file mode 100644
index 0000000..89acf69
--- /dev/null
+++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<!DOCTYPE suppressions PUBLIC
+    "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
+    "https://checkstyle.org/dtds/suppressions_1_2.dtd">
+<suppressions>
+  <!-- Be more lenient on tests. -->
+  <suppress checks="Javadoc" files=".*[/\\]test[/\\].*" />
+  <suppress checks="MultipleStringLiterals" files=".*[/\\]test[/\\].*" />
+  <suppress checks="DesignForExtension" files=".*[/\\]test[/\\].*" />
+  <suppress checks="LineLength" files=".*[/\\]test[/\\].*" />
+  <suppress checks="IllegalCatch" files=".*[/\\]test[/\\].*" />
+</suppressions>
diff --git a/src/main/resources/checkstyle/checkstyle.xml b/src/main/resources/checkstyle/checkstyle.xml
index a138af6..68f301e 100644
--- a/src/main/resources/checkstyle/checkstyle.xml
+++ b/src/main/resources/checkstyle/checkstyle.xml
@@ -17,86 +17,205 @@
    limitations under the License.
   -->
 
-<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
-
-<!-- Commons RNG customization of default Checkstyle behavior -->
+<!DOCTYPE module PUBLIC
+          "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
+          "https://checkstyle.org/dtds/configuration_1_3.dtd">
+
+<!-- 
+  Commons RNG customization of default Checkstyle behaviour:
+  https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/sun_checks.xml
+-->
 <module name="Checker">
+  <module name="SuppressionFilter">
+    <!-- Default property set by maven-checkstyle-plugin -->
+    <property name="file" value="${checkstyle.suppressions.file}"/>
+    <property name="optional" value="false"/>
+  </module>
+
   <property name="localeLanguage" value="en"/>
 
-  <module name="TreeWalker">
+  <property name="fileExtensions" value="java, properties, xml" />
 
-    <!-- Operator must be at end of wrapped line -->
-    <module name="OperatorWrap">
-      <property name="option" value="eol"/>
-    </module>
+  <!-- Excludes all 'module-info.java' files -->
+  <!-- See https://checkstyle.org/config_filefilters.html -->
+  <module name="BeforeExecutionExclusionFileFilter">
+    <property name="fileNamePattern" value="module\-info\.java$" />
+  </module>
 
-    <!-- No if/else/do/for/while without braces -->
-    <module name="NeedBraces"/>
+  <!-- Checks that a package-info.java file exists for each package. -->
+  <!-- See http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage -->
+  <module name="JavadocPackage" />
+
+  <!-- Checks whether files end with a new line. -->
+  <!-- See http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile -->
+  <module name="NewlineAtEndOfFile" />
+
+  <!-- Checks that property files contain the same keys. -->
+  <!-- See http://checkstyle.sourceforge.net/config_misc.html#Translation -->
+  <module name="Translation" />
+
+  <!-- Checks for Size Violations. -->
+  <!-- See http://checkstyle.sourceforge.net/config_sizes.html -->
+  <module name="FileLength" />
+
+  <!-- Checks for whitespace -->
+  <!-- See http://checkstyle.sourceforge.net/config_whitespace.html -->
+  <module name="FileTabCharacter" />
+
+  <!-- Miscellaneous other checks. -->
+  <!-- See http://checkstyle.sourceforge.net/config_misc.html -->
+  <module name="RegexpSingleline">
+    <property name="format" value="\s+$" />
+    <property name="minimum" value="0" />
+    <property name="maximum" value="0" />
+    <property name="message" value="Line has trailing spaces." />
+  </module>
 
-    <!-- Interfaces must be types (not just constants) -->
-    <module name="InterfaceIsType"/>
+  <!-- Checks for Headers -->
+  <!-- See http://checkstyle.sourceforge.net/config_header.html -->
+  <module name="Header">
+    <property name="headerFile" value="${checkstyle.header.file}"/>
+  </module>
 
-    <!-- Must have class / interface header comments -->
-    <module name="JavadocType"/>
+  <module name="TreeWalker">
 
-     <!-- Require method javadocs, allow undeclared RTE -->
+    <!-- Checks for Javadoc comments. -->
+    <!-- See http://checkstyle.sourceforge.net/config_javadoc.html -->
+    <!-- Require method javadocs, allow undeclared RTE -->
     <module name="JavadocMethod">
       <property name="allowUndeclaredRTE" value="true"/>
       <property name="allowThrowsTagsForSubclasses" value="true"/>
       <property name="validateThrows" value="false"/>
     </module>
+    <module name="JavadocType" />
+    <module name="JavadocVariable" />
+    <module name="JavadocStyle" />
+    <!-- <module name="MissingJavadocType"/> -->
 
-    <!-- Require field javadoc -->
-    <module name="JavadocVariable"/>
+    <!-- Checks for Naming Conventions. -->
+    <!-- See http://checkstyle.sourceforge.net/config_naming.html -->
+    <module name="ConstantName" />
+    <module name="LocalFinalVariableName" />
+    <module name="LocalVariableName" />
+    <module name="MemberName" />
+    <module name="MethodName" />
+    <module name="PackageName" />
+    <module name="ParameterName" />
+    <module name="StaticVariableName" />
+    <module name="TypeName" />
+
+    <!-- Checks for imports -->
+    <!-- See http://checkstyle.sourceforge.net/config_import.html -->
+    <module name="AvoidStarImport" />
+    <module name="IllegalImport" /> <!-- defaults to sun.* packages -->
+    <module name="RedundantImport" />
+    <module name="UnusedImports">
+      <property name="processJavadoc" value="false" />
+    </module>
 
-    <!-- No public fields -->
-    <module name="VisibilityModifier">
-       <property name="protectedAllowed" value="true"/>
+    <!-- Checks for Size Violations. -->
+    <!-- See http://checkstyle.sourceforge.net/config_sizes.html -->
+    <module name="LineLength">
+      <!-- Ignore lines that begin with " * ", such as within a Javadoc comment. -->
+      <property name="ignorePattern" value="^ *\* *[^ ]"/>
+      <property name="max" value="120"/>
+    </module>
+    <module name="MethodLength" />
+    <module name="ParameterNumber" />
+
+    <!-- Checks for whitespace -->
+    <!-- See http://checkstyle.sourceforge.net/config_whitespace.html -->
+    <module name="EmptyForIteratorPad" />
+    <module name="GenericWhitespace" />
+    <module name="MethodParamPad" />
+    <module name="NoWhitespaceAfter" />
+    <module name="NoWhitespaceBefore" />
+    <!-- Operator must be at end of wrapped line -->
+    <module name="OperatorWrap">
+      <property name="option" value="eol"/>
+    </module>
+    <module name="ParenPad" />
+    <module name="TypecastParenPad" />
+    <module name="WhitespaceAfter">
+      <property name="tokens" value="COMMA, SEMI, LITERAL_IF, LITERAL_ELSE, LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, DO_WHILE"/>
+    </module>
+    <module name="WhitespaceAround">
+      <property name="allowEmptyConstructors" value="true"/>
+      <property name="allowEmptyTypes" value="true"/>
     </module>
 
-    <!-- Require hash code override when equals is -->
-    <module name="EqualsHashCode"/>
+    <!-- Modifier Checks -->
+    <!-- See http://checkstyle.sourceforge.net/config_modifiers.html -->
+    <module name="ModifierOrder" />
+    <module name="RedundantModifier" />
 
+    <!-- Checks for blocks. You know, those {}'s -->
+    <!-- See http://checkstyle.sourceforge.net/config_blocks.html -->
+    <module name="AvoidNestedBlocks" />
+    <module name="EmptyBlock" />
+    <module name="LeftCurly" />
+    <module name="NeedBraces" />
+    <module name="RightCurly" />
+
+    <!-- Checks for common coding problems -->
+    <!-- See http://checkstyle.sourceforge.net/config_coding.html -->
+    <module name="EmptyStatement" />
+    <module name="EqualsHashCode" />
+    <!-- Method parameters and local variables should not hide fields, except in constructors and setters -->
+    <module name="HiddenField">
+        <property name="ignoreConstructorParameter" value="true" />
+        <property name="ignoreSetter" value="true" />
+    </module>
     <!-- Disallow unnecessary instantiation of Boolean, String -->
     <module name="IllegalInstantiation">
       <property name="classes" value="java.lang.Boolean, java.lang.String"/>
     </module>
+    <!-- Allowed for algorithm implementations. -->
+    <!-- <module name="InnerAssignment" /> -->
+    <!-- <module name="MagicNumber" /> -->
+    <module name="MissingSwitchDefault" />
+    <module name="MultipleVariableDeclarations" />
+    <module name="SimplifyBooleanExpression" />
+    <module name="SimplifyBooleanReturn" />
+
+    <!-- Checks for class design -->
+    <!-- See http://checkstyle.sourceforge.net/config_design.html -->
+    <module name="DesignForExtension" />
+    <module name="FinalClass" />
+    <module name="HideUtilityClassConstructor" />
+    <module name="InterfaceIsType" />
+    <!-- No public fields -->
+    <module name="VisibilityModifier">
+       <property name="protectedAllowed" value="true"/>
+    </module>
 
-    <!-- Required for SuppressionCommentFilter below -->
-    <module name="FileContentsHolder"/>
+    <!-- Miscellaneous other checks. -->
+    <!-- See http://checkstyle.sourceforge.net/config_misc.html -->
+    <module name="ArrayTypeStyle" />
+    <!-- <module name="FinalParameters" />  -->
+    <module name="TodoComment">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="UpperEll" />
 
-    <!--  Import should be explicit, really needed and only from pure java packages -->
-    <module name="AvoidStarImport" />
-    <module name="UnusedImports" />
-    <module name="IllegalImport" />
+    <!-- Addition to Checkstyle sun_checks.xml  -->
 
-    <!-- Utility class should not be instantiated, they must have a private constructor -->
-    <module name="HideUtilityClassConstructor" />
+    <!-- Indentation of 4 spaces. -->
+    <module name="Indentation">
+      <!-- Indentation style recommended by Oracle -->
+      <property name="caseIndent" value="0"/>
+    </module>
 
-    <!-- Switch statements should be complete and with independent cases -->
+    <!-- Switch statements should have independent cases -->
     <module name="FallThrough" />
-    <module name="MissingSwitchDefault" />
 
     <!-- Constant names should obey the traditional all uppercase naming convention -->
     <module name="ConstantName" />
 
-    <!-- Method parameters and local variables should not hide fields, except in constructors and setters -->
-    <module name="HiddenField">
-        <property name="ignoreConstructorParameter" value="true" />
-        <property name="ignoreSetter" value="true" />
-    </module>
-
-    <!-- No trailing whitespace -->
-    <module name="Regexp">
-      <property name="format" value="[ \t]+$"/>
-      <property name="illegalPattern" value="true"/>
-      <property name="message" value="Trailing whitespace"/>
-    </module>
-
     <!-- No System.out.println() statements -->
     <module name="Regexp">
       <!-- no sysouts -->
-      <property name="format" value="System\.out\.println"/>
+      <property name="format" value="System\.(out|err)\."/>
       <property name="illegalPattern" value="true"/>
     </module>
 
@@ -104,13 +223,9 @@
     <module name="Regexp">
       <property name="format" value="@author"/>
       <property name="illegalPattern" value="true"/>
-      <property name="message" value="developers names should be in pom file"/>
+      <property name="message" value="Developers names should be in pom file"/>
     </module>
 
-    <!-- Use a consistent way to put modifiers -->
-    <module name="RedundantModifier" />
-    <module name="ModifierOrder" />
-
     <!-- Use a consistent way to put declarations -->
     <module name="DeclarationOrder" />
 
@@ -123,9 +238,6 @@
     <!-- Don't use = or != for string comparisons -->
     <module name="StringLiteralEquality" />
 
-   <!-- Don't declare multiple variables in the same statement -->
-    <module name="MultipleVariableDeclarations" />
-
     <!-- String literals more than one character long should not be repeated several times -->
     <!-- the "unchecked" string is also accepted to allow @SuppressWarnings("unchecked") -->
     <module name="MultipleStringLiterals" >
@@ -135,68 +247,17 @@
     <!-- Check if @Override tags are present  -->
     <module name="MissingOverride" />
 
-    <!-- <module name="TodoComment" /> -->
-
-  </module>
+    <!-- Setup special comments to suppress specific checks from source files -->
+    <module name="SuppressionCommentFilter">
+      <property name="offCommentFormat" value="CHECKSTYLE\: stop ([\w\|]+)"/>
+      <property name="onCommentFormat"  value="CHECKSTYLE\: resume ([\w\|]+)"/>
+      <property name="checkFormat"      value="$1"/>
+    </module>
+    <module name="SuppressionCommentFilter">
+      <property name="offCommentFormat" value="CHECKSTYLE\: stop all"/>
+      <property name="onCommentFormat"  value="CHECKSTYLE\: resume all"/>
+    </module>
 
-  <!-- Verify that EVERY source file has the appropriate license -->
-  <module name="Header">
-    <property name="headerFile" value="${checkstyle.header.file}"/>
   </module>
 
-  <!-- No tabs allowed! -->
-  <module name="FileTabCharacter"/>
-
-  <!-- Require files to end with newline characters -->
-  <module name="NewlineAtEndOfFile"/>
-
-  <!-- Require package javadoc -->
-  <module name="JavadocPackage"/>
-
-  <!-- Setup special comments to suppress specific checks from source files -->
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop JavadocVariable"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume JavadocVariable"/>
-    <property name="checkFormat"      value="JavadocVariable"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop JavadocMethodCheck"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume JavadocMethodCheck"/>
-    <property name="checkFormat"      value="JavadocMethodCheck"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop ConstantName"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume ConstantName"/>
-    <property name="checkFormat"      value="ConstantName"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop HideUtilityClassConstructor"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume HideUtilityClassConstructor"/>
-    <property name="checkFormat"      value="HideUtilityClassConstructor"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop MultipleVariableDeclarations"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume MultipleVariableDeclarations"/>
-    <property name="checkFormat"      value="MultipleVariableDeclarations"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop IllegalCatch"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume IllegalCatch"/>
-    <property name="checkFormat"      value="IllegalCatch"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop DeclarationOrder"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume DeclarationOrder"/>
-    <property name="checkFormat"      value="DeclarationOrder"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop RedundantModifier"/>
-    <property name="onCommentFormat"  value="CHECKSTYLE\: resume RedundantModifier"/>
-    <property name="checkFormat"      value="RedundantModifier"/>
-  </module>
-  <module name="SuppressionCommentFilter">
-    <property name="offCommentFormat" value="CHECKSTYLE\: stop all"/>
-    <property name="onCommentFormat" value="CHECKSTYLE\: resume all"/>
-  </module>
 </module>
-


[commons-numbers] 28/32: Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-numbers

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

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

commit eb10d9f59ec16ea088613a8ffb6f01f2cb650c49
Merge: 5326c6a 1e9d978
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Nov 8 18:00:20 2019 +0000

    Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-numbers

 .../commons/numbers/fraction/BigFraction.java      | 26 +---------------------
 .../apache/commons/numbers/fraction/Fraction.java  | 13 +----------
 2 files changed, 2 insertions(+), 37 deletions(-)