28 T num_segments =
static_cast<T
>(
values.size() - 1);
29 int64_t index =
static_cast<int64_t
>(x * num_segments);
31 T step = T(1) / num_segments;
32 T prev =
static_cast<T
>(index) * step;
33 T curr =
static_cast<T
>(index + 1) * step;
34 T t = (x - prev) / (curr - prev);
35 return interpolate_linear(
values[index],
values[index + 1], t);
The interval template represents a closed interval of two numbers, i.e.
Template class representing a regularly (equidistant breakpoints) sampled piecewise linear function/a...
interval< T > domain
The domain (range of input values) of the function.
T evaluate(T x) const
Return the function value at position x.
std::vector< T > values
The sample values of the function evenly spread over the domain.