?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/math.zip
???????
PK �^�[��2 2 - interpolators/vector_barycentric_rational.hppnu �[��� /* * Copyright Nick Thompson, 2019 * 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) * * Exactly the same as barycentric_rational.hpp, but delivers values in $\mathbb{R}^n$. * In some sense this is trivial, since each component of the vector is computed in exactly the same * as would be computed by barycentric_rational.hpp. But this is a bit more efficient and convenient. */ #ifndef BOOST_MATH_INTERPOLATORS_VECTOR_BARYCENTRIC_RATIONAL_HPP #define BOOST_MATH_INTERPOLATORS_VECTOR_BARYCENTRIC_RATIONAL_HPP #include <memory> #include <boost/math/interpolators/detail/vector_barycentric_rational_detail.hpp> namespace boost{ namespace math{ template<class TimeContainer, class SpaceContainer> class vector_barycentric_rational { public: using Real = typename TimeContainer::value_type; using Point = typename SpaceContainer::value_type; vector_barycentric_rational(TimeContainer&& times, SpaceContainer&& points, size_t approximation_order = 3); void operator()(Point& x, Real t) const; // I have validated using google benchmark that returning a value is no more expensive populating it, // at least for Eigen vectors with known size at compile-time. // This is kinda a weird thing to discover since it goes against the advice of basically every high-performance computing book. Point operator()(Real t) const { Point p; this->operator()(p, t); return p; } void prime(Point& dxdt, Real t) const { Point x; m_imp->eval_with_prime(x, dxdt, t); } Point prime(Real t) const { Point p; this->prime(p, t); return p; } void eval_with_prime(Point& x, Point& dxdt, Real t) const { m_imp->eval_with_prime(x, dxdt, t); return; } std::pair<Point, Point> eval_with_prime(Real t) const { Point x; Point dxdt; m_imp->eval_with_prime(x, dxdt, t); return {x, dxdt}; } private: std::shared_ptr<detail::vector_barycentric_rational_imp<TimeContainer, SpaceContainer>> m_imp; }; template <class TimeContainer, class SpaceContainer> vector_barycentric_rational<TimeContainer, SpaceContainer>::vector_barycentric_rational(TimeContainer&& times, SpaceContainer&& points, size_t approximation_order): m_imp(std::make_shared<detail::vector_barycentric_rational_imp<TimeContainer, SpaceContainer>>(std::move(times), std::move(points), approximation_order)) { return; } template <class TimeContainer, class SpaceContainer> void vector_barycentric_rational<TimeContainer, SpaceContainer>::operator()(typename SpaceContainer::value_type& p, typename TimeContainer::value_type t) const { m_imp->operator()(p, t); return; } }} #endif PK �^�[���mQ Q interpolators/cubic_b_spline.hppnu �[��� // Copyright Nick Thompson, 2017 // 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) // This implements the compactly supported cubic b spline algorithm described in // Kress, Rainer. "Numerical analysis, volume 181 of Graduate Texts in Mathematics." (1998). // Splines of compact support are faster to evaluate and are better conditioned than classical cubic splines. // Let f be the function we are trying to interpolate, and s be the interpolating spline. // The routine constructs the interpolant in O(N) time, and evaluating s at a point takes constant time. // The order of accuracy depends on the regularity of the f, however, assuming f is // four-times continuously differentiable, the error is of O(h^4). // In addition, we can differentiate the spline and obtain a good interpolant for f'. // The main restriction of this method is that the samples of f must be evenly spaced. // Look for barycentric rational interpolation for non-evenly sampled data. // Properties: // - s(x_j) = f(x_j) // - All cubic polynomials interpolated exactly #ifndef BOOST_MATH_INTERPOLATORS_CUBIC_B_SPLINE_HPP #define BOOST_MATH_INTERPOLATORS_CUBIC_B_SPLINE_HPP #include <boost/math/interpolators/detail/cubic_b_spline_detail.hpp> #include <boost/config/header_deprecated.hpp> BOOST_HEADER_DEPRECATED("<boost/math/interpolators/cardinal_cubic_b_spline.hpp>"); namespace boost{ namespace math{ template <class Real> class cubic_b_spline { public: // If you don't know the value of the derivative at the endpoints, leave them as nans and the routine will estimate them. // f[0] = f(a), f[length -1] = b, step_size = (b - a)/(length -1). template <class BidiIterator> cubic_b_spline(const BidiIterator f, BidiIterator end_p, Real left_endpoint, Real step_size, Real left_endpoint_derivative = std::numeric_limits<Real>::quiet_NaN(), Real right_endpoint_derivative = std::numeric_limits<Real>::quiet_NaN()); cubic_b_spline(const Real* const f, size_t length, Real left_endpoint, Real step_size, Real left_endpoint_derivative = std::numeric_limits<Real>::quiet_NaN(), Real right_endpoint_derivative = std::numeric_limits<Real>::quiet_NaN()); cubic_b_spline() = default; Real operator()(Real x) const; Real prime(Real x) const; Real double_prime(Real x) const; private: std::shared_ptr<detail::cubic_b_spline_imp<Real>> m_imp; }; template<class Real> cubic_b_spline<Real>::cubic_b_spline(const Real* const f, size_t length, Real left_endpoint, Real step_size, Real left_endpoint_derivative, Real right_endpoint_derivative) : m_imp(std::make_shared<detail::cubic_b_spline_imp<Real>>(f, f + length, left_endpoint, step_size, left_endpoint_derivative, right_endpoint_derivative)) { } template <class Real> template <class BidiIterator> cubic_b_spline<Real>::cubic_b_spline(BidiIterator f, BidiIterator end_p, Real left_endpoint, Real step_size, Real left_endpoint_derivative, Real right_endpoint_derivative) : m_imp(std::make_shared<detail::cubic_b_spline_imp<Real>>(f, end_p, left_endpoint, step_size, left_endpoint_derivative, right_endpoint_derivative)) { } template<class Real> Real cubic_b_spline<Real>::operator()(Real x) const { return m_imp->operator()(x); } template<class Real> Real cubic_b_spline<Real>::prime(Real x) const { return m_imp->prime(x); } template<class Real> Real cubic_b_spline<Real>::double_prime(Real x) const { return m_imp->double_prime(x); } }} #endif PK �^�[|�uP P ! interpolators/quintic_hermite.hppnu �[��� /* * 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_QUINTIC_HERMITE_HPP #define BOOST_MATH_INTERPOLATORS_QUINTIC_HERMITE_HPP #include <algorithm> #include <stdexcept> #include <memory> #include <boost/math/interpolators/detail/quintic_hermite_detail.hpp> namespace boost { namespace math { namespace interpolators { template<class RandomAccessContainer> class quintic_hermite { public: using Real = typename RandomAccessContainer::value_type; quintic_hermite(RandomAccessContainer && x, RandomAccessContainer && y, RandomAccessContainer && dydx, RandomAccessContainer && d2ydx2) : impl_(std::make_shared<detail::quintic_hermite_detail<RandomAccessContainer>>(std::move(x), std::move(y), std::move(dydx), std::move(d2ydx2))) {} Real operator()(Real x) const { return impl_->operator()(x); } Real prime(Real x) const { return impl_->prime(x); } Real double_prime(Real x) const { return impl_->double_prime(x); } friend std::ostream& operator<<(std::ostream & os, const quintic_hermite & m) { os << *m.impl_; return os; } void push_back(Real x, Real y, Real dydx, Real d2ydx2) { impl_->push_back(x, y, dydx, d2ydx2); } int64_t bytes() const { return impl_->bytes() + sizeof(impl_); } std::pair<Real, Real> domain() const { return impl_->domain(); } private: std::shared_ptr<detail::quintic_hermite_detail<RandomAccessContainer>> impl_; }; template<class RandomAccessContainer> class cardinal_quintic_hermite { public: using Real = typename RandomAccessContainer::value_type; cardinal_quintic_hermite(RandomAccessContainer && y, RandomAccessContainer && dydx, RandomAccessContainer && d2ydx2, Real x0, Real dx) : impl_(std::make_shared<detail::cardinal_quintic_hermite_detail<RandomAccessContainer>>(std::move(y), std::move(dydx), std::move(d2ydx2), 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_quintic_hermite_detail<RandomAccessContainer>> impl_; }; template<class RandomAccessContainer> class cardinal_quintic_hermite_aos { public: using Point = typename RandomAccessContainer::value_type; using Real = typename Point::value_type; cardinal_quintic_hermite_aos(RandomAccessContainer && data, Real x0, Real dx) : impl_(std::make_shared<detail::cardinal_quintic_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_->bytes() + sizeof(impl_); } std::pair<Real, Real> domain() const { return impl_->domain(); } private: std::shared_ptr<detail::cardinal_quintic_hermite_detail_aos<RandomAccessContainer>> impl_; }; } } } #endif PK �^�[[z�b� � &