2 Copyright 2019 Nick Thompson
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
9 [section:vector_barycentric Vector-valued Barycentric Rational Interpolation]
14 #include <boost/math/interpolators/vector_barycentric_rational.hpp>
16 namespace boost{ namespace math{
18 template<class TimeContainer, class SpaceContainer>
19 class vector_barycentric_rational
22 using Real = typename TimeContainer::value_type;
23 using Point = typename SpaceContainer::value_type;
24 vector_barycentric_rational(TimeContainer&& times, SpaceContainer&& points, size_t approximation_order = 3);
26 void operator()(Point& x, Real t) const;
28 Point operator()(Real t) const;
30 void prime(Point& dxdt, Real t) const;
34 void eval_with_prime(Point& x, Point& dxdt, Real t) const;
36 std::pair<Point, Point> eval_with_prime(Real t) const;
44 The /n/ dimensional vector-valued barycentric rational interpolator is exactly the same as /n/ scalar-valued barycentric rational interpolators.
45 This is provided primarily for convenience and a slight improvement in efficiency over using /n/ different rational interpolators and combining their results.
47 Use of the class requires a `Point`-type which has size known at compile-time.
48 These requirements are satisfied by (for example) `Eigen::Vector2d`s and `std::array<Real, N>` classes.
49 The call to the constructor computes the weights:
51 using boost::math::vector_barycentric_rational;
52 std::vector<double> t(100);
53 std::vector<Eigen::Vector2d> y(100);
54 // initialize t and y . . .
55 vector_barycentric_rational<decltype(t), decltype(y)> interpolant(std::move(t), std::move(y));
57 To evaluate the interpolant, use
60 Eigen::Vector2d y = interpolant(t);
62 If you want to populate a vector passed into the interpolant, rather than get it returned, that syntax is supported:
67 We tested this with `Eigen::Vector`s and found no performance benefit, but other `Point`-types might not be the same.
69 To evaluate the derivative of the interpolant use
71 auto [y, y_prime] = interpolant.eval_with_prime(x);
73 Computation of the derivative requires evaluation, so if you can try to use both values at once.
76 [endsect] [/section:vector_barycentric Vector Barycentric Rational Interpolation]