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/02/02 13:28:56 UTC
[01/50] commons-numbers git commit: NUMBERS-49: set doubles in
tangent, tanh, divide and reciprocal to final
Repository: commons-numbers
Updated Branches:
refs/heads/feature__NUMBERS-51__field 797e40250 -> d2ff5bfb3
NUMBERS-49: set doubles in tangent, tanh, divide and reciprocal to final
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/dc430844
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/dc430844
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/dc430844
Branch: refs/heads/feature__NUMBERS-51__field
Commit: dc430844316a5b49f63363efb4d774e31f4eb3dc
Parents: 463f017
Author: Eric Barnhill <er...@apache.org>
Authored: Thu Sep 7 15:55:04 2017 +0200
Committer: Eric Barnhill <er...@apache.org>
Committed: Thu Sep 7 15:55:04 2017 +0200
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 30 ++++++++++----------
1 file changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/dc430844/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 e771bca..5470d5e 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
@@ -187,13 +187,13 @@ public class Complex implements Serializable {
if (imaginary == 0.0) {
return Math.abs(real);
}
- double q = real / imaginary;
+ final double q = real / imaginary;
return Math.abs(imaginary) * Math.sqrt(1 + q * q);
} else {
if (real == 0.0) {
return Math.abs(imaginary);
}
- double q = imaginary / real;
+ final double q = imaginary / real;
return Math.abs(real) * Math.sqrt(1 + q * q);
}
}
@@ -314,13 +314,13 @@ in the
}
if (Math.abs(c) < Math.abs(d)) {
- double q = c / d;
- double denominator = c * q + d;
+ final double q = c / d;
+ final double denominator = c * q + d;
return new Complex((real * q + imaginary) / denominator,
(imaginary * q - real) / denominator);
} else {
- double q = d / c;
- double denominator = d * q + c;
+ final double q = d / c;
+ final double denominator = d * q + c;
return new Complex((imaginary * q + real) / denominator,
(imaginary - real * q) / denominator);
}
@@ -355,7 +355,7 @@ in the
if (Math.abs(real) < Math.abs(imaginary)) {
final double q = real / imaginary;
final double scale = 1. / (real * q + imaginary);
- final double scaleQ;
+ double scaleQ = 0;
if (q != 0 && scale != 0) {
scaleQ = scale * q;
}
@@ -363,7 +363,7 @@ in the
} else {
final double q = imaginary / real;
final double scale = 1. / (imaginary * q + real);
- final double scaleQ;
+ double scaleQ = 0;
if (q != 0 && scale != 0) {
scaleQ = scale * q;
}
@@ -1038,7 +1038,7 @@ in the
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
}
- double t = Math.sqrt((Math.abs(real) + abs()) / 2.0);
+ final double t = Math.sqrt((Math.abs(real) + abs()) / 2.0);
if (real >= 0.0) {
return new Complex(t, imaginary / (2.0 * t));
} else {
@@ -1085,9 +1085,9 @@ in the
return new Complex(0.0, -1.0);
}
- double real2 = 2.0 * real;
- double imaginary2 = 2.0 * imaginary;
- double d = Math.cos(real2) + Math.cosh(imaginary2);
+ final double real2 = 2.0 * real;
+ final double imaginary2 = 2.0 * imaginary;
+ final double d = Math.cos(real2) + Math.cosh(imaginary2);
return new Complex(Math.sin(real2) / d,
Math.sinh(imaginary2) / d);
@@ -1117,9 +1117,9 @@ in the
} else if (Double.isNaN(real) && imaginary == 0) {
return new Complex(Double.NaN, 0);
}
- double real2 = 2.0 * real;
- double imaginary2 = 2.0 * imaginary;
- double d = Math.cosh(real2) + Math.cos(imaginary2);
+ final double real2 = 2.0 * real;
+ final double imaginary2 = 2.0 * imaginary;
+ final double d = Math.cosh(real2) + Math.cos(imaginary2);
return new Complex(Math.sinh(real2) / d,
Math.sin(imaginary2) / d);
[37/50] commons-numbers git commit: Unnecessary instantiation.
Posted by er...@apache.org.
Unnecessary instantiation.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/49ed2b81
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/49ed2b81
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/49ed2b81
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 49ed2b81e8a086fd0a801ba2fa54a4f16827512f
Parents: 5dbfebe
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 13:09:33 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 13:09:33 2018 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/49ed2b81/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 a56c641..d474c31 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
@@ -706,7 +706,7 @@ public class Complex implements Serializable {
*/
public Complex atan() {
return this.add(I).divide(I.subtract(this)).log()
- .multiply(I.divide(createComplex(2, 0)));
+ .multiply(I.multiply(0.5));
}
/**
[19/50] commons-numbers git commit: Deleted unused method.
Posted by er...@apache.org.
Deleted unused method.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/662d201b
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/662d201b
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/662d201b
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 662d201b68ed5100abf2ee40359734194850562d
Parents: 2e07396
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:56:54 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:56:54 2018 +0100
----------------------------------------------------------------------
.../org/apache/commons/numbers/complex/Complex.java | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/662d201b/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 60e85c8..99888f2 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
@@ -1261,18 +1261,7 @@ public class Complex implements Serializable {
}
}
- /**
- * Check that the argument is positive and throw a RuntimeException
- * if it is not.
- * @param arg {@code int} to check
- */
- private static void checkNotNegative(int arg) {
- if (arg <= 0) {
- throw new RuntimeException("Complex: Non-positive argument");
- }
- }
-
- /**
+ /**
* Check that the argument is positive and throw a RuntimeException
* if it is not.
* @param arg {@code double} to check
[17/50] commons-numbers git commit: Javadoc.
Posted by er...@apache.org.
Javadoc.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/3f3b7ad0
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/3f3b7ad0
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/3f3b7ad0
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 3f3b7ad0122b37a9e831ea0eedfc7602956de5d2
Parents: b2d2267
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:43:40 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:43:40 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/3f3b7ad0/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 281822b..b1e7f50 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
@@ -475,7 +475,7 @@ public class Complex implements Serializable {
}
/**
- * Get a hashCode for the complex number.
+ * Get a hash code for the complex number.
* Any {@code Double.NaN} value in real or imaginary part produces
* the same hash code {@code 7}.
*
@@ -489,6 +489,10 @@ public class Complex implements Serializable {
return 37 * (17 * hash(imaginary) + hash(real));
}
+ /**
+ * @param d Value.
+ * @return a hash code for the given value.
+ */
private int hash(double d) {
final long v = Double.doubleToLongBits(d);
return (int)(v^(v>>>32));
@@ -1291,6 +1295,18 @@ public class Complex implements Serializable {
return new Double(x).equals(new Double(y));
}
+ /**
+ * Check that a value meets all the following conditions:
+ * <ul>
+ * <li>it is not {@code NaN},</li>
+ * <li>it is not infinite,</li>
+ * <li>it is not zero,</li>
+ * </ul>
+ *
+ * @param d Value.
+ * @return {@code true} if {@code d} meets all the conditions and
+ * {@code false} otherwise.
+ */
private static boolean neitherInfiniteNorZeroNorNaN(double d) {
if (!Double.isNaN(d) && !Double.isInfinite(d) && d != 0) {
return true;
[28/50] commons-numbers git commit: Activate "Jacoco".
Posted by er...@apache.org.
Activate "Jacoco".
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/2d1f7676
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/2d1f7676
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/2d1f7676
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 2d1f76767c8de17b65a9e091f3a08119719e7870
Parents: 11ab8c2
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Wed Jan 31 16:51:56 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Wed Jan 31 16:51:56 2018 +0100
----------------------------------------------------------------------
.../src/site/resources/profile.jacoco | 17 +++++++++++++++++
.../src/site/resources/profile.jacoco | 17 +++++++++++++++++
.../src/site/resources/profile.jacoco | 17 +++++++++++++++++
.../src/site/resources/profile.jacoco | 17 +++++++++++++++++
.../src/site/resources/profile.jacoco | 17 +++++++++++++++++
.../src/site/resources/profile.jacoco | 17 +++++++++++++++++
.../src/site/resources/profile.jacoco | 17 +++++++++++++++++
.../src/site/resources/profile.jacoco | 17 +++++++++++++++++
.../src/site/resources/profile.jacoco | 17 +++++++++++++++++
9 files changed, 153 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2d1f7676/commons-numbers-angle/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/site/resources/profile.jacoco b/commons-numbers-angle/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-angle/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2d1f7676/commons-numbers-arrays/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-arrays/src/site/resources/profile.jacoco b/commons-numbers-arrays/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-arrays/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2d1f7676/commons-numbers-combinatorics/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-combinatorics/src/site/resources/profile.jacoco b/commons-numbers-combinatorics/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-combinatorics/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2d1f7676/commons-numbers-complex/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/site/resources/profile.jacoco b/commons-numbers-complex/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-complex/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2d1f7676/commons-numbers-core/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-core/src/site/resources/profile.jacoco b/commons-numbers-core/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-core/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2d1f7676/commons-numbers-fraction/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-fraction/src/site/resources/profile.jacoco b/commons-numbers-fraction/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-fraction/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2d1f7676/commons-numbers-gamma/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-gamma/src/site/resources/profile.jacoco b/commons-numbers-gamma/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-gamma/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2d1f7676/commons-numbers-primes/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-primes/src/site/resources/profile.jacoco b/commons-numbers-primes/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-primes/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2d1f7676/commons-numbers-quaternion/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-quaternion/src/site/resources/profile.jacoco b/commons-numbers-quaternion/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-quaternion/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom
[11/50] commons-numbers git commit: Trailing spaces.
Posted by er...@apache.org.
Trailing spaces.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/5ed62806
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/5ed62806
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/5ed62806
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 5ed62806c78286c006a8fe0919a8b51822542eb7
Parents: dc83272
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Mon Jan 29 02:08:10 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Mon Jan 29 02:08:10 2018 +0100
----------------------------------------------------------------------
commons-numbers-field/src/site/xdoc/index.xml | 1 -
.../java/org/apache/commons/numbers/field/FieldParametricTest.java | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/5ed62806/commons-numbers-field/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/commons-numbers-field/src/site/xdoc/index.xml b/commons-numbers-field/src/site/xdoc/index.xml
index 95ea0ac..74187e7 100644
--- a/commons-numbers-field/src/site/xdoc/index.xml
+++ b/commons-numbers-field/src/site/xdoc/index.xml
@@ -16,7 +16,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
<document>
<properties>
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/5ed62806/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
index fc123b8..4fee7cd 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
@@ -108,6 +108,6 @@ public class FieldParametricTest {
public void testDistributivity() {
final Object r1 = field.multiply(a, field.add(b, c));
final Object r2 = field.add(field.multiply(a, b), field.multiply(a, c));
- Assert.assertTrue(r1.equals(r2));
+ Assert.assertTrue(r1.equals(r2));
}
}
[02/50] commons-numbers git commit: NUMBERS-48: Dead code has been
removed
Posted by er...@apache.org.
NUMBERS-48: Dead code has been removed
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/16322d83
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/16322d83
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/16322d83
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 16322d83ab3092e93a1e2d7f576b185682c16f69
Parents: dc43084
Author: Eric Barnhill <er...@apache.org>
Authored: Wed Sep 13 15:16:46 2017 +0200
Committer: Eric Barnhill <er...@apache.org>
Committed: Wed Sep 13 15:16:46 2017 +0200
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/16322d83/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 5470d5e..71a4220 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
@@ -184,9 +184,6 @@ public class Complex implements Serializable {
*/
public double abs() {
if (Math.abs(real) < Math.abs(imaginary)) {
- if (imaginary == 0.0) {
- return Math.abs(real);
- }
final double q = real / imaginary;
return Math.abs(imaginary) * Math.sqrt(1 + q * q);
} else {
[18/50] commons-numbers git commit: Unnecessary branching.
Posted by er...@apache.org.
Unnecessary branching.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/2e07396d
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/2e07396d
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/2e07396d
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 2e07396d80cdd9ee2d7c824bbd5e6b321234cbfa
Parents: 3f3b7ad
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:45:33 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:45:33 2018 +0100
----------------------------------------------------------------------
.../main/java/org/apache/commons/numbers/complex/Complex.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2e07396d/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 b1e7f50..60e85c8 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
@@ -1308,8 +1308,8 @@ public class Complex implements Serializable {
* {@code false} otherwise.
*/
private static boolean neitherInfiniteNorZeroNorNaN(double d) {
- if (!Double.isNaN(d) && !Double.isInfinite(d) && d != 0) {
- return true;
- } else return false;
+ return !Double.isNaN(d) &&
+ !Double.isInfinite(d) &&
+ d != 0;
}
}
[05/50] commons-numbers git commit: Merge branch 'complex-dev'
Posted by er...@apache.org.
Merge branch 'complex-dev'
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/4b955ca2
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/4b955ca2
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/4b955ca2
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 4b955ca24a338ffa89bb49b3b0c8cabeb35fbea7
Parents: 71303aa 8830e47
Author: Eric Barnhill <er...@apache.org>
Authored: Fri Jan 26 15:36:15 2018 +0100
Committer: Eric Barnhill <er...@apache.org>
Committed: Fri Jan 26 15:36:15 2018 +0100
----------------------------------------------------------------------
.gitignore | 1 +
.../apache/commons/numbers/complex/Complex.java | 819 +++++++++----------
.../commons/numbers/complex/ComplexUtils.java | 806 ++++++++++++------
.../commons/numbers/complex/CStandardTest.java | 282 +++++++
.../commons/numbers/complex/ComplexTest.java | 687 +---------------
5 files changed, 1273 insertions(+), 1322 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/4b955ca2/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
----------------------------------------------------------------------
diff --cc commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
index 1275b27,529521d..3fabfab
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
+++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
@@@ -744,17 -881,17 +881,17 @@@ public class ComplexUtils
*/
public static double[][] complex2Interleaved(Complex[][] c, int interleavedDim) {
if (interleavedDim > 1 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
- final int width = c.length;
- final int height = c[0].length;
- double[][] d;
+ final int w = c.length;
+ final int h = c[0].length;
+ double[][] i;
if (interleavedDim == 0) {
- d = new double[2 * width][height];
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- d[x * 2][y] = c[x][y].getReal();
- d[x * 2 + 1][y] = c[x][y].getImaginary();
+ i = new double[2 * w][h];
+ for (int x = 0; x < w; x++) {
+ for (int y = 0; y < h; y++) {
+ i[x * 2][y] = c[x][y].getReal();
+ i[x * 2 + 1][y] = c[x][y].getImaginary();
}
}
} else {
@@@ -797,19 -934,19 +934,19 @@@
*/
public static double[][][] complex2Interleaved(Complex[][][] c, int interleavedDim) {
if (interleavedDim > 2 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
- int width = c.length;
- int height = c[0].length;
- int depth = c[0][0].length;
- double[][][] d;
+ int w = c.length;
+ int h = c[0].length;
+ int d = c[0][0].length;
+ double[][][] i;
if (interleavedDim == 0) {
- d = new double[2 * width][height][depth];
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- for (int z = 0; z < depth; z++) {
- d[x * 2][y][z] = c[x][y][z].getReal();
- d[x * 2 + 1][y][z] = c[x][y][z].getImaginary();
+ i = new double[2 * w][h][d];
+ for (int x = 0; x < w; x++) {
+ for (int y = 0; y < h; y++) {
+ for (int z = 0; z < d; z++) {
+ i[x * 2][y][z] = c[x][y][z].getReal();
+ i[x * 2 + 1][y][z] = c[x][y][z].getImaginary();
}
}
}
@@@ -865,17 -1089,17 +1089,17 @@@
*/
public static float[][] complex2InterleavedFloat(Complex[][] c, int interleavedDim) {
if (interleavedDim > 1 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
- final int width = c.length;
- final int height = c[0].length;
- float[][] d;
+ final int w = c.length;
+ final int h = c[0].length;
+ float[][] i;
if (interleavedDim == 0) {
- d = new float[2 * width][height];
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- d[x * 2][y] = (float) c[x][y].getReal();
- d[x * 2 + 1][y] = (float) c[x][y].getImaginary();
+ i = new float[2 * w][h];
+ for (int x = 0; x < w; x++) {
+ for (int y = 0; y < h; y++) {
+ i[x * 2][y] = (float) c[x][y].getReal();
+ i[x * 2 + 1][y] = (float) c[x][y].getImaginary();
}
}
} else {
@@@ -919,19 -1143,19 +1143,19 @@@
*/
public static float[][][] complex2InterleavedFloat(Complex[][][] c, int interleavedDim) {
if (interleavedDim > 2 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
- final int width = c.length;
- final int height = c[0].length;
- final int depth = c[0][0].length;
- float[][][] d;
+ final int w = c.length;
+ final int h = c[0].length;
+ final int d = c[0][0].length;
+ float[][][] i;
if (interleavedDim == 0) {
- d = new float[2 * width][height][depth];
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- for (int z = 0; z < depth; z++) {
- d[x * 2][y][z] = (float) c[x][y][z].getReal();
- d[x * 2 + 1][y][z] = (float) c[x][y][z].getImaginary();
+ i = new float[2 * w][h][d];
+ for (int x = 0; x < w; x++) {
+ for (int y = 0; y < h; y++) {
+ for (int z = 0; z < d; z++) {
+ i[x * 2][y][z] = (float) c[x][y][z].getReal();
+ i[x * 2 + 1][y][z] = (float) c[x][y][z].getImaginary();
}
}
}
@@@ -983,20 -1207,20 +1207,20 @@@
* @param interleavedDim Depth level of the array to interleave
* @return 2D {@code Complex} array
*
- * @since 4.0
+ * @since 1.0
*/
- public static Complex[][] interleaved2Complex(double[][] d, int interleavedDim) {
+ public static Complex[][] interleaved2Complex(double[][] i, int interleavedDim) {
if (interleavedDim > 1 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
- final int width = d.length;
- final int height = d[0].length;
+ final int w = i.length;
+ final int h = i[0].length;
Complex[][] c;
if (interleavedDim == 0) {
- c = new Complex[width / 2][height];
- for (int x = 0; x < width / 2; x++) {
- for (int y = 0; y < height; y++) {
- c[x][y] = new Complex(d[x * 2][y], d[x * 2 + 1][y]);
+ c = new Complex[w / 2][h];
+ for (int x = 0; x < w / 2; x++) {
+ for (int y = 0; y < h; y++) {
+ c[x][y] = new Complex(i[x * 2][y], i[x * 2 + 1][y]);
}
}
} else {
@@@ -1032,22 -1256,22 +1256,22 @@@
* @param interleavedDim Depth level of the array to interleave
* @return 3D {@code Complex} array
*
- * @since 4.0
+ * @since 1.0
*/
- public static Complex[][][] interleaved2Complex(double[][][] d, int interleavedDim) {
+ public static Complex[][][] interleaved2Complex(double[][][] i, int interleavedDim) {
if (interleavedDim > 2 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
- final int width = d.length;
- final int height = d[0].length;
- final int depth = d[0][0].length;
+ final int w = i.length;
+ final int h = i[0].length;
+ final int d = i[0][0].length;
Complex[][][] c;
if (interleavedDim == 0) {
- c = new Complex[width / 2][height][depth];
- for (int x = 0; x < width / 2; x++) {
- for (int y = 0; y < height; y++) {
- for (int z = 0; z < depth; z++) {
- c[x][y][z] = new Complex(d[x * 2][y][z], d[x * 2 + 1][y][z]);
+ c = new Complex[w / 2][h][d];
+ for (int x = 0; x < w / 2; x++) {
+ for (int y = 0; y < h; y++) {
+ for (int z = 0; z < d; z++) {
+ c[x][y][z] = new Complex(i[x * 2][y][z], i[x * 2 + 1][y][z]);
}
}
}
@@@ -1095,20 -1386,20 +1386,20 @@@
* @param interleavedDim Depth level of the array to interleave
* @return 2D {@code Complex} array
*
- * @since 4.0
+ * @since 1.0
*/
- public static Complex[][] interleaved2Complex(float[][] d, int interleavedDim) {
+ public static Complex[][] interleaved2Complex(float[][] i, int interleavedDim) {
if (interleavedDim > 1 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
- final int width = d.length;
- final int height = d[0].length;
+ final int w = i.length;
+ final int h = i[0].length;
Complex[][] c;
if (interleavedDim == 0) {
- c = new Complex[width / 2][height];
- for (int x = 0; x < width / 2; x++) {
- for (int y = 0; y < height; y++) {
- c[x][y] = new Complex(d[x * 2][y], d[x * 2 + 1][y]);
+ c = new Complex[w / 2][h];
+ for (int x = 0; x < w / 2; x++) {
+ for (int y = 0; y < h; y++) {
+ c[x][y] = new Complex(i[x * 2][y], i[x * 2 + 1][y]);
}
}
} else {
@@@ -1144,22 -1435,22 +1435,22 @@@
* @param interleavedDim Depth level of the array to interleave
* @return 3D {@code Complex} array
*
- * @since 4.0
+ * @since 1.0
*/
- public static Complex[][][] interleaved2Complex(float[][][] d, int interleavedDim) {
+ public static Complex[][][] interleaved2Complex(float[][][] i, int interleavedDim) {
if (interleavedDim > 2 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
- final int width = d.length;
- final int height = d[0].length;
- final int depth = d[0][0].length;
+ final int w = i.length;
+ final int h = i[0].length;
+ final int d = i[0][0].length;
Complex[][][] c;
if (interleavedDim == 0) {
- c = new Complex[width / 2][height][depth];
- for (int x = 0; x < width/2; x ++) {
- for (int y = 0; y < height; y++) {
- for (int z = 0; z < depth; z++) {
- c[x][y][z] = new Complex(d[x * 2][y][z], d[x * 2 + 1][y][z]);
+ c = new Complex[w / 2][h][d];
+ for (int x = 0; x < w/2; x ++) {
+ for (int y = 0; y < h; y++) {
+ for (int z = 0; z < d; z++) {
+ c[x][y][z] = new Complex(i[x * 2][y][z], i[x * 2 + 1][y][z]);
}
}
}
[50/50] commons-numbers git commit: Merge branch 'master' into
feature__NUMBERS-51__field
Posted by er...@apache.org.
Merge branch 'master' into feature__NUMBERS-51__field
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/d2ff5bfb
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/d2ff5bfb
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/d2ff5bfb
Branch: refs/heads/feature__NUMBERS-51__field
Commit: d2ff5bfb36620400c4c5bf02d03396eea9acca54
Parents: 7b1d76a 810f26c
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Fri Feb 2 14:27:23 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Fri Feb 2 14:27:23 2018 +0100
----------------------------------------------------------------------
.../src/site/resources/profile.jacoco | 17 +
.../src/site/resources/profile.jacoco | 17 +
.../src/site/resources/profile.jacoco | 17 +
.../apache/commons/numbers/complex/Complex.java | 415 +++++++++++--------
.../src/site/resources/profile.jacoco | 17 +
.../src/site/resources/profile.jacoco | 17 +
.../src/site/resources/profile.jacoco | 17 +
.../src/site/resources/profile.jacoco | 17 +
.../src/site/resources/profile.jacoco | 17 +
.../src/site/resources/profile.jacoco | 17 +
pom.xml | 2 +-
src/site/site.xml | 6 +-
12 files changed, 390 insertions(+), 186 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d2ff5bfb/pom.xml
----------------------------------------------------------------------
[07/50] commons-numbers git commit: Nit-picks (alignment).
Posted by er...@apache.org.
Nit-picks (alignment).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/dd15519e
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/dd15519e
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/dd15519e
Branch: refs/heads/feature__NUMBERS-51__field
Commit: dd15519eabf02dcb09824de7cf753de9865883d6
Parents: bf05e06
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Sat Jan 27 17:53:53 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Sat Jan 27 17:53:53 2018 +0100
----------------------------------------------------------------------
.../main/java/org/apache/commons/numbers/complex/Complex.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/dd15519e/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 71a4220..ee0c147 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
@@ -195,10 +195,9 @@ public class Complex implements Serializable {
}
}
- /**
+ /**
* Return the norm of this complex number, defined as the square of the magnitude
-in the
- * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/cproj.html">
+ * in the <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/cproj.html">
* IEEE and ISO C standards</a>.
*
* @return the norm.
@@ -222,7 +221,7 @@ in the
public Complex add(Complex addend) {
checkNotNull(addend);
return new Complex(real + addend.getReal(),
- imaginary + addend.getImaginary());
+ imaginary + addend.getImaginary());
}
/**
[46/50] commons-numbers git commit: Self-documenting.
Posted by er...@apache.org.
Self-documenting.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/ac1975ce
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/ac1975ce
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/ac1975ce
Branch: refs/heads/feature__NUMBERS-51__field
Commit: ac1975ce8826cc668823de2cd36d1fa612b301a7
Parents: bcbfee1
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Fri Feb 2 01:42:00 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Fri Feb 2 01:42:00 2018 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/ac1975ce/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 125a0b4..7187507 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
@@ -1117,7 +1117,7 @@ public class Complex implements Serializable {
* @return the square root of <code>1 - this<sup>2</sup></code>.
*/
public Complex sqrt1z() {
- return ONE.subtract(multiply(this)).sqrt();
+ return ONE.subtract(square()).sqrt();
}
/**
[20/50] commons-numbers git commit: Added "throw" statement.
Posted by er...@apache.org.
Added "throw" statement.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/590010c7
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/590010c7
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/590010c7
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 590010c7663c06e46c21865b803e34f844e468c5
Parents: 662d201
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:59:42 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:59:42 2018 +0100
----------------------------------------------------------------------
.../java/org/apache/commons/numbers/complex/ComplexUtils.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/590010c7/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
index f0b39b6..3fdd10f 100644
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
+++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
@@ -987,7 +987,7 @@ public class ComplexUtils {
*/
public static double[][][][] complex2Interleaved(Complex[][][][] c, int interleavedDim) {
if (interleavedDim > 2 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
int w = c.length;
int h = c[0].length;
@@ -1309,7 +1309,7 @@ public class ComplexUtils {
*/
public static Complex[][][][] interleaved2Complex(double[][][][] i, int interleavedDim) {
if (interleavedDim > 2 || interleavedDim < 0) {
- new IndexOutOfRangeException(interleavedDim);
+ throw new IndexOutOfRangeException(interleavedDim);
}
final int w = i.length;
final int h = i[0].length;
[31/50] commons-numbers git commit: Visual clean-up (nit-picks).
Posted by er...@apache.org.
Visual clean-up (nit-picks).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/21d5060f
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/21d5060f
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/21d5060f
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 21d5060f71811799cf5ef64cd872a4f1dee74997
Parents: e42ec50
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 12:48:28 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 12:48:28 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 120 +++++++++----------
1 file changed, 60 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/21d5060f/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 9b4508a..c0561ad 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
@@ -46,7 +46,7 @@ import org.apache.commons.numbers.core.Precision;
*/
public class Complex implements Serializable {
/** The square root of -1. A number representing "0.0 + 1.0i" */
- public static final Complex I = new Complex(0.0, 1.0);
+ public static final Complex I = new Complex(0, 1);
// CHECKSTYLE: stop ConstantName
/** A complex number representing "NaN + NaNi" */
public static final Complex NaN = new Complex(Double.NaN, Double.NaN);
@@ -54,9 +54,9 @@ public class Complex implements Serializable {
/** A complex number representing "+INF + INFi" */
public static final Complex INF = new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
/** A complex number representing "1.0 + 0.0i" */
- public static final Complex ONE = new Complex(1.0, 0.0);
+ public static final Complex ONE = new Complex(1, 0);
/** A complex number representing "0.0 + 0.0i" */
- public static final Complex ZERO = new Complex(0.0, 0.0);
+ public static final Complex ZERO = new Complex(0, 0);
/** Serializable version identifier */
private static final long serialVersionUID = -6195664516687396620L;
@@ -72,7 +72,7 @@ public class Complex implements Serializable {
* @param real Real part.
*/
public Complex(double real) {
- this(real, 0.0);
+ this(real, 0);
}
/**
@@ -189,7 +189,7 @@ public class Complex implements Serializable {
final double q = real / imaginary;
return Math.abs(imaginary) * Math.sqrt(1 + q * q);
} else {
- if (real == 0.0) {
+ if (real == 0) {
return Math.abs(imaginary);
}
final double q = imaginary / real;
@@ -301,8 +301,8 @@ public class Complex implements Serializable {
final double c = divisor.getReal();
final double d = divisor.getImaginary();
- if (c == 0.0 &&
- d == 0.0) {
+ if (c == 0 &&
+ d == 0) {
return NaN;
}
@@ -652,7 +652,7 @@ public class Complex implements Serializable {
* @return the inverse cosine of this complex number.
*/
public Complex acos() {
- if (real == 0.0&& Double.isNaN(imaginary)) {
+ if (real == 0 && Double.isNaN(imaginary)) {
return new Complex(Math.PI * 0.5, Double.NaN);
} else if (neitherInfiniteNorZeroNorNaN(real) &&
imaginary == Double.POSITIVE_INFINITY) {
@@ -705,7 +705,7 @@ public class Complex implements Serializable {
*/
public Complex atan() {
return this.add(I).divide(I.subtract(this)).log()
- .multiply(I.divide(createComplex(2.0, 0.0)));
+ .multiply(I.divide(createComplex(2, 0)));
}
/**
@@ -725,7 +725,7 @@ public class Complex implements Serializable {
return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.5);
} else if (real == Double.POSITIVE_INFINITY &&
!Double.isInfinite(imaginary) && !Double.isNaN(imaginary)) {
- return new Complex(Double.POSITIVE_INFINITY, 0.0);
+ 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);
@@ -733,8 +733,8 @@ public class Complex implements Serializable {
Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
} else if (Double.isNaN(real) &&
- imaginary == 0.0) {
- return new Complex(Double.NaN, 0.0);
+ imaginary == 0) {
+ return new Complex(Double.NaN, 0);
} else if (Double.isNaN(real) &&
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
@@ -754,10 +754,10 @@ public class Complex implements Serializable {
* @since 1.2
*/
public Complex atanh(){
- if (real == 0.0 && Double.isNaN(imaginary)) {
+ if (real == 0 && Double.isNaN(imaginary)) {
return new Complex(0, Double.NaN);
- } else if (neitherInfiniteNorZeroNorNaN(real) && imaginary == 0.0) {
- return new Complex(Double.POSITIVE_INFINITY, 0.0);
+ } else if (neitherInfiniteNorZeroNorNaN(real) && imaginary == 0) {
+ return new Complex(Double.POSITIVE_INFINITY, 0);
} else if (neitherInfiniteNorZeroNorNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
return new Complex(0, Math.PI*0.5);
} else if (real == Double.POSITIVE_INFINITY && neitherInfiniteNorZeroNorNaN(imaginary)) {
@@ -833,15 +833,15 @@ public class Complex implements Serializable {
* @return the hyperbolic cosine of this complex number.
*/
public Complex cosh() {
- if (real == 0.0 &&
+ if (real == 0 &&
imaginary == Double.POSITIVE_INFINITY) {
- return new Complex(Double.NaN, 0.0);
- } else if (real == 0.0 &&
+ return new Complex(Double.NaN, 0);
+ } else if (real == 0 &&
Double.isNaN(imaginary)) {
- return new Complex(Double.NaN, 0.0);
+ return new Complex(Double.NaN, 0);
} else if (real == Double.POSITIVE_INFINITY &&
- imaginary == 0.0) {
- return new Complex(Double.POSITIVE_INFINITY, 0.0);
+ imaginary == 0) {
+ return new Complex(Double.POSITIVE_INFINITY, 0);
} else if (real == Double.POSITIVE_INFINITY &&
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
@@ -849,8 +849,8 @@ public class Complex implements Serializable {
Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
} else if (Double.isNaN(real) &&
- imaginary == 0.0) {
- return new Complex(Double.NaN, 0.0);
+ imaginary == 0) {
+ return new Complex(Double.NaN, 0);
}
return new Complex(Math.cosh(real) * Math.cos(imaginary),
@@ -875,8 +875,8 @@ public class Complex implements Serializable {
*/
public Complex exp() {
if (real == Double.POSITIVE_INFINITY &&
- imaginary == 0.0) {
- return new Complex(Double.POSITIVE_INFINITY, 0.0);
+ imaginary == 0) {
+ return new Complex(Double.POSITIVE_INFINITY, 0);
} else if (real == Double.NEGATIVE_INFINITY &&
imaginary == Double.POSITIVE_INFINITY) {
return Complex.ZERO;
@@ -890,8 +890,8 @@ public class Complex implements Serializable {
Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
} else if (Double.isNaN(real) &&
- imaginary == 0.0) {
- return new Complex(Double.NaN, 0.0);
+ imaginary == 0) {
+ return new Complex(Double.NaN, 0);
}
double expReal = Math.exp(real);
return new Complex(expReal * Math.cos(imaginary),
@@ -958,10 +958,10 @@ public class Complex implements Serializable {
*/
public Complex pow(Complex x) {
checkNotNull(x);
- if (real == 0.0 &&
- imaginary == 0.0) {
+ if (real == 0 &&
+ imaginary == 0) {
if (x.real > 0 &&
- x.imaginary == 0.0) {
+ x.imaginary == 0) {
// 0 raised to positive number is 0
return ZERO;
} else {
@@ -980,8 +980,8 @@ public class Complex implements Serializable {
* @see #pow(Complex)
*/
public Complex pow(double x) {
- if (real == 0.0 &&
- imaginary == 0.0) {
+ if (real == 0 &&
+ imaginary == 0) {
if (x > 0) {
// 0 raised to positive number is 0
return ZERO;
@@ -1032,18 +1032,18 @@ public class Complex implements Serializable {
* @return the hyperbolic sine of {@code this}.
*/
public Complex sinh() {
- if (real == 0.0 &&
- imaginary == 0.0) {
+ if (real == 0 &&
+ imaginary == 0) {
return Complex.ZERO;
- } else if (real == 0.0 &&
+ } else if (real == 0 &&
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(0, Double.NaN);
- } else if (real == 0.0 &&
+ } else if (real == 0 &&
Double.isNaN(imaginary)) {
return new Complex(0, Double.NaN);
} else if (real == Double.POSITIVE_INFINITY &&
- imaginary == 0.0) {
- return new Complex(Double.POSITIVE_INFINITY, 0.0);
+ imaginary == 0) {
+ return new Complex(Double.POSITIVE_INFINITY, 0);
} else if (real == Double.POSITIVE_INFINITY &&
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
@@ -1051,8 +1051,8 @@ public class Complex implements Serializable {
Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
} else if (Double.isNaN(real) &&
- imaginary == 0.0) {
- return new Complex(Double.NaN, 0.0);
+ imaginary == 0) {
+ return new Complex(Double.NaN, 0);
}
return new Complex(Math.sinh(real) * Math.cos(imaginary),
Math.cosh(real) * Math.sin(imaginary));
@@ -1076,15 +1076,15 @@ public class Complex implements Serializable {
* @return the square root of {@code this}.
*/
public Complex sqrt() {
- if (real == 0.0 &&
- imaginary == 0.0) {
- return new Complex(0.0, 0.0);
+ if (real == 0 &&
+ imaginary == 0) {
+ return new Complex(0, 0);
} else if (neitherInfiniteNorZeroNorNaN(real) &&
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
} else if (real == Double.NEGATIVE_INFINITY &&
neitherInfiniteNorZeroNorNaN(imaginary)) {
- return new Complex(0.0, Double.NaN);
+ return new Complex(0, Double.NaN);
} else if (real == Double.NEGATIVE_INFINITY &&
Double.isNaN(imaginary)) {
return new Complex(Double.NaN, Double.POSITIVE_INFINITY);
@@ -1093,11 +1093,11 @@ public class Complex implements Serializable {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
}
- final double t = Math.sqrt((Math.abs(real) + abs()) / 2.0);
- if (real >= 0.0) {
- return new Complex(t, imaginary / (2.0 * t));
+ final double t = Math.sqrt((Math.abs(real) + abs()) / 2);
+ if (real >= 0) {
+ return new Complex(t, imaginary / (2 * t));
} else {
- return new Complex(Math.abs(imaginary) / (2.0 * t),
+ return new Complex(Math.abs(imaginary) / (2 * t),
Math.copySign(1d, imaginary) * t);
}
}
@@ -1113,7 +1113,7 @@ public class Complex implements Serializable {
* @return the square root of <code>1 - this<sup>2</sup></code>.
*/
public Complex sqrt1z() {
- return new Complex(1.0, 0.0).subtract(this.multiply(this)).sqrt();
+ return new Complex(1, 0).subtract(this.multiply(this)).sqrt();
}
/**
@@ -1133,15 +1133,15 @@ public class Complex implements Serializable {
* @return the tangent of {@code this}.
*/
public Complex tan() {
- if (imaginary > 20.0) {
- return new Complex(0.0, 1.0);
+ if (imaginary > 20) {
+ return new Complex(0, 1);
}
- if (imaginary < -20.0) {
- return new Complex(0.0, -1.0);
+ if (imaginary < -20) {
+ return new Complex(0, -1);
}
- final double real2 = 2.0 * real;
- final double imaginary2 = 2.0 * imaginary;
+ final double real2 = 2 * real;
+ final double imaginary2 = 2 * imaginary;
final double d = Math.cos(real2) + Math.cosh(imaginary2);
return new Complex(Math.sin(real2) / d,
@@ -1167,16 +1167,16 @@ public class Complex implements Serializable {
public Complex tanh() {
if (real == Double.POSITIVE_INFINITY &&
imaginary == Double.POSITIVE_INFINITY) {
- return new Complex(1.0, 0.0);
+ return new Complex(1, 0);
} else if (real == Double.POSITIVE_INFINITY &&
Double.isNaN(imaginary)) {
- return new Complex(1.0, 0.0);
+ return new Complex(1, 0);
} else if (Double.isNaN(real) &&
imaginary == 0) {
return new Complex(Double.NaN, 0);
}
- final double real2 = 2.0 * real;
- final double imaginary2 = 2.0 * imaginary;
+ final double real2 = 2 * real;
+ final double imaginary2 = 2 * imaginary;
final double d = Math.cosh(real2) + Math.cos(imaginary2);
return new Complex(Math.sinh(real2) / d,
@@ -1242,7 +1242,7 @@ public class Complex implements Serializable {
final List<Complex> result = new ArrayList<Complex>();
// nth root of abs -- faster / more accurate to use a solver here?
- final double nthRootOfAbs = Math.pow(abs(), 1.0 / n);
+ final double nthRootOfAbs = Math.pow(abs(), 1d / n);
// Compute nth roots of complex number with k = 0, 1, ... n-1
final double nthPhi = getArgument() / n;
[38/50] commons-numbers git commit: Unnecessary instantiation.
Posted by er...@apache.org.
Unnecessary instantiation.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/2af72846
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/2af72846
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/2af72846
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 2af72846f1b96315804a320f6fd95bcd5458a547
Parents: 49ed2b8
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 13:11:37 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 13:11:37 2018 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2af72846/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 d474c31..ca0eea8 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
@@ -1086,7 +1086,7 @@ public class Complex implements Serializable {
public Complex sqrt() {
if (real == 0 &&
imaginary == 0) {
- return new Complex(0, 0);
+ return ZERO;
} else if (neitherInfiniteNorZeroNorNaN(real) &&
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
[39/50] commons-numbers git commit: Use custom serial version
identifier.
Posted by er...@apache.org.
Use custom serial version identifier.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/f50fbcf4
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/f50fbcf4
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/f50fbcf4
Branch: refs/heads/feature__NUMBERS-51__field
Commit: f50fbcf42c2693055127bda1060a636697427bbb
Parents: 2af7284
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 13:17:24 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 13:17:24 2018 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/f50fbcf4/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 ca0eea8..bdb6c7e 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
@@ -59,7 +59,7 @@ public class Complex implements Serializable {
public static final Complex ZERO = new Complex(0, 0);
/** Serializable version identifier */
- private static final long serialVersionUID = -6195664516687396620L;
+ private static final long serialVersionUID = 20180201L;
/** The imaginary part. */
private final double imaginary;
[21/50] commons-numbers git commit: CheckStyle.
Posted by er...@apache.org.
CheckStyle.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/d011f8be
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/d011f8be
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/d011f8be
Branch: refs/heads/feature__NUMBERS-51__field
Commit: d011f8be2a166e49ebb496a254fff4d74060f818
Parents: 590010c
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 16:38:48 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 16:38:48 2018 +0100
----------------------------------------------------------------------
.../commons/numbers/core/ArithmeticUtils.java | 14 +++++++++-----
.../numbers/fraction/FractionException.java | 1 +
.../apache/commons/numbers/gamma/Digamma.java | 4 ++--
.../apache/commons/numbers/gamma/LogBeta.java | 2 +-
.../apache/commons/numbers/gamma/LogGamma.java | 1 +
.../commons/numbers/gamma/RegularizedGamma.java | 20 ++++++++++++++++----
6 files changed, 30 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
----------------------------------------------------------------------
diff --git a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
index 13055f2..36a84f5 100644
--- a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
+++ b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
@@ -603,7 +603,7 @@ public final class ArithmeticUtils {
*
* @param a Addend.
* @param b Addend.
- * @param pattern Pattern to use for any thrown exception.
+ * @param message Pattern to use for any thrown exception.
* @return the sum {@code a + b}.
* @throws ArithmeticException if the result cannot be represented
* as a {@code long}.
@@ -748,16 +748,19 @@ public final class ArithmeticUtils {
return dividend >= 0L || dividend < divisor ? 0L : 1L;
}
+ /**
+ * Exception.
+ */
private static class NumbersArithmeticException extends ArithmeticException {
/** Serializable version Id. */
- private static final long serialVersionUID = -6024911025449780474L;
-
+ private static final long serialVersionUID = 20180130L;
+ /** Argument to construct a message. */
private final Object[] formatArguments;
/**
* Default constructor.
*/
- public NumbersArithmeticException() {
+ NumbersArithmeticException() {
this("arithmetic exception");
}
@@ -768,11 +771,12 @@ public final class ArithmeticUtils {
* the error.
* @param args Arguments.
*/
- public NumbersArithmeticException(String message, Object ... args) {
+ NumbersArithmeticException(String message, Object ... args) {
super(message);
this.formatArguments = args;
}
+ /** {@inheritDoc} */
@Override
public String getMessage() {
return MessageFormat.format(super.getMessage(), formatArguments);
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
----------------------------------------------------------------------
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
index 1eea0d6..b89bb42 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
@@ -50,6 +50,7 @@ class FractionException extends ArithmeticException {
this.formatArguments = formatArguments;
}
+ /** {@inheritDoc} */
@Override
public String getMessage() {
return MessageFormat.format(super.getMessage(), formatArguments);
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
----------------------------------------------------------------------
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
index 4caa4e7..24d329e 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
@@ -19,11 +19,11 @@ package org.apache.commons.numbers.gamma;
/**
* <a href="http://en.wikipedia.org/wiki/Digamma_function">Digamma function</a>.
* <p>
- * It is defined as the logarithmic derivative of the \( \Gamma \)
+ * It is defined as the logarithmic derivative of the \( \Gamma \)
* ({@link Gamma}) function:
* \( \frac{d}{dx}(\ln \Gamma(x)) = \frac{\Gamma^\prime(x)}{\Gamma(x)} \).
* </p>
- *
+ *
* @see Gamma
*/
public class Digamma {
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java
----------------------------------------------------------------------
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java
index e29aa30..a1fd6ac 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogBeta.java
@@ -253,7 +253,7 @@ public class LogBeta {
* @param a First argument.
* @param b Second argument.
* @return the value of {@code log(Gamma(b) / Gamma(a + b))}.
- * @throws NumberIsTooSmallException if {@code a < 0} or {@code b < 10}.
+ * @throws IllegalArgumentException if {@code a < 0} or {@code b < 10}.
*/
private static double logGammaMinusLogGammaSum(double a,
double b) {
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java
----------------------------------------------------------------------
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java
index 9698155..f58a3bc 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/LogGamma.java
@@ -22,6 +22,7 @@ package org.apache.commons.numbers.gamma;
* Class is immutable.
*/
public class LogGamma {
+ /** Lanczos constant. */
private static final double LANCZOS_G = 607d / 128d;
/** Performance. */
private static final double HALF_LOG_2_PI = 0.5 * Math.log(2.0 * Math.PI);
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d011f8be/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java
----------------------------------------------------------------------
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java
index 94b79d2..cf35665 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/RegularizedGamma.java
@@ -38,7 +38,9 @@ public class RegularizedGamma {
/**
* Computes the regularized gamma function \( P(a, x) \).
*
- * {@inheritDoc}
+ * @param a Argument.
+ * @param x Argument.
+ * @return \( P(a, x) \).
*/
public static double value(double a,
double x) {
@@ -64,7 +66,11 @@ public class RegularizedGamma {
* </li>
* </ul>
*
- * {@inheritDoc}
+ * @param a Argument.
+ * @param x Argument.
+ * @param epsilon Tolerance in continued fraction evaluation.
+ * @param maxIterations Maximum number of iterations in continued fraction evaluation.
+ * @return \( P(a, x) \).
*/
public static double value(double a,
double x,
@@ -117,7 +123,9 @@ public class RegularizedGamma {
/**
* Computes the regularized gamma function \( Q(a, x) = 1 - P(a, x) \).
*
- * {@inheritDoc}
+ * @param a Argument.
+ * @param x Argument.
+ * @return \( Q(a, x) \).
*/
public static double value(double a,
double x) {
@@ -140,7 +148,11 @@ public class RegularizedGamma {
* </li>
* </ul>
*
- * {@inheritDoc}
+ * @param a Argument.
+ * @param x Argument.
+ * @param epsilon Tolerance in continued fraction evaluation.
+ * @param maxIterations Maximum number of iterations in continued fraction evaluation.
+ * @return \( Q(a, x) \).
*/
public static double value(final double a,
double x,
[34/50] commons-numbers git commit: Alignment (nit-picks).
Posted by er...@apache.org.
Alignment (nit-picks).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/a88c7677
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/a88c7677
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/a88c7677
Branch: refs/heads/feature__NUMBERS-51__field
Commit: a88c7677c6f4dfcea2d8ef29f353afe3045df06a
Parents: 2daea44
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 12:56:56 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 12:56:56 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a88c7677/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 7034f94..31d1cf5 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
@@ -756,17 +756,23 @@ public class Complex implements Serializable {
public Complex atanh(){
if (real == 0 && Double.isNaN(imaginary)) {
return new Complex(0, Double.NaN);
- } else if (neitherInfiniteNorZeroNorNaN(real) && imaginary == 0) {
+ } else if (neitherInfiniteNorZeroNorNaN(real) &&
+ imaginary == 0) {
return new Complex(Double.POSITIVE_INFINITY, 0);
- } else if (neitherInfiniteNorZeroNorNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (neitherInfiniteNorZeroNorNaN(real) &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(0, Math.PI * 0.5);
- } else if (real == Double.POSITIVE_INFINITY && neitherInfiniteNorZeroNorNaN(imaginary)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ neitherInfiniteNorZeroNorNaN(imaginary)) {
return new Complex(0, Math.PI * 0.5);
- } else if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(0, Math.PI * 0.5);
- } else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(0, Double.NaN);
- } else if (Double.isNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (Double.isNaN(real) &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(0, Math.PI * 0.5);
}
return this.add(Complex.ONE).divide(Complex.ONE.subtract(this)).log().divide(new Complex(2));
[43/50] commons-numbers git commit: Alignment (nit-picks).
Posted by er...@apache.org.
Alignment (nit-picks).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/4b213be0
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/4b213be0
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/4b213be0
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 4b213be04032d250e93bdd6eeccb2bbfcd2054f8
Parents: 1b2eb22
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Fri Feb 2 00:52:04 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Fri Feb 2 00:52:04 2018 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/4b213be0/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 93e0614..d9d096a 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
@@ -148,7 +148,8 @@ public class Complex implements Serializable {
* @return {@code boolean}
*/
public boolean isInfinite() {
- if (Double.isInfinite(real) || Double.isInfinite(imaginary)) {
+ if (Double.isInfinite(real) ||
+ Double.isInfinite(imaginary)) {
return true;
} else {
return false;
[27/50] commons-numbers git commit: Upgrade to CP 43.
Posted by er...@apache.org.
Upgrade to CP 43.
Requires change in the declaration of MathJax in the web site template.
MathJax does not work anymore as a consequence:
https://issues.apache.org/jira/browse/COMMONSSITE-100
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/11ab8c24
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/11ab8c24
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/11ab8c24
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 11ab8c24429863228a0c52890e80a3f4678dfae0
Parents: d011f8b
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Wed Jan 31 16:37:10 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Wed Jan 31 16:37:10 2018 +0100
----------------------------------------------------------------------
pom.xml | 2 +-
src/site/site.xml | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/11ab8c24/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ba4dc6a..02db55b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
- <version>41</version>
+ <version>43</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/11ab8c24/src/site/site.xml
----------------------------------------------------------------------
diff --git a/src/site/site.xml b/src/site/site.xml
index 4cf098d..7bcb683 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -37,10 +37,10 @@
<!-- <menu name="User Guide">
<item name="Contents" href="/userguide/index.html"/>
</menu> -->
-
+
<head>
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
- </script>
+ <![CDATA[<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
+ </script>]]>
</head>
</body>
[29/50] commons-numbers git commit: Use more specific exception type.
Posted by er...@apache.org.
Use more specific exception type.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/393cf663
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/393cf663
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/393cf663
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 393cf6636de3bac72d09c60b900b2b124fa40e18
Parents: 2d1f767
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 12:19:49 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 12:19:49 2018 +0100
----------------------------------------------------------------------
.../main/java/org/apache/commons/numbers/complex/Complex.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/393cf663/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 99888f2..be58584 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
@@ -1175,7 +1175,7 @@ public class Complex implements Serializable {
public List<Complex> nthRoot(int n) {
if (n <= 0) {
- throw new RuntimeException("cannot compute nth root for null or negative n: {0}");
+ throw new IllegalArgumentException("cannot compute nth root for null or negative n: {0}");
}
final List<Complex> result = new ArrayList<Complex>();
@@ -1257,7 +1257,7 @@ public class Complex implements Serializable {
*/
private static void checkNotNull(Object o) {
if (o == null) {
- throw new RuntimeException("Null Argument to Complex Method");
+ throw new IllegalArgumentException("Null Argument to Complex Method");
}
}
@@ -1268,7 +1268,7 @@ public class Complex implements Serializable {
*/
private static void checkNotNegative(double arg) {
if (arg <= 0) {
- throw new RuntimeException("Complex: Non-positive argument");
+ throw new IllegalArgumentException("Complex: Non-positive argument");
}
}
[40/50] commons-numbers git commit: Visual clean-up (nit-picks).
Posted by er...@apache.org.
Visual clean-up (nit-picks).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/5de033d1
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/5de033d1
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/5de033d1
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 5de033d1b793e6260767609e735105013be6c0d7
Parents: f50fbcf
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 13:22:45 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 13:22:45 2018 +0100
----------------------------------------------------------------------
.../org/apache/commons/numbers/complex/Complex.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/5de033d1/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 bdb6c7e..6e52674 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
@@ -740,7 +740,7 @@ public class Complex implements Serializable {
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
}
- return square().add(Complex.ONE).sqrt().add(this).log();
+ return square().add(ONE).sqrt().add(this).log();
}
/**
@@ -777,7 +777,7 @@ public class Complex implements Serializable {
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(0, Math.PI * 0.5);
}
- return this.add(Complex.ONE).divide(Complex.ONE.subtract(this)).log().multiply(0.5);
+ return this.add(ONE).divide(ONE.subtract(this)).log().multiply(0.5);
}
/**
* Compute the
@@ -791,7 +791,7 @@ public class Complex implements Serializable {
* @since 1.2
*/
public Complex acosh() {
- return square().subtract(Complex.ONE).sqrt().add(this).log();
+ return square().subtract(ONE).sqrt().add(this).log();
}
/**
@@ -1121,7 +1121,7 @@ public class Complex implements Serializable {
* @return the square root of <code>1 - this<sup>2</sup></code>.
*/
public Complex sqrt1z() {
- return Complex.ONE.subtract(this.multiply(this)).sqrt();
+ return ONE.subtract(this.multiply(this)).sqrt();
}
/**
@@ -1142,7 +1142,7 @@ public class Complex implements Serializable {
*/
public Complex tan() {
if (imaginary > 20) {
- return Complex.ONE;
+ return ONE;
}
if (imaginary < -20) {
return new Complex(0, -1);
@@ -1175,10 +1175,10 @@ public class Complex implements Serializable {
public Complex tanh() {
if (real == Double.POSITIVE_INFINITY &&
imaginary == Double.POSITIVE_INFINITY) {
- return Complex.ONE;
+ return ONE;
} else if (real == Double.POSITIVE_INFINITY &&
Double.isNaN(imaginary)) {
- return Complex.ONE;
+ return ONE;
} else if (Double.isNaN(real) &&
imaginary == 0) {
return new Complex(Double.NaN, 0);
[14/50] commons-numbers git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/commons-numbers.git
Posted by er...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/commons-numbers.git
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/6caed745
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/6caed745
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/6caed745
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 6caed745053368c11a4e2fccdf8108e7d7cc4a22
Parents: 45dee2e 230b026
Author: Eric Barnhill <er...@apache.org>
Authored: Mon Jan 29 13:32:19 2018 +0100
Committer: Eric Barnhill <er...@apache.org>
Committed: Mon Jan 29 13:32:19 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 10 +-
.../apache/commons/numbers/core/Precision.java | 117 -------------------
.../commons/numbers/core/PrecisionTest.java | 107 -----------------
3 files changed, 5 insertions(+), 229 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/6caed745/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
----------------------------------------------------------------------
[48/50] commons-numbers git commit: Remove deprecated HTML attribute
(Javadoc).
Posted by er...@apache.org.
Remove deprecated HTML attribute (Javadoc).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/51467b04
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/51467b04
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/51467b04
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 51467b04f01be6c408fe7ba0077090cb6dee27b2
Parents: b077fd5
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Fri Feb 2 13:26:12 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Fri Feb 2 13:26:12 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 34 ++++++++++----------
1 file changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/51467b04/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 f3295c3..763b903 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
@@ -638,7 +638,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/InverseCosine.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/InverseCosine.html">
* inverse cosine</a> of this complex number.
* Implements the formula:
* <p>
@@ -680,7 +680,7 @@ public class Complex implements Serializable {
}
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/InverseSine.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/InverseSine.html">
* inverse sine</a> of this complex number.
* <p>
* {@code asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))}
@@ -692,7 +692,7 @@ public class Complex implements Serializable {
}
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/InverseTangent.html">
* inverse tangent</a> of this complex number.
* Implements the formula:
* <p>
@@ -706,7 +706,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/InverseHyperbolicSine.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/InverseHyperbolicSine.html">
* inverse hyperbolic sine</a> of this complex number.
* Implements the formula:
* <p>
@@ -739,7 +739,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/InverseHyperbolicTangent.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/InverseHyperbolicTangent.html">
* inverse hyperbolic tangent</a> of this complex number.
* Implements the formula:
* <p>
@@ -774,7 +774,7 @@ public class Complex implements Serializable {
}
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/InverseHyperbolicCosine.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/InverseHyperbolicCosine.html">
* inverse hyperbolic cosine</a> of this complex number.
* Implements the formula:
* <p>
@@ -797,7 +797,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/Cosine.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/Cosine.html">
* cosine</a> of this complex number.
* Implements the formula:
* <p>
@@ -817,7 +817,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/HyperbolicCosine.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/HyperbolicCosine.html">
* hyperbolic cosine</a> of this complex number.
* Implements the formula:
* <pre>
@@ -859,7 +859,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/ExponentialFunction.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/ExponentialFunction.html">
* exponential function</a> of this complex number.
* Implements the formula:
* <pre>
@@ -900,7 +900,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/NaturalLogarithm.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/NaturalLogarithm.html">
* natural logarithm</a> of this complex number.
* Implements the formula:
* <pre>
@@ -932,7 +932,7 @@ public class Complex implements Serializable {
/**
* Compute the base 10 or
- * <a href="http://mathworld.wolfram.com/CommonLogarithm.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/CommonLogarithm.html">
* common logarithm</a> of this complex number.
*
* @return the base 10 logarithm of <code>this</code>.
@@ -994,7 +994,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/Sine.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/Sine.html">
* sine</a>
* of this complex number.
* Implements the formula:
@@ -1016,7 +1016,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/HyperbolicSine.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/HyperbolicSine.html">
* hyperbolic sine</a> of this complex number.
* Implements the formula:
* <pre>
@@ -1059,7 +1059,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/SquareRoot.html">
* square root</a> of this complex number.
* Implements the following algorithm to compute {@code sqrt(a + bi)}:
* <ol><li>Let {@code t = sqrt((|a| + |a + bi|) / 2)}</li>
@@ -1103,7 +1103,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/SquareRoot.html">
* square root</a> of <code>1 - this<sup>2</sup></code> for this complex
* number.
* Computes the result directly as
@@ -1117,7 +1117,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/Tangent.html">
* tangent</a> of this complex number.
* Implements the formula:
* <pre>
@@ -1149,7 +1149,7 @@ public class Complex implements Serializable {
/**
* Compute the
- * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top">
+ * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html">
* hyperbolic tangent</a> of this complex number.
* Implements the formula:
* <pre>
[30/50] commons-numbers git commit: Alignment (nit-picks).
Posted by er...@apache.org.
Alignment (nit-picks).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/e42ec505
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/e42ec505
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/e42ec505
Branch: refs/heads/feature__NUMBERS-51__field
Commit: e42ec505d2899d3fd239c01dc01a0c3d71302b4b
Parents: 393cf66
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 12:43:34 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 12:43:34 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 213 ++++++++++++-------
1 file changed, 137 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/e42ec505/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 be58584..9b4508a 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
@@ -133,7 +133,8 @@ public class Complex implements Serializable {
* @return {@code boolean}
*/
public boolean isNaN() {
- if (Double.isNaN(real) || Double.isNaN(imaginary)) {
+ if (Double.isNaN(real) ||
+ Double.isNaN(imaginary)) {
return true;
} else {
return false;
@@ -166,7 +167,8 @@ public class Complex implements Serializable {
* @return {@code Complex} projected onto the Riemann sphere.
*/
public Complex proj() {
- if (Double.isInfinite(real) || Double.isInfinite(imaginary)) {
+ if (Double.isInfinite(real) ||
+ Double.isInfinite(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY);
} else {
return this;
@@ -299,11 +301,15 @@ public class Complex implements Serializable {
final double c = divisor.getReal();
final double d = divisor.getImaginary();
- if (c == 0.0 && d == 0.0) {
+ if (c == 0.0 &&
+ d == 0.0) {
return NaN;
}
- if ( (Double.isInfinite(c) || Double.isInfinite(d))&& (Double.isInfinite(real) || Double.isInfinite(imaginary))) {
+ if ((Double.isInfinite(c) ||
+ Double.isInfinite(d)) &&
+ (Double.isInfinite(real) ||
+ Double.isInfinite(imaginary))) {
return ZERO;
}
@@ -311,12 +317,12 @@ public class Complex implements Serializable {
final double q = c / d;
final double denominator = c * q + d;
return new Complex((real * q + imaginary) / denominator,
- (imaginary * q - real) / denominator);
+ (imaginary * q - real) / denominator);
} else {
final double q = d / c;
final double denominator = d * q + c;
return new Complex((imaginary * q + real) / denominator,
- (imaginary - real * q) / denominator);
+ (imaginary - real * q) / denominator);
}
}
@@ -333,10 +339,11 @@ public class Complex implements Serializable {
return NaN;
}
if (Double.isInfinite(divisor)) {
- return !(Double.isInfinite(real) || Double.isInfinite(imaginary)) ? ZERO : NaN;
+ return !(Double.isInfinite(real) ||
+ Double.isInfinite(imaginary)) ? ZERO : NaN;
}
return new Complex(real / divisor,
- imaginary / divisor);
+ imaginary / divisor);
}
/**
@@ -350,7 +357,8 @@ public class Complex implements Serializable {
final double q = real / imaginary;
final double scale = 1. / (real * q + imaginary);
double scaleQ = 0;
- if (q != 0 && scale != 0) {
+ if (q != 0 &&
+ scale != 0) {
scaleQ = scale * q;
}
return new Complex(scaleQ, -scale);
@@ -358,7 +366,8 @@ public class Complex implements Serializable {
final double q = imaginary / real;
final double scale = 1. / (imaginary * q + real);
double scaleQ = 0;
- if (q != 0 && scale != 0) {
+ if (q != 0 &&
+ scale != 0) {
scaleQ = scale * q;
}
return new Complex(scale, -scaleQ);
@@ -397,7 +406,7 @@ public class Complex implements Serializable {
if (other instanceof Complex){
Complex c = (Complex) other;
return equals(real, c.real) &&
- equals(imaginary, c.imaginary);
+ equals(imaginary, c.imaginary);
}
return false;
}
@@ -418,7 +427,9 @@ public class Complex implements Serializable {
*
* @see Precision#equals(double,double,int)
*/
- public static boolean equals(Complex x, Complex y, int maxUlps) {
+ public static boolean equals(Complex x,
+ Complex y,
+ int maxUlps) {
return Precision.equals(x.real, y.real, maxUlps) &&
Precision.equals(x.imaginary, y.imaginary, maxUlps);
}
@@ -431,7 +442,8 @@ public class Complex implements Serializable {
* @param y Second value (cannot be {@code null}).
* @return {@code true} if the values are equal.
*/
- public static boolean equals(Complex x, Complex y) {
+ public static boolean equals(Complex x,
+ Complex y) {
return equals(x, y, 1);
}
@@ -449,7 +461,9 @@ public class Complex implements Serializable {
*
* @see Precision#equals(double,double,double)
*/
- public static boolean equals(Complex x, Complex y, double eps) {
+ public static boolean equals(Complex x,
+ Complex y,
+ double eps) {
return Precision.equals(x.real, y.real, eps) &&
Precision.equals(x.imaginary, y.imaginary, eps);
}
@@ -483,7 +497,8 @@ public class Complex implements Serializable {
*/
@Override
public int hashCode() {
- if (Double.isNaN(real) || Double.isNaN(imaginary)) {
+ if (Double.isNaN(real) ||
+ Double.isNaN(imaginary)) {
return 7;
}
return 37 * (17 * hash(imaginary) + hash(real));
@@ -495,7 +510,7 @@ public class Complex implements Serializable {
*/
private int hash(double d) {
final long v = Double.doubleToLongBits(d);
- return (int)(v^(v>>>32));
+ return (int) (v ^ (v >>> 32));
//return new Double(d).hashCode();
}
@@ -610,7 +625,7 @@ public class Complex implements Serializable {
public Complex subtract(Complex subtrahend) {
checkNotNull(subtrahend);
return new Complex(real - subtrahend.getReal(),
- imaginary - subtrahend.getImaginary());
+ imaginary - subtrahend.getImaginary());
}
/**
@@ -639,21 +654,29 @@ public class Complex implements Serializable {
public Complex acos() {
if (real == 0.0&& Double.isNaN(imaginary)) {
return new Complex(Math.PI * 0.5, Double.NaN);
- } else if (neitherInfiniteNorZeroNorNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (neitherInfiniteNorZeroNorNaN(real) &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Math.PI * 0.5, Double.NEGATIVE_INFINITY);
- } else if (real == Double.NEGATIVE_INFINITY && imaginary == 1) {
+ } else if (real == Double.NEGATIVE_INFINITY &&
+ imaginary == 1) {
return new Complex(Math.PI, Double.NEGATIVE_INFINITY);
- } else if (real == Double.POSITIVE_INFINITY && imaginary == 1) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ imaginary == 1) {
return new Complex(0, Double.NEGATIVE_INFINITY);
- } else if (real == Double.NEGATIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (real == Double.NEGATIVE_INFINITY &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Math.PI * 0.75, Double.NEGATIVE_INFINITY);
- } else if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Math.PI * 0.25, Double.NEGATIVE_INFINITY);
- } else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(Double.NaN , Double.POSITIVE_INFINITY);
- } else if (real == Double.NEGATIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.NEGATIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
- } else if (Double.isNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (Double.isNaN(real) &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
}
return this.add(this.sqrt1z().multiply(I)).log().multiply(I.negate());
@@ -682,7 +705,7 @@ public class Complex implements Serializable {
*/
public Complex atan() {
return this.add(I).divide(I.subtract(this)).log()
- .multiply(I.divide(createComplex(2.0, 0.0)));
+ .multiply(I.divide(createComplex(2.0, 0.0)));
}
/**
@@ -697,17 +720,23 @@ public class Complex implements Serializable {
* @since 1.2
*/
public Complex asinh(){
- if (neitherInfiniteNorZeroNorNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
+ if (neitherInfiniteNorZeroNorNaN(real) &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.5);
- } else if (real == Double.POSITIVE_INFINITY && !Double.isInfinite(imaginary) && !Double.isNaN(imaginary)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ !Double.isInfinite(imaginary) && !Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, 0.0);
- } else if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ } else 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)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
- } else if (Double.isNaN(real) && imaginary == 0.0) {
+ } else if (Double.isNaN(real) &&
+ imaginary == 0.0) {
return new Complex(Double.NaN, 0.0);
- } else if (Double.isNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (Double.isNaN(real) &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
}
return square().add(Complex.ONE).sqrt().add(this).log();
@@ -783,7 +812,7 @@ public class Complex implements Serializable {
*/
public Complex cos() {
return new Complex(Math.cos(real) * Math.cosh(imaginary),
- -Math.sin(real) * Math.sinh(imaginary));
+ -Math.sin(real) * Math.sinh(imaginary));
}
/**
@@ -804,22 +833,28 @@ public class Complex implements Serializable {
* @return the hyperbolic cosine of this complex number.
*/
public Complex cosh() {
- if (real == 0.0&& imaginary == Double.POSITIVE_INFINITY) {
+ if (real == 0.0 &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.NaN, 0.0);
- } else if (real == 0.0&& Double.isNaN(imaginary)) {
+ } else if (real == 0.0 &&
+ Double.isNaN(imaginary)) {
return new Complex(Double.NaN, 0.0);
- } else if (real == Double.POSITIVE_INFINITY && imaginary == 0.0) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ imaginary == 0.0) {
return new Complex(Double.POSITIVE_INFINITY, 0.0);
- } else if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
- } else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
- } else if (Double.isNaN(real) && imaginary == 0.0) {
+ } else if (Double.isNaN(real) &&
+ imaginary == 0.0) {
return new Complex(Double.NaN, 0.0);
}
return new Complex(Math.cosh(real) * Math.cos(imaginary),
- Math.sinh(real) * Math.sin(imaginary));
+ Math.sinh(real) * Math.sin(imaginary));
}
/**
@@ -839,22 +874,28 @@ public class Complex implements Serializable {
* @return <code><i>e</i><sup>this</sup></code>.
*/
public Complex exp() {
- if (real == Double.POSITIVE_INFINITY && imaginary == 0.0) {
+ if (real == Double.POSITIVE_INFINITY &&
+ imaginary == 0.0) {
return new Complex(Double.POSITIVE_INFINITY, 0.0);
- } else if (real == Double.NEGATIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (real == Double.NEGATIVE_INFINITY &&
+ imaginary == Double.POSITIVE_INFINITY) {
return Complex.ZERO;
- } else if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
- } else if (real == Double.NEGATIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.NEGATIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return Complex.ZERO;
- } else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
- } else if (Double.isNaN(real) && imaginary == 0.0) {
+ } else if (Double.isNaN(real) &&
+ imaginary == 0.0) {
return new Complex(Double.NaN, 0.0);
}
double expReal = Math.exp(real);
return new Complex(expReal * Math.cos(imaginary),
- expReal * Math.sin(imaginary));
+ expReal * Math.sin(imaginary));
}
/**
@@ -875,15 +916,18 @@ public class Complex implements Serializable {
* of {@code this}.
*/
public Complex log() {
- if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ 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)) {
+ } 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) {
+ } 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));
+ Math.atan2(imaginary, real));
}
/**
@@ -895,7 +939,7 @@ public class Complex implements Serializable {
*/
public Complex log10() {
return new Complex(Math.log(abs())/Math.log(10),
- Math.atan2(imaginary, real));
+ Math.atan2(imaginary, real));
}
/**
@@ -914,8 +958,10 @@ public class Complex implements Serializable {
*/
public Complex pow(Complex x) {
checkNotNull(x);
- if (real == 0.0&& imaginary == 0.0) {
- if (x.real > 0 && x.imaginary == 0.0) {
+ if (real == 0.0 &&
+ imaginary == 0.0) {
+ if (x.real > 0 &&
+ x.imaginary == 0.0) {
// 0 raised to positive number is 0
return ZERO;
} else {
@@ -934,7 +980,8 @@ public class Complex implements Serializable {
* @see #pow(Complex)
*/
public Complex pow(double x) {
- if (real == 0.0&& imaginary == 0.0) {
+ if (real == 0.0 &&
+ imaginary == 0.0) {
if (x > 0) {
// 0 raised to positive number is 0
return ZERO;
@@ -965,7 +1012,7 @@ public class Complex implements Serializable {
*/
public Complex sin() {
return new Complex(Math.sin(real) * Math.cosh(imaginary),
- Math.cos(real) * Math.sinh(imaginary));
+ Math.cos(real) * Math.sinh(imaginary));
}
/**
@@ -985,23 +1032,30 @@ public class Complex implements Serializable {
* @return the hyperbolic sine of {@code this}.
*/
public Complex sinh() {
- if (real == 0.0&& imaginary == 0.0) {
+ if (real == 0.0 &&
+ imaginary == 0.0) {
return Complex.ZERO;
- } else if (real == 0.0&& imaginary == Double.POSITIVE_INFINITY) {
+ } else if (real == 0.0 &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(0, Double.NaN);
- } else if (real == 0.0&& Double.isNaN(imaginary)) {
+ } else if (real == 0.0 &&
+ Double.isNaN(imaginary)) {
return new Complex(0, Double.NaN);
- } else if (real == Double.POSITIVE_INFINITY && imaginary == 0.0) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ imaginary == 0.0) {
return new Complex(Double.POSITIVE_INFINITY, 0.0);
- } else if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
- } else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
- } else if (Double.isNaN(real) && imaginary == 0.0) {
+ } else if (Double.isNaN(real) &&
+ imaginary == 0.0) {
return new Complex(Double.NaN, 0.0);
}
return new Complex(Math.sinh(real) * Math.cos(imaginary),
- Math.cosh(real) * Math.sin(imaginary));
+ Math.cosh(real) * Math.sin(imaginary));
}
/**
@@ -1022,15 +1076,20 @@ public class Complex implements Serializable {
* @return the square root of {@code this}.
*/
public Complex sqrt() {
- if (real == 0.0 && imaginary == 0.0) {
+ if (real == 0.0 &&
+ imaginary == 0.0) {
return new Complex(0.0, 0.0);
- } else if (neitherInfiniteNorZeroNorNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
+ } else if (neitherInfiniteNorZeroNorNaN(real) &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
- } else if (real == Double.NEGATIVE_INFINITY && neitherInfiniteNorZeroNorNaN(imaginary)) {
+ } else if (real == Double.NEGATIVE_INFINITY &&
+ neitherInfiniteNorZeroNorNaN(imaginary)) {
return new Complex(0.0, Double.NaN);
- } else if (real == Double.NEGATIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.NEGATIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(Double.NaN, Double.POSITIVE_INFINITY);
- } else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
}
@@ -1039,7 +1098,7 @@ public class Complex implements Serializable {
return new Complex(t, imaginary / (2.0 * t));
} else {
return new Complex(Math.abs(imaginary) / (2.0 * t),
- Math.copySign(1d, imaginary) * t);
+ Math.copySign(1d, imaginary) * t);
}
}
@@ -1086,7 +1145,7 @@ public class Complex implements Serializable {
final double d = Math.cos(real2) + Math.cosh(imaginary2);
return new Complex(Math.sin(real2) / d,
- Math.sinh(imaginary2) / d);
+ Math.sinh(imaginary2) / d);
}
/**
@@ -1106,11 +1165,14 @@ public class Complex implements Serializable {
* @return the hyperbolic tangent of {@code this}.
*/
public Complex tanh() {
- if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
+ if (real == Double.POSITIVE_INFINITY &&
+ imaginary == Double.POSITIVE_INFINITY) {
return new Complex(1.0, 0.0);
- } else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
+ } else if (real == Double.POSITIVE_INFINITY &&
+ Double.isNaN(imaginary)) {
return new Complex(1.0, 0.0);
- } else if (Double.isNaN(real) && imaginary == 0) {
+ } else if (Double.isNaN(real) &&
+ imaginary == 0) {
return new Complex(Double.NaN, 0);
}
final double real2 = 2.0 * real;
@@ -1118,7 +1180,7 @@ public class Complex implements Serializable {
final double d = Math.cosh(real2) + Math.cos(imaginary2);
return new Complex(Math.sinh(real2) / d,
- Math.sin(imaginary2) / d);
+ Math.sin(imaginary2) / d);
}
/**
@@ -1173,7 +1235,6 @@ public class Complex implements Serializable {
* @return a List of all {@code n}-th roots of {@code this}.
*/
public List<Complex> nthRoot(int n) {
-
if (n <= 0) {
throw new IllegalArgumentException("cannot compute nth root for null or negative n: {0}");
}
[44/50] commons-numbers git commit: Javadoc.
Posted by er...@apache.org.
Javadoc.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/bc690a66
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/bc690a66
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/bc690a66
Branch: refs/heads/feature__NUMBERS-51__field
Commit: bc690a66125db034b7ec86ad5c40aa0294bfedc6
Parents: 4b213be
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Fri Feb 2 01:15:54 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Fri Feb 2 01:15:54 2018 +0100
----------------------------------------------------------------------
.../main/java/org/apache/commons/numbers/complex/Complex.java | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/bc690a66/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 d9d096a..19eb2fc 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
@@ -108,7 +108,6 @@ public class Complex implements Serializable {
* @param r the modulus of the complex number to create
* @param theta the argument of the complex number to create
* @return {@code Complex}
- * @since 1.1
*/
public Complex polar(double r, double theta) {
checkNotNegative(r);
@@ -719,7 +718,6 @@ public class Complex implements Serializable {
* {@code asinh(z) = log(z+sqrt(z^2+1))}
* </p><p>
* @return the inverse hyperbolic cosine of this complex number
- * @since 1.2
*/
public Complex asinh(){
if (neitherInfiniteNorZeroNorNaN(real) &&
@@ -753,7 +751,6 @@ public class Complex implements Serializable {
* {@code atanh(z) = log((1+z)/(1-z))/2}
* </p><p>
* @return the inverse hyperbolic cosine of this complex number
- * @since 1.2
*/
public Complex atanh(){
if (real == 0 &&
@@ -789,7 +786,6 @@ public class Complex implements Serializable {
* {@code acosh(z) = log(z+sqrt(z^2-1))}
* </p><p>
* @return the inverse hyperbolic cosine of this complex number
- * @since 1.2
*/
public Complex acosh() {
return square().subtract(ONE).sqrt().add(this).log();
[12/50] commons-numbers git commit: Javadoc (unit test).
Posted by er...@apache.org.
Javadoc (unit test).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/a51b5a04
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/a51b5a04
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/a51b5a04
Branch: refs/heads/feature__NUMBERS-51__field
Commit: a51b5a047044a7fd1dec085c955a75688755f336
Parents: 5ed6280
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Mon Jan 29 02:13:07 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Mon Jan 29 02:13:07 2018 +0100
----------------------------------------------------------------------
.../src/test/java/org/apache/commons/numbers/field/FieldsList.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a51b5a04/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
----------------------------------------------------------------------
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
index e937e0c..df5fa67 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
@@ -24,7 +24,7 @@ import java.util.Collections;
import org.apache.commons.numbers.fraction.Fraction;
/**
- * List of samplers.
+ * List of fields.
*/
public class FieldsList {
/** List of all fields implemented in the library. */
[22/50] commons-numbers git commit: Merge branch 'master' into
feature__NUMBERS-51__field
Posted by er...@apache.org.
Merge branch 'master' into feature__NUMBERS-51__field
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/6d14b163
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/6d14b163
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/6d14b163
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 6d14b1638b117c65b90d42d380104470e017c262
Parents: 1a71d5a d011f8b
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 16:48:25 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 16:48:25 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 40 +++++++++++---------
.../commons/numbers/complex/ComplexUtils.java | 4 +-
.../commons/numbers/core/ArithmeticUtils.java | 14 ++++---
.../numbers/fraction/FractionException.java | 1 +
.../apache/commons/numbers/gamma/Digamma.java | 4 +-
.../apache/commons/numbers/gamma/LogBeta.java | 2 +-
.../apache/commons/numbers/gamma/LogGamma.java | 1 +
.../commons/numbers/gamma/RegularizedGamma.java | 20 ++++++++--
8 files changed, 54 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
[16/50] commons-numbers git commit: NUMBERS-55: Fixed "hashCode".
Posted by er...@apache.org.
NUMBERS-55: Fixed "hashCode".
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/b2d22678
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/b2d22678
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/b2d22678
Branch: refs/heads/feature__NUMBERS-51__field
Commit: b2d226785278777545ed72b1c55146ea5de5b4b8
Parents: 6caed74
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 15:34:06 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 15:34:06 2018 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/b2d22678/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 ac08732..281822b 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
@@ -486,8 +486,7 @@ public class Complex implements Serializable {
if (Double.isNaN(real) || Double.isNaN(imaginary)) {
return 7;
}
- return 37 * 17 * (hash(imaginary) +
- hash(real));
+ return 37 * (17 * hash(imaginary) + hash(real));
}
private int hash(double d) {
[23/50] commons-numbers git commit: NUMBERS-51: Class "FP64"
("double" with "Field" API).
Posted by er...@apache.org.
NUMBERS-51: Class "FP64" ("double" with "Field" API).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/de85ffc2
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/de85ffc2
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/de85ffc2
Branch: refs/heads/feature__NUMBERS-51__field
Commit: de85ffc2843e43e0c0e426151a995d0c7dc77673
Parents: 6d14b16
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Tue Jan 30 16:49:41 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Tue Jan 30 16:49:41 2018 +0100
----------------------------------------------------------------------
.../org/apache/commons/numbers/field/FP64.java | 127 +++++++++++++++++++
.../apache/commons/numbers/field/FP64Field.java | 39 ++++++
2 files changed, 166 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/de85ffc2/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64.java
----------------------------------------------------------------------
diff --git a/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64.java b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64.java
new file mode 100644
index 0000000..1bb2097
--- /dev/null
+++ b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.numbers.field;
+
+import org.apache.commons.numbers.core.NativeOperators;
+import org.apache.commons.numbers.core.Precision;
+
+/**
+ * Wraps a {@code double} value in order to be used as a field
+ * element.
+ */
+public class FP64 extends Number
+ implements NativeOperators<FP64> {
+ /** Value. */
+ private final double value;
+
+ /**
+ * @param Value value.
+ */
+ public FP64(double value) {
+ this.value = value;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public FP64 add(FP64 a) {
+ return new FP64(value + a.value);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public FP64 negate() {
+ return new FP64(-value);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public FP64 multiply(FP64 a) {
+ return new FP64(value * a.value);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public FP64 reciprocal() {
+ return new FP64(1 / value);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public FP64 subtract(FP64 a) {
+ return new FP64(value - a.value);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public FP64 divide(FP64 a) {
+ return new FP64(value / a.value);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public FP64 multiply(int n) {
+ return new FP64(value * n);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof FP64) {
+ final FP64 o = (FP64) other;
+ return Precision.equals(value, o.value, 1);
+ }
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int hashCode() {
+ return Double.valueOf(value).hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return Double.toString(value);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double doubleValue() {
+ return value;
+ }
+ /** {@inheritDoc} */
+ @Override
+ public float floatValue() {
+ return (float) value;
+ }
+ /** {@inheritDoc} */
+ @Override
+ public int intValue() {
+ return (int) value;
+ }
+ /** {@inheritDoc} */
+ @Override
+ public long longValue() {
+ return (long) value;
+ }
+ /** {@inheritDoc} */
+ @Override
+ public byte byteValue() {
+ return (byte) value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/de85ffc2/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64Field.java
----------------------------------------------------------------------
diff --git a/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64Field.java b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64Field.java
new file mode 100644
index 0000000..f63665c
--- /dev/null
+++ b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64Field.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.numbers.field;
+
+/**
+ * {@link Double} field.
+ */
+public class FP64Field extends AbstractField<FP64> {
+ /** 0d */
+ private static final FP64 ZERO = new FP64(Double.valueOf(0));
+ /** 1d */
+ private static final FP64 ONE = new FP64(Double.valueOf(1));
+
+ /** {@inheritDoc} */
+ @Override
+ public FP64 one() {
+ return ONE;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public FP64 zero() {
+ return ZERO;
+ }
+}
[49/50] commons-numbers git commit: Javadoc (nit-picks).
Posted by er...@apache.org.
Javadoc (nit-picks).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/810f26cf
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/810f26cf
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/810f26cf
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 810f26cfe80d4e23c45f57e05d552ae1bb9b1518
Parents: 51467b0
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Fri Feb 2 13:48:45 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Fri Feb 2 13:48:45 2018 +0100
----------------------------------------------------------------------
.../main/java/org/apache/commons/numbers/complex/Complex.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/810f26cf/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 763b903..422cb30 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
@@ -180,7 +180,9 @@ public class Complex implements Serializable {
* Returns {@code NaN} if either real or imaginary part is {@code NaN}
* and {@code Double.POSITIVE_INFINITY} if neither part is {@code NaN},
* but at least one part is infinite.
- * This code follows the <a href="http://www.iso-9899.info/wiki/The_Standard">ISO C Standard</a>, Annex G, in calculating the returned value (i.e. the hypot(x,y) method)
+ * This code follows the
+ * <a href="http://www.iso-9899.info/wiki/The_Standard">ISO C Standard</a>,
+ * Annex G, in calculating the returned value (i.e. the hypot(x,y) method).
*
* @return the absolute value.
*/
[26/50] commons-numbers git commit: Implement "Comparable".
Posted by er...@apache.org.
Implement "Comparable".
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/7b1d76a0
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/7b1d76a0
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/7b1d76a0
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 7b1d76a0f0ad89da418d88da75496428d80ccc4c
Parents: dd45364
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Wed Jan 31 15:12:58 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Wed Jan 31 15:12:58 2018 +0100
----------------------------------------------------------------------
.../main/java/org/apache/commons/numbers/field/FP64.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/7b1d76a0/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64.java
----------------------------------------------------------------------
diff --git a/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64.java b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64.java
index 1bb2097..19ab4b1 100644
--- a/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64.java
+++ b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FP64.java
@@ -24,7 +24,8 @@ import org.apache.commons.numbers.core.Precision;
* element.
*/
public class FP64 extends Number
- implements NativeOperators<FP64> {
+ implements NativeOperators<FP64>,
+ Comparable<FP64> {
/** Value. */
private final double value;
@@ -124,4 +125,10 @@ public class FP64 extends Number
public byte byteValue() {
return (byte) value;
}
+
+ /** {@inheritDoc} */
+ @Override
+ public int compareTo(FP64 other) {
+ return Double.compare(value, other.value);
+ }
}
[25/50] commons-numbers git commit: Add "FP64" test case (unit test).
Posted by er...@apache.org.
Add "FP64" test case (unit test).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/dd45364d
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/dd45364d
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/dd45364d
Branch: refs/heads/feature__NUMBERS-51__field
Commit: dd45364d7c1a37e99c1a788f3b493766fddf3065
Parents: e1ac4ed
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Wed Jan 31 15:12:36 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Wed Jan 31 15:12:36 2018 +0100
----------------------------------------------------------------------
.../test/java/org/apache/commons/numbers/field/FieldsList.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/dd45364d/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
----------------------------------------------------------------------
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
index df5fa67..0dc52cc 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldsList.java
@@ -38,6 +38,10 @@ public class FieldsList {
new Fraction(13, 4),
new Fraction(5, 29),
new Fraction(-279, 11));
+ add(new FP64Field(),
+ new FP64(23.45678901),
+ new FP64(-543.2109876),
+ new FP64(-234.5678901));
} catch (Exception e) {
System.err.println("Unexpected exception while creating the list of fields: " + e);
[33/50] commons-numbers git commit: Unnecessary instantiations.
Posted by er...@apache.org.
Unnecessary instantiations.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/2daea445
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/2daea445
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/2daea445
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 2daea445e878c98fc0f0a5a90deb413813fdc8cf
Parents: 7da7fa9
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 12:56:06 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 12:56:06 2018 +0100
----------------------------------------------------------------------
.../java/org/apache/commons/numbers/complex/Complex.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/2daea445/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 b45093d..7034f94 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
@@ -1113,7 +1113,7 @@ public class Complex implements Serializable {
* @return the square root of <code>1 - this<sup>2</sup></code>.
*/
public Complex sqrt1z() {
- return new Complex(1, 0).subtract(this.multiply(this)).sqrt();
+ return Complex.ONE.subtract(this.multiply(this)).sqrt();
}
/**
@@ -1134,7 +1134,7 @@ public class Complex implements Serializable {
*/
public Complex tan() {
if (imaginary > 20) {
- return new Complex(0, 1);
+ return Complex.ONE;
}
if (imaginary < -20) {
return new Complex(0, -1);
@@ -1167,10 +1167,10 @@ public class Complex implements Serializable {
public Complex tanh() {
if (real == Double.POSITIVE_INFINITY &&
imaginary == Double.POSITIVE_INFINITY) {
- return new Complex(1, 0);
+ return Complex.ONE;
} else if (real == Double.POSITIVE_INFINITY &&
Double.isNaN(imaginary)) {
- return new Complex(1, 0);
+ return Complex.ONE;
} else if (Double.isNaN(real) &&
imaginary == 0) {
return new Complex(Double.NaN, 0);
[24/50] commons-numbers git commit: Check method (unit test).
Posted by er...@apache.org.
Check method (unit test).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/e1ac4ed5
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/e1ac4ed5
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/e1ac4ed5
Branch: refs/heads/feature__NUMBERS-51__field
Commit: e1ac4ed5fa59459869121d287d70b0f97a1e7ff6
Parents: de85ffc
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Wed Jan 31 15:11:28 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Wed Jan 31 15:11:28 2018 +0100
----------------------------------------------------------------------
.../numbers/field/FieldParametricTest.java | 28 +++++++++++++-------
1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/e1ac4ed5/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
index 4fee7cd..faea48c 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FieldParametricTest.java
@@ -58,56 +58,66 @@ public class FieldParametricTest {
public void testAdditionAssociativity() {
final Object r1 = field.add(field.add(a, b), c);
final Object r2 = field.add(a, field.add(b, c));
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testAdditionCommutativity() {
final Object r1 = field.add(a, b);
final Object r2 = field.add(b, a);
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testAdditiveIdentity() {
final Object r1 = field.add(a, field.zero());
final Object r2 = a;
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testAdditiveInverse() {
final Object r1 = field.add(a, field.negate(a));
final Object r2 = field.zero();
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testMultiplicationAssociativity() {
final Object r1 = field.multiply(field.multiply(a, b), c);
final Object r2 = field.multiply(a, field.multiply(b, c));
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testMultiplicationCommutativity() {
final Object r1 = field.multiply(a, b);
final Object r2 = field.multiply(b, a);
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testMultiplicativeIdentity() {
final Object r1 = field.multiply(a, field.one());
final Object r2 = a;
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testMultiplicativeInverse() {
final Object r1 = field.multiply(a, field.reciprocal(a));
final Object r2 = field.one();
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
}
@Test
public void testDistributivity() {
final Object r1 = field.multiply(a, field.add(b, c));
final Object r2 = field.add(field.multiply(a, b), field.multiply(a, c));
- Assert.assertTrue(r1.equals(r2));
+ assertEquals(r1, r2);
+ }
+
+ /**
+ * @param a Instance.
+ * @param b Instance.
+ */
+ private void assertEquals(Object a,
+ Object b) {
+ Assert.assertTrue(a + " != " + b,
+ a.equals(b));
}
}
[13/50] commons-numbers git commit: Minor Javadoc corrections.
Posted by er...@apache.org.
Minor Javadoc corrections.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/45dee2ed
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/45dee2ed
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/45dee2ed
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 45dee2ede42d17a36bb02e21b962f70eb92d1b88
Parents: 4b955ca
Author: Eric Barnhill <er...@apache.org>
Authored: Mon Jan 29 13:30:06 2018 +0100
Committer: Eric Barnhill <er...@apache.org>
Committed: Mon Jan 29 13:30:06 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 30 +++++++++-----------
.../commons/numbers/complex/ComplexUtils.java | 24 ++++++++--------
2 files changed, 25 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/45dee2ed/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 71a4220..0e8bb4d 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
@@ -129,7 +129,7 @@ public class Complex implements Serializable {
/**
* Returns true if either real or imaginary component of the Complex
* is NaN
- *
+ *
* @return {@code boolean}
*/
public boolean isNaN() {
@@ -142,8 +142,8 @@ public class Complex implements Serializable {
/**
* Returns true if either real or imaginary component of the Complex
- * is Infinite
- *
+ * is Infinite
+ *
* @return {@code boolean}
*/
public boolean isInfinite() {
@@ -217,7 +217,6 @@ in the
*
* @param addend Value to be added to this {@code Complex}.
* @return {@code this + addend}.
- * @if {@code addend} is {@code null}.
*/
public Complex add(Complex addend) {
checkNotNull(addend);
@@ -250,7 +249,6 @@ in the
/**
* Returns the conjugate of this complex number.
* C++11 grammar.
- * </p>
* @return the conjugate of this complex object.
*/
public Complex conj() {
@@ -295,7 +293,6 @@ in the
*
* @param divisor Value by which this {@code Complex} is to be divided.
* @return {@code this / divisor}.
- * @if {@code divisor} is {@code null}.
*/
public Complex divide(Complex divisor) {
checkNotNull(divisor);
@@ -538,23 +535,22 @@ in the
* Returns a {@code Complex} whose value is {@code this * factor}.
* Implements preliminary checks for {@code NaN} and infinity followed by
* the definitional formula:
- * <p>
+ *
* {@code (a + bi)(c + di) = (ac - bd) + (ad + bc)i}
- * </p>
+ *
* Returns {@link #NaN} if either {@code this} or {@code factor} has one or
* more {@code NaN} parts.
- * <p>
+ *
* Returns {@link #INF} if neither {@code this} nor {@code factor} has one
* or more {@code NaN} parts and if either {@code this} or {@code factor}
* has one or more infinite parts (same result is returned regardless of
* the sign of the components).
- * </p><p>
+ *
* Returns finite values in components of the result per the definitional
- * formula in all remaining cases.</p>
+ * formula in all remaining cases.
*
* @param factor value to be multiplied by this {@code Complex}.
* @return {@code this * factor}.
- * @if {@code factor} is {@code null}.
*/
public Complex multiply(Complex factor) {
checkNotNull(factor);
@@ -649,14 +645,14 @@ in the
} else if (real == Double.NEGATIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
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(Math.PI * 0.25, Double.NEGATIVE_INFINITY);
} else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
return new Complex(Double.NaN , Double.POSITIVE_INFINITY);
} else if (real == Double.NEGATIVE_INFINITY && Double.isNaN(imaginary)) {
return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
} else if (Double.isNaN(real) && imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
- }
+ }
return this.add(this.sqrt1z().multiply(I)).log().multiply(I.negate());
}
/**
@@ -812,7 +808,7 @@ in the
} else if (real == Double.POSITIVE_INFINITY && imaginary == 0.0) {
return new Complex(Double.POSITIVE_INFINITY, 0.0);
} else if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
- return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
+ return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
} else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
} else if (Double.isNaN(real) && imaginary == 0.0) {
@@ -1112,7 +1108,7 @@ in the
} else if (real == Double.POSITIVE_INFINITY && Double.isNaN(imaginary)) {
return new Complex(1.0, 0.0);
} else if (Double.isNaN(real) && imaginary == 0) {
- return new Complex(Double.NaN, 0);
+ return new Complex(Double.NaN, 0);
}
final double real2 = 2.0 * real;
final double imaginary2 = 2.0 * imaginary;
@@ -1283,7 +1279,7 @@ in the
throw new RuntimeException("Complex: Non-positive argument");
}
}
-
+
/**
* Returns {@code true} if the values are equal according to semantics of
* {@link Double#equals(Object)}.
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/45dee2ed/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
index 3fabfab..f0b39b6 100644
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
+++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
@@ -592,7 +592,7 @@ public class ComplexUtils {
* Converts a 2D imaginary array {@code double[][]} to a 2D
* {@code Complex[][]} array.
*
- * @param d 2D array
+ * @param i 2D array
* @return 2D {@code Complex} array
*
* @since 1.0
@@ -610,7 +610,7 @@ public class ComplexUtils {
* Converts a 3D imaginary array {@code double[][][]} to a {@code Complex[]}
* array.
*
- * @param d 3D complex imaginary array
+ * @param i 3D complex imaginary array
* @return 3D {@code Complex} array
*
* @since 1.0
@@ -628,7 +628,7 @@ public class ComplexUtils {
* Converts a 4D imaginary array {@code double[][][][]} to a 4D {@code Complex[][][][]}
* array.
*
- * @param d 4D complex imaginary array
+ * @param i 4D complex imaginary array
* @return 4D {@code Complex} array
*
* @since 1.0
@@ -999,7 +999,7 @@ public class ComplexUtils {
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
for (int z = 0; z < d; z++) {
- for (int t = 0; t > v; t++) {
+ for (int t = 0; t > v; t++) {
i[x * 2][y][z][t] = c[x][y][z][t].getReal();
i[x * 2 + 1][y][z][t] = c[x][y][z][t].getImaginary();
}
@@ -1011,7 +1011,7 @@ public class ComplexUtils {
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
for (int z = 0; z < d; z++) {
- for (int t = 0; t > v; t++) {
+ for (int t = 0; t > v; t++) {
i[x][y * 2][z][t] = c[x][y][z][t].getReal();
i[x][y * 2 + 1][z][t] = c[x][y][z][t].getImaginary();
}
@@ -1023,7 +1023,7 @@ public class ComplexUtils {
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
for (int z = 0; z < d; z++) {
- for (int t = 0; t > v; t++) {
+ for (int t = 0; t > v; t++) {
i[x][y][z * 2][t] = c[x][y][z][t].getReal();
i[x][y][z * 2 + 1][t] = c[x][y][z][t].getImaginary();
}
@@ -1035,7 +1035,7 @@ public class ComplexUtils {
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
for (int z = 0; z < d; z++) {
- for (int t = 0; t > v; t++) {
+ for (int t = 0; t > v; t++) {
i[x][y][z][t * 2] = c[x][y][z][t].getReal();
i[x][y][z][t * 2 + 1] = c[x][y][z][t].getImaginary();
}
@@ -1203,7 +1203,7 @@ public class ComplexUtils {
* Converts a 2D interleaved complex {@code double[][]} array to a
* {@code Complex[][]} array.
*
- * @param d 2D complex interleaved array
+ * @param i 2D complex interleaved array
* @param interleavedDim Depth level of the array to interleave
* @return 2D {@code Complex} array
*
@@ -1252,7 +1252,7 @@ public class ComplexUtils {
* Converts a 3D interleaved complex {@code double[][][]} array to a
* {@code Complex[][][]} array.
*
- * @param d 3D complex interleaved array
+ * @param i 3D complex interleaved array
* @param interleavedDim Depth level of the array to interleave
* @return 3D {@code Complex} array
*
@@ -1301,7 +1301,7 @@ public class ComplexUtils {
* Converts a 4D interleaved complex {@code double[][][][]} array to a
* {@code Complex[][][][]} array.
*
- * @param d 4D complex interleaved array
+ * @param i 4D complex interleaved array
* @param interleavedDim Depth level of the array to interleave
* @return 4D {@code Complex} array
*
@@ -1382,7 +1382,7 @@ public class ComplexUtils {
* Converts a 2D interleaved complex {@code float[][]} array to a
* {@code Complex[][]} array.
*
- * @param d 2D complex interleaved float array
+ * @param i 2D complex interleaved float array
* @param interleavedDim Depth level of the array to interleave
* @return 2D {@code Complex} array
*
@@ -1431,7 +1431,7 @@ public class ComplexUtils {
* Converts a 3D interleaved complex {@code float[][][]} array to a
* {@code Complex[][][]} array.
*
- * @param d 3D complex interleaved float array
+ * @param i 3D complex interleaved float array
* @param interleavedDim Depth level of the array to interleave
* @return 3D {@code Complex} array
*
[35/50] commons-numbers git commit: Alignment (nit-picks).
Posted by er...@apache.org.
Alignment (nit-picks).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/818603c2
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/818603c2
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/818603c2
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 818603c2895c10ec24c687105dc53cb64843a632
Parents: a88c767
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 12:59:23 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 12:59:23 2018 +0100
----------------------------------------------------------------------
.../main/java/org/apache/commons/numbers/complex/Complex.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/818603c2/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 31d1cf5..e544e28 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
@@ -652,7 +652,8 @@ public class Complex implements Serializable {
* @return the inverse cosine of this complex number.
*/
public Complex acos() {
- if (real == 0 && Double.isNaN(imaginary)) {
+ if (real == 0 &&
+ Double.isNaN(imaginary)) {
return new Complex(Math.PI * 0.5, Double.NaN);
} else if (neitherInfiniteNorZeroNorNaN(real) &&
imaginary == Double.POSITIVE_INFINITY) {
@@ -754,7 +755,8 @@ public class Complex implements Serializable {
* @since 1.2
*/
public Complex atanh(){
- if (real == 0 && Double.isNaN(imaginary)) {
+ if (real == 0 &&
+ Double.isNaN(imaginary)) {
return new Complex(0, Double.NaN);
} else if (neitherInfiniteNorZeroNorNaN(real) &&
imaginary == 0) {
[15/50] commons-numbers git commit: Merge branch 'master' into
feature__NUMBERS-51__field
Posted by er...@apache.org.
Merge branch 'master' into feature__NUMBERS-51__field
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/1a71d5a7
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/1a71d5a7
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/1a71d5a7
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 1a71d5a77f4d2b418f46dcfa98fb1adbdc4fb3a7
Parents: a51b5a0 6caed74
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Mon Jan 29 15:23:21 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Mon Jan 29 15:23:21 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 30 +++++++++-----------
.../commons/numbers/complex/ComplexUtils.java | 24 ++++++++--------
2 files changed, 25 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
[42/50] commons-numbers git commit: Space around operator (nit-picks).
Posted by er...@apache.org.
Space around operator (nit-picks).
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/1b2eb222
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/1b2eb222
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/1b2eb222
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 1b2eb2220f873f2ba7e45e749c49bc2930af6666
Parents: a4bee70
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 14:00:31 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 14:00:31 2018 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1b2eb222/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 53e3ff1..93e0614 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
@@ -946,7 +946,7 @@ public class Complex implements Serializable {
* @return the base 10 logarithm of <code>this</code>.
*/
public Complex log10() {
- return new Complex(Math.log(abs())/Math.log(10),
+ return new Complex(Math.log(abs()) / Math.log(10),
Math.atan2(imaginary, real));
}
[45/50] commons-numbers git commit: Visual clean-up (unnecessary
usage of "this").
Posted by er...@apache.org.
Visual clean-up (unnecessary usage of "this").
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/bcbfee1d
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/bcbfee1d
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/bcbfee1d
Branch: refs/heads/feature__NUMBERS-51__field
Commit: bcbfee1dc3026cf65e5c430bd01b0995e5e9da99
Parents: bc690a6
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Fri Feb 2 01:21:07 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Fri Feb 2 01:21:07 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/complex/Complex.java | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/bcbfee1d/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 19eb2fc..125a0b4 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
@@ -680,7 +680,7 @@ public class Complex implements Serializable {
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
}
- return this.add(this.sqrt1z().multiply(I)).log().multiply(I.negate());
+ return add(sqrt1z().multiply(I)).log().multiply(I.negate());
}
/**
* Compute the
@@ -692,7 +692,7 @@ public class Complex implements Serializable {
* @return the inverse sine of this complex number
*/
public Complex asin() {
- return sqrt1z().add(this.multiply(I)).log().multiply(I.negate());
+ return sqrt1z().add(multiply(I)).log().multiply(I.negate());
}
/**
* Compute the
@@ -705,8 +705,7 @@ public class Complex implements Serializable {
* @return the inverse tangent of this complex number
*/
public Complex atan() {
- return this.add(I).divide(I.subtract(this)).log()
- .multiply(I.multiply(0.5));
+ return add(I).divide(I.subtract(this)).log().multiply(I.multiply(0.5));
}
/**
@@ -775,7 +774,7 @@ public class Complex implements Serializable {
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(0, Math.PI * 0.5);
}
- return this.add(ONE).divide(ONE.subtract(this)).log().multiply(0.5);
+ return add(ONE).divide(ONE.subtract(this)).log().multiply(0.5);
}
/**
* Compute the
@@ -796,8 +795,8 @@ public class Complex implements Serializable {
*
* @return square of this complex number
*/
- public Complex square(){
- return this.multiply(this);
+ public Complex square() {
+ return multiply(this);
}
/**
@@ -974,7 +973,7 @@ public class Complex implements Serializable {
return NaN;
}
}
- return this.log().multiply(x).exp();
+ return log().multiply(x).exp();
}
/**
@@ -995,7 +994,7 @@ public class Complex implements Serializable {
return NaN;
}
}
- return this.log().multiply(x).exp();
+ return log().multiply(x).exp();
}
/**
@@ -1118,7 +1117,7 @@ public class Complex implements Serializable {
* @return the square root of <code>1 - this<sup>2</sup></code>.
*/
public Complex sqrt1z() {
- return ONE.subtract(this.multiply(this)).sqrt();
+ return ONE.subtract(multiply(this)).sqrt();
}
/**
[08/50] commons-numbers git commit: Redundant method call.
Posted by er...@apache.org.
Redundant method call.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/230b0262
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/230b0262
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/230b0262
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 230b026267d745cbf9b09d0efef6af47b7da17d0
Parents: dd15519
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Sat Jan 27 17:55:54 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Sat Jan 27 17:55:54 2018 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/230b0262/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 ee0c147..04b1959 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
@@ -203,7 +203,8 @@ public class Complex implements Serializable {
* @return the norm.
*/
public double norm() {
- return abs()*abs();
+ final double a = abs();
+ return a * a;
}
/**
[32/50] commons-numbers git commit: More nit-picks.
Posted by er...@apache.org.
More nit-picks.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/7da7fa97
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/7da7fa97
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/7da7fa97
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 7da7fa9711ec6cf25903c045fb0eeb5267971f8d
Parents: 21d5060
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 12:52:50 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 12:52:50 2018 +0100
----------------------------------------------------------------------
.../java/org/apache/commons/numbers/complex/Complex.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/7da7fa97/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 c0561ad..b45093d 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
@@ -573,7 +573,7 @@ public class Complex implements Serializable {
public Complex multiply(Complex factor) {
checkNotNull(factor);
return new Complex(real * factor.real - imaginary * factor.imaginary,
- real * factor.imaginary + imaginary * factor.real);
+ real * factor.imaginary + imaginary * factor.real);
}
/**
@@ -759,15 +759,15 @@ public class Complex implements Serializable {
} else if (neitherInfiniteNorZeroNorNaN(real) && imaginary == 0) {
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, Math.PI * 0.5);
} else if (real == Double.POSITIVE_INFINITY && neitherInfiniteNorZeroNorNaN(imaginary)) {
- return new Complex(0, Math.PI*0.5);
+ return new Complex(0, Math.PI * 0.5);
} else if (real == Double.POSITIVE_INFINITY && imaginary == Double.POSITIVE_INFINITY) {
- return new Complex(0, Math.PI*0.5);
+ return new Complex(0, Math.PI * 0.5);
} 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, Math.PI * 0.5);
}
return this.add(Complex.ONE).divide(Complex.ONE.subtract(this)).log().divide(new Complex(2));
}
[06/50] commons-numbers git commit: NUMBERS-43: Remove "round(float)".
Posted by er...@apache.org.
NUMBERS-43: Remove "round(float)".
See discussion on the JIRA page:
https://issues.apache.org/jira/browse/NUMBERS-43
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/bf05e066
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/bf05e066
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/bf05e066
Branch: refs/heads/feature__NUMBERS-51__field
Commit: bf05e066c816245609e0315b27103192906b2d17
Parents: 4b955ca
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Sat Jan 27 17:31:11 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Sat Jan 27 17:31:11 2018 +0100
----------------------------------------------------------------------
.../apache/commons/numbers/core/Precision.java | 117 -------------------
.../commons/numbers/core/PrecisionTest.java | 107 -----------------
2 files changed, 224 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/bf05e066/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
----------------------------------------------------------------------
diff --git a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
index e71e1e4..11fe704 100644
--- a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
+++ b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java
@@ -461,123 +461,6 @@ public class Precision {
}
/**
- * Rounds the given value to the specified number of decimal places.
- * The value is rounded using the {@link BigDecimal#ROUND_HALF_UP} method.
- *
- * @param x Value to round.
- * @param scale Number of digits to the right of the decimal point.
- * @return the rounded value.
- */
- public static float round(float x, int scale) {
- return round(x, scale, BigDecimal.ROUND_HALF_UP);
- }
-
- /**
- * Rounds the given value to the specified number of decimal places.
- * The value is rounded using the given method which is any method defined
- * in {@link BigDecimal}.
- *
- * @param x Value to round.
- * @param scale Number of digits to the right of the decimal point.
- * @param roundingMethod Rounding method as defined in {@link BigDecimal}.
- * @return the rounded value.
- * @throws ArithmeticException if an exact operation is required but result is not exact
- * @throws IllegalArgumentException if {@code roundingMethod} is not a valid rounding method.
- */
- public static float round(float x, int scale, int roundingMethod) {
- final float sign = Math.copySign(1f, x);
- final float factor = (float) Math.pow(10.0f, scale) * sign;
- return (float) roundUnscaled(x * factor, sign, roundingMethod) / factor;
- }
-
- /**
- * Rounds the given non-negative value to the "nearest" integer. Nearest is
- * determined by the rounding method specified. Rounding methods are defined
- * in {@link BigDecimal}.
- *
- * @param unscaled Value to round.
- * @param sign Sign of the original, scaled value.
- * @param roundingMethod Rounding method, as defined in {@link BigDecimal}.
- * @return the rounded value.
- * @throws ArithmeticException if an exact operation is required but result is not exact
- * @throws IllegalArgumentException if {@code roundingMethod} is not a valid rounding method.
- */
- private static double roundUnscaled(double unscaled,
- double sign,
- int roundingMethod) {
- switch (roundingMethod) {
- case BigDecimal.ROUND_CEILING :
- if (sign == -1) {
- unscaled = Math.floor(Math.nextAfter(unscaled, Double.NEGATIVE_INFINITY));
- } else {
- unscaled = Math.ceil(Math.nextAfter(unscaled, Double.POSITIVE_INFINITY));
- }
- break;
- case BigDecimal.ROUND_DOWN :
- unscaled = Math.floor(Math.nextAfter(unscaled, Double.NEGATIVE_INFINITY));
- break;
- case BigDecimal.ROUND_FLOOR :
- if (sign == -1) {
- unscaled = Math.ceil(Math.nextAfter(unscaled, Double.POSITIVE_INFINITY));
- } else {
- unscaled = Math.floor(Math.nextAfter(unscaled, Double.NEGATIVE_INFINITY));
- }
- break;
- case BigDecimal.ROUND_HALF_DOWN : {
- unscaled = Math.nextAfter(unscaled, Double.NEGATIVE_INFINITY);
- double fraction = unscaled - Math.floor(unscaled);
- if (fraction > 0.5) {
- unscaled = Math.ceil(unscaled);
- } else {
- unscaled = Math.floor(unscaled);
- }
- break;
- }
- case BigDecimal.ROUND_HALF_EVEN : {
- double fraction = unscaled - Math.floor(unscaled);
- if (fraction > 0.5) {
- unscaled = Math.ceil(unscaled);
- } else if (fraction < 0.5) {
- unscaled = Math.floor(unscaled);
- } else {
- // The following equality test is intentional and needed for rounding purposes
- if (Math.floor(unscaled) / 2.0 == Math.floor(Math.floor(unscaled) / 2.0)) { // even
- unscaled = Math.floor(unscaled);
- } else { // odd
- unscaled = Math.ceil(unscaled);
- }
- }
- break;
- }
- case BigDecimal.ROUND_HALF_UP : {
- unscaled = Math.nextAfter(unscaled, Double.POSITIVE_INFINITY);
- double fraction = unscaled - Math.floor(unscaled);
- if (fraction >= 0.5) {
- unscaled = Math.ceil(unscaled);
- } else {
- unscaled = Math.floor(unscaled);
- }
- break;
- }
- case BigDecimal.ROUND_UNNECESSARY :
- if (unscaled != Math.floor(unscaled)) {
- throw new ArithmeticException();
- }
- break;
- case BigDecimal.ROUND_UP :
- // do not round if the discarded fraction is equal to zero
- if (unscaled != Math.floor(unscaled)) {
- unscaled = Math.ceil(Math.nextAfter(unscaled, Double.POSITIVE_INFINITY));
- }
- break;
- default :
- throw new IllegalArgumentException("Unhandled rounding method: " + roundingMethod);
- }
- return unscaled;
- }
-
-
- /**
* Computes a number {@code delta} close to {@code originalDelta} with
* the property that <pre><code>
* x + delta - x
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/bf05e066/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
index 188c949..8d63c43 100644
--- a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
+++ b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/PrecisionTest.java
@@ -394,113 +394,6 @@ public class PrecisionTest {
Assert.assertEquals("-0.0", Double.toString(Precision.round(-1e-10, 0)));
}
- @Test
- public void testRoundFloat() {
- float x = 1.234567890f;
- Assert.assertEquals(1.23f, Precision.round(x, 2), 0.0);
- Assert.assertEquals(1.235f, Precision.round(x, 3), 0.0);
- Assert.assertEquals(1.2346f, Precision.round(x, 4), 0.0);
-
- // BZ 35904
- Assert.assertEquals(30.1f, Precision.round(30.095f, 2), 0.0f);
- Assert.assertEquals(30.1f, Precision.round(30.095f, 1), 0.0f);
- Assert.assertEquals(50.09f, Precision.round(50.085f, 2), 0.0f);
- Assert.assertEquals(50.19f, Precision.round(50.185f, 2), 0.0f);
- Assert.assertEquals(50.01f, Precision.round(50.005f, 2), 0.0f);
- Assert.assertEquals(30.01f, Precision.round(30.005f, 2), 0.0f);
- Assert.assertEquals(30.65f, Precision.round(30.645f, 2), 0.0f);
-
- Assert.assertEquals(1.24f, Precision.round(x, 2, BigDecimal.ROUND_CEILING), 0.0);
- Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_CEILING), 0.0);
- Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_CEILING), 0.0);
- Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_CEILING), 0.0);
- Assert.assertEquals(-1.234f, Precision.round(-x, 3, BigDecimal.ROUND_CEILING), 0.0);
- Assert.assertEquals(-1.2345f, Precision.round(-x, 4, BigDecimal.ROUND_CEILING), 0.0);
-
- Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_DOWN), 0.0);
- Assert.assertEquals(1.234f, Precision.round(x, 3, BigDecimal.ROUND_DOWN), 0.0);
- Assert.assertEquals(1.2345f, Precision.round(x, 4, BigDecimal.ROUND_DOWN), 0.0);
- Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_DOWN), 0.0);
- Assert.assertEquals(-1.234f, Precision.round(-x, 3, BigDecimal.ROUND_DOWN), 0.0);
- Assert.assertEquals(-1.2345f, Precision.round(-x, 4, BigDecimal.ROUND_DOWN), 0.0);
-
- Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_FLOOR), 0.0);
- Assert.assertEquals(1.234f, Precision.round(x, 3, BigDecimal.ROUND_FLOOR), 0.0);
- Assert.assertEquals(1.2345f, Precision.round(x, 4, BigDecimal.ROUND_FLOOR), 0.0);
- Assert.assertEquals(-1.24f, Precision.round(-x, 2, BigDecimal.ROUND_FLOOR), 0.0);
- Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_FLOOR), 0.0);
- Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_FLOOR), 0.0);
-
- Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_HALF_DOWN), 0.0);
- Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_HALF_DOWN), 0.0);
- Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_HALF_DOWN), 0.0);
- Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_HALF_DOWN), 0.0);
- Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_HALF_DOWN), 0.0);
- Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_HALF_DOWN), 0.0);
- Assert.assertEquals(1.234f, Precision.round(1.2345f, 3, BigDecimal.ROUND_HALF_DOWN), 0.0);
- Assert.assertEquals(-1.234f, Precision.round(-1.2345f, 3, BigDecimal.ROUND_HALF_DOWN), 0.0);
-
- Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_HALF_EVEN), 0.0);
- Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_HALF_EVEN), 0.0);
- Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_HALF_EVEN), 0.0);
- Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_HALF_EVEN), 0.0);
- Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_HALF_EVEN), 0.0);
- Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_HALF_EVEN), 0.0);
- Assert.assertEquals(1.234f, Precision.round(1.2345f, 3, BigDecimal.ROUND_HALF_EVEN), 0.0);
- Assert.assertEquals(-1.234f, Precision.round(-1.2345f, 3, BigDecimal.ROUND_HALF_EVEN), 0.0);
- Assert.assertEquals(1.236f, Precision.round(1.2355f, 3, BigDecimal.ROUND_HALF_EVEN), 0.0);
- Assert.assertEquals(-1.236f, Precision.round(-1.2355f, 3, BigDecimal.ROUND_HALF_EVEN), 0.0);
-
- Assert.assertEquals(1.23f, Precision.round(x, 2, BigDecimal.ROUND_HALF_UP), 0.0);
- Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_HALF_UP), 0.0);
- Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_HALF_UP), 0.0);
- Assert.assertEquals(-1.23f, Precision.round(-x, 2, BigDecimal.ROUND_HALF_UP), 0.0);
- Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_HALF_UP), 0.0);
- Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_HALF_UP), 0.0);
- Assert.assertEquals(1.235f, Precision.round(1.2345f, 3, BigDecimal.ROUND_HALF_UP), 0.0);
- Assert.assertEquals(-1.235f, Precision.round(-1.2345f, 3, BigDecimal.ROUND_HALF_UP), 0.0);
-
- Assert.assertEquals(-1.23f, Precision.round(-1.23f, 2, BigDecimal.ROUND_UNNECESSARY), 0.0);
- Assert.assertEquals(1.23f, Precision.round(1.23f, 2, BigDecimal.ROUND_UNNECESSARY), 0.0);
-
- try {
- Precision.round(1.234f, 2, BigDecimal.ROUND_UNNECESSARY);
- Assert.fail();
- } catch (ArithmeticException ex) {
- // success
- }
-
- Assert.assertEquals(1.24f, Precision.round(x, 2, BigDecimal.ROUND_UP), 0.0);
- Assert.assertEquals(1.235f, Precision.round(x, 3, BigDecimal.ROUND_UP), 0.0);
- Assert.assertEquals(1.2346f, Precision.round(x, 4, BigDecimal.ROUND_UP), 0.0);
- Assert.assertEquals(-1.24f, Precision.round(-x, 2, BigDecimal.ROUND_UP), 0.0);
- Assert.assertEquals(-1.235f, Precision.round(-x, 3, BigDecimal.ROUND_UP), 0.0);
- Assert.assertEquals(-1.2346f, Precision.round(-x, 4, BigDecimal.ROUND_UP), 0.0);
-
- try {
- Precision.round(1.234f, 2, 1923);
- Assert.fail();
- } catch (IllegalArgumentException ex) {
- // success
- }
-
- // special values
- TestUtils.assertEquals(Float.NaN, Precision.round(Float.NaN, 2), 0.0f);
- Assert.assertEquals(0.0f, Precision.round(0.0f, 2), 0.0f);
- Assert.assertEquals(Float.POSITIVE_INFINITY, Precision.round(Float.POSITIVE_INFINITY, 2), 0.0f);
- Assert.assertEquals(Float.NEGATIVE_INFINITY, Precision.round(Float.NEGATIVE_INFINITY, 2), 0.0f);
- // comparison of positive and negative zero is not possible -> always equal thus do string comparison
- Assert.assertEquals("-0.0", Float.toString(Precision.round(-0.0f, 0)));
- Assert.assertEquals("-0.0", Float.toString(Precision.round(-1e-10f, 0)));
-
- // MATH-1070
- Assert.assertEquals(0.0f, Precision.round(0f, 2, BigDecimal.ROUND_UP), 0.0f);
- Assert.assertEquals(0.05f, Precision.round(0.05f, 2, BigDecimal.ROUND_UP), 0.0f);
- Assert.assertEquals(0.06f, Precision.round(0.051f, 2, BigDecimal.ROUND_UP), 0.0f);
- Assert.assertEquals(0.06f, Precision.round(0.0505f, 2, BigDecimal.ROUND_UP), 0.0f);
- Assert.assertEquals(0.06f, Precision.round(0.059f, 2, BigDecimal.ROUND_UP), 0.0f);
- }
-
@Test
public void testIssue721() {
[41/50] commons-numbers git commit: Unnecessary use of accessors.
Posted by er...@apache.org.
Unnecessary use of accessors.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/a4bee700
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/a4bee700
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/a4bee700
Branch: refs/heads/feature__NUMBERS-51__field
Commit: a4bee7004200d68afe8c6831b3eced555d98d8da
Parents: 5de033d
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 13:24:34 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 13:24:34 2018 +0100
----------------------------------------------------------------------
.../org/apache/commons/numbers/complex/Complex.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a4bee700/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 6e52674..53e3ff1 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
@@ -222,8 +222,8 @@ public class Complex implements Serializable {
*/
public Complex add(Complex addend) {
checkNotNull(addend);
- return new Complex(real + addend.getReal(),
- imaginary + addend.getImaginary());
+ return new Complex(real + addend.real,
+ imaginary + addend.imaginary);
}
/**
@@ -299,8 +299,8 @@ public class Complex implements Serializable {
public Complex divide(Complex divisor) {
checkNotNull(divisor);
- final double c = divisor.getReal();
- final double d = divisor.getImaginary();
+ final double c = divisor.real;
+ final double d = divisor.imaginary;
if (c == 0 &&
d == 0) {
return NaN;
@@ -624,8 +624,8 @@ public class Complex implements Serializable {
*/
public Complex subtract(Complex subtrahend) {
checkNotNull(subtrahend);
- return new Complex(real - subtrahend.getReal(),
- imaginary - subtrahend.getImaginary());
+ return new Complex(real - subtrahend.real,
+ imaginary - subtrahend.imaginary);
}
/**
@@ -1209,7 +1209,7 @@ public class Complex implements Serializable {
* @return the argument of {@code this}.
*/
public double getArgument() {
- return Math.atan2(getImaginary(), getReal());
+ return Math.atan2(imaginary, real);
}
/**
[04/50] commons-numbers git commit: Small cleanup
Posted by er...@apache.org.
Small cleanup
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/8830e479
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/8830e479
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/8830e479
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 8830e47976f109bda6cf9a763d7276c814a37b22
Parents: fc70d93
Author: Eric Barnhill <er...@apache.org>
Authored: Fri Jan 26 15:35:59 2018 +0100
Committer: Eric Barnhill <er...@apache.org>
Committed: Fri Jan 26 15:35:59 2018 +0100
----------------------------------------------------------------------
.../commons/numbers/complex/Complex.java.orig | 1320 ------------------
1 file changed, 1320 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/8830e479/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java.orig
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java.orig b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java.orig
deleted file mode 100644
index d3c7ce0..0000000
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java.orig
+++ /dev/null
@@ -1,1320 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.numbers.complex;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.numbers.core.Precision;
-/**
- * Representation of a Complex number, i.e., a number which has both a
- * real and imaginary part.
- * <p>
- * Implementations of arithmetic operations handle {@code NaN} and
- * infinite values according to the rules for {@link java.lang.Double}, i.e.
- * {@link #equals} is an equivalence relation for all instances that have
- * a {@code NaN} in either real or imaginary part, e.g. the following are
- * considered equal:
- * <ul>
- * <li>{@code 1 + NaNi}</li>
- * <li>{@code NaN + i}</li>
- * <li>{@code NaN + NaNi}</li>
- * </ul><p>
- * Note that this contradicts the IEEE-754 standard for floating
- * point numbers (according to which the test {@code x == x} must fail if
- * {@code x} is {@code NaN}). The method
- * {@link org.apache.commons.numbers.core.Precision#equals(double,double,int)
- * equals for primitive double} in class {@code Precision} conforms with
- * IEEE-754 while this class conforms with the standard behavior for Java
- * object types.</p>
- *
- */
-public class Complex implements Serializable {
- /** The square root of -1. A number representing "0.0 + 1.0i" */
- public static final Complex I = new Complex(0.0, 1.0);
- // CHECKSTYLE: stop ConstantName
- /** A complex number representing "NaN + NaNi" */
- public static final Complex NaN = new Complex(Double.NaN, Double.NaN);
- // CHECKSTYLE: resume ConstantName
- /** A complex number representing "+INF + INFi" */
- public static final Complex INF = new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
- /** A complex number representing "1.0 + 0.0i" */
- public static final Complex ONE = new Complex(1.0, 0.0);
- /** A complex number representing "0.0 + 0.0i" */
- public static final Complex ZERO = new Complex(0.0, 0.0);
-
- /** Serializable version identifier */
- private static final long serialVersionUID = 201701120L;
-
- /** The imaginary part. */
- private final double imaginary;
- /** The real part. */
- private final double real;
- /** Record whether this complex number is equal to NaN. */
- private final transient boolean isNaN;
- /** Record whether this complex number is infinite. */
- private final transient boolean isInfinite;
-
- /**
- * Create a complex number given only the real part.
- *
- * @param real Real part.
- */
- public Complex(double real) {
- this(real, 0.0);
- }
-
- /**
- * Create a complex number given the real and imaginary parts.
- *
- * @param real Real part.
- * @param imaginary Imaginary part.
- */
- public Complex(double real, double imaginary) {
- this.real = real;
- this.imaginary = imaginary;
-
- isNaN = Double.isNaN(real) || Double.isNaN(imaginary);
- isInfinite = !isNaN &&
- (Double.isInfinite(real) || Double.isInfinite(imaginary));
- }
-
- /**
- * Return the absolute value of this complex number.
- * Returns {@code NaN} if either real or imaginary part is {@code NaN}
- * and {@code Double.POSITIVE_INFINITY} if neither part is {@code NaN},
- * but at least one part is infinite.
- * This code follows the <a href="http://www.iso-9899.info/wiki/The_Standard">ISO C Standard</a>, Annex G, in calculating the returned value (i.e. the hypot(x,y) method)
- *
- * @return the absolute value.
- */
- public double abs() {
- if (isNaN) {
- return Double.NaN;
- }
- if (isInfinite()) {
- return Double.POSITIVE_INFINITY;
- }
- if (Math.abs(real) < Math.abs(imaginary)) {
- if (imaginary == 0.0) {
- return Math.abs(real);
- }
- double q = real / imaginary;
- return Math.abs(imaginary) * Math.sqrt(1 + q * q);
- } else {
- if (real == 0.0) {
- return Math.abs(imaginary);
- }
- double q = imaginary / real;
- return Math.abs(real) * Math.sqrt(1 + q * q);
- }
- }
-
- /**
- * Returns a {@code Complex} whose value is
- * {@code (this + addend)}.
- * Uses the definitional formula
- * <p>
- * {@code (a + bi) + (c + di) = (a+c) + (b+d)i}
- * </p>
- * If either {@code this} or {@code addend} has a {@code NaN} value in
- * either part, {@link #NaN} is returned; otherwise {@code Infinite}
- * and {@code NaN} values are returned in the parts of the result
- * according to the rules for {@link java.lang.Double} arithmetic.
- *
- * @param addend Value to be added to this {@code Complex}.
- * @return {@code this + addend}.
- */
- public Complex add(Complex addend) {
- checkNotNull(addend);
- if (isNaN || addend.isNaN) {
- return NaN;
- }
-
- return createComplex(real + addend.getReal(),
- imaginary + addend.getImaginary());
- }
-
- /**
- * Returns a {@code Complex} whose value is {@code (this + addend)},
- * with {@code addend} interpreted as a real number.
- *
- * @param addend Value to be added to this {@code Complex}.
- * @return {@code this + addend}.
- * @see #add(Complex)
- */
- public Complex add(double addend) {
- if (isNaN || Double.isNaN(addend)) {
- return NaN;
- }
-
- return createComplex(real + addend, imaginary);
- }
-
- /**
- * Returns the conjugate of this complex number.
- * The conjugate of {@code a + bi} is {@code a - bi}.
- * <p>
- * {@link #NaN} is returned if either the real or imaginary
- * part of this Complex number equals {@code Double.NaN}.
- * </p><p>
- * If the imaginary part is infinite, and the real part is not
- * {@code NaN}, the returned value has infinite imaginary part
- * of the opposite sign, e.g. the conjugate of
- * {@code 1 + POSITIVE_INFINITY i} is {@code 1 - NEGATIVE_INFINITY i}.
- * </p>
- * @return the conjugate of this Complex object.
- */
- public Complex conjugate() {
- if (isNaN) {
- return NaN;
- }
-
- return createComplex(real, -imaginary);
- }
-
- /**
- * Returns a {@code Complex} whose value is
- * {@code (this / divisor)}.
- * Implements the definitional formula
- * <pre>
- * <code>
- * a + bi ac + bd + (bc - ad)i
- * ----------- = -------------------------
- * c + di c<sup>2</sup> + d<sup>2</sup>
- * </code>
- * </pre>
- * but uses
- * <a href="http://doi.acm.org/10.1145/1039813.1039814">
- * prescaling of operands</a> to limit the effects of overflows and
- * underflows in the computation.
- * <p>
- * {@code Infinite} and {@code NaN} values are handled according to the
- * following rules, applied in the order presented:
- * <ul>
- * <li>If either {@code this} or {@code divisor} has a {@code NaN} value
- * in either part, {@link #NaN} is returned.
- * </li>
- * <li>If {@code divisor} equals {@link #ZERO}, {@link #NaN} is returned.
- * </li>
- * <li>If {@code this} and {@code divisor} are both infinite,
- * {@link #NaN} is returned.
- * </li>
- * <li>If {@code this} is finite (i.e., has no {@code Infinite} or
- * {@code NaN} parts) and {@code divisor} is infinite (one or both parts
- * infinite), {@link #ZERO} is returned.
- * </li>
- * <li>If {@code this} is infinite and {@code divisor} is finite,
- * {@code NaN} values are returned in the parts of the result if the
- * {@link java.lang.Double} rules applied to the definitional formula
- * force {@code NaN} results.
- * </li>
- * </ul>
- *
- * @param divisor Value by which this {@code Complex} is to be divided.
- * @return {@code this / divisor}.
- */
- public Complex divide(Complex divisor) {
- checkNotNull(divisor);
- if (isNaN || divisor.isNaN) {
- return NaN;
- }
-
- final double c = divisor.getReal();
- final double d = divisor.getImaginary();
- if (c == 0.0 && d == 0.0) {
- return NaN;
- }
-
- if (divisor.isInfinite() && !isInfinite()) {
- return ZERO;
- }
-
- if (Math.abs(c) < Math.abs(d)) {
- double q = c / d;
- double denominator = c * q + d;
- return createComplex((real * q + imaginary) / denominator,
- (imaginary * q - real) / denominator);
- } else {
- double q = d / c;
- double denominator = d * q + c;
- return createComplex((imaginary * q + real) / denominator,
- (imaginary - real * q) / denominator);
- }
- }
-
- /**
- * Returns a {@code Complex} whose value is {@code (this / divisor)},
- * with {@code divisor} interpreted as a real number.
- *
- * @param divisor Value by which this {@code Complex} is to be divided.
- * @return {@code this / divisor}.
- * @see #divide(Complex)
- */
- public Complex divide(double divisor) {
- if (isNaN || Double.isNaN(divisor)) {
- return NaN;
- }
- if (divisor == 0d) {
- return NaN;
- }
- if (Double.isInfinite(divisor)) {
- return !isInfinite() ? ZERO : NaN;
- }
- return createComplex(real / divisor,
- imaginary / divisor);
- }
-
- /**
- * Returns the multiplicative inverse this instance.
- *
- * @return {@code 1 / this}.
- * @see #divide(Complex)
- */
- public Complex reciprocal() {
- if (isNaN) {
- return NaN;
- }
-
- if (real == 0.0 && imaginary == 0.0) {
- return INF;
- }
-
- if (isInfinite) {
- return ZERO;
- }
-
- if (Math.abs(real) < Math.abs(imaginary)) {
- double q = real / imaginary;
- double scale = 1. / (real * q + imaginary);
- return createComplex(scale * q, -scale);
- } else {
- double q = imaginary / real;
- double scale = 1. / (imaginary * q + real);
- return createComplex(scale, -scale * q);
- }
- }
-
- /**
- * Test for equality with another object.
- * If both the real and imaginary parts of two complex numbers
- * are exactly the same, and neither is {@code Double.NaN}, the two
- * Complex objects are considered to be equal.
- * The behavior is the same as for JDK's {@link Double#equals(Object)
- * Double}:
- * <ul>
- * <li>All {@code NaN} values are considered to be equal,
- * i.e, if either (or both) real and imaginary parts of the complex
- * number are equal to {@code Double.NaN}, the complex number is equal
- * to {@code NaN}.
- * </li>
- * <li>
- * Instances constructed with different representations of zero (i.e.
- * either "0" or "-0") are <em>not</em> considered to be equal.
- * </li>
- * </ul>
- *
- * @param other Object to test for equality with this instance.
- * @return {@code true} if the objects are equal, {@code false} if object
- * is {@code null}, not an instance of {@code Complex}, or not equal to
- * this instance.
- */
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
- if (other instanceof Complex){
- Complex c = (Complex) other;
- if (c.isNaN) {
- return isNaN;
- } else {
- return equals(real, c.real) &&
- equals(imaginary, c.imaginary);
- }
- }
- return false;
- }
-
- /**
- * Test for the floating-point equality between Complex objects.
- * It returns {@code true} if both arguments are equal or within the
- * range of allowed error (inclusive).
- *
- * @param x First value (cannot be {@code null}).
- * @param y Second value (cannot be {@code null}).
- * @param maxUlps {@code (maxUlps - 1)} is the number of floating point
- * values between the real (resp. imaginary) parts of {@code x} and
- * {@code y}.
- * @return {@code true} if there are fewer than {@code maxUlps} floating
- * point values between the real (resp. imaginary) parts of {@code x}
- * and {@code y}.
- *
- * @see Precision#equals(double,double,int)
- */
- public static boolean equals(Complex x, Complex y, int maxUlps) {
- return Precision.equals(x.real, y.real, maxUlps) &&
- Precision.equals(x.imaginary, y.imaginary, maxUlps);
- }
-
- /**
- * Returns {@code true} iff the values are equal as defined by
- * {@link #equals(Complex,Complex,int) equals(x, y, 1)}.
- *
- * @param x First value (cannot be {@code null}).
- * @param y Second value (cannot be {@code null}).
- * @return {@code true} if the values are equal.
- */
- public static boolean equals(Complex x, Complex y) {
- return equals(x, y, 1);
- }
-
- /**
- * Returns {@code true} if, both for the real part and for the imaginary
- * part, there is no double value strictly between the arguments or the
- * difference between them is within the range of allowed error
- * (inclusive). Returns {@code false} if either of the arguments is NaN.
- *
- * @param x First value (cannot be {@code null}).
- * @param y Second value (cannot be {@code null}).
- * @param eps Amount of allowed absolute error.
- * @return {@code true} if the values are two adjacent floating point
- * numbers or they are within range of each other.
- *
- * @see Precision#equals(double,double,double)
- */
- public static boolean equals(Complex x, Complex y, double eps) {
- return Precision.equals(x.real, y.real, eps) &&
- Precision.equals(x.imaginary, y.imaginary, eps);
- }
-
- /**
- * Returns {@code true} if, both for the real part and for the imaginary
- * part, there is no double value strictly between the arguments or the
- * relative difference between them is smaller or equal to the given
- * tolerance. Returns {@code false} if either of the arguments is NaN.
- *
- * @param x First value (cannot be {@code null}).
- * @param y Second value (cannot be {@code null}).
- * @param eps Amount of allowed relative error.
- * @return {@code true} if the values are two adjacent floating point
- * numbers or they are within range of each other.
- *
- * @see Precision#equalsWithRelativeTolerance(double,double,double)
- */
- public static boolean equalsWithRelativeTolerance(Complex x, Complex y,
- double eps) {
- return Precision.equalsWithRelativeTolerance(x.real, y.real, eps) &&
- Precision.equalsWithRelativeTolerance(x.imaginary, y.imaginary, eps);
- }
-
- /**
- * Get a hashCode for the complex number.
- * Any {@code Double.NaN} value in real or imaginary part produces
- * the same hash code {@code 7}.
- *
- * @return a hash code value for this object.
- */
- @Override
- public int hashCode() {
- if (isNaN) {
- return 7;
- }
-<<<<<<< HEAD
- return 37 * 17 * (hash(imaginary) +
- hash(real));
- }
-
- private int hash(double d) {
- final long v = Double.doubleToLongBits(d);
- return (int)(v^(v>>>32));
- //return new Double(d).hashCode();
-=======
- return 37 * (17 * hash(imaginary) +
- hash(real));
->>>>>>> eb-test
- }
-
- /**
- * Access the imaginary part.
- *
- * @return the imaginary part.
- */
- public double getImaginary() {
- return imaginary;
- }
-
- /**
- * Access the real part.
- *
- * @return the real part.
- */
- public double getReal() {
- return real;
- }
-
- /**
- * Checks whether either or both parts of this complex number is
- * {@code NaN}.
- *
- * @return true if either or both parts of this complex number is
- * {@code NaN}; false otherwise.
- */
- public boolean isNaN() {
- return isNaN;
- }
-
- /**
- * Checks whether either the real or imaginary part of this complex number
- * takes an infinite value (either {@code Double.POSITIVE_INFINITY} or
- * {@code Double.NEGATIVE_INFINITY}) and neither part
- * is {@code NaN}.
- *
- * @return true if one or both parts of this complex number are infinite
- * and neither part is {@code NaN}.
- */
- public boolean isInfinite() {
- return isInfinite;
- }
-
- /**
- * Returns a {@code Complex} whose value is {@code this * factor}.
- * Implements preliminary checks for {@code NaN} and infinity followed by
- * the definitional formula:
- * <p>
- * {@code (a + bi)(c + di) = (ac - bd) + (ad + bc)i}
- * </p>
- * Returns {@link #NaN} if either {@code this} or {@code factor} has one or
- * more {@code NaN} parts.
- * <p>
- * Returns {@link #INF} if neither {@code this} nor {@code factor} has one
- * or more {@code NaN} parts and if either {@code this} or {@code factor}
- * has one or more infinite parts (same result is returned regardless of
- * the sign of the components).
- * </p><p>
- * Returns finite values in components of the result per the definitional
- * formula in all remaining cases.</p>
- *
- * @param factor value to be multiplied by this {@code Complex}.
- * @return {@code this * factor}.
- */
- public Complex multiply(Complex factor) {
- checkNotNull(factor);
- if (isNaN || factor.isNaN) {
- return NaN;
- }
- if (Double.isInfinite(real) ||
- Double.isInfinite(imaginary) ||
- Double.isInfinite(factor.real) ||
- Double.isInfinite(factor.imaginary)) {
- // we don't use isInfinite() to avoid testing for NaN again
- return INF;
- }
- return createComplex(real * factor.real - imaginary * factor.imaginary,
- real * factor.imaginary + imaginary * factor.real);
- }
-
- /**
- * Returns a {@code Complex} whose value is {@code this * factor}, with {@code factor}
- * interpreted as a integer number.
- *
- * @param factor value to be multiplied by this {@code Complex}.
- * @return {@code this * factor}.
- * @see #multiply(Complex)
- */
- public Complex multiply(final int factor) {
- if (isNaN) {
- return NaN;
- }
- if (Double.isInfinite(real) ||
- Double.isInfinite(imaginary)) {
- return INF;
- }
- return createComplex(real * factor, imaginary * factor);
- }
-
- /**
- * Returns a {@code Complex} whose value is {@code this * factor}, with {@code factor}
- * interpreted as a real number.
- *
- * @param factor value to be multiplied by this {@code Complex}.
- * @return {@code this * factor}.
- * @see #multiply(Complex)
- */
- public Complex multiply(double factor) {
- if (isNaN || Double.isNaN(factor)) {
- return NaN;
- }
- if (Double.isInfinite(real) ||
- Double.isInfinite(imaginary) ||
- Double.isInfinite(factor)) {
- // we don't use isInfinite() to avoid testing for NaN again
- return INF;
- }
- return createComplex(real * factor, imaginary * factor);
- }
-
- /**
- * Returns a {@code Complex} whose value is {@code (-this)}.
- * Returns {@code NaN} if either real or imaginary
- * part of this Complex number is {@code Double.NaN}.
- *
- * @return {@code -this}.
- */
- public Complex negate() {
- if (isNaN) {
- return NaN;
- }
-
- return createComplex(-real, -imaginary);
- }
-
- /**
- * Returns a {@code Complex} whose value is
- * {@code (this - subtrahend)}.
- * Uses the definitional formula
- * <p>
- * {@code (a + bi) - (c + di) = (a-c) + (b-d)i}
- * </p>
- * If either {@code this} or {@code subtrahend} has a {@code NaN]} value in either part,
- * {@link #NaN} is returned; otherwise infinite and {@code NaN} values are
- * returned in the parts of the result according to the rules for
- * {@link java.lang.Double} arithmetic.
- *
- * @param subtrahend value to be subtracted from this {@code Complex}.
- * @return {@code this - subtrahend}.
- */
- public Complex subtract(Complex subtrahend) {
- checkNotNull(subtrahend);
- if (isNaN || subtrahend.isNaN) {
- return NaN;
- }
-
- return createComplex(real - subtrahend.getReal(),
- imaginary - subtrahend.getImaginary());
- }
-
- /**
- * Returns a {@code Complex} whose value is
- * {@code (this - subtrahend)}.
- *
- * @param subtrahend value to be subtracted from this {@code Complex}.
- * @return {@code this - subtrahend}.
- * @see #subtract(Complex)
- */
- public Complex subtract(double subtrahend) {
- if (isNaN || Double.isNaN(subtrahend)) {
- return NaN;
- }
- return createComplex(real - subtrahend, imaginary);
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/InverseCosine.html" TARGET="_top">
- * inverse cosine</a> of this complex number.
- * Implements the formula:
- * <p>
- * {@code acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))}
- * </p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN} or infinite.
- *
- * @return the inverse cosine of this complex number.
- */
- public Complex acos() {
- if (isNaN) {
- return NaN;
- }
-
- return this.add(this.sqrt1z().multiply(I)).log().multiply(I.negate());
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/InverseSine.html" TARGET="_top">
- * inverse sine</a> of this complex number.
- * Implements the formula:
- * <p>
- * {@code asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))}
- * </p><p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN} or infinite.</p>
- *
- * @return the inverse sine of this complex number.
- */
- public Complex asin() {
- if (isNaN) {
- return NaN;
- }
-
- return sqrt1z().add(this.multiply(I)).log().multiply(I.negate());
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top">
- * inverse tangent</a> of this complex number.
- * Implements the formula:
- * <p>
- * {@code atan(z) = (i/2) log((i + z)/(i - z))}
- * </p><p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN} or infinite.</p>
- *
- * @return the inverse tangent of this complex number
- */
- public Complex atan() {
- if (isNaN) {
- return NaN;
- }
-
- return this.add(I).divide(I.subtract(this)).log()
- .multiply(I.divide(createComplex(2.0, 0.0)));
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/Cosine.html" TARGET="_top">
- * cosine</a> of this complex number.
- * Implements the formula:
- * <p>
- * {@code cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i}
- * </p><p>
- * where the (real) functions on the right-hand side are
- * {@link Math#sin}, {@link Math#cos},
- * {@link Math#cosh} and {@link Math#sinh}.
- * </p><p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p><p>
- * Infinite values in real or imaginary parts of the input may result in
- * infinite or NaN values returned in parts of the result.</p>
- * <pre>
- * Examples:
- * <code>
- * cos(1 ± INFINITY i) = 1 \u2213 INFINITY i
- * cos(±INFINITY + i) = NaN + NaN i
- * cos(±INFINITY ± INFINITY i) = NaN + NaN i
- * </code>
- * </pre>
- *
- * @return the cosine of this complex number.
- */
- public Complex cos() {
- if (isNaN) {
- return NaN;
- }
-
- return createComplex(Math.cos(real) * Math.cosh(imaginary),
- -Math.sin(real) * Math.sinh(imaginary));
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/HyperbolicCosine.html" TARGET="_top">
- * hyperbolic cosine</a> of this complex number.
- * Implements the formula:
- * <pre>
- * <code>
- * cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i
- * </code>
- * </pre>
- * where the (real) functions on the right-hand side are
- * {@link Math#sin}, {@link Math#cos},
- * {@link Math#cosh} and {@link Math#sinh}.
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p>
- * Infinite values in real or imaginary parts of the input may result in
- * infinite or NaN values returned in parts of the result.
- * <pre>
- * Examples:
- * <code>
- * cosh(1 ± INFINITY i) = NaN + NaN i
- * cosh(±INFINITY + i) = INFINITY ± INFINITY i
- * cosh(±INFINITY ± INFINITY i) = NaN + NaN i
- * </code>
- * </pre>
- *
- * @return the hyperbolic cosine of this complex number.
- */
- public Complex cosh() {
- if (isNaN) {
- return NaN;
- }
-
- return createComplex(Math.cosh(real) * Math.cos(imaginary),
- Math.sinh(real) * Math.sin(imaginary));
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/ExponentialFunction.html" TARGET="_top">
- * exponential function</a> of this complex number.
- * Implements the formula:
- * <pre>
- * <code>
- * exp(a + bi) = exp(a)cos(b) + exp(a)sin(b)i
- * </code>
- * </pre>
- * where the (real) functions on the right-hand side are
- * {@link Math#exp}, {@link Math#cos}, and
- * {@link Math#sin}.
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p>
- * Infinite values in real or imaginary parts of the input may result in
- * infinite or NaN values returned in parts of the result.
- * <pre>
- * Examples:
- * <code>
- * exp(1 ± INFINITY i) = NaN + NaN i
- * exp(INFINITY + i) = INFINITY + INFINITY i
- * exp(-INFINITY + i) = 0 + 0i
- * exp(±INFINITY ± INFINITY i) = NaN + NaN i
- * </code>
- * </pre>
- *
- * @return <code><i>e</i><sup>this</sup></code>.
- */
- public Complex exp() {
- if (isNaN) {
- return NaN;
- }
-
- double expReal = Math.exp(real);
- return createComplex(expReal * Math.cos(imaginary),
- expReal * Math.sin(imaginary));
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/NaturalLogarithm.html" TARGET="_top">
- * natural logarithm</a> of this complex number.
- * Implements the formula:
- * <pre>
- * <code>
- * log(a + bi) = ln(|a + bi|) + arg(a + bi)i
- * </code>
- * </pre>
- * where ln on the right hand side is {@link Math#log},
- * {@code |a + bi|} is the modulus, {@link Complex#abs}, and
- * {@code arg(a + bi) = }{@link Math#atan2}(b, a).
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p>
- * Infinite (or critical) values in real or imaginary parts of the input may
- * result in infinite or NaN values returned in parts of the result.
- * <pre>
- * Examples:
- * <code>
- * log(1 ± INFINITY i) = INFINITY ± (π/2)i
- * log(INFINITY + i) = INFINITY + 0i
- * log(-INFINITY + i) = INFINITY + πi
- * log(INFINITY ± INFINITY i) = INFINITY ± (π/4)i
- * log(-INFINITY ± INFINITY i) = INFINITY ± (3π/4)i
- * log(0 + 0i) = -INFINITY + 0i
- * </code>
- * </pre>
- *
- * @return the value <code>ln this</code>, the natural logarithm
- * of {@code this}.
- */
- public Complex log() {
- if (isNaN) {
- return NaN;
- }
- return createComplex(Math.log(abs()),
- Math.atan2(imaginary, real));
- }
-
- /**
- * Returns of value of this complex number raised to the power of {@code x}.
- * Implements the formula:
- * <pre>
- * <code>
- * y<sup>x</sup> = exp(x·log(y))
- * </code>
- * </pre>
- * where {@code exp} and {@code log} are {@link #exp} and
- * {@link #log}, respectively.
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN} or infinite, or if {@code y}
- * equals {@link Complex#ZERO}.</p>
- *
- * @param x exponent to which this {@code Complex} is to be raised.
- * @return <code> this<sup>x</sup></code>.
- */
- public Complex pow(Complex x) {
- checkNotNull(x);
- if (real == 0 && imaginary == 0) {
- if (x.real > 0 && x.imaginary == 0) {
- // 0 raised to positive number is 0
- return ZERO;
- } else {
- // 0 raised to anything else is NaN
- return NaN;
- }
- }
- return this.log().multiply(x).exp();
- }
-
- /**
- * Returns of value of this complex number raised to the power of {@code x}.
- *
- * @param x exponent to which this {@code Complex} is to be raised.
- * @return <code>this<sup>x</sup></code>.
- * @see #pow(Complex)
- */
- public Complex pow(double x) {
- if (real == 0 && imaginary == 0) {
- if (x > 0) {
- // 0 raised to positive number is 0
- return ZERO;
- } else {
- // 0 raised to anything else is NaN
- return NaN;
- }
- }
- return this.log().multiply(x).exp();
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/Sine.html" TARGET="_top">
- * sine</a>
- * of this complex number.
- * Implements the formula:
- * <pre>
- * <code>
- * sin(a + bi) = sin(a)cosh(b) - cos(a)sinh(b)i
- * </code>
- * </pre>
- * where the (real) functions on the right-hand side are
- * {@link Math#sin}, {@link Math#cos},
- * {@link Math#cosh} and {@link Math#sinh}.
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p><p>
- * Infinite values in real or imaginary parts of the input may result in
- * infinite or {@code NaN} values returned in parts of the result.
- * <pre>
- * Examples:
- * <code>
- * sin(1 ± INFINITY i) = 1 ± INFINITY i
- * sin(±INFINITY + i) = NaN + NaN i
- * sin(±INFINITY ± INFINITY i) = NaN + NaN i
- * </code>
- * </pre>
- *
- * @return the sine of this complex number.
- */
- public Complex sin() {
- if (isNaN) {
- return NaN;
- }
-
- return createComplex(Math.sin(real) * Math.cosh(imaginary),
- Math.cos(real) * Math.sinh(imaginary));
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/HyperbolicSine.html" TARGET="_top">
- * hyperbolic sine</a> of this complex number.
- * Implements the formula:
- * <pre>
- * <code>
- * sinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)i
- * </code>
- * </pre>
- * where the (real) functions on the right-hand side are
- * {@link Math#sin}, {@link Math#cos},
- * {@link Math#cosh} and {@link Math#sinh}.
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p><p>
- * Infinite values in real or imaginary parts of the input may result in
- * infinite or NaN values returned in parts of the result.
- * <pre>
- * Examples:
- * <code>
- * sinh(1 ± INFINITY i) = NaN + NaN i
- * sinh(±INFINITY + i) = ± INFINITY + INFINITY i
- * sinh(±INFINITY ± INFINITY i) = NaN + NaN i
- * </code>
- * </pre>
- *
- * @return the hyperbolic sine of {@code this}.
- */
- public Complex sinh() {
- if (isNaN) {
- return NaN;
- }
-
- return createComplex(Math.sinh(real) * Math.cos(imaginary),
- Math.cosh(real) * Math.sin(imaginary));
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top">
- * square root</a> of this complex number.
- * Implements the following algorithm to compute {@code sqrt(a + bi)}:
- * <ol><li>Let {@code t = sqrt((|a| + |a + bi|) / 2)}</li>
- * <li><pre>if {@code a ≥ 0} return {@code t + (b/2t)i}
- * else return {@code |b|/2t + sign(b)t i }</pre></li>
- * </ol>
- * where <ul>
- * <li>{@code |a| = }{@link Math#abs}(a)</li>
- * <li>{@code |a + bi| = }{@link Complex#abs}(a + bi)</li>
- * <li>{@code sign(b) = }{@link Math#copySign(double,double) copySign(1d, b)}
- * </ul>
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p>
- * Infinite values in real or imaginary parts of the input may result in
- * infinite or NaN values returned in parts of the result.
- * <pre>
- * Examples:
- * <code>
- * sqrt(1 ± INFINITY i) = INFINITY + NaN i
- * sqrt(INFINITY + i) = INFINITY + 0i
- * sqrt(-INFINITY + i) = 0 + INFINITY i
- * sqrt(INFINITY ± INFINITY i) = INFINITY + NaN i
- * sqrt(-INFINITY ± INFINITY i) = NaN ± INFINITY i
- * </code>
- * </pre>
- *
- * @return the square root of {@code this}.
- */
- public Complex sqrt() {
- if (isNaN) {
- return NaN;
- }
-
- if (real == 0.0 && imaginary == 0.0) {
- return createComplex(0.0, 0.0);
- }
-
- double t = Math.sqrt((Math.abs(real) + abs()) / 2.0);
- if (real >= 0.0) {
- return createComplex(t, imaginary / (2.0 * t));
- } else {
- return createComplex(Math.abs(imaginary) / (2.0 * t),
- Math.copySign(1d, imaginary) * t);
- }
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top">
- * square root</a> of <code>1 - this<sup>2</sup></code> for this complex
- * number.
- * Computes the result directly as
- * {@code sqrt(ONE.subtract(z.multiply(z)))}.
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p>
- * Infinite values in real or imaginary parts of the input may result in
- * infinite or NaN values returned in parts of the result.
- *
- * @return the square root of <code>1 - this<sup>2</sup></code>.
- */
- public Complex sqrt1z() {
- return createComplex(1.0, 0.0).subtract(this.multiply(this)).sqrt();
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/Tangent.html" TARGET="_top">
- * tangent</a> of this complex number.
- * Implements the formula:
- * <pre>
- * <code>
- * tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i
- * </code>
- * </pre>
- * where the (real) functions on the right-hand side are
- * {@link Math#sin}, {@link Math#cos}, {@link Math#cosh} and
- * {@link Math#sinh}.
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p>
- * Infinite (or critical) values in real or imaginary parts of the input may
- * result in infinite or NaN values returned in parts of the result.
- * <pre>
- * Examples:
- * <code>
- * tan(a ± INFINITY i) = 0 ± i
- * tan(±INFINITY + bi) = NaN + NaN i
- * tan(±INFINITY ± INFINITY i) = NaN + NaN i
- * tan(±π/2 + 0 i) = ±INFINITY + NaN i
- * </code>
- * </pre>
- *
- * @return the tangent of {@code this}.
- */
- public Complex tan() {
- if (isNaN || Double.isInfinite(real)) {
- return NaN;
- }
- if (imaginary > 20.0) {
- return createComplex(0.0, 1.0);
- }
- if (imaginary < -20.0) {
- return createComplex(0.0, -1.0);
- }
-
- double real2 = 2.0 * real;
- double imaginary2 = 2.0 * imaginary;
- double d = Math.cos(real2) + Math.cosh(imaginary2);
-
- return createComplex(Math.sin(real2) / d,
- Math.sinh(imaginary2) / d);
- }
-
- /**
- * Compute the
- * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html" TARGET="_top">
- * hyperbolic tangent</a> of this complex number.
- * Implements the formula:
- * <pre>
- * <code>
- * tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i
- * </code>
- * </pre>
- * where the (real) functions on the right-hand side are
- * {@link Math#sin}, {@link Math#cos}, {@link Math#cosh} and
- * {@link Math#sinh}.
- * <p>
- * Returns {@link Complex#NaN} if either real or imaginary part of the
- * input argument is {@code NaN}.
- * </p>
- * Infinite values in real or imaginary parts of the input may result in
- * infinite or NaN values returned in parts of the result.
- * <pre>
- * Examples:
- * <code>
- * tanh(a ± INFINITY i) = NaN + NaN i
- * tanh(±INFINITY + bi) = ±1 + 0 i
- * tanh(±INFINITY ± INFINITY i) = NaN + NaN i
- * tanh(0 + (π/2)i) = NaN + INFINITY i
- * </code>
- * </pre>
- *
- * @return the hyperbolic tangent of {@code this}.
- */
- public Complex tanh() {
- if (isNaN || Double.isInfinite(imaginary)) {
- return NaN;
- }
- if (real > 20.0) {
- return createComplex(1.0, 0.0);
- }
- if (real < -20.0) {
- return createComplex(-1.0, 0.0);
- }
- double real2 = 2.0 * real;
- double imaginary2 = 2.0 * imaginary;
- double d = Math.cosh(real2) + Math.cos(imaginary2);
-
- return createComplex(Math.sinh(real2) / d,
- Math.sin(imaginary2) / d);
- }
-
-
-
- /**
- * Compute the argument of this complex number.
- * The argument is the angle phi between the positive real axis and
- * the point representing this number in the complex plane.
- * The value returned is between -PI (not inclusive)
- * and PI (inclusive), with negative values returned for numbers with
- * negative imaginary parts.
- * <p>
- * If either real or imaginary part (or both) is NaN, NaN is returned.
- * Infinite parts are handled as {@code Math.atan2} handles them,
- * essentially treating finite parts as zero in the presence of an
- * infinite coordinate and returning a multiple of pi/4 depending on
- * the signs of the infinite parts.
- * See the javadoc for {@code Math.atan2} for full details.
- *
- * @return the argument of {@code this}.
- */
- public double getArgument() {
- return Math.atan2(getImaginary(), getReal());
- }
-
- /**
- * Computes the n-th roots of this complex number.
- * The nth roots are defined by the formula:
- * <pre>
- * <code>
- * z<sub>k</sub> = abs<sup>1/n</sup> (cos(phi + 2πk/n) + i (sin(phi + 2πk/n))
- * </code>
- * </pre>
- * for <i>{@code k=0, 1, ..., n-1}</i>, where {@code abs} and {@code phi}
- * are respectively the {@link #abs() modulus} and
- * {@link #getArgument() argument} of this complex number.
- * <p>
- * If one or both parts of this complex number is NaN, a list with just
- * one element, {@link #NaN} is returned.
- * if neither part is NaN, but at least one part is infinite, the result
- * is a one-element list containing {@link #INF}.
- *
- * @param n Degree of root.
- * @return a List of all {@code n}-th roots of {@code this}.
- */
- public List<Complex> nthRoot(int n) {
-
- if (n <= 0) {
- throw new RuntimeException("cannot compute nth root for null or negative n: {0}");
- }
-
- final List<Complex> result = new ArrayList<Complex>();
-
- if (isNaN) {
- result.add(NaN);
- return result;
- }
- if (isInfinite()) {
- result.add(INF);
- return result;
- }
-
- // nth root of abs -- faster / more accurate to use a solver here?
- final double nthRootOfAbs = Math.pow(abs(), 1.0 / n);
-
- // Compute nth roots of complex number with k = 0, 1, ... n-1
- final double nthPhi = getArgument() / n;
- final double slice = 2 * Math.PI / n;
- double innerPart = nthPhi;
- for (int k = 0; k < n ; k++) {
- // inner part
- final double realPart = nthRootOfAbs * Math.cos(innerPart);
- final double imaginaryPart = nthRootOfAbs * Math.sin(innerPart);
- result.add(createComplex(realPart, imaginaryPart));
- innerPart += slice;
- }
-
- return result;
- }
-
- /**
- * Create a complex number given the real and imaginary parts.
- *
- * @param realPart Real part.
- * @param imaginaryPart Imaginary part.
- * @return a new complex number instance.
- * @see #valueOf(double, double)
- */
- protected Complex createComplex(double realPart,
- double imaginaryPart) {
- return new Complex(realPart, imaginaryPart);
- }
-
- /**
- * Create a complex number given the real and imaginary parts.
- *
- * @param realPart Real part.
- * @param imaginaryPart Imaginary part.
- * @return a Complex instance.
- */
- public static Complex valueOf(double realPart,
- double imaginaryPart) {
- if (Double.isNaN(realPart) ||
- Double.isNaN(imaginaryPart)) {
- return NaN;
- }
- return new Complex(realPart, imaginaryPart);
- }
-
- /**
- * Create a complex number given only the real part.
- *
- * @param realPart Real part.
- * @return a Complex instance.
- */
- public static Complex valueOf(double realPart) {
- if (Double.isNaN(realPart)) {
- return NaN;
- }
- return new Complex(realPart);
- }
-
- /**
- * Resolve the transient fields in a deserialized Complex Object.
- * Subclasses will need to override {@link #createComplex} to
- * deserialize properly.
- *
- * @return A Complex instance with all fields resolved.
- */
- protected final Object readResolve() {
- return createComplex(real, imaginary);
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- return "(" + real + ", " + imaginary + ")";
- }
-
- /**
- * Checks that an object is not null.
- *
- * @param o Object to be checked.
- */
- private static void checkNotNull(Object o) {
- if (o == null) {
- throw new RuntimeException("Null Argument to Complex Method");
- }
- }
-
- /**
- * Returns {@code true} if the values are equal according to semantics of
- * {@link Double#equals(Object)}.
- *
- * @param x Value
- * @param y Value
- * @return {@code new Double(x).equals(new Double(y))}
- */
- private static boolean equals(double x, double y) {
- return new Double(x).equals(new Double(y));
- }
-
- /**
- * Returns an integer hash code representing the given double value.
- *
- * @param value the value to be hashed
- * @return the hash code
- */
- private static int hash(double value) {
- return new Double(value).hashCode();
- }
-}
[47/50] commons-numbers git commit: NUMBERS-59: Removed null checking
in Complex()
Posted by er...@apache.org.
NUMBERS-59: Removed null checking in Complex()
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/b077fd57
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/b077fd57
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/b077fd57
Branch: refs/heads/feature__NUMBERS-51__field
Commit: b077fd577c26357c9abde43f261c9029c8891ae9
Parents: ac1975c
Author: Eric Barnhill <er...@apache.org>
Authored: Fri Feb 2 10:06:32 2018 +0100
Committer: Eric Barnhill <er...@apache.org>
Committed: Fri Feb 2 10:06:32 2018 +0100
----------------------------------------------------------------------
.../org/apache/commons/numbers/complex/Complex.java | 16 ----------------
1 file changed, 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/b077fd57/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 7187507..f3295c3 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
@@ -221,7 +221,6 @@ public class Complex implements Serializable {
* @return {@code this + addend}.
*/
public Complex add(Complex addend) {
- checkNotNull(addend);
return new Complex(real + addend.real,
imaginary + addend.imaginary);
}
@@ -297,7 +296,6 @@ public class Complex implements Serializable {
* @return {@code this / divisor}.
*/
public Complex divide(Complex divisor) {
- checkNotNull(divisor);
final double c = divisor.real;
final double d = divisor.imaginary;
@@ -571,7 +569,6 @@ public class Complex implements Serializable {
* @return {@code this * factor}.
*/
public Complex multiply(Complex factor) {
- checkNotNull(factor);
return new Complex(real * factor.real - imaginary * factor.imaginary,
real * factor.imaginary + imaginary * factor.real);
}
@@ -623,7 +620,6 @@ public class Complex implements Serializable {
* @return {@code this - subtrahend}.
*/
public Complex subtract(Complex subtrahend) {
- checkNotNull(subtrahend);
return new Complex(real - subtrahend.real,
imaginary - subtrahend.imaginary);
}
@@ -961,7 +957,6 @@ public class Complex implements Serializable {
* @return <code> this<sup>x</sup></code>.
*/
public Complex pow(Complex x) {
- checkNotNull(x);
if (real == 0 &&
imaginary == 0) {
if (x.real > 0 &&
@@ -1316,17 +1311,6 @@ public class Complex implements Serializable {
}
/**
- * Checks that an object is not null.
- *
- * @param o Object to be checked.
- */
- private static void checkNotNull(Object o) {
- if (o == null) {
- throw new IllegalArgumentException("Null Argument to Complex Method");
- }
- }
-
- /**
* Check that the argument is positive and throw a RuntimeException
* if it is not.
* @param arg {@code double} to check
[09/50] commons-numbers git commit: Merge branch 'master' into
feature__NUMBERS-51__field
Posted by er...@apache.org.
Merge branch 'master' into feature__NUMBERS-51__field
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/b58c73e0
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/b58c73e0
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/b58c73e0
Branch: refs/heads/feature__NUMBERS-51__field
Commit: b58c73e0b5f88a0945ec94b68158eabd4be6b9b3
Parents: 797e402 230b026
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Mon Jan 29 01:57:14 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Mon Jan 29 01:57:14 2018 +0100
----------------------------------------------------------------------
.gitignore | 1 +
.../apache/commons/numbers/complex/Complex.java | 821 +++++++++----------
.../commons/numbers/complex/ComplexUtils.java | 806 ++++++++++++------
.../commons/numbers/complex/CStandardTest.java | 282 +++++++
.../commons/numbers/complex/ComplexTest.java | 687 +---------------
.../apache/commons/numbers/core/Precision.java | 117 ---
.../commons/numbers/core/PrecisionTest.java | 107 ---
7 files changed, 1274 insertions(+), 1547 deletions(-)
----------------------------------------------------------------------
[36/50] commons-numbers git commit: Unnecessary instantiation.
Posted by er...@apache.org.
Unnecessary instantiation.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/5dbfebeb
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/5dbfebeb
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/5dbfebeb
Branch: refs/heads/feature__NUMBERS-51__field
Commit: 5dbfebebe6a85d844abe0587404d7b3e70299229
Parents: 818603c
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Thu Feb 1 13:05:56 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Thu Feb 1 13:05:56 2018 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/commons/numbers/complex/Complex.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/5dbfebeb/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 e544e28..a56c641 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
@@ -777,7 +777,7 @@ public class Complex implements Serializable {
imaginary == Double.POSITIVE_INFINITY) {
return new Complex(0, Math.PI * 0.5);
}
- return this.add(Complex.ONE).divide(Complex.ONE.subtract(this)).log().divide(new Complex(2));
+ return this.add(Complex.ONE).divide(Complex.ONE.subtract(this)).log().multiply(0.5);
}
/**
* Compute the
[10/50] commons-numbers git commit: Typo.
Posted by er...@apache.org.
Typo.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/dc83272b
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/dc83272b
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/dc83272b
Branch: refs/heads/feature__NUMBERS-51__field
Commit: dc83272b53d93bc8d79870a59a15f204815db2a6
Parents: b58c73e
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Mon Jan 29 02:03:06 2018 +0100
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Mon Jan 29 02:03:06 2018 +0100
----------------------------------------------------------------------
commons-numbers-field/README.md | 2 +-
commons-numbers-field/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/dc83272b/commons-numbers-field/README.md
----------------------------------------------------------------------
diff --git a/commons-numbers-field/README.md b/commons-numbers-field/README.md
index 97a7314..aef0c98 100644
--- a/commons-numbers-field/README.md
+++ b/commons-numbers-field/README.md
@@ -61,7 +61,7 @@ Alternatively you can pull it from the central Maven repositories:
```xml
<dependency>
<groupId>org.apache.commons</groupId>
- <artifactId>commons-numbers-filed</artifactId>
+ <artifactId>commons-numbers-field</artifactId>
<version>1.0</version>
</dependency>
```
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/dc83272b/commons-numbers-field/pom.xml
----------------------------------------------------------------------
diff --git a/commons-numbers-field/pom.xml b/commons-numbers-field/pom.xml
index cd78011..5295443 100644
--- a/commons-numbers-field/pom.xml
+++ b/commons-numbers-field/pom.xml
@@ -27,7 +27,7 @@
</parent>
<groupId>org.apache.commons</groupId>
- <artifactId>commons-numbers-filed</artifactId>
+ <artifactId>commons-numbers-field</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Apache Commons Numbers Field</name>
[03/50] commons-numbers git commit: NUMBERS-22: Added file
ComplexTest.java to file tracker
Posted by er...@apache.org.
NUMBERS-22: Added file ComplexTest.java to file tracker
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/fc70d935
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/fc70d935
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/fc70d935
Branch: refs/heads/feature__NUMBERS-51__field
Commit: fc70d935fdadc5d5a7862cf9a929da91b72b00d6
Parents: 16322d8
Author: Eric Barnhill <er...@apache.org>
Authored: Fri Jan 26 14:54:16 2018 +0100
Committer: Eric Barnhill <er...@apache.org>
Committed: Fri Jan 26 14:54:16 2018 +0100
----------------------------------------------------------------------
.../commons/numbers/complex/ComplexTest.java | 849 +++++++++++++++++++
1 file changed, 849 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/fc70d935/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
new file mode 100644
index 0000000..b1ffab6
--- /dev/null
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
@@ -0,0 +1,849 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.numbers.complex;
+
+import java.util.List;
+
+import org.apache.commons.numbers.complex.Complex;
+import org.apache.commons.numbers.complex.ComplexUtils;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ */
+public class ComplexTest {
+
+
+ private static final double inf = Double.POSITIVE_INFINITY;
+ private static final double neginf = Double.NEGATIVE_INFINITY;
+ private static final double nan = Double.NaN;
+ private static final double pi = Math.PI;
+ private static final Complex oneInf = new Complex(1, inf);
+ private static final Complex oneNegInf = new Complex(1, neginf);
+ private static final Complex infOne = new Complex(inf, 1);
+ private static final Complex infZero = new Complex(inf, 0);
+ private static final Complex infNaN = new Complex(inf, nan);
+ private static final Complex infNegInf = new Complex(inf, neginf);
+ private static final Complex infInf = new Complex(inf, inf);
+ private static final Complex negInfInf = new Complex(neginf, inf);
+ private static final Complex negInfZero = new Complex(neginf, 0);
+ private static final Complex negInfOne = new Complex(neginf, 1);
+ private static final Complex negInfNaN = new Complex(neginf, nan);
+ private static final Complex negInfNegInf = new Complex(neginf, neginf);
+ private static final Complex oneNaN = new Complex(1, nan);
+ private static final Complex zeroInf = new Complex(0, inf);
+ private static final Complex zeroNaN = new Complex(0, nan);
+ private static final Complex nanInf = new Complex(nan, inf);
+ private static final Complex nanNegInf = new Complex(nan, neginf);
+ private static final Complex nanZero = new Complex(nan, 0);
+
+ @Test
+ public void testConstructor() {
+ Complex z = new Complex(3.0, 4.0);
+ Assert.assertEquals(3.0, z.getReal(), 1.0e-5);
+ Assert.assertEquals(4.0, z.getImaginary(), 1.0e-5);
+ }
+
+ @Test
+ public void testConstructorNaN() {
+ Complex z = new Complex(3.0, Double.NaN);
+ Assert.assertTrue(z.isNaN());
+
+ z = new Complex(nan, 4.0);
+ Assert.assertTrue(z.isNaN());
+
+ z = new Complex(3.0, 4.0);
+ Assert.assertFalse(z.isNaN());
+ }
+
+ @Test
+ public void testAbs() {
+ Complex z = new Complex(3.0, 4.0);
+ Assert.assertEquals(5.0, z.abs(), 1.0e-5);
+ }
+
+ @Test
+ public void testAbsNaN() {
+ Assert.assertTrue(Double.isNaN(Complex.NaN.abs()));
+ Complex z = new Complex(inf, nan);
+ Assert.assertTrue(Double.isNaN(z.abs()));
+ }
+
+ @Test
+ public void testAdd() {
+ Complex x = new Complex(3.0, 4.0);
+ Complex y = new Complex(5.0, 6.0);
+ Complex z = x.add(y);
+ Assert.assertEquals(8.0, z.getReal(), 1.0e-5);
+ Assert.assertEquals(10.0, z.getImaginary(), 1.0e-5);
+ }
+
+ @Test
+ public void testAddInf() {
+ Complex x = new Complex(1, 1);
+ Complex z = new Complex(inf, 0);
+ Complex w = x.add(z);
+ Assert.assertEquals(w.getImaginary(), 1, 0);
+ Assert.assertEquals(inf, w.getReal(), 0);
+
+ x = new Complex(neginf, 0);
+ Assert.assertTrue(Double.isNaN(x.add(z).getReal()));
+ }
+
+
+ @Test
+ public void testScalarAdd() {
+ Complex x = new Complex(3.0, 4.0);
+ double yDouble = 2.0;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.add(yComplex), x.add(yDouble));
+ }
+
+ @Test
+ public void testScalarAddNaN() {
+ Complex x = new Complex(3.0, 4.0);
+ double yDouble = Double.NaN;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.add(yComplex), x.add(yDouble));
+ }
+
+ @Test
+ public void testScalarAddInf() {
+ Complex x = new Complex(1, 1);
+ double yDouble = Double.POSITIVE_INFINITY;
+
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.add(yComplex), x.add(yDouble));
+
+ x = new Complex(neginf, 0);
+ Assert.assertEquals(x.add(yComplex), x.add(yDouble));
+ }
+
+ @Test
+ public void testConjugate() {
+ Complex x = new Complex(3.0, 4.0);
+ Complex z = x.conjugate();
+ Assert.assertEquals(3.0, z.getReal(), 1.0e-5);
+ Assert.assertEquals(-4.0, z.getImaginary(), 1.0e-5);
+ }
+
+ @Test
+ public void testConjugateNaN() {
+ Complex z = Complex.NaN.conjugate();
+ Assert.assertTrue(z.isNaN());
+ }
+
+ @Test
+ public void testConjugateInfiinite() {
+ Complex z = new Complex(0, inf);
+ Assert.assertEquals(neginf, z.conjugate().getImaginary(), 0);
+ z = new Complex(0, neginf);
+ Assert.assertEquals(inf, z.conjugate().getImaginary(), 0);
+ }
+
+ @Test
+ public void testDivide() {
+ Complex x = new Complex(3.0, 4.0);
+ Complex y = new Complex(5.0, 6.0);
+ Complex z = x.divide(y);
+ Assert.assertEquals(39.0 / 61.0, z.getReal(), 1.0e-5);
+ Assert.assertEquals(2.0 / 61.0, z.getImaginary(), 1.0e-5);
+ }
+
+ @Test
+ public void testDivideReal() {
+ Complex x = new Complex(2d, 3d);
+ Complex y = new Complex(2d, 0d);
+ Assert.assertEquals(new Complex(1d, 1.5), x.divide(y));
+
+ }
+
+ @Test
+ public void testDivideImaginary() {
+ Complex x = new Complex(2d, 3d);
+ Complex y = new Complex(0d, 2d);
+ Assert.assertEquals(new Complex(1.5d, -1d), x.divide(y));
+ }
+
+ @Test
+ public void testDivideZero() {
+ Complex x = new Complex(3.0, 4.0);
+ Complex z = x.divide(Complex.ZERO);
+ // Assert.assertEquals(z, Complex.INF); // See MATH-657
+ Assert.assertEquals(z, Complex.NaN);
+ }
+
+ @Test
+ public void testDivideZeroZero() {
+ Complex x = new Complex(0.0, 0.0);
+ Complex z = x.divide(Complex.ZERO);
+ Assert.assertEquals(z, Complex.NaN);
+ }
+
+ @Test
+ public void testDivideNaN() {
+ Complex x = new Complex(3.0, 4.0);
+ Complex z = x.divide(Complex.NaN);
+ Assert.assertTrue(z.isNaN());
+ }
+
+ @Test
+ public void testDivideNaNInf() {
+ Complex z = oneInf.divide(Complex.ONE);
+ Assert.assertTrue(Double.isNaN(z.getReal()));
+ Assert.assertEquals(inf, z.getImaginary(), 0);
+
+ z = negInfNegInf.divide(oneNaN);
+ Assert.assertTrue(Double.isNaN(z.getReal()));
+ Assert.assertTrue(Double.isNaN(z.getImaginary()));
+
+ z = negInfInf.divide(Complex.ONE);
+ Assert.assertTrue(Double.isNaN(z.getReal()));
+ Assert.assertTrue(Double.isNaN(z.getImaginary()));
+ }
+
+ @Test
+ public void testScalarDivide() {
+ Complex x = new Complex(3.0, 4.0);
+ double yDouble = 2.0;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.divide(yComplex), x.divide(yDouble));
+ }
+
+ @Test
+ public void testScalarDivideNaN() {
+ Complex x = new Complex(3.0, 4.0);
+ double yDouble = Double.NaN;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.divide(yComplex), x.divide(yDouble));
+ }
+
+ @Test
+ public void testScalarDivideZero() {
+ Complex x = new Complex(1,1);
+ TestUtils.assertEquals(x.divide(Complex.ZERO), x.divide(0), 0);
+ }
+
+ @Test
+ public void testReciprocal() {
+ Complex z = new Complex(5.0, 6.0);
+ Complex act = z.reciprocal();
+ double expRe = 5.0 / 61.0;
+ double expIm = -6.0 / 61.0;
+ Assert.assertEquals(expRe, act.getReal(), Math.ulp(expRe));
+ Assert.assertEquals(expIm, act.getImaginary(), Math.ulp(expIm));
+ }
+
+ @Test
+ public void testReciprocalReciprocal() {
+ Complex z = new Complex(5.0, 6.0);
+ Complex zRR = z.reciprocal().reciprocal();
+ final double tol = 1e-14;
+ Assert.assertEquals(zRR.getReal(), z.getReal(), tol);
+ Assert.assertEquals(zRR.getImaginary(), z.getImaginary(), tol);
+ }
+
+ @Test
+ public void testReciprocalReal() {
+ Complex z = new Complex(-2.0, 0.0);
+ Assert.assertTrue(Complex.equals(new Complex(-0.5, 0.0), z.reciprocal()));
+ }
+
+ @Test
+ public void testReciprocalImaginary() {
+ Complex z = new Complex(0.0, -2.0);
+ Assert.assertEquals(new Complex(0.0, 0.5), z.reciprocal());
+ }
+
+ @Test
+ public void testReciprocalNaN() {
+ Assert.assertTrue(Complex.NaN.reciprocal().isNaN());
+ }
+
+ @Test
+ public void testMultiply() {
+ Complex x = new Complex(3.0, 4.0);
+ Complex y = new Complex(5.0, 6.0);
+ Complex z = x.multiply(y);
+ Assert.assertEquals(-9.0, z.getReal(), 1.0e-5);
+ Assert.assertEquals(38.0, z.getImaginary(), 1.0e-5);
+ }
+
+ @Test
+ public void testMultiplyInfInf() {
+ // Assert.assertTrue(infInf.multiply(infInf).isNaN()); // MATH-620
+ Assert.assertTrue(infInf.multiply(infInf).isInfinite());
+ }
+
+ @Test
+ public void testScalarMultiply() {
+ Complex x = new Complex(3.0, 4.0);
+ double yDouble = 2.0;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble));
+ int zInt = -5;
+ Complex zComplex = new Complex(zInt);
+ Assert.assertEquals(x.multiply(zComplex), x.multiply(zInt));
+ }
+
+ @Test
+ public void testScalarMultiplyNaN() {
+ Complex x = new Complex(3.0, 4.0);
+ double yDouble = Double.NaN;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble));
+ }
+
+ @Test
+ public void testScalarMultiplyInf() {
+ Complex x = new Complex(1, 1);
+ double yDouble = Double.POSITIVE_INFINITY;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble));
+
+ yDouble = Double.NEGATIVE_INFINITY;
+ yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.multiply(yComplex), x.multiply(yDouble));
+ }
+
+ @Test
+ public void testNegate() {
+ Complex x = new Complex(3.0, 4.0);
+ Complex z = x.negate();
+ Assert.assertEquals(-3.0, z.getReal(), 1.0e-5);
+ Assert.assertEquals(-4.0, z.getImaginary(), 1.0e-5);
+ }
+
+ @Test
+ public void testNegateNaN() {
+ Complex z = Complex.NaN.negate();
+ Assert.assertTrue(z.isNaN());
+ }
+
+ @Test
+ public void testSubtract() {
+ Complex x = new Complex(3.0, 4.0);
+ Complex y = new Complex(5.0, 6.0);
+ Complex z = x.subtract(y);
+ Assert.assertEquals(-2.0, z.getReal(), 1.0e-5);
+ Assert.assertEquals(-2.0, z.getImaginary(), 1.0e-5);
+ }
+
+ @Test
+ public void testSubtractInf() {
+ Complex x = new Complex(1, 1);
+ Complex z = new Complex(neginf, 0);
+ Complex w = x.subtract(z);
+ Assert.assertEquals(w.getImaginary(), 1, 0);
+ Assert.assertEquals(inf, w.getReal(), 0);
+
+ x = new Complex(neginf, 0);
+ Assert.assertTrue(Double.isNaN(x.subtract(z).getReal()));
+ }
+
+ @Test
+ public void testScalarSubtract() {
+ Complex x = new Complex(3.0, 4.0);
+ double yDouble = 2.0;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble));
+ }
+
+ @Test
+ public void testScalarSubtractNaN() {
+ Complex x = new Complex(3.0, 4.0);
+ double yDouble = Double.NaN;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble));
+ }
+
+ @Test
+ public void testScalarSubtractInf() {
+ Complex x = new Complex(1, 1);
+ double yDouble = Double.POSITIVE_INFINITY;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble));
+
+ x = new Complex(neginf, 0);
+ Assert.assertEquals(x.subtract(yComplex), x.subtract(yDouble));
+ }
+
+
+ @Test
+ public void testEqualsNull() {
+ Complex x = new Complex(3.0, 4.0);
+ Assert.assertFalse(x.equals(null));
+ }
+
+ @Test(expected=NullPointerException.class)
+ public void testFloatingPointEqualsPrecondition1() {
+ Complex.equals(new Complex(3.0, 4.0), null, 3);
+ }
+ @Test(expected=NullPointerException.class)
+ public void testFloatingPointEqualsPrecondition2() {
+ Complex.equals(null, new Complex(3.0, 4.0), 3);
+ }
+
+ @Test
+ public void testEqualsClass() {
+ Complex x = new Complex(3.0, 4.0);
+ Assert.assertFalse(x.equals(this));
+ }
+
+ @Test
+ public void testEqualsSame() {
+ Complex x = new Complex(3.0, 4.0);
+ Assert.assertTrue(x.equals(x));
+ }
+
+ @Test
+ public void testFloatingPointEquals() {
+ double re = -3.21;
+ double im = 456789e10;
+
+ final Complex x = new Complex(re, im);
+ Complex y = new Complex(re, im);
+
+ Assert.assertTrue(x.equals(y));
+ Assert.assertTrue(Complex.equals(x, y));
+
+ final int maxUlps = 5;
+ for (int i = 0; i < maxUlps; i++) {
+ re = Math.nextUp(re);
+ im = Math.nextUp(im);
+ }
+ y = new Complex(re, im);
+ Assert.assertTrue(Complex.equals(x, y, maxUlps));
+
+ re = Math.nextUp(re);
+ im = Math.nextUp(im);
+ y = new Complex(re, im);
+ Assert.assertFalse(Complex.equals(x, y, maxUlps));
+ }
+
+ @Test
+ public void testFloatingPointEqualsNaN() {
+ Complex c = new Complex(Double.NaN, 1);
+ Assert.assertFalse(Complex.equals(c, c));
+
+ c = new Complex(1, Double.NaN);
+ Assert.assertFalse(Complex.equals(c, c));
+ }
+
+ @Test
+ public void testFloatingPointEqualsWithAllowedDelta() {
+ final double re = 153.0000;
+ final double im = 152.9375;
+ final double tol1 = 0.0625;
+ final Complex x = new Complex(re, im);
+ final Complex y = new Complex(re + tol1, im + tol1);
+ Assert.assertTrue(Complex.equals(x, y, tol1));
+
+ final double tol2 = 0.0624;
+ Assert.assertFalse(Complex.equals(x, y, tol2));
+ }
+
+ @Test
+ public void testFloatingPointEqualsWithAllowedDeltaNaN() {
+ final Complex x = new Complex(0, Double.NaN);
+ final Complex y = new Complex(Double.NaN, 0);
+ Assert.assertFalse(Complex.equals(x, Complex.ZERO, 0.1));
+ Assert.assertFalse(Complex.equals(x, x, 0.1));
+ Assert.assertFalse(Complex.equals(x, y, 0.1));
+ }
+
+ @Test
+ public void testFloatingPointEqualsWithRelativeTolerance() {
+ final double tol = 1e-4;
+ final double re = 1;
+ final double im = 1e10;
+
+ final double f = 1 + tol;
+ final Complex x = new Complex(re, im);
+ final Complex y = new Complex(re * f, im * f);
+ Assert.assertTrue(Complex.equalsWithRelativeTolerance(x, y, tol));
+ }
+
+ @Test
+ public void testFloatingPointEqualsWithRelativeToleranceNaN() {
+ final Complex x = new Complex(0, Double.NaN);
+ final Complex y = new Complex(Double.NaN, 0);
+ Assert.assertFalse(Complex.equalsWithRelativeTolerance(x, Complex.ZERO, 0.1));
+ Assert.assertFalse(Complex.equalsWithRelativeTolerance(x, x, 0.1));
+ Assert.assertFalse(Complex.equalsWithRelativeTolerance(x, y, 0.1));
+ }
+
+ @Test
+ public void testEqualsTrue() {
+ Complex x = new Complex(3.0, 4.0);
+ Complex y = new Complex(3.0, 4.0);
+ Assert.assertTrue(x.equals(y));
+ }
+
+ @Test
+ public void testEqualsRealDifference() {
+ Complex x = new Complex(0.0, 0.0);
+ Complex y = new Complex(0.0 + Double.MIN_VALUE, 0.0);
+ Assert.assertFalse(x.equals(y));
+ }
+
+ @Test
+ public void testEqualsImaginaryDifference() {
+ Complex x = new Complex(0.0, 0.0);
+ Complex y = new Complex(0.0, 0.0 + Double.MIN_VALUE);
+ Assert.assertFalse(x.equals(y));
+ }
+
+ @Test
+ public void testHashCode() {
+ Complex x = new Complex(0.0, 0.0);
+ Complex y = new Complex(0.0, 0.0 + Double.MIN_VALUE);
+ Assert.assertFalse(x.hashCode()==y.hashCode());
+ y = new Complex(0.0 + Double.MIN_VALUE, 0.0);
+ Assert.assertFalse(x.hashCode()==y.hashCode());
+ Complex realNaN = new Complex(Double.NaN, 0.0);
+ Complex imaginaryNaN = new Complex(0.0, Double.NaN);
+ Assert.assertEquals(realNaN.hashCode(), imaginaryNaN.hashCode());
+ Assert.assertEquals(imaginaryNaN.hashCode(), Complex.NaN.hashCode());
+
+ // MATH-1118
+ // "equals" and "hashCode" must be compatible: if two objects have
+ // different hash codes, "equals" must return false.
+ final String msg = "'equals' not compatible with 'hashCode'";
+
+ x = new Complex(0.0, 0.0);
+ y = new Complex(0.0, -0.0);
+ Assert.assertTrue(x.hashCode() != y.hashCode());
+ Assert.assertFalse(msg, x.equals(y));
+
+ x = new Complex(0.0, 0.0);
+ y = new Complex(-0.0, 0.0);
+ Assert.assertTrue(x.hashCode() != y.hashCode());
+ Assert.assertFalse(msg, x.equals(y));
+ }
+
+ @Test
+ @Ignore
+ public void testJava() {// TODO more debug
+ System.out.println(">>testJava()");
+ // MathTest#testExpSpecialCases() checks the following:
+ // Assert.assertEquals("exp of -infinity should be 0.0", 0.0, Math.exp(Double.NEGATIVE_INFINITY), Precision.EPSILON);
+ // Let's check how well Math works:
+ System.out.println("Math.exp="+Math.exp(Double.NEGATIVE_INFINITY));
+ String props[] = {
+ "java.version", // Java Runtime Environment version
+ "java.vendor", // Java Runtime Environment vendor
+ "java.vm.specification.version", // Java Virtual Machine specification version
+ "java.vm.specification.vendor", // Java Virtual Machine specification vendor
+ "java.vm.specification.name", // Java Virtual Machine specification name
+ "java.vm.version", // Java Virtual Machine implementation version
+ "java.vm.vendor", // Java Virtual Machine implementation vendor
+ "java.vm.name", // Java Virtual Machine implementation name
+ "java.specification.version", // Java Runtime Environment specification version
+ "java.specification.vendor", // Java Runtime Environment specification vendor
+ "java.specification.name", // Java Runtime Environment specification name
+ "java.class.version", // Java class format version number
+ };
+ for(String t : props) {
+ System.out.println(t + "=" + System.getProperty(t));
+ }
+ System.out.println("<<testJava()");
+ }
+
+
+ @Test
+ public void testScalarPow() {
+ Complex x = new Complex(3, 4);
+ double yDouble = 5.0;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.pow(yComplex), x.pow(yDouble));
+ }
+
+ @Test
+ public void testScalarPowNaNBase() {
+ Complex x = Complex.NaN;
+ double yDouble = 5.0;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.pow(yComplex), x.pow(yDouble));
+ }
+
+ @Test
+ public void testScalarPowNaNExponent() {
+ Complex x = new Complex(3, 4);
+ double yDouble = Double.NaN;
+ Complex yComplex = new Complex(yDouble);
+ Assert.assertEquals(x.pow(yComplex), x.pow(yDouble));
+ }
+ @Test
+ public void testSqrtPolar() {
+ final double tol = 1e-12;
+ double r = 1;
+ for (int i = 0; i < 5; i++) {
+ r += i;
+ double theta = 0;
+ for (int j = 0; j < 11; j++) {
+ theta += pi / 12;
+ Complex z = ComplexUtils.polar2Complex(r, theta);
+ Complex sqrtz = ComplexUtils.polar2Complex(Math.sqrt(r), theta / 2);
+ TestUtils.assertEquals(sqrtz, z.sqrt(), tol);
+ }
+ }
+ }
+
+ @Test
+ public void testSqrt1z() {
+ Complex z = new Complex(3, 4);
+ Complex expected = new Complex(4.08033, -2.94094);
+ TestUtils.assertEquals(expected, z.sqrt1z(), 1.0e-5);
+ }
+
+ @Test
+ public void testSqrt1zNaN() {
+ Assert.assertTrue(Complex.NaN.sqrt1z().isNaN());
+ }
+
+ /**
+ * Test: computing <b>third roots</b> of z.
+ * <pre>
+ * <code>
+ * <b>z = -2 + 2 * i</b>
+ * => z_0 = 1 + i
+ * => z_1 = -1.3660 + 0.3660 * i
+ * => z_2 = 0.3660 - 1.3660 * i
+ * </code>
+ * </pre>
+ */
+ @Test
+ public void testNthRoot_normal_thirdRoot() {
+ // The complex number we want to compute all third-roots for.
+ Complex z = new Complex(-2,2);
+ // The List holding all third roots
+ Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]);
+ // Returned Collection must not be empty!
+ Assert.assertEquals(3, thirdRootsOfZ.length);
+ // test z_0
+ Assert.assertEquals(1.0, thirdRootsOfZ[0].getReal(), 1.0e-5);
+ Assert.assertEquals(1.0, thirdRootsOfZ[0].getImaginary(), 1.0e-5);
+ // test z_1
+ Assert.assertEquals(-1.3660254037844386, thirdRootsOfZ[1].getReal(), 1.0e-5);
+ Assert.assertEquals(0.36602540378443843, thirdRootsOfZ[1].getImaginary(), 1.0e-5);
+ // test z_2
+ Assert.assertEquals(0.366025403784439, thirdRootsOfZ[2].getReal(), 1.0e-5);
+ Assert.assertEquals(-1.3660254037844384, thirdRootsOfZ[2].getImaginary(), 1.0e-5);
+ }
+
+
+ /**
+ * Test: computing <b>fourth roots</b> of z.
+ * <pre>
+ * <code>
+ * <b>z = 5 - 2 * i</b>
+ * => z_0 = 1.5164 - 0.1446 * i
+ * => z_1 = 0.1446 + 1.5164 * i
+ * => z_2 = -1.5164 + 0.1446 * i
+ * => z_3 = -1.5164 - 0.1446 * i
+ * </code>
+ * </pre>
+ */
+ @Test
+ public void testNthRoot_normal_fourthRoot() {
+ // The complex number we want to compute all third-roots for.
+ Complex z = new Complex(5,-2);
+ // The List holding all fourth roots
+ Complex[] fourthRootsOfZ = z.nthRoot(4).toArray(new Complex[0]);
+ // Returned Collection must not be empty!
+ Assert.assertEquals(4, fourthRootsOfZ.length);
+ // test z_0
+ Assert.assertEquals(1.5164629308487783, fourthRootsOfZ[0].getReal(), 1.0e-5);
+ Assert.assertEquals(-0.14469266210702247, fourthRootsOfZ[0].getImaginary(), 1.0e-5);
+ // test z_1
+ Assert.assertEquals(0.14469266210702256, fourthRootsOfZ[1].getReal(), 1.0e-5);
+ Assert.assertEquals(1.5164629308487783, fourthRootsOfZ[1].getImaginary(), 1.0e-5);
+ // test z_2
+ Assert.assertEquals(-1.5164629308487783, fourthRootsOfZ[2].getReal(), 1.0e-5);
+ Assert.assertEquals(0.14469266210702267, fourthRootsOfZ[2].getImaginary(), 1.0e-5);
+ // test z_3
+ Assert.assertEquals(-0.14469266210702275, fourthRootsOfZ[3].getReal(), 1.0e-5);
+ Assert.assertEquals(-1.5164629308487783, fourthRootsOfZ[3].getImaginary(), 1.0e-5);
+ }
+
+ /**
+ * Test: computing <b>third roots</b> of z.
+ * <pre>
+ * <code>
+ * <b>z = 8</b>
+ * => z_0 = 2
+ * => z_1 = -1 + 1.73205 * i
+ * => z_2 = -1 - 1.73205 * i
+ * </code>
+ * </pre>
+ */
+ @Test
+ public void testNthRoot_cornercase_thirdRoot_imaginaryPartEmpty() {
+ // The number 8 has three third roots. One we all already know is the number 2.
+ // But there are two more complex roots.
+ Complex z = new Complex(8,0);
+ // The List holding all third roots
+ Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]);
+ // Returned Collection must not be empty!
+ Assert.assertEquals(3, thirdRootsOfZ.length);
+ // test z_0
+ Assert.assertEquals(2.0, thirdRootsOfZ[0].getReal(), 1.0e-5);
+ Assert.assertEquals(0.0, thirdRootsOfZ[0].getImaginary(), 1.0e-5);
+ // test z_1
+ Assert.assertEquals(-1.0, thirdRootsOfZ[1].getReal(), 1.0e-5);
+ Assert.assertEquals(1.7320508075688774, thirdRootsOfZ[1].getImaginary(), 1.0e-5);
+ // test z_2
+ Assert.assertEquals(-1.0, thirdRootsOfZ[2].getReal(), 1.0e-5);
+ Assert.assertEquals(-1.732050807568877, thirdRootsOfZ[2].getImaginary(), 1.0e-5);
+ }
+
+
+ /**
+ * Test: computing <b>third roots</b> of z with real part 0.
+ * <pre>
+ * <code>
+ * <b>z = 2 * i</b>
+ * => z_0 = 1.0911 + 0.6299 * i
+ * => z_1 = -1.0911 + 0.6299 * i
+ * => z_2 = -2.3144 - 1.2599 * i
+ * </code>
+ * </pre>
+ */
+ @Test
+ public void testNthRoot_cornercase_thirdRoot_realPartZero() {
+ // complex number with only imaginary part
+ Complex z = new Complex(0,2);
+ // The List holding all third roots
+ Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new Complex[0]);
+ // Returned Collection must not be empty!
+ Assert.assertEquals(3, thirdRootsOfZ.length);
+ // test z_0
+ Assert.assertEquals(1.0911236359717216, thirdRootsOfZ[0].getReal(), 1.0e-5);
+ Assert.assertEquals(0.6299605249474365, thirdRootsOfZ[0].getImaginary(), 1.0e-5);
+ // test z_1
+ Assert.assertEquals(-1.0911236359717216, thirdRootsOfZ[1].getReal(), 1.0e-5);
+ Assert.assertEquals(0.6299605249474365, thirdRootsOfZ[1].getImaginary(), 1.0e-5);
+ // test z_2
+ Assert.assertEquals(-2.3144374213981936E-16, thirdRootsOfZ[2].getReal(), 1.0e-5);
+ Assert.assertEquals(-1.2599210498948732, thirdRootsOfZ[2].getImaginary(), 1.0e-5);
+ }
+
+ /**
+ * Test standard values
+ */
+ @Test
+ public void testGetArgument() {
+ Complex z = new Complex(1, 0);
+ Assert.assertEquals(0.0, z.getArgument(), 1.0e-12);
+
+ z = new Complex(1, 1);
+ Assert.assertEquals(Math.PI/4, z.getArgument(), 1.0e-12);
+
+ z = new Complex(0, 1);
+ Assert.assertEquals(Math.PI/2, z.getArgument(), 1.0e-12);
+
+ z = new Complex(-1, 1);
+ Assert.assertEquals(3 * Math.PI/4, z.getArgument(), 1.0e-12);
+
+ z = new Complex(-1, 0);
+ Assert.assertEquals(Math.PI, z.getArgument(), 1.0e-12);
+
+ z = new Complex(-1, -1);
+ Assert.assertEquals(-3 * Math.PI/4, z.getArgument(), 1.0e-12);
+
+ z = new Complex(0, -1);
+ Assert.assertEquals(-Math.PI/2, z.getArgument(), 1.0e-12);
+
+ z = new Complex(1, -1);
+ Assert.assertEquals(-Math.PI/4, z.getArgument(), 1.0e-12);
+
+ }
+
+ /**
+ * Verify atan2-style handling of infinite parts
+ */
+ @Test
+ public void testGetArgumentInf() {
+ Assert.assertEquals(Math.PI/4, infInf.getArgument(), 1.0e-12);
+ Assert.assertEquals(Math.PI/2, oneInf.getArgument(), 1.0e-12);
+ Assert.assertEquals(0.0, infOne.getArgument(), 1.0e-12);
+ Assert.assertEquals(Math.PI/2, zeroInf.getArgument(), 1.0e-12);
+ Assert.assertEquals(0.0, infZero.getArgument(), 1.0e-12);
+ Assert.assertEquals(Math.PI, negInfOne.getArgument(), 1.0e-12);
+ Assert.assertEquals(-3.0*Math.PI/4, negInfNegInf.getArgument(), 1.0e-12);
+ Assert.assertEquals(-Math.PI/2, oneNegInf.getArgument(), 1.0e-12);
+ }
+
+ /**
+ * Verify that either part NaN results in NaN
+ */
+ @Test
+ public void testGetArgumentNaN() {
+ Assert.assertTrue(Double.isNaN(nanZero.getArgument()));
+ Assert.assertTrue(Double.isNaN(zeroNaN.getArgument()));
+ Assert.assertTrue(Double.isNaN(Complex.NaN.getArgument()));
+ }
+
+ /*
+ @Test
+ public void testSerial() {
+ Complex z = new Complex(3.0, 4.0);
+ Assert.assertEquals(z, TestUtils.serializeAndRecover(z));
+ Complex ncmplx = (Complex)TestUtils.serializeAndRecover(oneNaN); Assert.assertEquals(nanZero, ncmplx); Assert.assertTrue(ncmplx.isNaN());
+ Complex infcmplx = (Complex)TestUtils.serializeAndRecover(infInf);
+ Assert.assertEquals(infInf, infcmplx);
+ Assert.assertTrue(infcmplx.isInfinite());
+ TestComplex tz = new TestComplex(3.0, 4.0);
+ Assert.assertEquals(tz, TestUtils.serializeAndRecover(tz));
+ TestComplex ntcmplx = (TestComplex)TestUtils.serializeAndRecover(new TestComplex(oneNaN));
+ Assert.assertEquals(nanZero, ntcmplx);
+ Assert.assertTrue(ntcmplx.isNaN());
+ TestComplex inftcmplx = (TestComplex)TestUtils.serializeAndRecover(new TestComplex(infInf));
+ Assert.assertEquals(infInf, inftcmplx);
+ Assert.assertTrue(inftcmplx.isInfinite());
+ }
+ */
+
+ /**
+ * Class to test extending Complex
+ */
+ public static class TestComplex extends Complex {
+
+ /**
+ * Serialization identifier.
+ */
+ private static final long serialVersionUID = 3268726724160389237L;
+
+ public TestComplex(double real, double imaginary) {
+ super(real, imaginary);
+ }
+
+ public TestComplex(Complex other){
+ this(other.getReal(), other.getImaginary());
+ }
+
+ @Override
+ protected TestComplex createComplex(double real, double imaginary){
+ return new TestComplex(real, imaginary);
+ }
+
+ }
+}