[Scipysvn] r5266  trunk/scipy/optimize/Zeros
scipysvn@scip...
scipysvn@scip...
Mon Dec 15 12:59:19 CST 2008
Author: charris
Date: 20081215 12:59:12 0600 (Mon, 15 Dec 2008)
New Revision: 5266
Modified:
trunk/scipy/optimize/Zeros/bisect.c
trunk/scipy/optimize/Zeros/brenth.c
trunk/scipy/optimize/Zeros/brentq.c
trunk/scipy/optimize/Zeros/ridder.c
Log:
Whitespace removal.
Modified: trunk/scipy/optimize/Zeros/bisect.c
===================================================================
 trunk/scipy/optimize/Zeros/bisect.c 20081215 18:58:14 UTC (rev 5265)
+++ trunk/scipy/optimize/Zeros/bisect.c 20081215 18:59:12 UTC (rev 5266)
@@ 7,9 +7,9 @@
{
int i;
double dm,xm,fm,fa,fb,tol;

+
tol = xtol + rtol*(fabs(xa) + fabs(xb));

+
fa = (*f)(xa,params);
fb = (*f)(xb,params);
params>funcalls = 2;
Modified: trunk/scipy/optimize/Zeros/brenth.c
===================================================================
 trunk/scipy/optimize/Zeros/brenth.c 20081215 18:58:14 UTC (rev 5265)
+++ trunk/scipy/optimize/Zeros/brenth.c 20081215 18:59:12 UTC (rev 5266)
@@ 5,28 +5,28 @@
/*
At the top of the loop the situation is the following:

+
1. the root is bracketed between xa and xb
2. xa is the most recent estimate
3. xp is the previous estimate
4. fp < fb

 The order of xa and xp doesn't matter, but assume xp < xb. Then xa lies to
+
+ The order of xa and xp doesn't matter, but assume xp < xb. Then xa lies to
the right of xp and the assumption is that xa is increasing towards the root.
In this situation we will attempt quadratic extrapolation as long as the
condition
 * fa < fp < fb

+ * fa < fp < fb
+
is satisfied. That is, the function value is decreasing as we go along.
Note the 4 above implies that the right inequlity already holds.
 The first check is that xa is still to the left of the root. If not, xb is
+ The first check is that xa is still to the left of the root. If not, xb is
replaced by xp and the interval reverses, with xb < xa. In this situation
 we will try linear interpolation. That this has happened is signaled by the
+ we will try linear interpolation. That this has happened is signaled by the
equality xb == xp;

+
The second check is that fa < fb. If this is not the case, we swap
xa and xb and resort to bisection.
@@ 39,7 +39,7 @@
double xblk = 0.0, fpre, fcur, fblk = 0.0, spre = 0.0, scur = 0.0, sbis, tol;
double stry, dpre, dblk;
int i;

+
fpre = (*f)(xpre,params);
fcur = (*f)(xcur,params);
params>funcalls = 2;
@@ 48,9 +48,9 @@
if (fcur == 0) return xcur;
params>iterations = 0;
for(i = 0; i < iter; i++) {

+
params>iterations++;

+
if (fpre*fcur < 0) {
xblk = xpre;
fblk = fpre;
@@ 60,12 +60,12 @@
xpre = xcur; xcur = xblk; xblk = xpre;
fpre = fcur; fcur = fblk; fblk = fpre;
}

+
tol = xtol + rtol*fabs(xcur);
sbis = (xblk  xcur)/2;
if (fcur == 0  fabs(sbis) < tol)
return xcur;

+
if (fabs(spre) > tol && fabs(fcur) < fabs(fpre)) {
if (xpre == xblk) {
/* interpolate */
@@ 77,7 +77,7 @@
dblk = (fblk  fcur)/(xblk  xcur);
stry = fcur*(fblk  fpre)/(fblk*dpre  fpre*dblk);
}

