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 2018/01/26 14:00:12 UTC

[21/37] commons-numbers git commit: NUMBERS-13: log() passes all tests

NUMBERS-13: log() passes all tests


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/ed752558
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/ed752558
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/ed752558

Branch: refs/heads/master
Commit: ed75255890e78d9b7ee261f7daad9b3436c74e8e
Parents: 6bf4d8b
Author: Eric Barnhill <er...@apache.org>
Authored: Wed Jul 19 16:14:04 2017 +0200
Committer: Eric Barnhill <er...@apache.org>
Committed: Wed Jul 19 16:14:04 2017 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/commons/numbers/complex/Complex.java | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/ed752558/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
----------------------------------------------------------------------
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 2a1795c..effa604 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
@@ -879,6 +879,13 @@ in the
      * of {@code this}.
      */
     public Complex log() {
+        if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+            return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.25);
+        } else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
+            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+        } else if (Double.isNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
+            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+        }
         return new Complex(Math.log(abs()),
                              Math.atan2(imaginary, real));
     }