commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r915522 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java site/xdoc/changes.xml test/java/org/apache/commons/math/analysis/solvers/BrentSolverTest.java
Date Tue, 23 Feb 2010 21:09:25 GMT
Author: luc
Date: Tue Feb 23 21:09:25 2010
New Revision: 915522

URL: http://svn.apache.org/viewvc?rev=915522&view=rev
Log:
Fixed wrong return values when enpoints are roots in Brent solver with a user provided initial
guess
JIRA: MATH-344

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/BrentSolverTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java?rev=915522&r1=915521&r2=915522&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java
Tue Feb 23 21:09:25 2010
@@ -112,7 +112,7 @@
         // return the first endpoint if it is good enough
         double yMin = f.value(min);
         if (Math.abs(yMin) <= functionValueAccuracy) {
-            setResult(yMin, 0);
+            setResult(min, 0);
             return result;
         }
 
@@ -124,7 +124,7 @@
         // return the second endpoint if it is good enough
         double yMax = f.value(max);
         if (Math.abs(yMax) <= functionValueAccuracy) {
-            setResult(yMax, 0);
+            setResult(max, 0);
             return result;
         }
 

Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=915522&r1=915521&r2=915522&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Tue Feb 23 21:09:25 2010
@@ -39,6 +39,10 @@
   </properties>
   <body>
     <release version="2.1" date="TBD" description="TBD">
+      <action dev="luc" type="fix" issue="MATH-344" >
+        Fixed wrong return values when enpoints are roots in Brent solver with
+        a user provided initial guess
+      </action>
       <action dev="luc" type="fix" issue="MATH-343" >
         Fixed a missing bracketing check of initial interval in Brent solver.
       </action>

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/BrentSolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/BrentSolverTest.java?rev=915522&r1=915521&r2=915522&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/BrentSolverTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/BrentSolverTest.java
Tue Feb 23 21:09:25 2010
@@ -308,10 +308,17 @@
 
         // endpoint is root
         double result = solver.solve(f, Math.PI, 4);
-        assertEquals(result, Math.PI, solver.getAbsoluteAccuracy());
+        assertEquals(Math.PI, result, solver.getAbsoluteAccuracy());
 
         result = solver.solve(f, 3, Math.PI);
-        assertEquals(result, Math.PI, solver.getAbsoluteAccuracy());
+        assertEquals(Math.PI, result, solver.getAbsoluteAccuracy());
+
+        result = solver.solve(f, Math.PI, 4, 3.5);
+        assertEquals(Math.PI, result, solver.getAbsoluteAccuracy());
+
+        result = solver.solve(f, 3, Math.PI, 3.07);
+        assertEquals(Math.PI, result, solver.getAbsoluteAccuracy());
+
     }
 
     public void testBadEndpoints() throws Exception {



Mime
View raw message