Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright Nick Thompson, 2020
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_CUBIC_HERMITE_HPP
0008 #define BOOST_MATH_INTERPOLATORS_CUBIC_HERMITE_HPP
0009 #include <memory>
0010 #include <boost/math/interpolators/detail/cubic_hermite_detail.hpp>
0011 
0012 namespace boost {
0013 namespace math {
0014 namespace interpolators {
0015 
0016 template<class RandomAccessContainer>
0017 class cubic_hermite {
0018 public:
0019     using Real = typename RandomAccessContainer::value_type;
0020 
0021     cubic_hermite(RandomAccessContainer && x, RandomAccessContainer && y, RandomAccessContainer && dydx) 
0022     : impl_(std::make_shared<detail::cubic_hermite_detail<RandomAccessContainer>>(std::move(x), std::move(y), std::move(dydx)))
0023     {}
0024 
0025     inline Real operator()(Real x) const {
0026         return impl_->operator()(x);
0027     }
0028 
0029     inline Real prime(Real x) const {
0030         return impl_->prime(x);
0031     }
0032 
0033     friend std::ostream& operator<<(std::ostream & os, const cubic_hermite & m)
0034     {
0035         os << *m.impl_;
0036         return os;
0037     }
0038 
0039     void push_back(Real x, Real y, Real dydx)
0040     {
0041         impl_->push_back(x, y, dydx);
0042     }
0043 
0044     int64_t bytes() const
0045     {
0046         return impl_->bytes() + sizeof(impl_);
0047     }
0048 
0049     std::pair<Real, Real> domain() const
0050     {
0051         return impl_->domain();
0052     }
0053 
0054 private:
0055     std::shared_ptr<detail::cubic_hermite_detail<RandomAccessContainer>> impl_;
0056 };
0057 
0058 template<class RandomAccessContainer>
0059 class cardinal_cubic_hermite {
0060 public:
0061     using Real = typename RandomAccessContainer::value_type;
0062 
0063     cardinal_cubic_hermite(RandomAccessContainer && y, RandomAccessContainer && dydx, Real x0, Real dx) 
0064     : impl_(std::make_shared<detail::cardinal_cubic_hermite_detail<RandomAccessContainer>>(std::move(y), std::move(dydx), x0, dx))
0065     {}
0066 
0067     inline Real operator()(Real x) const
0068     {
0069         return impl_->operator()(x);
0070     }
0071 
0072     inline Real prime(Real x) const
0073     {
0074         return impl_->prime(x);
0075     }
0076 
0077     friend std::ostream& operator<<(std::ostream & os, const cardinal_cubic_hermite & m)
0078     {
0079         os << *m.impl_;
0080         return os;
0081     }
0082 
0083     int64_t bytes() const
0084     {
0085         return impl_->bytes() + sizeof(impl_);
0086     }
0087 
0088     std::pair<Real, Real> domain() const
0089     {
0090         return impl_->domain();
0091     }
0092 
0093 private:
0094     std::shared_ptr<detail::cardinal_cubic_hermite_detail<RandomAccessContainer>> impl_;
0095 };
0096 
0097 
0098 template<class RandomAccessContainer>
0099 class cardinal_cubic_hermite_aos {
0100 public:
0101     using Point = typename RandomAccessContainer::value_type;
0102     using Real = typename Point::value_type;
0103 
0104     cardinal_cubic_hermite_aos(RandomAccessContainer && data, Real x0, Real dx) 
0105     : impl_(std::make_shared<detail::cardinal_cubic_hermite_detail_aos<RandomAccessContainer>>(std::move(data), x0, dx))
0106     {}
0107 
0108     inline Real operator()(Real x) const
0109     {
0110         return impl_->operator()(x);
0111     }
0112 
0113     inline Real prime(Real x) const
0114     {
0115         return impl_->prime(x);
0116     }
0117 
0118     friend std::ostream& operator<<(std::ostream & os, const cardinal_cubic_hermite_aos & m)
0119     {
0120         os << *m.impl_;
0121         return os;
0122     }
0123 
0124     int64_t bytes() const
0125     {
0126         return impl_->bytes() + sizeof(impl_);
0127     }
0128 
0129     std::pair<Real, Real> domain() const
0130     {
0131         return impl_->domain();
0132     }
0133 
0134 private:
0135     std::shared_ptr<detail::cardinal_cubic_hermite_detail_aos<RandomAccessContainer>> impl_;
0136 };
0137 
0138 }
0139 }
0140 }
0141 #endif