Class CubicSplineInterpolant

Class Documentation

class CubicSplineInterpolant

Public Functions

CubicSplineInterpolant(Eigen::VectorXd const &x_vec, Eigen::VectorXd const &y_vec)

Performs cubic interpolation (or maximum degree possible, where inputs are shorter than 4 elements)

Initialise an interpolant as follows:

Eigen::VectorXd xvals(3); Eigen::VectorXd yvals(xvals.rows());

xvals << 0, 15, 30; yvals << 0, 12, 17;

CubicSplineInterpolant s(xvals, yvals);

double operator()(double xi) const

Evaluate interpolant at values xi whose yi values are unknown.

Performs cubic interpolation (or maximum degree possible, where inputs are shorter than 4 elements)

Initialise and evaluate an interpolant:

// … Initialise interpolant (see constructor) … CubicSplineInterpolant s(xvals, yvals); std::cout << s(12.34) << std::endl;

Return
double interpolated value yi corresponding to location xi
Parameters
  • xi: double (or eigen VectorXd) of target x values for the interpolation

Eigen::VectorXd operator()(Eigen::VectorXd const &xi_vec)