You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/07/27 02:13:43 UTC

[GitHub] [commons-numbers] sumanth-rajkumar opened a new pull request, #120: Numbers 188 refactored complex scalar binary functions

sumanth-rajkumar opened a new pull request, #120:
URL: https://github.com/apache/commons-numbers/pull/120

   This PR refactors Complex class using functional interfaces and static methods. 
   This allows reuse of the refactored static functions for Operations on List/Matrices of Complex Numbers (NUMBERS-186)
   
   The changes retain binary backward compatibility.
   
   Summary of changes
   
   1) Introduced following interfaces for Complex Number Operations
   
    ComplexScalarFunction - binary operations on a complex number represented as double real and imaginary parts and a double scalar operand
   
   2) Refactored all complex-scalar binary operations instance methods of Complex class as static functions in ComplexFunctions
   The static functions use the functional interface signatures described above


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-numbers] codecov-commenter commented on pull request #120: Numbers 188 refactored complex scalar binary functions

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #120:
URL: https://github.com/apache/commons-numbers/pull/120#issuecomment-1196190562

   # [Codecov](https://codecov.io/gh/apache/commons-numbers/pull/120?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#120](https://codecov.io/gh/apache/commons-numbers/pull/120?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (60d5d45) into [complex-gsoc-2022](https://codecov.io/gh/apache/commons-numbers/commit/7386b095d767ef184bed9bbbf6b2d84f46a617f4?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7386b09) will **increase** coverage by `0.00%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@                 Coverage Diff                  @@
   ##             complex-gsoc-2022     #120   +/-   ##
   ====================================================
     Coverage                99.13%   99.13%           
   - Complexity                1684     1699   +15     
   ====================================================
     Files                       65       65           
     Lines                     4259     4274   +15     
     Branches                   835      836    +1     
   ====================================================
   + Hits                      4222     4237   +15     
     Misses                      10       10           
     Partials                    27       27           
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/commons-numbers/pull/120?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ache/commons/numbers/complex/ComplexFunctions.java](https://codecov.io/gh/apache/commons-numbers/pull/120/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9ucy1udW1iZXJzLWNvbXBsZXgvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvbnVtYmVycy9jb21wbGV4L0NvbXBsZXhGdW5jdGlvbnMuamF2YQ==) | `100.00% <100.00%> (ø)` | |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-numbers] aherbert merged pull request #120: Numbers 188 refactored complex scalar binary functions

Posted by GitBox <gi...@apache.org>.
aherbert merged PR #120:
URL: https://github.com/apache/commons-numbers/pull/120


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-numbers] aherbert commented on a diff in pull request #120: Numbers 188 refactored complex scalar binary functions

Posted by GitBox <gi...@apache.org>.
aherbert commented on code in PR #120:
URL: https://github.com/apache/commons-numbers/pull/120#discussion_r930748847


