Skip to content

Commit e052d9d

Browse files
author
Gilles Sadowski
committed
Remove methods that were calling the "Math" implementation.
1 parent 2275353 commit e052d9d

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/AccurateMath.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,6 @@ private static double doubleHighPart(double d) {
375375
return Double.longBitsToDouble(xl);
376376
}
377377

378-
/** Compute the square root of a number.
379-
* <p><b>Note:</b> this implementation currently delegates to {@link Math#sqrt}
380-
* @param a number on which evaluation is done
381-
* @return square root of a
382-
*/
383-
public static double sqrt(final double a) {
384-
return Math.sqrt(a);
385-
}
386-
387378
/** Compute the hyperbolic cosine of a number.
388379
* @param x number on which evaluation is done
389380
* @return hyperbolic cosine of x
@@ -705,7 +696,7 @@ public static double tanh(double x) {
705696
* @return inverse hyperbolic cosine of a
706697
*/
707698
public static double acosh(final double a) {
708-
return AccurateMath.log(a + AccurateMath.sqrt(a * a - 1));
699+
return AccurateMath.log(a + Math.sqrt(a * a - 1));
709700
}
710701

711702
/** Compute the inverse hyperbolic sine of a number.
@@ -721,7 +712,7 @@ public static double asinh(double a) {
721712

722713
double absAsinh;
723714
if (a > 0.167) {
724-
absAsinh = AccurateMath.log(AccurateMath.sqrt(a * a + 1) + a);
715+
absAsinh = AccurateMath.log(Math.sqrt(a * a + 1) + a);
725716
} else {
726717
final double a2 = a * a;
727718
if (a > 0.097) {
@@ -820,14 +811,6 @@ public static float nextDown(final float a) {
820811
return nextAfter(a, Float.NEGATIVE_INFINITY);
821812
}
822813

823-
/** Returns a pseudo-random number between 0.0 and 1.0.
824-
* <p><b>Note:</b> this implementation currently delegates to {@link Math#random}
825-
* @return a random number between 0.0 and 1.0
826-
*/
827-
public static double random() {
828-
return Math.random();
829-
}
830-
831814
/**
832815
* Exponential function.
833816
*
@@ -2801,7 +2784,7 @@ public static double asin(double x) {
28012784

28022785
/* Square root */
28032786
double y;
2804-
y = sqrt(za);
2787+
y = Math.sqrt(za);
28052788
temp = y * HEX_40000000;
28062789
ya = y + temp - temp;
28072790
yb = y - ya;
@@ -2876,7 +2859,7 @@ public static double acos(double x) {
28762859
za = temp;
28772860

28782861
/* Square root */
2879-
double y = sqrt(za);
2862+
double y = Math.sqrt(za);
28802863
temp = y * HEX_40000000;
28812864
ya = y + temp - temp;
28822865
yb = y - ya;
@@ -3682,7 +3665,7 @@ public static double hypot(final double x, final double y) {
36823665
final double scaledY = scalb(y, -middleExp);
36833666

36843667
// compute scaled hypotenuse
3685-
final double scaledH = sqrt(scaledX * scaledX + scaledY * scaledY);
3668+
final double scaledH = Math.sqrt(scaledX * scaledX + scaledY * scaledY);
36863669

36873670
// remove scaling
36883671
return scalb(scaledH, middleExp);

commons-math-core/src/main/java/org/apache/commons/math4/core/jdkmath/JdkMath.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,15 @@ public enum Impl {
284284
NEXTUP_FLOAT = AccurateMath::nextUp;
285285
NEXTUP_DOUBLE = AccurateMath::nextUp;
286286
POW = AccurateMath::pow;
287-
RANDOM = AccurateMath::random;
287+
RANDOM = Math::random; // Not implemented.
288288
RINT = AccurateMath::rint;
289289
ROUND_DOUBLE = AccurateMath::round;
290290
ROUND_FLOAT = AccurateMath::round;
291291
SCALB_DOUBLE = AccurateMath::scalb;
292292
SCALB_FLOAT = AccurateMath::scalb;
293293
SIGNUM_DOUBLE = AccurateMath::signum;
294294
SIGNUM_FLOAT = AccurateMath::signum;
295-
SQRT = AccurateMath::sqrt;
295+
SQRT = Math::sqrt; // Not implemented.
296296
SIN = AccurateMath::sin;
297297
SINH = AccurateMath::sinh;
298298
SUBTRACTEXACT_INT = AccurateMath::subtractExact;

0 commit comments

Comments
 (0)