1 #ifndef liblogintpack_h
2 #define liblogintpack_h
17 const double centered = (l-lmin)/(lmax-lmin)*
base;
18 int8_t
r=std::ceil(centered);
21 if(x<0) r = r==0 ? -1 : -
r;
25 int8_t
pack8log(
double x,
double lmin,
double lmax, uint8_t
base=128)
29 const double centered = (l-lmin)/(lmax-lmin)*
base;
33 if(x<0) r = r==0 ? -1 : -
r;
43 const double centered = (l-lmin)/(lmax-lmin)*(
base-1);
44 int8_t
r=round(centered);
47 if(x<0) r = r==0 ? -1 : -
r;
55 const double basef=
base;
56 const double l=lmin+
std::abs(i)/basef*(lmax-lmin);
58 if(i<0)
return -val;
else return val;
65 const double basef=
base-1;
66 double l=lmin+
std::abs(i)/basef*(lmax-lmin);
69 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)
constexpr int8_t smallestNegative
int8_t pack8logCeil(double x, double lmin, double lmax, uint8_t base=128)
int8_t pack8logClosed(double x, double lmin, double lmax, uint8_t base=128)
Abs< T >::type abs(const T &t)
constexpr int8_t smallestPositive
double unpack8logClosed(int8_t i, double lmin, double lmax, uint8_t base=128)
reverse of pack8logClosed