Public Member Functions | List of all members
intrp::BarycentricRational Class Reference

A barycentric rational interpolation class. More...

#include <BarycentricRational.hpp>

Public Member Functions

 BarycentricRational (std::vector< double > x_values, std::vector< double > y_values, size_t order) noexcept
double operator() (double x_to_interp_to) const noexcept
size_t order () const noexcept
void pup (PUP::er &p) noexcept

Detailed Description

A barycentric rational interpolation class.

The class builds a barycentric rational interpolant of a specified order using the x_values and y_values passed into the constructor. Barycentric interpolation requires \(3N\) storage, and costs \(\mathcal{O}(Nd)\) to construct, where \(N\) is the size of the x- and y-value vectors and \(d\) is the order of the interpolant. The evaluation cost is \(\mathcal{O}(N)\) compared to \(\mathcal{O}(d)\) of a spline method, but constructing the barycentric interpolant does not require any derivatives of the function to be known.

The interpolation function is

\[ \mathcal{I}(x)=\frac{\sum_{i=0}^{N-1}w_i y_i / (x-x_i)}{\sum_{i=0}^{N-1}w_i/(x-x_i)} \]

where \(w_i\) are the weights. The weights are computed using

\[ w_k=\sum_{i=k-d\\0\le i < N-d}^{k}(-1)^{i} \prod_{j=i\\j\ne k}^{i+d}\frac{1}{x_k-x_j} \]

Requires: x_values.size() == y_values.size() and x_values_.size() >= order

The documentation for this class was generated from the following file: