Repository navigation
Prevent intermediate overflow in Akima spline weighted derivatives - #351
Open
JackieTien97 wants to merge 2 commits into
Open
JackieTien97 wants to merge 2 commits into
JackieTien97 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #351 +/- ##
============================================
+ Coverage 86.54% 87.21% +0.67%
+ Complexity 9787 91 -9696
============================================
Files 532 499 -33
Lines 35516 33535 -1981
Branches 6194 5853 -341
============================================
- Hits 30738 29249 -1489
+ Misses 3518 3160 -358
+ Partials 1260 1126 -134 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
aherbert
requested changes
Nov 7, 2026
aherbert
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fix. I would suggest also raising an exception if the differences overflow and there are regions in the interpolator that will not work.
| final double weightedP = wP * differences[i - 1]; | ||
| final double weightedM = wM * differences[i]; | ||
| final double weightedSum = weightedP + weightedM; | ||
| final double weightSum = wP + wM; |
Contributor
There was a problem hiding this 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finite samples can produce
NaNin Akima interpolation because the weighted slope products overflow before division. For example, withx = {0, 2, 4, 6, 8}andy = {0, 1e200, 0, 1e200, 0}, evaluating the interpolant at3returnsNaNinstead of approximately5e199.Preserve the existing calculation when the intermediate sums are finite and at least one weighted product is nonzero. Otherwise, normalize the two weights before forming the convex combination of slopes. Keeping the existing arithmetic for representable products preserves small contributions when the weights have very different magnitudes; unconditionally normalizing those weights can itself underflow a weight.
Add regression coverage for:
1e200,-1e200, and1e-200in both modes.y = {1e-200, 0, 0, 1e200, 1e200}must retain the value-1.875e-201atx = 3in both modes.Also add a release-note entry.
Validation:
mvn clean verifypasses: 3,828 tests reported, 33 skipped, no failures or errors.