1 #ifndef liblogintpack_h 2 #define liblogintpack_h 17 const double centered = (l-lmin)/(lmax-lmin)*
base;
18 int16_t
r=std::ceil(centered);
21 if(x<0) r = r==0 ? -1 : -
r;
26 inline int16_t
pack16log(
double x,
double lmin,
double lmax, uint16_t
base=32768)
31 const double centered = (l-lmin)/(lmax-lmin)*
base;
32 int16_t
r=std::floor(centered);
33 if(centered-r>delta) r+=1;
36 if(x<0) r = r==0 ? -1 : -
r;
46 const double centered = (l-lmin)/(lmax-lmin)*(
base-1);
47 int16_t
r=round(centered);
50 if(x<0) r = r==0 ? -1 : -
r;
58 const double basef=
base;
59 const double l=lmin+
std::abs(i)/basef*(lmax-lmin);
61 if(i<0)
return -
val;
else return val;
68 const double basef=
base-1;
69 double l=lmin+
std::abs(i)/basef*(lmax-lmin);
72 if(i<0)
return -
val;
else return val;
82 const double centered = (l-lmin)/(lmax-lmin)*
base;
83 int8_t
r=std::ceil(centered);
86 if(x<0) r = r==0 ? -1 : -
r;
91 int8_t
pack8log(
double x,
double lmin,
double lmax, uint8_t
base=128)
95 const double centered = (l-lmin)/(lmax-lmin)*
base;
99 if(x<0) r = r==0 ? -1 : -
r;
110 const double centered = (l-lmin)/(lmax-lmin)*(
base-1);
111 int8_t
r=round(centered);
113 if(centered < 0) r=0;
114 if(x<0) r = r==0 ? -1 : -
r;
122 const double basef=
base;
123 const double l=lmin+
std::abs(i)/basef*(lmax-lmin);
125 if(i<0)
return -
val;
else return val;
133 const double basef=
base-1;
134 double l=lmin+
std::abs(i)/basef*(lmax-lmin);
137 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)