+
if (2*fabs(stry) < DMIN(fabs(spre), 3*fabs(sbis)  tol)) {
/* accept step */
spre = scur; scur = stry;
@@ 91,13 +91,13 @@
/* bisect */
spre = sbis; scur = sbis;
}

+
xpre = xcur; fpre = fcur;
 if (fabs(scur) > tol)
+ if (fabs(scur) > tol)
xcur += scur;
 else
+ else
xcur += (sbis > 0 ? tol : tol);

+
fcur = (*f)(xcur, params);
params>funcalls++;
}
Modified: trunk/scipy/optimize/Zeros/brentq.c
===================================================================
 trunk/scipy/optimize/Zeros/brentq.c 20081215 18:58:14 UTC (rev 5265)
+++ trunk/scipy/optimize/Zeros/brentq.c 20081215 18:59:12 UTC (rev 5266)
@@ 7,25 +7,25 @@
/*
At the top of the loop the situation is the following:

+
1. the root is bracketed between xa and xb
2. xa is the most recent estimate
3. xp is the previous estimate
4. fp < fb

 The order of xa and xp doesn't matter, but assume xp < xb. Then xa lies to
+
+ The order of xa and xp doesn't matter, but assume xp < xb. Then xa lies to
the right of xp and the assumption is that xa is increasing towards the root.
In this situation we will attempt quadratic extrapolation as long as the
condition
 * fa < fp < fb

+ * fa < fp < fb
+
is satisfied. That is, the function value is decreasing as we go along.
Note the 4 above implies that the right inequlity already holds.
 The first check is that xa is still to the left of the root. If not, xb is
+ The first check is that xa is still to the left of the root. If not, xb is
replaced by xp and the interval reverses, with xb < xa. In this situation
 we will try linear interpolation. That this has happened is signaled by the
+ we will try linear interpolation. That this has happened is signaled by the
equality xb == xp;
The second check is that fa < fb. If this is not the case, we swap
@@ 40,7 +40,7 @@
double xblk = 0.0, fpre, fcur, fblk = 0.0, spre = 0.0, scur = 0.0, sbis, tol;
double stry, dpre, dblk;
int i;

+
fpre = (*f)(xpre, params);
fcur = (*f)(xcur, params);
params>funcalls = 2;
@@ 59,14 +59,14 @@
xpre = xcur; xcur = xblk; xblk = xpre;
fpre = fcur; fcur = fblk; fblk = fpre;
}

+
tol = xtol + rtol*fabs(xcur);
sbis = (xblk  xcur)/2;
if (fcur == 0  fabs(sbis) < tol)
return xcur;

+
if (fabs(spre) > tol && fabs(fcur) < fabs(fpre)) {
 if (xpre == xblk) {
+ if (xpre == xblk) {
/* interpolate */
stry = fcur*(xcur  xpre)/(fcur  fpre);
}
@@ 85,19 +85,19 @@
spre = sbis; scur = sbis;
}
}
 else {
+ else {
/* bisect */
spre = sbis; scur = sbis;
}

+
xpre = xcur; fpre = fcur;
if (fabs(scur) > tol)
xcur += scur;
 else
+ else
xcur += (sbis > 0 ? tol : tol);

+
fcur = (*f)(xcur, params);
 params>funcalls++;
+ params>funcalls++;
}
ERROR(params,CONVERR, xcur);
}
Modified: trunk/scipy/optimize/Zeros/ridder.c
===================================================================
 trunk/scipy/optimize/Zeros/ridder.c 20081215 18:58:14 UTC (rev 5265)
+++ trunk/scipy/optimize/Zeros/ridder.c 20081215 18:59:12 UTC (rev 5266)
@@ 9,7 +9,7 @@
double
ridder(callback_type f, double xa, double xb, double xtol, double rtol, int iter, default_parameters *params)
{
+{
int i;
double dm,dn,xm,xn=0.0,fn,fm,fa,fb,tol;
More information about the Scipysvn
mailing list