commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ericbarnh...@apache.org
Subject commons-numbers git commit: NUMBERS-13: log() passes all tests
Date Wed, 19 Jul 2017 14:12:05 GMT
Repository: commons-numbers
Updated Branches:
  refs/heads/complex-dev 6bf4d8b74 -> ed7525589


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/complex-dev
Commit: ed75255890e78d9b7ee261f7daad9b3436c74e8e
Parents: 6bf4d8b
Author: Eric Barnhill <ericbarnhill@apache.org>
Authored: Wed Jul 19 16:14:04 2017 +0200
Committer: Eric Barnhill <ericbarnhill@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));
     }


Mime
View raw message