Skip to content

Commit ed8b313

Browse files
committed
kill ExtraMath's hypot and log10 for their equivalents in Java 1.5's
java.lang.Math
1 parent ec3a2eb commit ed8b313

4 files changed

Lines changed: 6 additions & 31 deletions

File tree

src/org/python/core/PyComplex.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Corporation for National Research Initiatives
22
package org.python.core;
33

4-
import org.python.core.util.ExtraMath;
54
import org.python.expose.ExposedGet;
65
import org.python.expose.ExposedMethod;
76
import org.python.expose.ExposedNew;
@@ -616,7 +615,7 @@ public static PyObject _pow(PyComplex value, PyComplex right) {
616615
return ipow(value, iexp);
617616
}
618617

619-
double abs = ExtraMath.hypot(xr, xi);
618+
double abs = Math.hypot(xr, xi);
620619
double len = Math.pow(abs, yr);
621620

622621
double at = Math.atan2(xi, xr);
@@ -656,7 +655,7 @@ public PyObject __abs__() {
656655

657656
@ExposedMethod
658657
final PyObject complex___abs__() {
659-
return new PyFloat(ExtraMath.hypot(real, imag));
658+
return new PyFloat(Math.hypot(real, imag));
660659
}
661660

662661
public PyObject __int__() {

src/org/python/core/PyString.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,7 +2287,7 @@ private String formatFloatExponential(PyObject arg, char e,
22872287
}
22882288
double power = 0.0;
22892289
if (v > 0)
2290-
power = ExtraMath.closeFloor(ExtraMath.log10(v));
2290+
power = ExtraMath.closeFloor(Math.log10(v));
22912291
//System.err.println("formatExp: "+v+", "+power);
22922292
int savePrecision = precision;
22932293
precision = 2;
@@ -2489,8 +2489,7 @@ else if (c == '(')
24892489
}
24902490

24912491
double v = arg.__float__().getValue();
2492-
int exponent = (int)ExtraMath.closeFloor(ExtraMath.log10(Math.abs(v == 0
2493-
? 1 : v)));
2492+
int exponent = (int)ExtraMath.closeFloor(Math.log10(Math.abs(v == 0 ? 1 : v)));
24942493
if (v == Double.POSITIVE_INFINITY) {
24952494
string = "inf";
24962495
} else if (v == Double.NEGATIVE_INFINITY) {

src/org/python/core/util/ExtraMath.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,15 @@
11
// Copyright (c) Corporation for National Research Initiatives
2-
32
package org.python.core.util;
43

54
/**
65
* A static utility class with two additional math functions.
76
*/
87
public class ExtraMath {
9-
public static double LOG10 = Math.log(10.0);
108

119
public static double EPSILON = Math.pow(2.0, -52.0);
1210

1311
public static double CLOSE = EPSILON * 2.0;
1412

15-
public static double log10(double v) {
16-
return Math.log(v) / LOG10;
17-
}
18-
19-
public static double hypot(double v, double w) {
20-
v = Math.abs(v);
21-
w = Math.abs(w);
22-
if (v < w) {
23-
double temp = v;
24-
v = w;
25-
w = temp;
26-
}
27-
if (v == 0.0) {
28-
return 0.0;
29-
} else {
30-
double wv = w / v;
31-
return v * Math.sqrt(1.0 + wv * wv);
32-
}
33-
}
34-
3513
/**
3614
* Are v and w "close" to each other? Uses a scaled tolerance.
3715
*/

src/org/python/modules/math.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
package org.python.modules;
33

44
import org.python.core.*;
5-
import org.python.core.util.ExtraMath;
65
import java.lang.Math;
76

87
public class math implements ClassDictInit {
@@ -129,7 +128,7 @@ public static double log10(PyObject v) {
129128
}
130129

131130
private static double log10(double v) {
132-
return check(ExtraMath.log10(v));
131+
return check(Math.log10(v));
133132
}
134133

135134
public static double sinh(double v) {
@@ -185,7 +184,7 @@ public static double ldexp(double v, int w) {
185184
}
186185

187186
public static double hypot(double v, double w) {
188-
return check(ExtraMath.hypot(v, w));
187+
return check(Math.hypot(v, w));
189188
}
190189

191190
public static double radians(double v) {

0 commit comments

Comments
 (0)