1 #ifndef liblogintpack_h 2 #define liblogintpack_h 16 const double centered = (l-lmin)/(lmax-lmin)*
base;
17 int16_t
r=std::ceil(centered);
20 if(x<0) r = r==0 ? -1 : -
r;
25 inline int16_t
pack16log(
double x,
double lmin,
double lmax, uint16_t
base=32768)
30 const double centered = (l-lmin)/(lmax-lmin)*
base;
31 int16_t
r=std::floor(centered);
32 if(centered-r>delta) r+=1;
35 if(x<0) r = r==0 ? -1 : -
r;
45 const double centered = (l-lmin)/(lmax-lmin)*(
base-1);
46 int16_t
r=round(centered);
49 if(x<0) r = r==0 ? -1 : -
r;
57 const double basef=
base;
58 const double l=lmin+
std::abs(i)/basef*(lmax-lmin);
60 if(i<0)
return -
val;
else return val;
67 const double basef=
base-1;
68 double l=lmin+
std::abs(i)/basef*(lmax-lmin);
71 if(i<0)
return -
val;
else return val;
81 const double centered = (l-lmin)/(lmax-lmin)*
base;
82 int8_t
r=std::ceil(centered);
85 if(x<0) r = r==0 ? -1 : -
r;
90 int8_t
pack8log(
double x,
double lmin,
double lmax, uint8_t
base=128)
94 const double centered = (l-lmin)/(lmax-lmin)*
base;
98 if(x<0) r = r==0 ? -1 : -
r;
109 const double centered = (l-lmin)/(lmax-lmin)*(
base-1);
110 int8_t
r=round(centered);
112 if(centered < 0) r=0;
113 if(x<0) r = r==0 ? -1 : -
r;
121 const double basef=
base;
122 const double l=lmin+
std::abs(i)/basef*(lmax-lmin);
124 if(i<0)
return -
val;
else return val;
132 const double basef=
base-1;
133 double l=lmin+
std::abs(i)/basef*(lmax-lmin);
136 if(i<0)
return -
val;
else return val;
double unpack8log(int8_t i, double lmin, double lmax, uint8_t base=128)
int8_t pack8log(double x, double lmin, double lmax, uint8_t base=128)
double unpack16log(int16_t i, double lmin, double lmax, uint16_t base=32768)
constexpr int8_t smallestNegative
int8_t pack8logCeil(double x, double lmin, double lmax, uint8_t base=128)
double unpack16logClosed(int16_t i, double lmin, double lmax, uint16_t base=32768)
reverse of pack8logClosed
int8_t pack8logClosed(double x, double lmin, double lmax, uint8_t base=128)
int16_t pack16logClosed(double x, double lmin, double lmax, uint16_t base=32768)
Abs< T >::type abs(const T &t)
base
Make Sure CMSSW is Setup ##.
constexpr int8_t smallestPositive
double unpack8logClosed(int8_t i, double lmin, double lmax, uint8_t base=128)
reverse of pack8logClosed
int16_t pack16log(double x, double lmin, double lmax, uint16_t base=32768)
int16_t pack16logCeil(double x, double lmin, double lmax, uint16_t base=32768)