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

Parameters:

x – value at which to interpolate

Returns:

corresponding interpolated y value

Vector operator()(Vector v) const

defines interpolation for a Vector of values

Parameters:

v – values at which to interpolate

Returns:

corresponding interpolated values

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

defines interpolation for a std::vector of values

Parameters:

v – values at which to interpolate

Returns:

corresponding interpolated values

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

defines 2D interpolation at x and y

Parameters:
  • x – value at which to interpolate

  • y – value at which to interpolate

Returns:

corresponding interpolated value

Private Functions

void Setup()

Check if vector lengths match and values are sorted ascendingly.

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

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

inline double EvalCubic1DSpline(double param[4], double x) const
Returns:

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)