Permalink
Browse files

Fix ticket #860, function calls miscounted in ridder.

Clean up indentation in brenth.c
  • Loading branch information...
1 parent a7a9d05 commit ddb17cc53d252f3f72773cd3ef5db04e1cfd6183 @charris charris committed Feb 12, 2009
Showing with 6 additions and 8 deletions.
  1. +5 −7 scipy/optimize/Zeros/brenth.c
  2. +1 −1 scipy/optimize/Zeros/ridder.c
@@ -48,14 +48,12 @@ brenth(callback_type f, double xa, double xb, double xtol, double rtol, int iter
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;
@@ -29,7 +29,7 @@ ridder(callback_type f, double xa, double xb, double xtol, double rtol, int iter
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;
}

0 comments on commit ddb17cc

Please sign in to comment.