From: <pj...@us...> - 2008-04-19 21:35:11
|
Revision: 4362 http://jython.svn.sourceforge.net/jython/?rev=4362&view=rev Author: pjenvey Date: 2008-04-19 14:35:10 -0700 (Sat, 19 Apr 2008) Log Message: ----------- kill ExtraMath's hypot and log10 for their equivalents in Java 1.5's java.lang.Math Modified Paths: -------------- trunk/jython/src/org/python/core/PyComplex.java trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/core/util/ExtraMath.java trunk/jython/src/org/python/modules/math.java Modified: trunk/jython/src/org/python/core/PyComplex.java =================================================================== --- trunk/jython/src/org/python/core/PyComplex.java 2008-04-19 21:14:24 UTC (rev 4361) +++ trunk/jython/src/org/python/core/PyComplex.java 2008-04-19 21:35:10 UTC (rev 4362) @@ -1,7 +1,6 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.core; -import org.python.core.util.ExtraMath; import org.python.expose.ExposedGet; import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; @@ -616,7 +615,7 @@ return ipow(value, iexp); } - double abs = ExtraMath.hypot(xr, xi); + double abs = Math.hypot(xr, xi); double len = Math.pow(abs, yr); double at = Math.atan2(xi, xr); @@ -656,7 +655,7 @@ @ExposedMethod final PyObject complex___abs__() { - return new PyFloat(ExtraMath.hypot(real, imag)); + return new PyFloat(Math.hypot(real, imag)); } public PyObject __int__() { Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2008-04-19 21:14:24 UTC (rev 4361) +++ trunk/jython/src/org/python/core/PyString.java 2008-04-19 21:35:10 UTC (rev 4362) @@ -2287,7 +2287,7 @@ } double power = 0.0; if (v > 0) - power = ExtraMath.closeFloor(ExtraMath.log10(v)); + power = ExtraMath.closeFloor(Math.log10(v)); //System.err.println("formatExp: "+v+", "+power); int savePrecision = precision; precision = 2; @@ -2489,8 +2489,7 @@ } double v = arg.__float__().getValue(); - int exponent = (int)ExtraMath.closeFloor(ExtraMath.log10(Math.abs(v == 0 - ? 1 : v))); + int exponent = (int)ExtraMath.closeFloor(Math.log10(Math.abs(v == 0 ? 1 : v))); if (v == Double.POSITIVE_INFINITY) { string = "inf"; } else if (v == Double.NEGATIVE_INFINITY) { Modified: trunk/jython/src/org/python/core/util/ExtraMath.java =================================================================== --- trunk/jython/src/org/python/core/util/ExtraMath.java 2008-04-19 21:14:24 UTC (rev 4361) +++ trunk/jython/src/org/python/core/util/ExtraMath.java 2008-04-19 21:35:10 UTC (rev 4362) @@ -1,37 +1,15 @@ // Copyright (c) Corporation for National Research Initiatives - package org.python.core.util; /** * A static utility class with two additional math functions. */ public class ExtraMath { - public static double LOG10 = Math.log(10.0); public static double EPSILON = Math.pow(2.0, -52.0); public static double CLOSE = EPSILON * 2.0; - public static double log10(double v) { - return Math.log(v) / LOG10; - } - - public static double hypot(double v, double w) { - v = Math.abs(v); - w = Math.abs(w); - if (v < w) { - double temp = v; - v = w; - w = temp; - } - if (v == 0.0) { - return 0.0; - } else { - double wv = w / v; - return v * Math.sqrt(1.0 + wv * wv); - } - } - /** * Are v and w "close" to each other? Uses a scaled tolerance. */ Modified: trunk/jython/src/org/python/modules/math.java =================================================================== --- trunk/jython/src/org/python/modules/math.java 2008-04-19 21:14:24 UTC (rev 4361) +++ trunk/jython/src/org/python/modules/math.java 2008-04-19 21:35:10 UTC (rev 4362) @@ -2,7 +2,6 @@ package org.python.modules; import org.python.core.*; -import org.python.core.util.ExtraMath; import java.lang.Math; public class math implements ClassDictInit { @@ -129,7 +128,7 @@ } private static double log10(double v) { - return check(ExtraMath.log10(v)); + return check(Math.log10(v)); } public static double sinh(double v) { @@ -185,7 +184,7 @@ } public static double hypot(double v, double w) { - return check(ExtraMath.hypot(v, w)); + return check(Math.hypot(v, w)); } public static double radians(double v) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |