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/09/29 01:38:18 UTC

[commons-numbers] branch master updated (05e7ab8 -> 85d79ed)

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

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


    from 05e7ab8  Javadoc.
     new 1112388  Named constants.
     new 85d79ed  Named constant.

The 2 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.


Summary of changes:
 .../apache/commons/numbers/complex/Complex.java    | 28 +++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)


[commons-numbers] 02/02: Named constant.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 85d79edf87cdbcb355a98a0d768449a62f55025b
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Sun Sep 29 03:37:37 2019 +0200

    Named constant.
---
 .../src/main/java/org/apache/commons/numbers/complex/Complex.java     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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 df581a9..28db64e 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
@@ -58,6 +58,8 @@ public final class Complex implements Serializable  {
     private static final double PI_OVER_2 = 0.5 * Math.PI;
     /** &pi;/4. */
     private static final double PI_OVER_4 = 0.25 * Math.PI;
+    /** "-i". */
+    private static final Complex MINUS_I = new Complex(0, -1);
 
     /** Serializable version identifier. */
     private static final long serialVersionUID = 20180201L;
@@ -1211,7 +1213,7 @@ public final class Complex implements Serializable  {
             return ONE;
         }
         if (imaginary < -20) {
-            return new Complex(0, -1);
+            return MINUS_I;
         }
 
         final double real2 = 2 * real;


[commons-numbers] 01/02: Named constants.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1112388285df80a39dd2ee781da6c81428642df1
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Sun Sep 29 03:31:27 2019 +0200

    Named constants.
---
 .../apache/commons/numbers/complex/Complex.java    | 24 +++++++++++++---------
 1 file changed, 14 insertions(+), 10 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 dc69104..df581a9 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
@@ -54,6 +54,10 @@ public final class Complex implements Serializable  {
     public static final Complex ZERO = new Complex(0, 0);
     /** A complex number representing "NaN + NaN i" */
     private static final Complex NAN = new Complex(Double.NaN, Double.NaN);
+    /** &pi;/2. */
+    private static final double PI_OVER_2 = 0.5 * Math.PI;
+    /** &pi;/4. */
+    private static final double PI_OVER_4 = 0.25 * Math.PI;
 
     /** Serializable version identifier. */
     private static final long serialVersionUID = 20180201L;
@@ -721,10 +725,10 @@ public final class Complex implements Serializable  {
     public Complex acos() {
         if (real == 0 &&
             Double.isNaN(imaginary)) {
-            return new Complex(Math.PI * 0.5, Double.NaN);
+            return new Complex(PI_OVER_2, Double.NaN);
         } else if (neitherInfiniteNorZeroNorNaN(real) &&
                    imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Math.PI * 0.5, Double.NEGATIVE_INFINITY);
+            return new Complex(PI_OVER_2, Double.NEGATIVE_INFINITY);
         } else if (real == Double.NEGATIVE_INFINITY &&
                    imaginary == 1) {
             return new Complex(Math.PI, Double.NEGATIVE_INFINITY);
@@ -736,7 +740,7 @@ public final class Complex implements Serializable  {
             return new Complex(Math.PI * 0.75, Double.NEGATIVE_INFINITY);
         } else if (real == Double.POSITIVE_INFINITY &&
                    imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Math.PI * 0.25, Double.NEGATIVE_INFINITY);
+            return new Complex(PI_OVER_4, Double.NEGATIVE_INFINITY);
         } else if (real == Double.POSITIVE_INFINITY &&
                    Double.isNaN(imaginary)) {
             return new Complex(Double.NaN , Double.POSITIVE_INFINITY);
@@ -788,13 +792,13 @@ public final class Complex implements Serializable  {
     public Complex asinh(){
         if (neitherInfiniteNorZeroNorNaN(real) &&
             imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.5);
+            return new Complex(Double.POSITIVE_INFINITY, PI_OVER_2);
         } else if (real == Double.POSITIVE_INFINITY &&
                    !Double.isInfinite(imaginary) && !Double.isNaN(imaginary)) {
             return new Complex(Double.POSITIVE_INFINITY, 0);
         } else if (real == Double.POSITIVE_INFINITY &&
                    imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.25);
+            return new Complex(Double.POSITIVE_INFINITY, PI_OVER_4);
         } else if (real == Double.POSITIVE_INFINITY &&
                    Double.isNaN(imaginary)) {
             return new Complex(Double.POSITIVE_INFINITY,  Double.NaN);
@@ -827,19 +831,19 @@ public final class Complex implements Serializable  {
             return new Complex(Double.POSITIVE_INFINITY, 0);
         } else if (neitherInfiniteNorZeroNorNaN(real) &&
                    imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(0, Math.PI * 0.5);
+            return new Complex(0, PI_OVER_2);
         } else if (real == Double.POSITIVE_INFINITY &&
                    neitherInfiniteNorZeroNorNaN(imaginary)) {
-            return new Complex(0, Math.PI * 0.5);
+            return new Complex(0, PI_OVER_2);
         } else if (real == Double.POSITIVE_INFINITY &&
                    imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(0, Math.PI * 0.5);
+            return new Complex(0, PI_OVER_2);
         } else if (real == Double.POSITIVE_INFINITY &&
                    Double.isNaN(imaginary)) {
             return new Complex(0, Double.NaN);
         } else if (Double.isNaN(real) &&
                    imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(0, Math.PI * 0.5);
+            return new Complex(0, PI_OVER_2);
         }
         return add(ONE).divide(ONE.subtract(this)).log().multiply(0.5);
     }
@@ -989,7 +993,7 @@ public final class Complex implements Serializable  {
     public Complex log() {
         if (real == Double.POSITIVE_INFINITY &&
             imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.25);
+            return new Complex(Double.POSITIVE_INFINITY, PI_OVER_4);
         } else if (real == Double.POSITIVE_INFINITY &&
                    Double.isNaN(imaginary)) {
             return new Complex(Double.POSITIVE_INFINITY, Double.NaN);