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 2019/12/04 19:03:27 UTC

[commons-numbers] branch NUMBERS-136 created (now 3714f9f)

This is an automated email from the ASF dual-hosted git repository.

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


      at 3714f9f  NUMBERS-136: log10() uses log() functionality

This branch includes the following new commits:

     new 3714f9f  NUMBERS-136: log10() uses log() functionality

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[commons-numbers] 01/01: NUMBERS-136: log10() uses log() functionality

Posted by er...@apache.org.
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 <er...@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);
     }
 
     /**