Skip to content

1d/2d cubic spline interpolator - #187

Merged
jacobmerson merged 21 commits into
SCOREC:developfrom
Sichao25:yus/spline_interpolator
Sep 25, 2025
Merged

jacobmerson merged 21 commits into
SCOREC:developfrom
Sichao25:yus/spline_interpolator

Conversation

@Sichao25

@Sichao25 Sichao25 commented Jul 28, 2025 •

Copy link
Copy Markdown
Contributor

Implemented 1D and 2D spline interpolators with corresponding test cases. The interpolators use mdspan as input to give users full control over memory allocation strategies, allowing compatibility with various data layouts.

While there is significant room for improvement in areas such as performance optimizations and implementation enhancements (e.g., more flexible constructors, integration with UniformGrid class, increased parallelism, C++ details, documentation ... ), this represents an initial version that's ready for preliminary feedback to identify any fundamental concerns.

@jacobmerson

Copy link
Copy Markdown
Collaborator

@Sichao25 I meged the Rank1View stuff.

}

template <typename T, typename MemorySpace>
void isUniformAscending(Rank1View<T, MemorySpace> x, const T &ztol) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just following up on this issue. mdspan doesn’t provide iterators, right? If so, would it be better to stick with a hand-coded loop here?.

@jacobmerson

Copy link
Copy Markdown
Collaborator

@Sichao25 We should be ready to make this into a regular pull request (currently it is a draft)

@Sichao25
Sichao25 marked this pull request as ready for review September 16, 2025 17:49
@Sichao25

Copy link
Copy Markdown
Contributor Author

Thanks for the notification. Just did that.

@jacobmerson jacobmerson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. One last thing I have for @Sichao25.

The test case is is comprehensive which is great. I think it would be helpful to have a simple example with some documentation of performing a single 2D interpolation.

Comment on lines +624 to +625
const T half = 0.5;
const T sixth = 0.166666666666666667;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be constexpr T half = 1./2 and constexpr T sixth = 1./6 like you have elsewhere.

Rank1View<T, MemorySpace> x,
LO nx, LO &ier) {
if (xget < x[0] || xget > x[nx - 1]) {
T zxtol = 4.0e-7 * std::max(std::abs(x[0]), std::abs(x[nx - 1]));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the tolerance be an argument to the function? It's not clear if this should be hardcoded.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is meant to be an argument, should it be user-configurable? That would mean adding it to the evaluate API with a default value.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally it's better to provide the user the ability to mess with tolerances. Comparing floating point numbers is surprisingly frought, so there isn't really a universal tolerance that works for everything.

@Sichao25
Sichao25 force-pushed the yus/spline_interpolator branch from c6cc582 to 780ced4 Compare September 19, 2025 16:25
@jacobmerson
jacobmerson self-requested a review September 19, 2025 18:45
@jacobmerson

jacobmerson commented Sep 25, 2025 •

Copy link
Copy Markdown
Collaborator

@Sichao25 Do you know how to re-run the pipelines so that the clang-tidy checks are run? Once we run that I am ready to merge this. Thanks for your work on this!

@Sichao25

Copy link
Copy Markdown
Contributor Author

I might need to merge the develop branch here.

@jacobmerson

Copy link
Copy Markdown
Collaborator

There aren't be any conflicts, so hopefully that will be relatively painless.

@jacobmerson
jacobmerson merged commit 3d5ab85 into SCOREC:develop Sep 25, 2025
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.

2 participants