aherbert commented on code in PR #351:
URL: https://github.com/apache/commons-math/pull/351#discussion_r4501127483


##########
commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/interpolation/AkimaSplineInterpolator.java:
##########
@@ -144,7 +144,23 @@ public PolynomialSplineFunction interpolate(double[] xvals,
                 final double xvM = xvals[i - 1];
                 firstDerivatives[i] = (((xvP - xv) * differences[i - 1]) + 
((xv - xvM) * differences[i])) / (xvP - xvM);
             } else {
-                firstDerivatives[i] = ((wP * differences[i - 1]) + (wM * 
differences[i])) / (wP + wM);
+                final double weightedP = wP * differences[i - 1];
+                final double weightedM = wM * differences[i];
+                final double weightedSum = weightedP + weightedM;
+                final double weightSum = wP + wM;

Review Comment:
   Note that prior to this step the computation of the computation of the 
`differences` can also overflow. Feel free to investigate if that can be 
recovered. Otherwise I suggest raising an exception for an interpolator that 
will not work.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to