whitespace fixes
This commit is contained in:
@ -924,66 +924,66 @@ int Balance::shift()
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (i < np) {
|
while (i < np) {
|
||||||
if (split[i+1] - split[i] < close) {
|
if (split[i+1] - split[i] < close) {
|
||||||
j = i+1;
|
j = i+1;
|
||||||
|
|
||||||
// I,J = set of consecutive splits that are collectively too close
|
// I,J = set of consecutive splits that are collectively too close
|
||||||
// if can expand set and not become too close to splits I-1 or J+1, do it
|
// if can expand set and not become too close to splits I-1 or J+1, do it
|
||||||
// else add split I-1 or J+1 to set and try again
|
// else add split I-1 or J+1 to set and try again
|
||||||
// delta = size of expanded split set that will satisy criterion
|
// delta = size of expanded split set that will satisy criterion
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
delta = (j-i) * close;
|
delta = (j-i) * close;
|
||||||
midpt = 0.5 * (split[i]+split[j]);
|
midpt = 0.5 * (split[i]+split[j]);
|
||||||
start = midpt - 0.5*delta;
|
start = midpt - 0.5*delta;
|
||||||
stop = midpt + 0.5*delta;
|
stop = midpt + 0.5*delta;
|
||||||
|
|
||||||
if (i > 0) lbound = split[i-1] + close;
|
if (i > 0) lbound = split[i-1] + close;
|
||||||
else lbound = 0.0;
|
else lbound = 0.0;
|
||||||
if (j < np) ubound = split[j+1] - close;
|
if (j < np) ubound = split[j+1] - close;
|
||||||
else ubound = 1.0;
|
else ubound = 1.0;
|
||||||
|
|
||||||
// start/stop are within bounds, reset the splits
|
// start/stop are within bounds, reset the splits
|
||||||
|
|
||||||
if (start >= lbound && stop <= ubound) break;
|
if (start >= lbound && stop <= ubound) break;
|
||||||
|
|
||||||
// try a shift to either bound, reset the splits if delta fits
|
// try a shift to either bound, reset the splits if delta fits
|
||||||
// these tests change start/stop
|
// these tests change start/stop
|
||||||
|
|
||||||
if (start < lbound) {
|
if (start < lbound) {
|
||||||
start = lbound;
|
start = lbound;
|
||||||
stop = start + delta;
|
stop = start + delta;
|
||||||
if (stop <= ubound) break;
|
if (stop <= ubound) break;
|
||||||
} else if (stop > ubound) {
|
} else if (stop > ubound) {
|
||||||
stop = ubound;
|
stop = ubound;
|
||||||
start = stop - delta;
|
start = stop - delta;
|
||||||
if (start >= lbound) break;
|
if (start >= lbound) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delta does not fit between lbound and ubound
|
// delta does not fit between lbound and ubound
|
||||||
// exit if can't expand set, else expand set
|
// exit if can't expand set, else expand set
|
||||||
// if can expand in either direction,
|
// if can expand in either direction,
|
||||||
// pick new split closest to current midpt of set
|
// pick new split closest to current midpt of set
|
||||||
|
|
||||||
if (i == 0 && j == np) {
|
if (i == 0 && j == np) {
|
||||||
start = 0.0; stop = 1.0;
|
start = 0.0; stop = 1.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == 0) j++;
|
if (i == 0) j++;
|
||||||
else if (j == np) i--;
|
else if (j == np) i--;
|
||||||
else if (midpt-lbound < ubound-midpt) i--;
|
else if (midpt-lbound < ubound-midpt) i--;
|
||||||
else j++;
|
else j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset all splits between I,J inclusive to be equi-spaced
|
// reset all splits between I,J inclusive to be equi-spaced
|
||||||
|
|
||||||
spacing = (stop-start) / (j-i);
|
spacing = (stop-start) / (j-i);
|
||||||
for (m = i; m <= j; m++)
|
for (m = i; m <= j; m++)
|
||||||
split[m] = start + (m-i)*spacing;
|
split[m] = start + (m-i)*spacing;
|
||||||
if (j == np) split[np] = 1.0;
|
if (j == np) split[np] = 1.0;
|
||||||
|
|
||||||
// continue testing beyond the J split
|
// continue testing beyond the J split
|
||||||
|
|
||||||
i = j+1;
|
i = j+1;
|
||||||
} else i++;
|
} else i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user