##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexScalarFunction.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.complex;
+
+/**
+ * Represents a binary operation on a Cartesian form of a complex number \( a + ib \)

Review Comment:
   ```
   Represents a binary operation on a Cartesian form of a complex number \( a + ib \)
   and a {@code double} scalar operand, where \( a \) ...
   ```



##########
commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java:
##########
@@ -980,27 +980,31 @@ void testImplicitTrig() {
             final double re = next(rng);
             final double im = next(rng);
             final Complex z = complex(re, im);
-            final Complex iz = z.multiplyImaginary(1);
+            final Complex iz = TestUtils.assertSame(z, 1, "multiplyImaginary", Complex::multiplyImaginary, ComplexFunctions::multiplyImaginary);
 
             Complex actual = TestUtils.assertSame(z, "asin", Complex::asin, ComplexFunctions::asin);
             Complex expected = TestUtils.assertSame(iz, "asinh", Complex::asinh, ComplexFunctions::asinh);
-            assertComplex(actual, expected.multiplyImaginary(-1));
+            expected = TestUtils.assertSame(expected, -1, "multiplyImaginary", Complex::multiplyImaginary, ComplexFunctions::multiplyImaginary);

Review Comment:
   Rename:
   ```
   actual -> c1
   expected -> c2
   ```
   These terms are not used 'correctly' when passed to the assertion which has arguments expected then actual.
    
   Single line:
   ```Java
   assertComplex(c1, TestUtils.assertSame(c2, -1, "multiplyImaginary", Complex::multiplyImaginary, ComplexFunctions::multiplyImaginary));
   ```
   



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -420,6 +420,62 @@ public static <R> R add(double real1, double imaginary1,
                             imaginary1 + imaginary2);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real + addend, imaginary)},
+     * with {@code addend} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) + c = (a + c) + i b \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method preserves the sign of the imaginary component \( b \) if it is {@code -0.0}.
+     * The sign would be lost if adding \( (c + i 0) \) using
+     * {@link #add(double, double, double, double, ComplexSink) add(Complex.ofCartesian(addend, 0))} since
+     * {@code -0.0 + 0.0 = 0.0}.
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param addend Value to be added to the complex number.
+     * @param action Consumer for the addition result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #add(double, double, double, double, ComplexSink)
+     * #ofCartesian(double, double)
+     */
+    public static <R> R add(double real, double imaginary, double addend, ComplexSink<R> action) {
+        return action.apply(real + addend, imaginary);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (real, imaginary + addend)},
+     * with {@code addend} interpreted as an imaginary number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) + i d = a + i (b + d) \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * imaginary-only and complex numbers.</p>
+     *
+     * <p>Note: This method preserves the sign of the real component \( a \) if it is {@code -0.0}.
+     * The sign would be lost if adding \( (0 + i d) \) using
+     * {@link #add(double, double, double, double, ComplexSink) add(Complex.ofCartesian(0, addend))} since

Review Comment:
   `#add(double, double, double, double, ComplexSink) add(real, imaginary, 0, addend, action)`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -420,6 +420,62 @@ public static <R> R add(double real1, double imaginary1,
                             imaginary1 + imaginary2);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real + addend, imaginary)},
+     * with {@code addend} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) + c = (a + c) + i b \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method preserves the sign of the imaginary component \( b \) if it is {@code -0.0}.
+     * The sign would be lost if adding \( (c + i 0) \) using
+     * {@link #add(double, double, double, double, ComplexSink) add(Complex.ofCartesian(addend, 0))} since

Review Comment:
   ``#add(double, double, double, double, ComplexSink) add(real, imaginary, addend, 0, action)`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -570,6 +724,72 @@ private static double changeNaNtoZero(double value) {
         return Double.isNaN(value) ? Math.copySign(0.0, value) : value;
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real * factor, imaginary * factor)}, with {@code factor}

Review Comment:
   `Computes the result of the multiplication of a complex number and a real number.`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -570,6 +724,72 @@ private static double changeNaNtoZero(double value) {
         return Double.isNaN(value) ? Math.copySign(0.0, value) : value;
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real * factor, imaginary * factor)}, with {@code factor}
+     * interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) c =  (ac) + i (bc) \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #multiply(double, double, double, double, ComplexSink) multiply(Complex.ofCartesian(factor, 0))}. Multiplication

Review Comment:
   `#multiply(double, double, double, double, ComplexSink) multiply(a, b, factor, 0, action)`



