Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the master branch, built from commit 68cc668162.
PrevUpHomeNext

Vector-valued Barycentric Rational Interpolation

Synopsis

#include <boost/math/interpolators/vector_barycentric_rational.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;

    Point operator()(Real t) const;

    void prime(Point& dxdt, Real t) const;

    Point prime(Real t);

    void eval_with_prime(Point& x, Point& dxdt, Real t) const;

    std::pair<Point, Point> eval_with_prime(Real t) const;
};

}}

Description

The n dimensional vector-valued barycentric rational interpolator is exactly the same as n scalar-valued barycentric rational interpolators. This is provided primarily for convenience and a slight improvement in efficiency over using n different rational interpolators and combining their results.

Use of the class requires a Point-type which has size known at compile-time. These requirements are satisfied by (for example) Eigen::Vector2ds and std::array<Real, N> classes. The call to the constructor computes the weights:

using boost::math::vector_barycentric_rational;
std::vector<double> t(100);
std::vector<Eigen::Vector2d> y(100);
// initialize t and y . . .
vector_barycentric_rational<decltype(t), decltype(y)> interpolant(std::move(t), std::move(y));

To evaluate the interpolant, use

double t = 2.3;
Eigen::Vector2d y = interpolant(t);

If you want to populate a vector passed into the interpolant, rather than get it returned, that syntax is supported:

Eigen::Vector2d y;
interpolant(y, t);

We tested this with Eigen::Vectors and found no performance benefit, but other Point-types might not be the same.

To evaluate the derivative of the interpolant use

auto [y, y_prime] = interpolant.eval_with_prime(x);

Computation of the derivative requires evaluation, so if you can try to use both values at once.


PrevUpHomeNext