Skip to content

Feat extrapolation configuration - #38

Merged
CD3 merged 11 commits into
masterfrom
feat-extrapolation-configuration
Dec 4, 2026
Merged

CD3 merged 11 commits into
masterfrom
feat-extrapolation-configuration

Conversation

@CD3

@CD3 CD3 commented Dec 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

CD3 and others added 11 commits October 11, 2026 21:08
Pin the current behavior (return 0 outside the domain) for every 1D and
2D interpolator in float and double, before adding extrapolation and
sentinel options. Known bugs are tagged [!shouldfail] or hidden with
[.] (known-crash, known-bug).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
get_[xy]_index_closest_to dereferenced lower_bound(...) - 1, which reads
before the start of the array for queries on the lower x or y edge, or
NaN. The search result is now clamped to the data range. NaN queries
now return Z(0,0) instead of an undefined value; NaN policy is left for
the sentinel work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After clamping the limits to the domain, a range entirely outside it
gave _a > _b. Above the domain this read past the end of the coefficient
arrays; below it returned a nonzero value. Return 0 instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover get_[xy]_index_closest_to at knots, between knots, ties, one ulp
either side of a knot, outside the data, +/-inf, and NaN (valid index
only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
derivative() checked the interval index instead of x, so queries below
x[0] used the first segment and returned a value (NaN at -inf). Use the
same bounds check as operator(). derivative() and integral() now call
checkData() and throw std::logic_error without data instead of
dereferencing a null pointer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
operator() now calls checkData() and throws std::logic_error without
data, like the other interpolators, instead of returning 0. The
triangulation and z lookup read through the data views instead of the
owned data vectors, which are empty when setUnsafeDataReference() is
used and caused a segfault.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The base copy constructors always pointed the copy's views at its own
data vectors, which are empty when setUnsafeDataReference() was used.
1D copies threw on every call and 2D copies aborted in
setup2DDataViews(). Copies now share the reference in that case. Also
fixes yView being created based on rhs.xView.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 1D and 2D regular grid interpolators require strictly increasing
coordinates (x outer, y inner for grids). This is not checked. Document
it in the README and the setData/setUnsafeDataReference comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Queries outside the data return 0; document what "outside" means for
each method. Results for NaN coordinates are unspecified. Tests that
pin current NaN results are kept as change detectors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Interpolators can now return a custom value or quiet NaN for queries
outside the data (setOutOfBoundsValue, setOutOfBoundsNaN), or
extrapolate (enableExtrapolation). The default is unchanged: return 0.

- Linear continues the end segments. CubicSpline and Monotonic continue
  in a straight line with the end-point slope. Bilinear and Bicubic
  continue the edge patch. NearestNeighbor returns the edge value.
  ThinPlateSpline evaluates the spline.
- LinearDelaunay cannot extrapolate; enableExtrapolation() on it is a
  compile error, as is setOutOfBoundsNaN() for types without a NaN.
- Settings are kept by copies (including AnyInterpolator) and batch().
- derivative() and integral() are not affected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CD3
CD3 merged commit 262adfe into master Dec 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant