]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/math/interpolators/septic_hermite.hpp
f428a7651ab1c002fa4d9dcf81b9e724732cc70f
[ceph.git] / ceph / src / boost / boost / math / interpolators / septic_hermite.hpp
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 #ifndef BOOST_MATH_INTERPOLATORS_SEPTIC_HERMITE_HPP
8 #define BOOST_MATH_INTERPOLATORS_SEPTIC_HERMITE_HPP
9 #include <algorithm>
10 #include <stdexcept>
11 #include <memory>
12 #include <boost/math/interpolators/detail/septic_hermite_detail.hpp>
13
14 namespace boost {
15 namespace math {
16 namespace interpolators {
17
18 template<class RandomAccessContainer>
19 class septic_hermite
20 {
21 public:
22 using Real = typename RandomAccessContainer::value_type;
23 septic_hermite(RandomAccessContainer && x, RandomAccessContainer && y, RandomAccessContainer && dydx,
24 RandomAccessContainer && d2ydx2, RandomAccessContainer && d3ydx3)
25 : impl_(std::make_shared<detail::septic_hermite_detail<RandomAccessContainer>>(std::move(x),
26 std::move(y), std::move(dydx), std::move(d2ydx2), std::move(d3ydx3)))
27 {}
28
29 inline Real operator()(Real x) const
30 {
31 return impl_->operator()(x);
32 }
33
34 inline Real prime(Real x) const
35 {
36 return impl_->prime(x);
37 }
38
39 inline Real double_prime(Real x) const
40 {
41 return impl_->double_prime(x);
42 }
43
44 friend std::ostream& operator<<(std::ostream & os, const septic_hermite & m)
45 {
46 os << *m.impl_;
47 return os;
48 }
49
50 int64_t bytes() const
51 {
52 return impl_->bytes() + sizeof(impl_);
53 }
54
55 std::pair<Real, Real> domain() const
56 {
57 return impl_->domain();
58 }
59
60 private:
61 std::shared_ptr<detail::septic_hermite_detail<RandomAccessContainer>> impl_;
62 };
63
64 template<class RandomAccessContainer>
65 class cardinal_septic_hermite
66 {
67 public:
68 using Real = typename RandomAccessContainer::value_type;
69 cardinal_septic_hermite(RandomAccessContainer && y, RandomAccessContainer && dydx,
70 RandomAccessContainer && d2ydx2, RandomAccessContainer && d3ydx3, Real x0, Real dx)
71 : impl_(std::make_shared<detail::cardinal_septic_hermite_detail<RandomAccessContainer>>(
72 std::move(y), std::move(dydx), std::move(d2ydx2), std::move(d3ydx3), x0, dx))
73 {}
74
75 inline Real operator()(Real x) const
76 {
77 return impl_->operator()(x);
78 }
79
80 inline Real prime(Real x) const
81 {
82 return impl_->prime(x);
83 }
84
85 inline Real double_prime(Real x) const
86 {
87 return impl_->double_prime(x);
88 }
89
90 int64_t bytes() const
91 {
92 return impl_->bytes() + sizeof(impl_);
93 }
94
95 std::pair<Real, Real> domain() const
96 {
97 return impl_->domain();
98 }
99
100 private:
101 std::shared_ptr<detail::cardinal_septic_hermite_detail<RandomAccessContainer>> impl_;
102 };
103
104
105 template<class RandomAccessContainer>
106 class cardinal_septic_hermite_aos {
107 public:
108 using Point = typename RandomAccessContainer::value_type;
109 using Real = typename Point::value_type;
110 cardinal_septic_hermite_aos(RandomAccessContainer && data, Real x0, Real dx)
111 : impl_(std::make_shared<detail::cardinal_septic_hermite_detail_aos<RandomAccessContainer>>(std::move(data), x0, dx))
112 {}
113
114 inline Real operator()(Real x) const
115 {
116 return impl_->operator()(x);
117 }
118
119 inline Real prime(Real x) const
120 {
121 return impl_->prime(x);
122 }
123
124 inline Real double_prime(Real x) const
125 {
126 return impl_->double_prime(x);
127 }
128
129 int64_t bytes() const
130 {
131 return impl_.size() + sizeof(impl_);
132 }
133
134 std::pair<Real, Real> domain() const
135 {
136 return impl_->domain();
137 }
138
139 private:
140 std::shared_ptr<detail::cardinal_septic_hermite_detail_aos<RandomAccessContainer>> impl_;
141 };
142
143 }
144 }
145 }
146 #endif