From fd70189643a3480928043ae65a1f7ca266498b23 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Tue, 17 Mar 2026 12:06:47 -0500 Subject: [PATCH 1/2] Add user facing domain access --- include/boost/math/interpolators/pchip.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/boost/math/interpolators/pchip.hpp b/include/boost/math/interpolators/pchip.hpp index 6697166df0..a4ad5a3579 100644 --- a/include/boost/math/interpolators/pchip.hpp +++ b/include/boost/math/interpolators/pchip.hpp @@ -121,6 +121,11 @@ class pchip { } } + std::pair domain() const + { + return impl_->domain(); + } + private: std::shared_ptr> impl_; }; From 9f8cf5caa8adbd4d38ec2f956bc90d490e49bc48 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Tue, 17 Mar 2026 12:06:55 -0500 Subject: [PATCH 2/2] Test domain function --- test/pchip_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/pchip_test.cpp b/test/pchip_test.cpp index 6e8ea235bf..5e8fb3c2ac 100644 --- a/test/pchip_test.cpp +++ b/test/pchip_test.cpp @@ -38,6 +38,10 @@ void test_constant() auto pchip_spline = pchip(std::move(x_copy), std::move(y_copy)); //std::cout << "Constant value pchip spline = " << pchip_spline << "\n"; + auto [lo, hi] = pchip_spline.domain(); + CHECK_ULP_CLOSE(lo, 0, 1); + CHECK_ULP_CLOSE(hi, 81, 1); + for (Real t = x[0]; t <= x.back(); t += Real(0.25)) { CHECK_ULP_CLOSE(Real(7), pchip_spline(t), 2); CHECK_ULP_CLOSE(Real(0), pchip_spline.prime(t), 2);