Skip to content

Commit

Permalink
Fix ticket #860, function calls miscounted in ridder.
Browse files Browse the repository at this point in the history
Clean up indentation in brenth.c
  • Loading branch information
charris committed Feb 12, 2009
1 parent a7a9d05 commit ddb17cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions scipy/optimize/Zeros/brenth.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion scipy/optimize/Zeros/ridder.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit ddb17cc

Please sign in to comment.