ArpackSupport: Round the Arnoldi iteration cap up as intended

iparam[2] is ARPACK's maxitr. The expression computing it wrapped an integer division in std::ceil:

iparam[2] = std::max(300, (int)std::ceil(2 * n / std::max(ncv, 1)));

n and ncv are both int, so 2 * n / max(ncv, 1) truncates before ceil ever sees the value, and ceil on an already-integral double is the identity. The rounding the code asks for never happened.

Measured for nev = 10 (so ncv = 20):

n exact 2n/ncv before after
3001 300.1 300 301
5000 500.0 500 500
12345 1234.5 1234 1235

numext::div_ceil performs the rounding in integer arithmetic, so the value matches what the expression was written to compute. Its preconditions hold: 2 * n is non-negative and max(ncv, 1) is positive.

No regression test: ArpackSupport requires an external ARPACK library and has no test target in the tree, and maxitr is an iteration cap whose off-by-one is not observable through the solver's public results.

This is split out of a larger conventions sweep so that the later std::numext:: pass does not silently preserve a dead ceil.

Merge request reports

Loading