Class LinearInterpolator#

Inheritance Relationships#

Base Type#

Class Documentation#

class LinearInterpolator : public Karana::Math::BaseInterpolator#

Piecewise linear interpolation method

Public Types

enum class Extrapolation#

How to extrapolate when sampling past the given data points

Values:

enumerator CONSTANT#

Use the value of the boundary data point.

enumerator LINEAR#

Linearly extend from the boundary point.

Public Functions

LinearInterpolator(ConstVecSlice indep, ConstVecSlice dep, std::optional<Extrapolation> extrapolation = std::nullopt)#

LinearInterpolator constructor.

Parameters:
  • indep – Monotonically increasing independent variable values

  • dep – Corresponding dependent variable values

  • extrapolation – How to extrapolate outside the data points. If omitted, extrapolated values are NaN.

virtual double operator()(double x) const override#

Sample the dependent variable.

Parameters:

x – A value for the independent variable

Returns:

The corresponding value for the dependent variable

virtual void operator()(ConstVecSlice x, VecSlice out) const#

Sample the dependent variable at multiple values.

Parameters:
  • x – A vector containing values for the independent variable

  • out – A matching sized vector to contain the result

virtual Vec operator()(ConstVecSlice x) const#

Sample the dependent variable at multiple values.

Parameters:

x – A vector containing values for the independent variable

Returns:

A corresponding vector of dependent variable values