/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/util/include/RAT/LinearInterp.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/util/include/RAT/LinearInterp.hh Source File
Ratpac-two
LinearInterp.hh
1 #ifndef __RAT_LinearInterp__
2 #define __RAT_LinearInterp__
3 
4 #include <vector>
5 
6 namespace RAT {
7 
8 template <class NumType>
9 class LinearInterp {
10  public:
11  LinearInterp() { npoints = 0; };
12  LinearInterp(int _npoints, const NumType _x[], const NumType _y[]) { Set(_npoints, _x, _y); };
13  LinearInterp(const std::vector<NumType> &_x, const std::vector<NumType> &_y) { Set(_x, _y); };
14 
15  void Set(int _npoints, const NumType _x[], const NumType _y[]);
16  void Set(const std::vector<NumType> &_x, const std::vector<NumType> &_y) {
17  npoints = _x.size();
18  x = _x;
19  y = _y;
20  };
21 
22  NumType operator()(const NumType xeval) const;
23 
24  NumType Min() { return x.front(); };
25  NumType Max() { return x.back(); };
26  int Points() { return npoints; };
27 
28  class RangeError {
29  public:
30  RangeError(const NumType _xlow, const NumType _xhigh, const NumType _xeval)
31  : xlow(_xlow), xhigh(_xhigh), xeval(_xeval){/* no-op */};
32  bool operator==(const RangeError &other) const {
33  return xlow == other.xlow && xhigh == other.xhigh && xeval == other.xeval;
34  };
35  NumType xlow, xhigh, xeval;
36  };
37 
38  protected:
39  int LowerElement(const NumType xeval) const;
40 
41  int npoints;
42  std::vector<NumType> x, y;
43 };
44 
45 #include "LinearInterp.icc"
46 
47 } // namespace RAT
48 
49 #endif
Definition: LinearInterp.hh:28
Definition: LinearInterp.hh:9
Definition: CCCrossSecMessenger.hh:29