@@ -1174,9 +1174,11 @@ namespace galsim {
11741174 for (int ix=0 ; ix<=max_ix; ++ix) {
11751175 xdbg<<" Start search for ix = " <<ix<<std::endl;
11761176 // Search along the two sides with either kx = ix or ky = ix.
1177+ double norm_kval = INFINITY; // something we know is above threshold
1178+
11771179 for (int iy=0 ; iy<=ix; ++iy) {
11781180 // The bottom side of the square in the lower-right quadrant.
1179- double norm_kval = fast_norm ((*_kimage)(iy,-ix));
1181+ norm_kval = fast_norm ((*_kimage)(iy,-ix));
11801182 xdbg<<" norm_kval at " <<iy<<' ,' <<-ix<<" = " <<norm_kval<<std::endl;
11811183 if (norm_kval <= thresh && iy != ix && ix != No2) {
11821184 // The top side of the square in the upper-right quadrant.
@@ -1205,8 +1207,13 @@ namespace galsim {
12051207 }
12061208 }
12071209 xdbg<<" Done ix = " <<ix<<" . Current count = " <<n_below_thresh<<std::endl;
1210+ // we can get here either if the loop above finishes normally or if it hits
1211+ // the break statement. So we have to test the last value of norm_kval to
1212+ // see if the break statement was hit. If it was not, then we can increment
1213+ // the counter for the # below thresh.
1214+ if (norm_kval <= thresh) ++n_below_thresh;
12081215 // If we get through 5 rows with nothing above the threshold, stop looking.
1209- if (++ n_below_thresh == 5 ) break ;
1216+ if (n_below_thresh == 5 ) break ;
12101217 }
12111218 xdbg<<" Finished. maxk_ix = " <<maxk_ix<<std::endl;
12121219 // Add 1 to get the first row that is below the threshold.
0 commit comments