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