-
Notifications
You must be signed in to change notification settings - Fork 11
/
AhTranslatorFunction.h
33 lines (25 loc) · 959 Bytes
/
AhTranslatorFunction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* AhTranslatorFunction.h
*
* Created on: Aug 22, 2012
* Author: herten
*/
#ifndef AHTRANSLATORFUNCTION_H_
#define AHTRANSLATORFUNCTION_H_
#include <functional>
class AhTranslatorFunction : public std::unary_function<int,int> {
public:
AhTranslatorFunction(double _inverseWidthOfCell, double _firstValue) : inverseWidthOfCell(_inverseWidthOfCell),
firstValue(_firstValue) {};
// Overloaded operators, see each description
__device__ int operator() (const double &value) const { //< operator to translate from continuous double space into matrix suitable int space
return ((value - firstValue) * inverseWidthOfCell);
}
__device__ double operator() (const int &value) const { //< opoerator to REtranslate ready-calculated integer matrix values into old-bordered double space
return ((value + firstValue) / inverseWidthOfCell);
}
private:
double inverseWidthOfCell;
double firstValue;
};
#endif /* AHTRANSLATORFUNCTION_H_ */