Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:41:22

0001 // Copyright Nick Thompson, 2019
0002 // Use, modification and distribution are subject to the
0003 // Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt
0005 // or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_MATH_INTERPOLATORS_CARDINAL_QUINTIC_B_SPLINE_HPP
0008 #define BOOST_MATH_INTERPOLATORS_CARDINAL_QUINTIC_B_SPLINE_HPP
0009 #include <memory>
0010 #include <limits>
0011 #include <boost/math/interpolators/detail/cardinal_quintic_b_spline_detail.hpp>
0012 
0013 
0014 namespace boost{ namespace math{ namespace interpolators {
0015 
0016 template <class Real>
0017 class cardinal_quintic_b_spline
0018 {
0019 public:
0020     // If you don't know the value of the derivative at the endpoints, leave them as nans and the routine will estimate them.
0021     // y[0] = y(a), y[n - 1] = y(b), step_size = (b - a)/(n -1).
0022     cardinal_quintic_b_spline(const Real* const y,
0023                                 size_t n,
0024                                 Real t0 /* initial time, left endpoint */,
0025                                 Real h  /*spacing, stepsize*/,
0026                                 std::pair<Real, Real> left_endpoint_derivatives = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN()},
0027                                 std::pair<Real, Real> right_endpoint_derivatives = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN()})
0028      : impl_(std::make_shared<detail::cardinal_quintic_b_spline_detail<Real>>(y, n, t0, h, left_endpoint_derivatives, right_endpoint_derivatives))
0029     {}
0030 
0031     // Oh the bizarre error messages if we template this on a RandomAccessContainer:
0032     cardinal_quintic_b_spline(std::vector<Real> const & y,
0033                                 Real t0 /* initial time, left endpoint */,
0034                                 Real h  /*spacing, stepsize*/,
0035                                 std::pair<Real, Real> left_endpoint_derivatives = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN()},
0036                                 std::pair<Real, Real> right_endpoint_derivatives = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN()})
0037      : impl_(std::make_shared<detail::cardinal_quintic_b_spline_detail<Real>>(y.data(), y.size(), t0, h, left_endpoint_derivatives, right_endpoint_derivatives))
0038     {}
0039 
0040 
0041     Real operator()(Real t) const {
0042         return impl_->operator()(t);
0043     }
0044 
0045     Real prime(Real t) const {
0046        return impl_->prime(t);
0047     }
0048 
0049     Real double_prime(Real t) const {
0050         return impl_->double_prime(t);
0051     }
0052 
0053     Real t_max() const {
0054         return impl_->t_max();
0055     }
0056 
0057 private:
0058     std::shared_ptr<detail::cardinal_quintic_b_spline_detail<Real>> impl_;
0059 };
0060 
0061 }}}
0062 #endif