You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2018/01/30 15:39:35 UTC

[1/6] commons-numbers git commit: NUMBERS-55: Fixed "hashCode".

Repository: commons-numbers
Updated Branches:
  refs/heads/master 6caed7450 -> d011f8be2


NUMBERS-55: Fixed "hashCode".


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/b2d22678
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/b2d22678
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/b2d22678

Branch: refs/heads/master
Commit: b2d226785278777545ed72b1c55146ea5de5b4b8
Parents: 6caed74
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:34:06 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:34:06 2018 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/commons/numbers/complex/Complex.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/b2d22678/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index ac08732..281822b 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
@@ -486,8 +486,7 @@ public class Complex implements Serializable  {
         if (Double.isNaN(real) || Double.isNaN(imaginary)) {
             return 7;
         }
-        return 37 * 17 * (hash(imaginary) +
-            hash(real));
+        return 37 * (17 * hash(imaginary) + hash(real));
     }
 
     private int hash(double d) {


[6/6] commons-numbers git commit: CheckStyle.

Posted by er...@apache.org.
CheckStyle.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/d011f8be
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/d011f8be
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/d011f8be

Branch: refs/heads/master
Commit: d011f8be2a166e49ebb496a254fff4d74060f818
Parents: 590010c
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 16:38:48 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 16:38:48 2018 +0100

----------------------------------------------------------------------
 .../commons/numbers/core/ArithmeticUtils.java   | 14 +++++++++-----
 .../numbers/fraction/FractionException.java     |  1 +
 .../apache/commons/numbers/gamma/Digamma.java   |  4 ++--
 .../apache/commons/numbers/gamma/LogBeta.java   |  2 +-
 .../apache/commons/numbers/gamma/LogGamma.java  |  1 +
 .../commons/numbers/gamma/RegularizedGamma.java | 20 ++++++++++++++++----
 6 files changed, 30 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
----------------------------------------------------------------------
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 13055f2..36a84f5 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
@@ -603,7 +603,7 @@ public final class ArithmeticUtils {
      *
      * @param a Addend.
      * @param b Addend.
-     * @param pattern Pattern to use for any thrown exception.
+     * @param message Pattern to use for any thrown exception.
      * @return the sum {@code a + b}.
      * @throws ArithmeticException if the result cannot be represented
      * as a {@code long}.
@@ -748,16 +748,19 @@ public final class ArithmeticUtils {
         return dividend >= 0L || dividend < divisor ? 0L : 1L;
     }
 
+    /**
+     * Exception.
+     */
     private static class NumbersArithmeticException extends ArithmeticException {
         /** Serializable version Id. */
-        private static final long serialVersionUID = -6024911025449780474L;
-
+        private static final long serialVersionUID = 20180130L;
+        /** Argument to construct a message. */
         private final Object[] formatArguments;
 
         /**
          * Default constructor.
          */
-        public NumbersArithmeticException() {
+        NumbersArithmeticException() {
             this("arithmetic exception");
         }
 
@@ -768,11 +771,12 @@ public final class ArithmeticUtils {
          * the error.
          * @param args Arguments.
          */
-        public NumbersArithmeticException(String message, Object ... args) {
+        NumbersArithmeticException(String message, Object ... args) {
             super(message);
             this.formatArguments = args;
         }
 
+        /** {@inheritDoc} */
         @Override
         public String getMessage() {
             return MessageFormat.format(super.getMessage(), formatArguments);

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
----------------------------------------------------------------------
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
index 1eea0d6..b89bb42 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
@@ -50,6 +50,7 @@ class FractionException extends ArithmeticException {
         this.formatArguments = formatArguments;
     }
 
+    /** {@inheritDoc} */
     @Override
     public String getMessage() {
         return MessageFormat.format(super.getMessage(), formatArguments);

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
----------------------------------------------------------------------
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 4caa4e7..24d329e 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
@@ -19,11 +19,11 @@ package org.apache.commons.numbers.gamma;
 /**
  * <a href="http://en.wikipedia.org/wiki/Digamma_function">Digamma function</a>.
  * <p>
- * It is defined as the logarithmic derivative of the \( \Gamma \) 
+ * It is defined as the logarithmic derivative of the \( \Gamma \)
  * ({@link Gamma}) function:
  * \( \frac{d}{dx}(\ln \Gamma(x)) = \frac{\Gamma^\prime(x)}{\Gamma(x)} \).
  * </p>
- * 
+ *
  * @see Gamma
  */
 public class Digamma {

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java
----------------------------------------------------------------------
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 e29aa30..a1fd6ac 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
@@ -253,7 +253,7 @@ public class LogBeta {
      * @param a First argument.
      * @param b Second argument.
      * @return the value of {@code log(Gamma(b) / Gamma(a + b))}.
-     * @throws NumberIsTooSmallException if {@code a < 0} or {@code b < 10}.
+     * @throws IllegalArgumentException if {@code a < 0} or {@code b < 10}.
      */
     private static double logGammaMinusLogGammaSum(double a,
                                                    double b) {

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java
----------------------------------------------------------------------
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 9698155..f58a3bc 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
@@ -22,6 +22,7 @@ package org.apache.commons.numbers.gamma;
  * Class is immutable.
  */
 public class LogGamma {
+    /** Lanczos constant. */
     private static final double LANCZOS_G = 607d / 128d;
     /** Performance. */
     private static final double HALF_LOG_2_PI = 0.5 * Math.log(2.0 * Math.PI);

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java
----------------------------------------------------------------------
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 94b79d2..cf35665 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
@@ -38,7 +38,9 @@ public class RegularizedGamma {
         /**
          * Computes the regularized gamma function \( P(a, x) \).
          *
-         * {@inheritDoc}
+         * @param a Argument.
+         * @param x Argument.
+         * @return \( P(a, x) \).
          */
         public static double value(double a,
                                    double x) {
@@ -64,7 +66,11 @@ public class RegularizedGamma {
          *  </li>
          * </ul>
          *
-         * {@inheritDoc}
+         * @param a Argument.
+         * @param x Argument.
+         * @param epsilon Tolerance in continued fraction evaluation.
+         * @param maxIterations Maximum number of iterations in continued fraction evaluation.
+         * @return \( P(a, x) \).
          */
         public static double value(double a,
                                    double x,
@@ -117,7 +123,9 @@ public class RegularizedGamma {
         /**
          * Computes the regularized gamma function \( Q(a, x) = 1 - P(a, x) \).
          *
-         * {@inheritDoc}
+         * @param a Argument.
+         * @param x Argument.
+         * @return \( Q(a, x) \).
          */
         public static double value(double a,
                                    double x) {
@@ -140,7 +148,11 @@ public class RegularizedGamma {
          *  </li>
          * </ul>
          *
-         * {@inheritDoc}
+         * @param a Argument.
+         * @param x Argument.
+         * @param epsilon Tolerance in continued fraction evaluation.
+         * @param maxIterations Maximum number of iterations in continued fraction evaluation.
+         * @return \( Q(a, x) \).
          */
         public static double value(final double a,
                                    double x,


[2/6] commons-numbers git commit: Javadoc.

Posted by er...@apache.org.
Javadoc.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/3f3b7ad0
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/3f3b7ad0
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/3f3b7ad0

Branch: refs/heads/master
Commit: 3f3b7ad0122b37a9e831ea0eedfc7602956de5d2
Parents: b2d2267
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:43:40 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:43:40 2018 +0100

----------------------------------------------------------------------
 .../apache/commons/numbers/complex/Complex.java   | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/3f3b7ad0/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index 281822b..b1e7f50 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
@@ -475,7 +475,7 @@ public class Complex implements Serializable  {
     }
 
     /**
-     * Get a hashCode for the complex number.
+     * Get a hash code for the complex number.
      * Any {@code Double.NaN} value in real or imaginary part produces
      * the same hash code {@code 7}.
      *
@@ -489,6 +489,10 @@ public class Complex implements Serializable  {
         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));
@@ -1291,6 +1295,18 @@ public class Complex implements Serializable  {
         return new Double(x).equals(new Double(y));
     }
 
+    /**
+     * 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 not zero,</li>
+     * </ul>
+     *
+     * @param d Value.
+     * @return {@code true} if {@code d} meets all the conditions and
+     * {@code false} otherwise.
+     */
     private static boolean neitherInfiniteNorZeroNorNaN(double d) {
         if (!Double.isNaN(d) && !Double.isInfinite(d) && d != 0) {
             return true;


[4/6] commons-numbers git commit: Deleted unused method.

Posted by er...@apache.org.
Deleted unused method.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/662d201b
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/662d201b
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/662d201b

Branch: refs/heads/master
Commit: 662d201b68ed5100abf2ee40359734194850562d
Parents: 2e07396
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:56:54 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:56:54 2018 +0100

----------------------------------------------------------------------
 .../org/apache/commons/numbers/complex/Complex.java    | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/662d201b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index 60e85c8..99888f2 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
@@ -1261,18 +1261,7 @@ public class Complex implements Serializable  {
         }
     }
 
-     /**
-     * Check that the argument is positive and throw a RuntimeException
-     * if it is not.
-     * @param arg {@code int} to check
-     */
-    private static void checkNotNegative(int arg) {
-        if (arg <= 0) {
-            throw new RuntimeException("Complex: Non-positive argument");
-        }
-    }
-
-     /**
+    /**
      * Check that the argument is positive and throw a RuntimeException
      * if it is not.
      * @param arg {@code double} to check


[5/6] commons-numbers git commit: Added "throw" statement.

Posted by er...@apache.org.
Added "throw" statement.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/590010c7
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/590010c7
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/590010c7

Branch: refs/heads/master
Commit: 590010c7663c06e46c21865b803e34f844e468c5
Parents: 662d201
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:59:42 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:59:42 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/commons/numbers/complex/ComplexUtils.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/590010c7/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
index f0b39b6..3fdd10f 100644
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
+++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
@@ -987,7 +987,7 @@ public class ComplexUtils {
      */
     public static double[][][][] complex2Interleaved(Complex[][][][] c, int interleavedDim) {
         if (interleavedDim > 2 || interleavedDim < 0) {
-            new IndexOutOfRangeException(interleavedDim);
+            throw new IndexOutOfRangeException(interleavedDim);
         }
         int w = c.length;
         int h = c[0].length;
@@ -1309,7 +1309,7 @@ public class ComplexUtils {
      */
     public static Complex[][][][] interleaved2Complex(double[][][][] i, int interleavedDim) {
         if (interleavedDim > 2 || interleavedDim < 0) {
-            new IndexOutOfRangeException(interleavedDim);
+            throw new IndexOutOfRangeException(interleavedDim);
         }
         final int w = i.length;
         final int h = i[0].length;


[3/6] commons-numbers git commit: Unnecessary branching.

Posted by er...@apache.org.
Unnecessary branching.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/2e07396d
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/2e07396d
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/2e07396d

Branch: refs/heads/master
Commit: 2e07396d80cdd9ee2d7c824bbd5e6b321234cbfa
Parents: 3f3b7ad
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:45:33 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:45:33 2018 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/commons/numbers/complex/Complex.java  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2e07396d/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index b1e7f50..60e85c8 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
@@ -1308,8 +1308,8 @@ public class Complex implements Serializable  {
      * {@code false} otherwise.
      */
     private static boolean neitherInfiniteNorZeroNorNaN(double d) {
-        if (!Double.isNaN(d) && !Double.isInfinite(d) && d != 0) {
-            return true;
-        } else return false;
+        return !Double.isNaN(d) &&
+            !Double.isInfinite(d) &&
+            d != 0;
     }
 }