• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright Nick Thompson, 2020
3  * Use, modification and distribution are subject to the
4  * Boost Software License, Version 1.0. (See accompanying file
5  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  */
7 
8 #ifndef BOOST_MATH_INTERPOLATORS_QUINTIC_HERMITE_HPP
9 #define BOOST_MATH_INTERPOLATORS_QUINTIC_HERMITE_HPP
10 #include <algorithm>
11 #include <stdexcept>
12 #include <memory>
13 #include <boost/math/interpolators/detail/quintic_hermite_detail.hpp>
14 
15 namespace boost::math::interpolators {
16 
17 template<class RandomAccessContainer>
18 class quintic_hermite {
19 public:
20     using Real = typename RandomAccessContainer::value_type;
quintic_hermite(RandomAccessContainer && x,RandomAccessContainer && y,RandomAccessContainer && dydx,RandomAccessContainer && d2ydx2)21     quintic_hermite(RandomAccessContainer && x, RandomAccessContainer && y, RandomAccessContainer && dydx, RandomAccessContainer && d2ydx2)
22      : impl_(std::make_shared<detail::quintic_hermite_detail<RandomAccessContainer>>(std::move(x), std::move(y), std::move(dydx), std::move(d2ydx2)))
23     {}
24 
operator ()(Real x) const25     Real operator()(Real x) const
26     {
27         return impl_->operator()(x);
28     }
29 
prime(Real x) const30     Real prime(Real x) const
31     {
32         return impl_->prime(x);
33     }
34 
double_prime(Real x) const35     Real double_prime(Real x) const
36     {
37         return impl_->double_prime(x);
38     }
39 
operator <<(std::ostream & os,const quintic_hermite & m)40     friend std::ostream& operator<<(std::ostream & os, const quintic_hermite & m)
41     {
42         os << *m.impl_;
43         return os;
44     }
45 
push_back(Real x,Real y,Real dydx,Real d2ydx2)46     void push_back(Real x, Real y, Real dydx, Real d2ydx2)
47     {
48         impl_->push_back(x, y, dydx, d2ydx2);
49     }
50 
bytes() const51     int64_t bytes() const
52     {
53         return impl_->bytes() + sizeof(impl_);
54     }
55 
domain() const56     std::pair<Real, Real> domain() const
57     {
58         return impl_->domain();
59     }
60 
61 private:
62     std::shared_ptr<detail::quintic_hermite_detail<RandomAccessContainer>> impl_;
63 };
64 
65 template<class RandomAccessContainer>
66 class cardinal_quintic_hermite {
67 public:
68     using Real = typename RandomAccessContainer::value_type;
cardinal_quintic_hermite(RandomAccessContainer && y,RandomAccessContainer && dydx,RandomAccessContainer && d2ydx2,Real x0,Real dx)69     cardinal_quintic_hermite(RandomAccessContainer && y, RandomAccessContainer && dydx, RandomAccessContainer && d2ydx2, Real x0, Real dx)
70      : impl_(std::make_shared<detail::cardinal_quintic_hermite_detail<RandomAccessContainer>>(std::move(y), std::move(dydx), std::move(d2ydx2), x0, dx))
71     {}
72 
operator ()(Real x) const73     inline Real operator()(Real x) const {
74         return impl_->operator()(x);
75     }
76 
prime(Real x) const77     inline Real prime(Real x) const {
78         return impl_->prime(x);
79     }
80 
double_prime(Real x) const81     inline Real double_prime(Real x) const
82     {
83         return impl_->double_prime(x);
84     }
85 
bytes() const86     int64_t bytes() const
87     {
88         return impl_->bytes() + sizeof(impl_);
89     }
90 
domain() const91     std::pair<Real, Real> domain() const
92     {
93         return impl_->domain();
94     }
95 
96 private:
97     std::shared_ptr<detail::cardinal_quintic_hermite_detail<RandomAccessContainer>> impl_;
98 };
99 
100 template<class RandomAccessContainer>
101 class cardinal_quintic_hermite_aos {
102 public:
103     using Point = typename RandomAccessContainer::value_type;
104     using Real = typename Point::value_type;
cardinal_quintic_hermite_aos(RandomAccessContainer && data,Real x0,Real dx)105     cardinal_quintic_hermite_aos(RandomAccessContainer && data, Real x0, Real dx)
106      : impl_(std::make_shared<detail::cardinal_quintic_hermite_detail_aos<RandomAccessContainer>>(std::move(data), x0, dx))
107     {}
108 
operator ()(Real x) const109     inline Real operator()(Real x) const
110     {
111         return impl_->operator()(x);
112     }
113 
prime(Real x) const114     inline Real prime(Real x) const
115     {
116         return impl_->prime(x);
117     }
118 
double_prime(Real x) const119     inline Real double_prime(Real x) const
120     {
121         return impl_->double_prime(x);
122     }
123 
bytes() const124     int64_t bytes() const
125     {
126         return impl_->bytes() + sizeof(impl_);
127     }
128 
domain() const129     std::pair<Real, Real> domain() const
130     {
131         return impl_->domain();
132     }
133 private:
134     std::shared_ptr<detail::cardinal_quintic_hermite_detail_aos<RandomAccessContainer>> impl_;
135 };
136 
137 
138 }
139 #endif
140