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 32bfd4fe4304251a4bcfe705b5c3b12e9dfd768e
Author: aherbert <[email protected]>
AuthorDate: Wed Apr 1 10:02:17 2020 +0100

    Complex: replace internal functional interface.
    
    The interface is identical to java.util.function.DoubleUnaryOperator.
---
 .../apache/commons/numbers/complex/Complex.java    | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 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 f2b5d8f..5713d65 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
@@ -20,6 +20,7 @@ package org.apache.commons.numbers.complex;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.function.DoubleUnaryOperator;
 
 /**
  * Cartesian representation of a complex number, i.e. a number which has both a
@@ -246,21 +247,6 @@ public final class Complex implements Serializable  {
     }
 
     /**
-     * Define a unary operation on a double.
-     * This is used in the log() and log10() functions.
-     */
-    @FunctionalInterface
-    private interface UnaryOperation {
-        /**
-         * Apply an operation to a value.
-         *
-         * @param value The value.
-         * @return The result.
-         */
-        double apply(double value);
-    }
-
-    /**
      * Private default constructor.
      *
      * @param real Real part.
@@ -2336,7 +2322,7 @@ public final class Complex implements Serializable  {
      * @see #abs()
      * @see #arg()
      */
-    private Complex log(UnaryOperation log, double logOfeOver2, double logOf2, 
ComplexConstructor constructor) {
+    private Complex log(DoubleUnaryOperator log, double logOfeOver2, double 
logOf2, ComplexConstructor constructor) {
         // Handle NaN
         if (Double.isNaN(real) || Double.isNaN(imaginary)) {
             // Return NaN unless infinite
@@ -2401,7 +2387,7 @@ public final class Complex implements Serializable  {
                 // Potential underflow.
                 if (y == 0) {
                     // Handle real only number
-                    return constructor.create(log.apply(x), arg());
+                    return constructor.create(log.applyAsDouble(x), arg());
                 }
                 // Scale up sub-normal numbers to make them normal by scaling 
by 2^54,
                 // i.e. more than the mantissa digits.
@@ -2410,7 +2396,7 @@ public final class Complex implements Serializable  {
                 // log(2^-54) = -54 * log(2)
                 re = -54 * logOf2;
             }
-            re += log.apply(abs(x, y));
+            re += log.applyAsDouble(abs(x, y));
         }
 
         // All ISO C99 edge cases for the imaginary are satisfied by the Math 
library.

Reply via email to