commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ericbarnh...@apache.org
Subject [commons-numbers] 01/01: NUMBERS-136: log10() uses log() functionality
Date Wed, 04 Dec 2019 19:03:28 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 3714f9f808444e726fa4c5250362f4ad6d79d54e
Author: Eric Barnhill <ericbarnhill@protonmail.ch>
AuthorDate: Wed Dec 4 11:02:43 2019 -0800

    NUMBERS-136: log10() uses log() functionality
---
 .../java/org/apache/commons/numbers/complex/Complex.java   | 14 ++------------
 1 file changed, 2 insertions(+), 12 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 d218a6a..5a2c070 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
@@ -1259,18 +1259,8 @@ 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));
+        Complex logE = log();
+        return ofCartesian(logE.real / Math.log(10), logE.imaginary);
     }
 
     /**


Mime
View raw message