33 #ifndef PLANCK_LINEAR_MAP_H 34 #define PLANCK_LINEAR_MAP_H 41 template<
typename T>
class linearMap
45 std::vector<double> x;
49 void addVal (
double x_,
const T &val)
51 sorted=x.empty()||(x_>x.back());
59 std::vector<size_t> idx;
68 x.clear(); y.clear(); sorted=
true;
71 T getVal_const (
double x_)
const 75 if (x.size()==1)
return y[0];
83 return (1.-frac)*y[index]+frac*y[index+1];
87 if (!sorted) sortMap();
88 return getVal_const(x_);
91 size_t size()
const {
return x.size(); }
92 double getX (
size_t idx) {
if (!sorted) sortMap();
return x[idx]; }
93 T getY (
size_t idx) {
if (!sorted) sortMap();
return y[idx]; }
void buildIndex(It begin, It end, std::vector< T2 > &idx, Comp comp)
void sortByIndex(It begin, It end, const std::vector< T2 > &idx)
#define planck_assert(testval, msg)
void interpol_helper(const Iter &begin, const Iter &end, const T &val, Comp comp, tsize &idx, T &frac)