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 2021/10/17 00:24:24 UTC
[commons-math] 11/11: Remove methods that were calling the "Math"
implementation.
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit e052d9dc532be69c75b24973cf585865c02b63b2
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Sun Oct 17 02:03:42 2021 +0200
Remove methods that were calling the "Math" implementation.
---
.../commons/math4/core/jdkmath/AccurateMath.java | 27 ++++------------------
.../apache/commons/math4/core/jdkmath/JdkMath.java | 4 ++--
2 files changed, 7 insertions(+), 24 deletions(-)
diff --git a/commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/AccurateMath.java b/commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/AccurateMath.java
index b4af270..632c3b3 100644
--- a/commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/AccurateMath.java
+++ b/commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/AccurateMath.java
@@ -375,15 +375,6 @@ public final class AccurateMath {
return Double.longBitsToDouble(xl);
}
- /** Compute the square root of a number.
- * <p><b>Note:</b> this implementation currently delegates to {@link Math#sqrt}
- * @param a number on which evaluation is done
- * @return square root of a
- */
- public static double sqrt(final double a) {
- return Math.sqrt(a);
- }
-
/** Compute the hyperbolic cosine of a number.
* @param x number on which evaluation is done
* @return hyperbolic cosine of x
@@ -705,7 +696,7 @@ public final class AccurateMath {
* @return inverse hyperbolic cosine of a
*/
public static double acosh(final double a) {
- return AccurateMath.log(a + AccurateMath.sqrt(a * a - 1));
+ return AccurateMath.log(a + Math.sqrt(a * a - 1));
}
/** Compute the inverse hyperbolic sine of a number.
@@ -721,7 +712,7 @@ public final class AccurateMath {
double absAsinh;
if (a > 0.167) {
- absAsinh = AccurateMath.log(AccurateMath.sqrt(a * a + 1) + a);
+ absAsinh = AccurateMath.log(Math.sqrt(a * a + 1) + a);
} else {
final double a2 = a * a;
if (a > 0.097) {
@@ -820,14 +811,6 @@ public final class AccurateMath {
return nextAfter(a, Float.NEGATIVE_INFINITY);
}
- /** Returns a pseudo-random number between 0.0 and 1.0.
- * <p><b>Note:</b> this implementation currently delegates to {@link Math#random}
- * @return a random number between 0.0 and 1.0
- */
- public static double random() {
- return Math.random();
- }
-
/**
* Exponential function.
*
@@ -2801,7 +2784,7 @@ public final class AccurateMath {
/* Square root */
double y;
- y = sqrt(za);
+ y = Math.sqrt(za);
temp = y * HEX_40000000;
ya = y + temp - temp;
yb = y - ya;
@@ -2876,7 +2859,7 @@ public final class AccurateMath {
za = temp;
/* Square root */
- double y = sqrt(za);
+ double y = Math.sqrt(za);
temp = y * HEX_40000000;
ya = y + temp - temp;
yb = y - ya;
@@ -3682,7 +3665,7 @@ public final class AccurateMath {
final double scaledY = scalb(y, -middleExp);
// compute scaled hypotenuse
- final double scaledH = sqrt(scaledX * scaledX + scaledY * scaledY);
+ final double scaledH = Math.sqrt(scaledX * scaledX + scaledY * scaledY);
// remove scaling
return scalb(scaledH, middleExp);
diff --git a/commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/JdkMath.java b/commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/JdkMath.java
index 6525ed7..52befc5 100644
--- a/commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/JdkMath.java
+++ b/commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/JdkMath.java
@@ -284,7 +284,7 @@ public final class JdkMath {
NEXTUP_FLOAT = AccurateMath::nextUp;
NEXTUP_DOUBLE = AccurateMath::nextUp;
POW = AccurateMath::pow;
- RANDOM = AccurateMath::random;
+ RANDOM = Math::random; // Not implemented.
RINT = AccurateMath::rint;
ROUND_DOUBLE = AccurateMath::round;
ROUND_FLOAT = AccurateMath::round;
@@ -292,7 +292,7 @@ public final class JdkMath {
SCALB_FLOAT = AccurateMath::scalb;
SIGNUM_DOUBLE = AccurateMath::signum;
SIGNUM_FLOAT = AccurateMath::signum;
- SQRT = AccurateMath::sqrt;
+ SQRT = Math::sqrt; // Not implemented.
SIN = AccurateMath::sin;
SINH = AccurateMath::sinh;
SUBTRACTEXACT_INT = AccurateMath::subtractExact;