Interpolation

class Interpolation

Public Functions

Interpolation(const std::vector<double> &x, const std::vector<double> &y, TYPE type = linear)

constructor linear interpolation for std::vector input

Parameters
  • x: table values for x

  • y: table values for y

  • type: linear or cubic interpolation

Interpolation(const Vector &x, const Vector &y, TYPE type = linear)

constructor linear interpolation for Vector input

Parameters
  • x: table values for x

  • y: table values for y

  • type: linear or cubic interpolation

Interpolation(const Vector &x, const Vector &y, const Matrix &data, TYPE type = cubic)

constructor cubic interpolation

Parameters
  • x: table values for x

  • y: table values for y

  • data: matrix w.r.t x y grid

  • type: of interpolation (linear, loglinear, cubic)

double operator()(double x) const

defines one dimensional interpolation at x

Return

corresponding interpolated y value

Parameters
  • x: value at which to interpolate

Vector operator()(Vector v) const

defines interpolation for a Vector of values

Return

corresponding interpolated values

Parameters
  • v: values at which to interpolate

std::vector<double> operator()(std::vector<double> v) const

defines interpolation for a std::vector of values

Return

corresponding interpolated values

Parameters
  • v: values at which to interpolate

double operator()(double x, double y) const

defines 2D interpolation at x and y

Return

corresponding interpolated value

Parameters
  • x: value at which to interpolate

  • y: value at which to interpolate

Private Functions

void Setup()

Check if vector lengths match and values are sorted ascendingly.

unsigned IndexOfClosestValue(double value, const Vector &v) const

Return

index of element closest to ‘value’ in ‘v’

double EvalCubic1DSpline(double param[4], double x) const

Return

value of third degree/cubic polynomial with parameters ‘param’ at ‘x’

Private Members

Vector _x

x input data

Vector _y

y input data

Matrix _data

data matrix w.r.t. x and y grid

TYPE _type

type of interpolation (linear, loglinear, cubic)