Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / math / doc / interpolators / vector_barycentric_rational.qbk
1 [/
2   Copyright 2019 Nick Thompson
3
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).
7 ]
8
9 [section:vector_barycentric Vector-valued Barycentric Rational Interpolation]
10
11 [heading Synopsis]
12
13 ``
14 #include <boost/math/interpolators/vector_barycentric_rational.hpp>
15
16 namespace boost{ namespace math{
17
18 template<class TimeContainer, class SpaceContainer>
19 class vector_barycentric_rational
20 {
21 public:
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);
25
26     void operator()(Point& x, Real t) const;
27
28     Point operator()(Real t) const;
29
30     void prime(Point& dxdt, Real t) const;
31
32     Point prime(Real t);
33
34     void eval_with_prime(Point& x, Point& dxdt, Real t) const;
35
36     std::pair<Point, Point> eval_with_prime(Real t) const;
37 };
38
39 }}
40 ``
41
42 [heading Description]
43
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.
46
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:
50
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));
56
57 To evaluate the interpolant, use
58
59     double t = 2.3;
60     Eigen::Vector2d y = interpolant(t);
61
62 If you want to populate a vector passed into the interpolant, rather than get it returned, that syntax is supported:
63
64     Eigen::Vector2d y;
65     interpolant(y, t);
66
67 We tested this with `Eigen::Vector`s and found no performance benefit, but other `Point`-types might not be the same.
68
69 To evaluate the derivative of the interpolant use
70
71     auto [y, y_prime] = interpolant.eval_with_prime(x);
72
73 Computation of the derivative requires evaluation, so if you can try to use both values at once.
74
75
76 [endsect] [/section:vector_barycentric Vector Barycentric Rational Interpolation]