commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r744621 - in /commons/sandbox/me/trunk: src/org/apache/commons/me/math/MoreMath.java test-src/org/apache/commons/me/math/TestMoreMath.java
Date Sun, 15 Feb 2009 07:36:01 GMT
Author: nick
Date: Sun Feb 15 07:36:00 2009
New Revision: 744621

URL: http://svn.apache.org/viewvc?rev=744621&view=rev
Log:
Improve the code for deciding how many log series expansions to run

Modified:
    commons/sandbox/me/trunk/src/org/apache/commons/me/math/MoreMath.java
    commons/sandbox/me/trunk/test-src/org/apache/commons/me/math/TestMoreMath.java

Modified: commons/sandbox/me/trunk/src/org/apache/commons/me/math/MoreMath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/me/trunk/src/org/apache/commons/me/math/MoreMath.java?rev=744621&r1=744620&r2=744621&view=diff
==============================================================================
--- commons/sandbox/me/trunk/src/org/apache/commons/me/math/MoreMath.java (original)
+++ commons/sandbox/me/trunk/src/org/apache/commons/me/math/MoreMath.java Sun Feb 15 07:36:00
2009
@@ -83,10 +83,9 @@
 		double sign = 1.0;
 		double val_m1 = val - 1.0;
 
-		// 50 times is normally ok if the value
-		// is over 0.06, otherwise up to 90
-		int steps = 50;
-		if(val < 0.06) { steps = 90; }
+		// Need at least 30 steps
+		// The smaller the number, the more we need
+		int steps = 30 + (int)(4 / val);
 
 		for(int i=1; i<=steps; i++) {
 			// Raise to the power

Modified: commons/sandbox/me/trunk/test-src/org/apache/commons/me/math/TestMoreMath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/me/trunk/test-src/org/apache/commons/me/math/TestMoreMath.java?rev=744621&r1=744620&r2=744621&view=diff
==============================================================================
--- commons/sandbox/me/trunk/test-src/org/apache/commons/me/math/TestMoreMath.java (original)
+++ commons/sandbox/me/trunk/test-src/org/apache/commons/me/math/TestMoreMath.java Sun Feb
15 07:36:00 2009
@@ -43,7 +43,7 @@
 		assertEquals(0.69314718, MoreMath.log(2.0), 0.001);
 		assertEquals(1.60943791, MoreMath.log(5.0), 0.001);
 		assertEquals(2.30258509, MoreMath.log(10.0), 0.001);
-		assertEquals(2.99573227, MoreMath.log(20.0), 0.002);
+		assertEquals(2.99573227, MoreMath.log(20.0), 0.001);
 	}
 
 	public void testLog10() {



Mime
View raw message