vector_barycentric_rational.qbk 2.4 KB

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