You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2020/04/07 17:30:00 UTC
[jira] [Resolved] (MATH-1530) Spline interpolation : Avoid
recomputing indexes when possible
[ https://issues.apache.org/jira/browse/MATH-1530?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gilles Sadowski resolved MATH-1530.
-----------------------------------
Fix Version/s: 4.0
Resolution: Done
Suggestion implemented (for {{SplineInterpolator}}) in commit 9c6ed8311fcb30518cc8935146d72a5b9126d41c ("master" branch).
> Spline interpolation : Avoid recomputing indexes when possible
> --------------------------------------------------------------
>
> Key: MATH-1530
> URL: https://issues.apache.org/jira/browse/MATH-1530
> Project: Commons Math
> Issue Type: Improvement
> Reporter: Yassine Damerdji
> Priority: Minor
> Fix For: 4.0
>
>
> In org.apache.commons.math4.analysis.interpolation.SplineInterpolator and in org.apache.commons.math4.analysis.interpolation.AkimaSplineInterpolator, many indices are recomputed many times.
> Example :
> {code:java}
> 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;
> }{code}
> can be replaced by :
> {code:java}
> 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;
> }
> {code}
> In my tests, I saved almost 2% of processing time with this optimization.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)