test_interpolate.cxx
Go to the documentation of this file.
2 #include <boost/math/interpolators/cubic_b_spline.hpp>
3 
4 #include <iostream>
5 
6 // https://www.boost.org/doc/libs/1_65_0/libs/math/doc/html/math_toolkit/interpolate/cubic_b.html
7 
8 using namespace WireCell;
9 
10 int main()
11 {
12  std::vector<double> f{0.01, -0.02, 0.3, 0.8, 1.9, -8.78, -22.6};
13  const double xstep = 0.01;
14  const double x0 = xstep;
15  boost::math::cubic_b_spline<double> spline(f.begin(), f.end(), x0, xstep);
16 
17  linterp<double> lin(f.begin(), f.end(), x0, xstep);
18 
19  for (double x = 0; x < x0 + xstep*10; x += 0.1*xstep) {
20  std::cout << std::setprecision(3)
21  << std::fixed << "x=" << x
22  << "\tlin(x)=" << lin(x)
23  << "\tspline(x)=" << spline(x)
24  << "\n";
25  }
26  return 0;
27 }
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
Definition: Main.h:22
list x
Definition: train.py:276
int main()