##########
commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java:
##########
@@ -1304,21 +1350,21 @@ void testSignedArithmetic() {
         // and the javadoc in Complex does not break down the actual cases.
 
         // 16: (x,-0.0) + x
-        assertSignedZeroArithmetic("addReal", Complex::add, ComplexTest::ofReal, Complex::add,
+        assertSignedZeroArithmetic("addReal", Complex::add, ComplexFunctions::add, ComplexTest::ofReal, Complex::add, ComplexFunctions::add,
             0b1111000000000000111100000000000011110000000000001111L);
         // 16: (-0.0,x) + x
-        assertSignedZeroArithmetic("addImaginary", Complex::addImaginary, ComplexTest::ofImaginary, Complex::add,
+        assertSignedZeroArithmetic("addImaginary", Complex::addImaginary, ComplexFunctions::addImaginary, ComplexTest::ofImaginary, Complex::add, ComplexFunctions::add,
             0b1111111111111111L);
         // 0:
-        assertSignedZeroArithmetic("subtractReal", Complex::subtract, ComplexTest::ofReal, Complex::subtract, 0);
+        assertSignedZeroArithmetic("subtractReal", Complex::subtract, ComplexFunctions::subtract, ComplexTest::ofReal, Complex::subtract, ComplexFunctions::subtract, 0);
         // 0:
-        assertSignedZeroArithmetic("subtractImaginary", Complex::subtractImaginary, ComplexTest::ofImaginary,
-            Complex::subtract, 0);
+        assertSignedZeroArithmetic("subtractImaginary", Complex::subtractImaginary, ComplexFunctions::subtractImaginary, ComplexTest::ofImaginary,
+            Complex::subtract, ComplexFunctions::subtract, 0);
         // 16: x - (x,+0.0)
-        assertSignedZeroArithmetic("subtractFromReal", Complex::subtractFrom, ComplexTest::ofReal,
+        assertSignedZeroArithmetic("subtractFromReal", Complex::subtractFrom, ComplexFunctions::subtractFrom, ComplexTest::ofReal,
             (y, z) -> z.subtract(y), 0b11110000000000001111000000000000111100000000000011110000L);

Review Comment:
   `(y, z) -> z.subtract(y), (a, b, c, d, action) -> ComplexFunctions.subtract(c, d, a, b, action), 0b11110000000000001111000000000000111100000000000011110000L);`



##########
commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java:
##########
@@ -1304,21 +1350,21 @@ void testSignedArithmetic() {
         // and the javadoc in Complex does not break down the actual cases.
 
         // 16: (x,-0.0) + x
-        assertSignedZeroArithmetic("addReal", Complex::add, ComplexTest::ofReal, Complex::add,
+        assertSignedZeroArithmetic("addReal", Complex::add, ComplexFunctions::add, ComplexTest::ofReal, Complex::add, ComplexFunctions::add,
             0b1111000000000000111100000000000011110000000000001111L);
         // 16: (-0.0,x) + x
-        assertSignedZeroArithmetic("addImaginary", Complex::addImaginary, ComplexTest::ofImaginary, Complex::add,
+        assertSignedZeroArithmetic("addImaginary", Complex::addImaginary, ComplexFunctions::addImaginary, ComplexTest::ofImaginary, Complex::add, ComplexFunctions::add,
             0b1111111111111111L);
         // 0:
-        assertSignedZeroArithmetic("subtractReal", Complex::subtract, ComplexTest::ofReal, Complex::subtract, 0);
+        assertSignedZeroArithmetic("subtractReal", Complex::subtract, ComplexFunctions::subtract, ComplexTest::ofReal, Complex::subtract, ComplexFunctions::subtract, 0);
         // 0:
-        assertSignedZeroArithmetic("subtractImaginary", Complex::subtractImaginary, ComplexTest::ofImaginary,
-            Complex::subtract, 0);
+        assertSignedZeroArithmetic("subtractImaginary", Complex::subtractImaginary, ComplexFunctions::subtractImaginary, ComplexTest::ofImaginary,
+            Complex::subtract, ComplexFunctions::subtract, 0);
         // 16: x - (x,+0.0)
-        assertSignedZeroArithmetic("subtractFromReal", Complex::subtractFrom, ComplexTest::ofReal,
+        assertSignedZeroArithmetic("subtractFromReal", Complex::subtractFrom, ComplexFunctions::subtractFrom, ComplexTest::ofReal,
             (y, z) -> z.subtract(y), 0b11110000000000001111000000000000111100000000000011110000L);
         // 16: x - (+0.0,x)
-        assertSignedZeroArithmetic("subtractFromImaginary", Complex::subtractFromImaginary, ComplexTest::ofImaginary,
+        assertSignedZeroArithmetic("subtractFromImaginary", Complex::subtractFromImaginary, ComplexFunctions::subtractFromImaginary, ComplexTest::ofImaginary,
             (y, z) -> z.subtract(y), 0b11111111111111110000000000000000L);

Review Comment:
   `(y, z) -> z.subtract(y), (a, b, c, d, action) -> ComplexFunctions.subtract(c, d, a, b, action), 0b11111111111111110000000000000000L);`



##########
commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CStandardTest.java:
##########
@@ -1056,8 +1060,10 @@ void testAbs() {
                 {1.40905821964671, 1.4090583434236112},
                 {1.912164268932753, 1.9121638616231227}}) {
             final Complex z = complex(pair[0], pair[1]);
-            assertAbs(z.abs(), z.multiplyImaginary(1));
-            Assertions.assertEquals(z.abs(), z.multiplyImaginary(1).abs(), "Expected |z| == |iz|");
+            final Complex result = TestUtils.assertSame(z, 1, "multiplyImaginary", Complex::multiplyImaginary, ComplexFunctions::multiplyImaginary);

Review Comment:
   ```Java
   final Complex iz = TestUtils.assertSame(z, 1, "multiplyImaginary", Complex::multiplyImaginary, ComplexFunctions::multiplyImaginary);
   Assertions.assertEquals(z.abs(), iz.abs(), "Expected |z| == |iz|")
   ```



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -442,6 +498,104 @@ public static <R> R subtract(double real1, double imaginary1,
                             imaginary1 - imaginary2);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (this - subtrahend)},

Review Comment:
   `Computes the result of the subtraction of a real number from a complex number.`



##########
commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java:
##########
@@ -457,6 +457,30 @@ public static Complex assertSame(Complex c1,
         return z;
     }
 
+    /**
+     * Assert the operation on the complex number and double operand is <em>exactly</em> equal to the operation on
+     * complex real and imaginary parts and double operand.
+     *
+     * @param c Input complex number.
+     * @param operand Scalar operand.
+     * @param name Operation name.
+     * @param operation1 Operation on the Complex object and double operand.
+     * @param operation2 Operation on the complex real and imaginary parts and double operand.
+     * @return Result complex number from the given operation.
+     */
+    public static Complex assertSame(Complex c,
+                                     double operand,
+                                     String name,
+                                     BiFunction<Complex, Double, Complex> operation1,
+                                     ComplexScalarFunction<ComplexNumber> operation2) {
+        final Complex z = operation1.apply(c, operand);
+        // Test operation2 produces the exact same result
+        final ComplexNumber z2 = operation2.apply(c.real(), c.imag(), operand, ComplexNumber::new);
+        Assertions.assertEquals(z.real(), z2.getReal(), () -> "Complex-Scalar binary operator mismatch: " + name + " real");

Review Comment:
   `"Scalar operator mismatch"`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -442,6 +498,104 @@ public static <R> R subtract(double real1, double imaginary1,
                             imaginary1 - imaginary2);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (this - subtrahend)},
+     * with {@code subtrahend} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) - c = (a - c) + i b \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param subtrahend Value to be subtracted from the complex number.
+     * @param action Consumer for the subtraction result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #subtract(double, double, double, double, ComplexSink)
+     */
+    public static <R> R subtract(double real, double imaginary, double subtrahend, ComplexSink<R> action) {
+        return action.apply(real - subtrahend, imaginary);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (real, imaginary - subtrahend)},

Review Comment:
   `Computes the result of the subtraction of an imaginary number from a complex number.`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -442,6 +498,104 @@ public static <R> R subtract(double real1, double imaginary1,
                             imaginary1 - imaginary2);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (this - subtrahend)},
+     * with {@code subtrahend} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) - c = (a - c) + i b \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param subtrahend Value to be subtracted from the complex number.
+     * @param action Consumer for the subtraction result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #subtract(double, double, double, double, ComplexSink)
+     */
+    public static <R> R subtract(double real, double imaginary, double subtrahend, ComplexSink<R> action) {
+        return action.apply(real - subtrahend, imaginary);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (real, imaginary - subtrahend)},
+     * with {@code subtrahend} interpreted as an imaginary number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) - i d = a + i (b - d) \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * imaginary-only and complex numbers.</p>
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param subtrahend Value to be subtracted from the complex number.
+     * @param action Consumer for the subtraction result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #subtract(double, double, double, double, ComplexSink)
+     */
+    public static <R> R subtractImaginary(double real, double imaginary, double subtrahend, ComplexSink<R> action) {
+        return action.apply(real, imaginary - subtrahend);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (minuend - real, -imaginary)},

Review Comment:
   `Computes the result of the subtraction of a complex number from a real number.`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -420,6 +420,62 @@ public static <R> R add(double real1, double imaginary1,
                             imaginary1 + imaginary2);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real + addend, imaginary)},

Review Comment:
   `Computes the result of the addition of a complex number and a real number .`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -570,6 +724,72 @@ private static double changeNaNtoZero(double value) {
         return Double.isNaN(value) ? Math.copySign(0.0, value) : value;
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real * factor, imaginary * factor)}, with {@code factor}
+     * interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) c =  (ac) + i (bc) \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #multiply(double, double, double, double, ComplexSink) multiply(Complex.ofCartesian(factor, 0))}. Multiplication
+     * can generate signed zeros if either {@code this} complex has zeros for the real
+     * and/or imaginary component, or if the factor is zero. The summation of signed zeros
+     * in {@link #multiply(double, double, double, double, ComplexSink)} may create zeros in the result that differ in sign
+     * from the equivalent call to multiply by a real-only number.
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param factor Value to be multiplied by the complex number.
+     * @param action Consumer for the multiplication result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action
+     * @see #multiply(double, double, double, double, ComplexSink)
+     */
+    public static <R> R multiply(double real, double imaginary, double factor, ComplexSink<R> action) {
+        return action.apply(real * factor, imaginary * factor);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (-imaginary * factor, real * factor)}, with {@code factor}

Review Comment:
   `Computes the result of the multiplication of a complex number and an imaginary number.`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -442,6 +498,104 @@ public static <R> R subtract(double real1, double imaginary1,
                             imaginary1 - imaginary2);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (this - subtrahend)},
