Function fast_interpolate

Function Documentation

vector<double> fast_interpolate(const std::vector<double> &x, const std::vector<double> &y, const std::vector<double> &z, double d)

For a curve defined by vectors (x,y), return the values interpolated at points z

Parameters:
  • x – : sorted x vector of the curve

  • y – : y vector of the curve

  • z – : sorted vector of values for which to get the interpolated values from (x,y) curve, if interpolation is possible. Else, return d

  • d – : default value in case of extrapolation This implementation is single pass : O(n + m) time, where n = x.size() and m = z.size(), instead of O(m*log(n)), owing to the assumption that x and z are sorted.