10 #define INTERPOLATE_H_
30 template <
typename T,
typename U>
34 int bound_delta = upper_bound - lower_bound;
37 int new_bound = floor(bound_delta / 2.0) + lower_bound;
41 return std::numeric_limits<int>::max();
48 else if (pt <= x[new_bound])
68 template <
typename T,
typename U,
typename P>
89 else if (pt >= x[length-1])
98 double m = (y[index] - y[index-1]) / (x[index] - x[index-1]);
101 y_pt = m * (pt - x[index]) + y[index];
int findUpperIndex(T *x, int upper_bound, int lower_bound, U pt)
This function finds the index of the first element in an array that is greater than the given paramet...
Definition: interpolate.h:31
P linearInterp(T *x, T *y, int length, U pt)
This function takes in the x and y values of a 1D function and returns the linearly interpolated y va...
Definition: interpolate.h:69