Skip to content

Conversation

@swvanbuuren
Copy link
Owner

This pull request introduces support for 4D linear interpolation in the codebase, including the addition of a LinearInterp4D class, enhanced assertion helpers for N-dimensional interpolation, and comprehensive tests for 4D interpolation functionality. The changes improve code reusability, extend functionality to higher dimensions, and ensure robust testing.

New functionality for 4D interpolation:

  • include/linear_interp.hpp: Added the LinearInterp4D class, which extends LinearInterpND to support 4-dimensional interpolation.

Enhanced assertion helpers:

  • tests/assertion_helpers.hpp: Refactored interpolation assertion helpers into a reusable InterpNDAssertions class for N-dimensional interpolation, and added support for 4D assertions via Interp4DAssertions.

Comprehensive testing:

  • tests/test_linear_interp.cpp: Added multiple tests for 4D interpolation, including tests for linear, direct template-based, and non-linear functions. These ensure correctness and validate interpolation behavior at grid points and midpoints.
  • tests/test_linear_interp.cpp: Introduced VectorN4 type alias for 4D vectors to facilitate testing.

@swvanbuuren swvanbuuren requested a review from Copilot July 5, 2025 12:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for 4D linear interpolation by introducing a new LinearInterp4D class, generalizes existing assertion helpers into a reusable N-dimensional framework, and provides comprehensive tests for 4D interpolation scenarios.

  • Introduce LinearInterp4D extending LinearInterpND for four dimensions
  • Refactor 1D–3D assertion helpers into InterpNDAssertions template and add a 4D wrapper
  • Add tests in tests/test_linear_interp.cpp covering linear, direct template-based, and nonlinear 4D interpolation

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/test_linear_interp.cpp Added VectorN4 alias and multiple 4D interpolation tests, including linear and nonlinear cases
tests/assertion_helpers.hpp Refactored per-dimension helpers into InterpNDAssertions<T, N, FuncValT> and added convenience wrappers for N=1–4
include/linear_interp.hpp Added LinearInterp4D class with ctor delegating to LinearInterpND<T, 4>
Comments suppressed due to low confidence (3)

tests/assertion_helpers.hpp:21

  • [nitpick] The InterpNDAssertions class lacks a top-level comment describing its purpose, template parameters, and usage. Adding a brief Doxygen or block comment would help future maintainers understand how and when to use this helper.
class InterpNDAssertions {

tests/assertion_helpers.hpp:35

  • [nitpick] The dim_name helper only handles up to 4 dimensions (x, y, z, w). If InterpNDAssertions is ever used for N > 4, dim_name will produce unexpected characters. Consider generalizing or documenting this limitation.
    static constexpr char dim_name(size_t i) {

tests/test_linear_interp.cpp:366

  • Tests currently cover grid points and midpoints for linear and quadratic functions. Consider adding edge-case tests (e.g., out-of-bounds coordinates, non-uniform grid spacing) to ensure error handling and robustness of LinearInterp4D::eval.
}

@swvanbuuren swvanbuuren force-pushed the swvanbuuren/nd-assertion-helper branch from a706bfa to ef2420b Compare July 5, 2025 12:41
@swvanbuuren swvanbuuren merged commit fcf092f into master Jul 5, 2025
3 checks passed
@swvanbuuren swvanbuuren deleted the swvanbuuren/nd-assertion-helper branch July 5, 2025 12:43
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