+     * with {@code subtrahend} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) - c = (a - c) + i b \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param subtrahend Value to be subtracted from the complex number.
+     * @param action Consumer for the subtraction result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #subtract(double, double, double, double, ComplexSink)
+     */
+    public static <R> R subtract(double real, double imaginary, double subtrahend, ComplexSink<R> action) {
+        return action.apply(real - subtrahend, imaginary);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (real, imaginary - subtrahend)},
+     * with {@code subtrahend} interpreted as an imaginary number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) - i d = a + i (b - d) \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * imaginary-only and complex numbers.</p>
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param subtrahend Value to be subtracted from the complex number.
+     * @param action Consumer for the subtraction result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #subtract(double, double, double, double, ComplexSink)
+     */
+    public static <R> R subtractImaginary(double real, double imaginary, double subtrahend, ComplexSink<R> action) {
+        return action.apply(real, imaginary - subtrahend);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (minuend - real, -imaginary)},
+     * with {@code minuend} interpreted as a real number.
+     * Implements the formula:
+     * \[ c - (a + i b) = (c - a) - i b \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method inverts the sign of the imaginary component \( b \) if it is {@code 0.0}.
+     * The sign would not be inverted if subtracting from \( c + i 0 \) using
+     * {@link #subtract(double, double, double, double, ComplexSink) Complex.ofCartesian(minuend, 0).subtract(this)} since
+     * {@code 0.0 - 0.0 = 0.0}.
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param minuend Value the complex number is to be subtracted from.
+     * @param action Consumer for the subtraction result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #subtract(double, double, double, double, ComplexSink)
+     * #ofCartesian(double, double)
+     */
+    public static <R> R subtractFrom(double real, double imaginary, double minuend, ComplexSink<R> action) {
+        return action.apply(minuend - real, -imaginary);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (-real, minuend - imaginary)},

Review Comment:
   `Computes the result of the subtraction of a complex number from an imaginary number.`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -420,6 +420,62 @@ public static <R> R add(double real1, double imaginary1,
                             imaginary1 + imaginary2);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real + addend, imaginary)},
