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