1 // Copyright Nick Thompson, 2019
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_MATH_INTERPOLATORS_CARDINAL_QUINTIC_B_SPLINE_HPP
8 #define BOOST_MATH_INTERPOLATORS_CARDINAL_QUINTIC_B_SPLINE_HPP
11 #include <boost/math/interpolators/detail/cardinal_quintic_b_spline_detail.hpp>
14 namespace boost{ namespace math{ namespace interpolators {
17 class cardinal_quintic_b_spline
20 // If you don't know the value of the derivative at the endpoints, leave them as nans and the routine will estimate them.
21 // y[0] = y(a), y[n - 1] = y(b), step_size = (b - a)/(n -1).
22 cardinal_quintic_b_spline(const Real* const y,
24 Real t0 /* initial time, left endpoint */,
25 Real h /*spacing, stepsize*/,
26 std::pair<Real, Real> left_endpoint_derivatives = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN()},
27 std::pair<Real, Real> right_endpoint_derivatives = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN()})
28 : impl_(std::make_shared<detail::cardinal_quintic_b_spline_detail<Real>>(y, n, t0, h, left_endpoint_derivatives, right_endpoint_derivatives))
31 // Oh the bizarre error messages if we template this on a RandomAccessContainer:
32 cardinal_quintic_b_spline(std::vector<Real> const & y,
33 Real t0 /* initial time, left endpoint */,
34 Real h /*spacing, stepsize*/,
35 std::pair<Real, Real> left_endpoint_derivatives = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN()},
36 std::pair<Real, Real> right_endpoint_derivatives = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN()})
37 : impl_(std::make_shared<detail::cardinal_quintic_b_spline_detail<Real>>(y.data(), y.size(), t0, h, left_endpoint_derivatives, right_endpoint_derivatives))
41 Real operator()(Real t) const {
42 return impl_->operator()(t);
45 Real prime(Real t) const {
46 return impl_->prime(t);
49 Real double_prime(Real t) const {
50 return impl_->double_prime(t);
54 return impl_->t_max();
58 std::shared_ptr<detail::cardinal_quintic_b_spline_detail<Real>> impl_;