+     * with {@code addend} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) + c = (a + c) + i b \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method preserves the sign of the imaginary component \( b \) if it is {@code -0.0}.
+     * The sign would be lost if adding \( (c + i 0) \) using
+     * {@link #add(double, double, double, double, ComplexSink) add(Complex.ofCartesian(addend, 0))} since
+     * {@code -0.0 + 0.0 = 0.0}.
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param addend Value to be added to the complex number.
+     * @param action Consumer for the addition result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #add(double, double, double, double, ComplexSink)
+     * #ofCartesian(double, double)
+     */
+    public static <R> R add(double real, double imaginary, double addend, ComplexSink<R> action) {
+        return action.apply(real + addend, imaginary);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (real, imaginary + addend)},

Review Comment:
   `Computes the result of the addition of a complex number and an imaginary number .`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -651,6 +871,73 @@ public static <R> R divide(double real1, double imaginary1,
         return action.apply(x, y);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real / divisor, imaginary / divisor)},

Review Comment:
   `Computes the result of the division of a complex number by a real number.`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -651,6 +871,73 @@ public static <R> R divide(double real1, double imaginary1,
         return action.apply(x, y);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real / divisor, imaginary / divisor)},
+     * with {@code divisor} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ \frac{a + i b}{c} = \frac{a}{c} + i \frac{b}{c} \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #divide(double, double, double, double, ComplexSink) divide(Complex.ofCartesian(divisor, 0))}. Division
+     * can generate signed zeros if {@code this} complex has zeros for the real
+     * and/or imaginary component, or the divisor is infinite. The summation of signed zeros
+     * in {@link #divide(double, double, double, double, ComplexSink)} may create zeros in the result that differ in sign
+     * from the equivalent call to divide by a real-only number.
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param divisor Value by which the complex number is to be divided.
+     * @param action Consumer for the division result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #divide(double, double, double, double, ComplexSink)
+     */
+    public static <R> R divide(double real, double imaginary, double divisor, ComplexSink<R> action) {
+        return action.apply(real / divisor, imaginary / divisor);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (imaginary / divisor, -real / divisor)},

Review Comment:
   `Computes the result of the division of a complex number by an imaginary number.`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -570,6 +724,72 @@ private static double changeNaNtoZero(double value) {
         return Double.isNaN(value) ? Math.copySign(0.0, value) : value;
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real * factor, imaginary * factor)}, with {@code factor}
+     * interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) c =  (ac) + i (bc) \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #multiply(double, double, double, double, ComplexSink) multiply(Complex.ofCartesian(factor, 0))}. Multiplication
+     * can generate signed zeros if either {@code this} complex has zeros for the real
+     * and/or imaginary component, or if the factor is zero. The summation of signed zeros
+     * in {@link #multiply(double, double, double, double, ComplexSink)} may create zeros in the result that differ in sign
+     * from the equivalent call to multiply by a real-only number.
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param factor Value to be multiplied by the complex number.
+     * @param action Consumer for the multiplication result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action
+     * @see #multiply(double, double, double, double, ComplexSink)
+     */
+    public static <R> R multiply(double real, double imaginary, double factor, ComplexSink<R> action) {
+        return action.apply(real * factor, imaginary * factor);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (-imaginary * factor, real * factor)}, with {@code factor}
+     * interpreted as an imaginary number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) id = (-bd) + i (ad) \]
+     *
+     * <p>This method can be used to compute the multiplication of the complex number \( z \)
+     * by \( i \) using a factor with magnitude 1.0. This should be used in preference to
+     * {@link #multiply(double, double, double, double, ComplexSink) multiply(Complex.I)} with or without {@link #negate(double, double, ComplexSink) negation}:</p>
+     *
+     * \[ \begin{aligned}
+     *    iz &amp;= (-b + i a) \\
+     *   -iz &amp;= (b - i a) \end{aligned} \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * imaginary-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #multiply(double, double, double, double, ComplexSink) multiply(Complex.ofCartesian(0, factor))}. Multiplication

Review Comment:
   `#multiply(double, double, double, double, ComplexSink) multiply(a, b, 0, factor, action)`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -651,6 +871,73 @@ public static <R> R divide(double real1, double imaginary1,
         return action.apply(x, y);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real / divisor, imaginary / divisor)},
+     * with {@code divisor} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ \frac{a + i b}{c} = \frac{a}{c} + i \frac{b}{c} \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #divide(double, double, double, double, ComplexSink) divide(Complex.ofCartesian(divisor, 0))}. Division
+     * can generate signed zeros if {@code this} complex has zeros for the real
+     * and/or imaginary component, or the divisor is infinite. The summation of signed zeros
+     * in {@link #divide(double, double, double, double, ComplexSink)} may create zeros in the result that differ in sign
+     * from the equivalent call to divide by a real-only number.
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param divisor Value by which the complex number is to be divided.
+     * @param action Consumer for the division result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #divide(double, double, double, double, ComplexSink)
+     */
+    public static <R> R divide(double real, double imaginary, double divisor, ComplexSink<R> action) {
+        return action.apply(real / divisor, imaginary / divisor);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (imaginary / divisor, -real / divisor)},
+     * with {@code divisor} interpreted as an imaginary number.
+     * Implements the formula:
+     *
+     * <p>\[ \frac{a + i b}{id} = \frac{b}{d} - i \frac{a}{d} \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * imaginary-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #divide(double, double, double, double, ComplexSink) divide(Complex.ofCartesian(0, divisor))}. Division
+     * can generate signed zeros if {@code this} complex has zeros for the real
+     * and/or imaginary component, or the divisor is infinite. The summation of signed zeros
+     * in {@link #divide(double, double, double, double, ComplexSink)} may create zeros in the result that differ in sign
+     * from the equivalent call to divide by an imaginary-only number.
+     *
+     * <p>Warning: This method will generate a different result from
+     * {@link #divide(double, double, double, double, ComplexSink) divide(Complex.ofCartesian(0, divisor))} if the divisor is zero.

Review Comment:
   Correct as above to remove `ofCartesian`
   



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -651,6 +871,73 @@ public static <R> R divide(double real1, double imaginary1,
         return action.apply(x, y);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real / divisor, imaginary / divisor)},
+     * with {@code divisor} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ \frac{a + i b}{c} = \frac{a}{c} + i \frac{b}{c} \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #divide(double, double, double, double, ComplexSink) divide(Complex.ofCartesian(divisor, 0))}. Division

Review Comment:
   `#divide(double, double, double, double, ComplexSink) divide(a, b, divisor, 0, action)`



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -442,6 +498,104 @@ public static <R> R subtract(double real1, double imaginary1,
                             imaginary1 - imaginary2);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (this - subtrahend)},
+     * with {@code subtrahend} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) - c = (a - c) + i b \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param subtrahend Value to be subtracted from the complex number.
+     * @param action Consumer for the subtraction result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #subtract(double, double, double, double, ComplexSink)
+     */
+    public static <R> R subtract(double real, double imaginary, double subtrahend, ComplexSink<R> action) {
+        return action.apply(real - subtrahend, imaginary);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (real, imaginary - subtrahend)},
+     * with {@code subtrahend} interpreted as an imaginary number.
+     * Implements the formula:
+     *
+     * <p>\[ (a + i b) - i d = a + i (b - d) \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * imaginary-only and complex numbers.</p>
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param subtrahend Value to be subtracted from the complex number.
+     * @param action Consumer for the subtraction result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #subtract(double, double, double, double, ComplexSink)
+     */
+    public static <R> R subtractImaginary(double real, double imaginary, double subtrahend, ComplexSink<R> action) {
+        return action.apply(real, imaginary - subtrahend);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (minuend - real, -imaginary)},
+     * with {@code minuend} interpreted as a real number.
+     * Implements the formula:
+     * \[ c - (a + i b) = (c - a) - i b \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method inverts the sign of the imaginary component \( b \) if it is {@code 0.0}.
+     * The sign would not be inverted if subtracting from \( c + i 0 \) using
+     * {@link #subtract(double, double, double, double, ComplexSink) Complex.ofCartesian(minuend, 0).subtract(this)} since
+     * {@code 0.0 - 0.0 = 0.0}.
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param minuend Value the complex number is to be subtracted from.
+     * @param action Consumer for the subtraction result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #subtract(double, double, double, double, ComplexSink)
+     * #ofCartesian(double, double)
+     */
+    public static <R> R subtractFrom(double real, double imaginary, double minuend, ComplexSink<R> action) {

Review Comment:
   Note: The `subtractFrom` and `subtractFromImaginary` made sense when they were object methods on Complex. The complex object (here an argument) is always first and the other arguments are passed to the object method.
   
   When viewed as a static API these methods appear out-of-place. Ideally you would want to express:
   ```
   c - (a + i b)
   i d - (a + i b)
   ```
   This makes more sense when the arguments are passed in the order of the formula. However if the method is named `subtract(c, a, b, ...)` then the signature matches `subtract(a, b, c, ...)`. It may be better to change these to:
   ```
   realSubtract(c, a, b, ...)
   imaginarySubtract(d, a, b, ...)
   ```
   This will require a bit more work in the unit tests as the method will need to be wrapped with a lambda to swap the arguments:
   ```
   // TestUtils
   /**
    * Computes the result of the subtraction of a complex number from an imaginary number.
    * Implements the formula:
    * \[ i d - (a + i b) = -a + i (d - b) \]
    *
    * <p>This method is a helper to replicate the method signature of the object-orientated
    * API in Complex (i.e. the complex argument is first) using the equivalent static API
    * function in ComplexFunctions.
    *
    * @param real Real part \( a \) of the complex number \( (a +ib) \).
    * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
    * @param minuend Value the complex number is to be subtracted from.
    * @param action Consumer for the subtraction result.
    * @param <R> the return type of the supplied action.
    * @return the object returned by the supplied action.
    */
   public static <R> R subtractFromImaginary(double real, double imaginary, double minuend, ComplexSink<R> action) {
       // Call the equivalent static API function
       return ComplexFunctions.imaginarySubtract(minuend, real, imaginary, action);
   }
   
   // ComplexFunctions updated to ...
   public static <R> R imaginarySubtract(double minuend, double real, double imaginary, ComplexSink<R> action) {
       return action.apply(-real, minuend - imaginary);
   }
   
   // Tests using ComplexFunctions::subtractFromImaginary are simply updated, e.g. in ComplexTest ...
           final Complex z2 = TestUtils.assertSame(x, y, "subtractFromImaginary", Complex::subtractFromImaginary, TestUtils::subtractFromImaginary);
   
   
   ```



##########
commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexFunctions.java:
##########
@@ -651,6 +871,73 @@ public static <R> R divide(double real1, double imaginary1,
         return action.apply(x, y);
     }
 
+    /**
+     * Returns a {@code Object} whose value is {@code (real / divisor, imaginary / divisor)},
+     * with {@code divisor} interpreted as a real number.
+     * Implements the formula:
+     *
+     * <p>\[ \frac{a + i b}{c} = \frac{a}{c} + i \frac{b}{c} \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * real-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #divide(double, double, double, double, ComplexSink) divide(Complex.ofCartesian(divisor, 0))}. Division
+     * can generate signed zeros if {@code this} complex has zeros for the real
+     * and/or imaginary component, or the divisor is infinite. The summation of signed zeros
+     * in {@link #divide(double, double, double, double, ComplexSink)} may create zeros in the result that differ in sign
+     * from the equivalent call to divide by a real-only number.
+     *
+     * @param real Real part \( a \) of the complex number \( (a +ib) \).
+     * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \).
+     * @param divisor Value by which the complex number is to be divided.
+     * @param action Consumer for the division result.
+     * @param <R> the return type of the supplied action.
+     * @return the object returned by the supplied action.
+     * @see #divide(double, double, double, double, ComplexSink)
+     */
+    public static <R> R divide(double real, double imaginary, double divisor, ComplexSink<R> action) {
+        return action.apply(real / divisor, imaginary / divisor);
+    }
+
+    /**
+     * Returns a {@code Object} whose value is {@code (imaginary / divisor, -real / divisor)},
+     * with {@code divisor} interpreted as an imaginary number.
+     * Implements the formula:
+     *
+     * <p>\[ \frac{a + i b}{id} = \frac{b}{d} - i \frac{a}{d} \]
+     *
+     * <p>This method is included for compatibility with ISO C99 which defines arithmetic between
+     * imaginary-only and complex numbers.</p>
+     *
+     * <p>Note: This method should be preferred over using
+     * {@link #divide(double, double, double, double, ComplexSink) divide(Complex.ofCartesian(0, divisor))}. Division

Review Comment:
   `#divide(double, double, double, double, ComplexSink) divide(a, b, 0, divisor, action)`



##########
commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java:
##########
@@ -1069,12 +1102,13 @@ void testMultiplyZeroByNegativeI() {
         for (final double a : zeros) {
             for (final double b : zeros) {
                 final Complex c = Complex.ofCartesian(a, b);
-                final Complex x = c.multiplyImaginary(-1.0);
+                final Complex x = TestUtils.assertSame(c, -1.0, "multiplyImaginary", Complex::multiplyImaginary, ComplexFunctions::multiplyImaginary);
                 // Check verses algebra solution
                 Assertions.assertEquals(b, x.getReal());
                 Assertions.assertEquals(-a, x.getImaginary());
-                final Complex z = c.multiply(negI);
-                final Complex z2 = c.multiply(Complex.I).negate();
+                final Complex z = TestUtils.assertSame(c, negI, "multiply", Complex::multiply, ComplexFunctions::multiply);
+                final Complex result1 = TestUtils.assertSame(c, Complex.I, "multiply", Complex::multiply, ComplexFunctions::multiply);

Review Comment:
   `result1` -> `ci`



##########
commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java:
##########
@@ -1378,6 +1425,32 @@ private static void assertSignedZeroArithmetic(String name, BiFunction<Complex,
         }
     }
 
+    private static void assertSignedZeroArithmetic(String name, BiFunction<Complex, Double, Complex> doubleOperation1,

Review Comment:
   Duplicating this method is not as maintainable as having only one version of it. I have suggested a call for the `subtractFromReal` and `subtractFromImaginary` tests to use a lambda for ComplexFunctions. You can then have only one instance of this method.
   
   Can you indent the arguments 8 spaces (from the `private` keyword).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org