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 e3351253466aab6ffc940e2dcd64cf7841ab5d0c
Author: Alex Herbert <aherb...@apache.org>
AuthorDate: Thu Dec 19 19:08:08 2019 +0000

    Remove unused/redundant methods.
    
    Overflow safe average method is only used when one argument is less than
    the other so compute
    inline.
    
    The getArgument method is not used.
---
 .../apache/commons/numbers/complex/Complex.java    | 32 ++--------------------
 1 file changed, 2 insertions(+), 30 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 33b6056..b0583ff 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
@@ -2359,8 +2359,8 @@ public final class Complex implements Serializable  {
                     // sqrt(2^exponent) = (2^exponent)^0.5 = 2^(exponent*0.5)
                     t = Math.scalb(Math.sqrt((scaleA + absC) / 2), exponent / 
2);
                 } else {
-                    // Over-flow safe average
-                    t = Math.sqrt(average(absA, absC));
+                    // Over-flow safe average: absA < absC and abdC is finite.
+                    t = Math.sqrt(absA + (absC - absA) / 2);
                 }
 
                 if (real >= 0) {
@@ -2386,19 +2386,6 @@ public final class Complex implements Serializable  {
     }
 
     /**
-     * Compute the average of two positive finite values in an overflow safe 
manner.
-     *
-     * @param a the first value
-     * @param b the second value
-     * @return the average
-     */
-    private static double average(double a, double b) {
-        return (a < b) ?
-            a + (b - a) / 2 :
-            b + (a - b) / 2;
-    }
-
-    /**
      * Compute the
      * <a href="http://mathworld.wolfram.com/Tangent.html";>
      * tangent</a> of this complex number.
@@ -2532,21 +2519,6 @@ public final class Complex implements Serializable  {
     }
 
     /**
-     * Compute the argument of the complex number.
-     *
-     * <p>This function exists for use in trigonomic functions.
-     *
-     * @param real Real part.
-     * @param imaginary Imaginary part.
-     * @return the argument.
-     * @see Math#atan2(double, double)
-     */
-    private static double getArgument(double real, double imaginary) {
-        // Delegate
-        return Math.atan2(imaginary, real);
-    }
-
-    /**
      * Computes the n-th roots of this complex number.
      * The nth roots are defined by the formula:
      * <pre>

Reply via email to