41 #include <drain/Type.h>
42 #include <drain/TypeUtils.h>
61 class LookUp :
public std::vector<T> {
77 LookUp2(
size_t size,
double scale=1.0) : std::vector<T>(size), max(getScale()), scale(scale*
static_cast<double>(max)), scaleInv(1.0/this->scale) {
79 throw std::runtime_error(
"LookUp: scale=0.0 not allowed.");
88 const double scaleInv;
90 double getScaled(
size_t i)
const {
91 return scaleInv * (*this)[i];
94 void putScaled(
size_t i,
double value){
95 (*this)[i] = scale * value;
104 return Type::call<drain::typeIsInteger>(
typeid(T)) ? Type::call<drain::typeMax,double>(
typeid(T)) : 1.0;
120 template <
class T,
class F>
124 FunctorLookUp(
size_t size,
double scale,
double scaleIndex = 1.0,
double offsetIndex=0.0) :
LookUp2<T>(size, scale), scaleIndex(scaleIndex), offsetIndex(offsetIndex) {
128 const double scaleIndex;
130 const double offsetIndex;
138 const size_t n = std::vector<T>::size();
139 const double coeff = scaleIndex/
static_cast<double>(n);
140 for (
size_t i=0; i<n; ++i)
141 this->putScaled(i, functor(offsetIndex + coeff*
static_cast<double>(i)));
Values are available from [0,2PI].
Definition: LookUp.h:121
Look-up tables.
Definition: LookUp.h:74
Look-up tables.
Definition: LookUp.h:61
Definition: DataSelector.cpp:1277