10 #ifndef SRC_INCLUDE_SMASH_INTERPOLATION_H_ 
   11 #define SRC_INCLUDE_SMASH_INTERPOLATION_H_ 
   13 #include <gsl/gsl_errno.h> 
   14 #include <gsl/gsl_spline.h> 
   88   std::vector<InterpolateLinear<T>> 
f_;
 
   94   slope_ = (y1 - y0) / (x1 - x0);
 
   95   yintercept_ = y0 - slope_ * x0;
 
  100   return slope_ * x + yintercept_;
 
  125 template <
typename T>
 
  128   T res = az * (ax * (ay * f8 + (1.0 - ay) * f6) +
 
  129                 (1.0 - ax) * (ay * f7 + (1.0 - ay) * f5)) +
 
  130           (1 - az) * (ax * (ay * f4 + (1.0 - ay) * f2) +
 
  131                       (1.0 - ax) * (ay * f3 + (1.0 - ay) * f1));
 
  146 template <
typename T, 
typename Cmp>
 
  149   std::iota(
p.begin(), 
p.end(), 0);
 
  150   std::sort(
p.begin(), 
p.end(),
 
  151             [&](
size_t i, 
size_t j) { return compare(v[i], v[j]); });
 
  163 template <
typename T>
 
  166   std::vector<T> copied_v = v;
 
  167   std::transform(
p.begin(), 
p.end(), copied_v.begin(),
 
  168                  [&](
size_t i) { return v[i]; });
 
  182 template <
typename T>
 
  184                       const std::string& error_position) {
 
  185   auto it = std::adjacent_find(x.begin(), x.end());
 
  187     std::stringstream error_msg;
 
  188     error_msg << error_position << 
": Each x value must be unique. \"" << *it
 
  189               << 
"\" was found twice.";
 
  190     throw std::runtime_error(error_msg.str());
 
  194 template <
typename T>
 
  196                                                 const std::vector<T>& y) {
 
  197   assert(x.size() == y.size());
 
  198   const size_t n = x.size();
 
  200       x, [&](T 
const& a, T 
const& b) { 
return a < b; });
 
  205   for (
size_t i = 0; i < 
n - 1; i++) {
 
  229 template <
typename T>
 
  231   const auto it = std::lower_bound(v.begin(), v.end(), x);
 
  232   if (it == v.begin()) {
 
  235     return it - 1 - v.begin();
 
  239 template <
typename T>
 
  243   if (i >= f_.size()) {
 
  266                         const std::vector<double>& y);
 
Represent a piecewise linear interpolation.
 
std::vector< InterpolateLinear< T > > f_
Piecewise linear interpolation using f(x_i)
 
T operator()(T x) const
Calculate spline interpolation at x.
 
InterpolateDataLinear(const std::vector< T > &x, const std::vector< T > &y)
Interpolate function f given discrete samples f(x_i) = y_i.
 
Represent a cubic spline interpolation.
 
double first_x_
First x value.
 
gsl_spline * spline_
GSL spline.
 
InterpolateDataSpline(const std::vector< double > &x, const std::vector< double > &y)
Interpolate function f given discrete samples f(x_i) = y_i.
 
~InterpolateDataSpline()
Destructor.
 
double last_y_
Last y value.
 
double operator()(double x) const
Calculate spline interpolation at x.
 
double first_y_
First y value.
 
gsl_interp_accel * acc_
GSL iterator for interpolation lookups.
 
double last_x_
Last x value.
 
Represent a linear interpolation.
 
T yintercept_
y-axis intercept of the linear interpolation.
 
T operator()(T x) const
Calculate spline interpolation at x.
 
T slope_
Slope of the linear interpolation.
 
InterpolateLinear(T x0, T y0, T x1, T y1)
Linear interpolation given two points (x0, y0) and (x1, y1).
 
size_t find_index(const std::vector< T > &v, T x)
Find the index in v that corresponds to the last value strictly smaller than x.
 
std::vector< T > apply_permutation(const std::vector< T > &v, const Permutation &p)
Apply a permutation to a vector.
 
void check_duplicates(const std::vector< T > &x, const std::string &error_position)
Check whether two components have the same value in a sorted vector x.
 
T interpolate_trilinear(T ax, T ay, T az, T f1, T f2, T f3, T f4, T f5, T f6, T f7, T f8)
Perform a trilinear 1st order interpolation.
 
Permutation generate_sort_permutation(std::vector< T > const &v, Cmp compare)
Calculate the permutations necessary for sorting a vector.
 
std::vector< size_t > Permutation
Represent a permutation.