Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Done
-
None
-
None
-
None
Description
In org.apache.commons.math4.analysis.interpolation.SplineInterpolator and in org.apache.commons.math4.analysis.interpolation.AkimaSplineInterpolator, many indices are recomputed many times.
Example :
for (int i = 1; i < n; i++) { g = 2d * (x[i+1] - x[i - 1]) - h[i - 1] * mu[i -1]; mu[i] = h[i] / g; }
can be replaced by :
while (i < n) {
g[i] = 2d * (x[iPlusOne] - x[iMinusOne]) - h[iMinusOne] * mu[iMinusOne];
mu[i] = h[i] / g[i];
iMinusOne = i;
i = iPlusOne;
iPlusOne = iPlusOne + 1;
}
In my tests, I saved almost 2% of processing time with this optimization.