[Scipy-svn] r5544 - trunk/scipy/optimize/Zeros

scipy-svn@scip... scipy-svn@scip...
Wed Feb 11 21:38:53 CST 2009


Author: charris
Date: 2009-02-11 21:38:50 -0600 (Wed, 11 Feb 2009)
New Revision: 5544

Modified:
   trunk/scipy/optimize/Zeros/brenth.c
   trunk/scipy/optimize/Zeros/ridder.c
Log:
Fix ticket #860, function calls miscounted in ridder.
Clean up indentation in brenth.c


Modified: trunk/scipy/optimize/Zeros/brenth.c
===================================================================
--- trunk/scipy/optimize/Zeros/brenth.c	2009-02-12 03:23:57 UTC (rev 5543)
+++ trunk/scipy/optimize/Zeros/brenth.c	2009-02-12 03:38:50 UTC (rev 5544)
@@ -48,14 +48,12 @@
     if (fcur == 0) return xcur;
     params->iterations = 0;
     for(i = 0; i < iter; i++) {
-
         params->iterations++;
-
-            if (fpre*fcur < 0) {
-                xblk = xpre;
-                fblk = fpre;
-                spre = scur = xcur - xpre;
-            }
+        if (fpre*fcur < 0) {
+            xblk = xpre;
+            fblk = fpre;
+            spre = scur = xcur - xpre;
+        }
         if (fabs(fblk) < fabs(fcur)) {
             xpre = xcur; xcur = xblk; xblk = xpre;
             fpre = fcur; fcur = fblk; fblk = fpre;

Modified: trunk/scipy/optimize/Zeros/ridder.c
===================================================================
--- trunk/scipy/optimize/Zeros/ridder.c	2009-02-12 03:23:57 UTC (rev 5543)
+++ trunk/scipy/optimize/Zeros/ridder.c	2009-02-12 03:38:50 UTC (rev 5544)
@@ -29,7 +29,7 @@
         dn = SIGN(fb - fa)*dm*fm/sqrt(fm*fm - fa*fb);
         xn = xm - SIGN(dn)*DMIN(fabs(dn),fabs(dm) - .5*tol);
         fn = (*f)(xn,params);
-        params->funcalls++;
+        params->funcalls += 2;
         if (fn*fm < 0.0) {
             xa = xn; fa = fn; xb = xm; fb = fm;
         }



More information about the Scipy-svn mailing list