SpECTRE  v2025.03.17
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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)
 
double operator() (double x_to_interp_to) const
 
const std::vector< double > & x_values () const
 
const std::vector< double > & y_values () const
 
size_t order () const
 
void pup (PUP::er &p)
 

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 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 O(N) compared to 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

I(x)=i=0N1wiyi/(xxi)i=0N1wi/(xxi)

where wi are the weights. The weights are computed using

wk=i=kd0i<Ndk(1)ij=ijki+d1xkxj

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


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