Skip to content

Commit 8b742ed

Browse files
authored
MAINT:integrate: Fix an off-by-one error in QUADPACK (scipy#21309)
* MAINT:integrate: Fix an off-by-one error in QUADPACK * BUG: integrate:quadpack: Use Fortran loop vars
1 parent 03d90ff commit 8b742ed

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

scipy/integrate/__quadpack.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ dqagie(double(*fcn)(double* x), const double bound, const int inf,
552552
// The smallest interval has the largest error. Before bisecting
553553
// decrease the sum of the errors over the larger intervals (erlarg)
554554
// and perform extrapolation.
555-
jupbnd = (*last > 2 + (limit/2) ? limit + 2 - L : L);
556-
for (k = nrmax; k <= jupbnd; k++) {
555+
jupbnd = (*last > 2 + (limit/2) ? limit + 3 - *last : *last);
556+
for (k = nrmax; k < jupbnd; k++) {
557557
maxerr = iord[nrmax];
558558
errmax = elist[maxerr];
559559
if (fabs(blist[maxerr] - alist[maxerr]) > small) { goto LINE90; }
@@ -1104,8 +1104,8 @@ dqagpe(double(*fcn)(double* x), const double a, const double b, int npts2,
11041104
// The smallest interval has the largest error. Before bisecting
11051105
// decrease the sum of the errors over the larger intervals (erlarg)
11061106
// and perform extrapolation.
1107-
jupbnd = (*last > 2 + (limit/2) ? limit + 2 - L : L);
1108-
for (k = nrmax; k <= jupbnd; k++) {
1107+
jupbnd = (*last > 2 + (limit/2) ? limit + 3 - *last : *last);
1108+
for (k = nrmax; k < jupbnd; k++) {
11091109
maxerr = iord[nrmax];
11101110
errmax = elist[maxerr];
11111111
if (level[maxerr] +1 <= levmax) { goto LINE160; } // break->continue
@@ -1531,8 +1531,8 @@ dqagse(double(*fcn)(double* x), const double a, const double b,
15311531
// The smallest interval has the largest error. Before bisecting
15321532
// decrease the sum of the errors over the larger intervals (erlarg)
15331533
// and perform extrapolation.
1534-
jupbnd = (*last > 2 + (limit/2) ? limit + 2 - L : L);
1535-
for (k = nrmax; k <= jupbnd; k++) {
1534+
jupbnd = (*last > 2 + (limit/2) ? limit + 3 - *last : *last);
1535+
for (k = nrmax; k < jupbnd; k++) {
15361536
maxerr = iord[nrmax];
15371537
errmax = elist[maxerr];
15381538
if (fabs(blist[maxerr] - alist[maxerr]) > small) { goto LINE90; } // break->continue
@@ -2715,9 +2715,9 @@ dqawoe(double(*fcn)(double* x), const double a, const double b, const double ome
27152715
// The smallest interval has the largest error. Before bisecting, decrease
27162716
// the sum of the erorrs over the larger intervals (erlarg) and perform
27172717
// extrapolation.
2718-
jupbnd = (*last > (limit/2 + 2) ? limit + 2 - *last : L);
2718+
jupbnd = (*last > 2 + (limit/2) ? limit + 3 - *last : *last);
27192719

2720-
for (k = nrmax; k <= jupbnd; k++) {
2720+
for (k = nrmax; k < jupbnd; k++) {
27212721
maxerr = iord[nrmax];
27222722
errmax = elist[maxerr];
27232723
if (fabs(blist[maxerr] - alist[maxerr]) > small) { goto LINE140; }

0 commit comments

Comments
 (0)