|
|
Go to the documentation of this file. 1 #ifndef liblogintpack_h
2 #define liblogintpack_h
16 const double centered = (
l - lmin) / (lmax - lmin) *
base;
18 if (centered >=
base - 1)
27 inline int16_t
pack16log(
double x,
double lmin,
double lmax, uint16_t
base = 32768) {
32 const double centered = (
l - lmin) / (lmax - lmin) *
base;
33 int16_t
r = std::floor(centered);
36 if (centered >=
base - 1)
51 const double centered = (
l - lmin) / (lmax - lmin) * (
base - 1);
52 int16_t
r = round(centered);
53 if (centered >=
base - 1)
62 inline double unpack16log(int16_t
i,
double lmin,
double lmax, uint16_t
base = 32768) {
65 const double basef =
base;
66 const double l = lmin +
std::abs(
i) / basef * (lmax - lmin);
78 const double basef =
base - 1;
79 double l = lmin +
std::abs(
i) / basef * (lmax - lmin);
93 const double centered = (
l - lmin) / (lmax - lmin) *
base;
95 if (centered >=
base - 1)
100 r =
r == 0 ? -1 : -
r;
104 inline int8_t
pack8log(
double x,
double lmin,
double lmax, uint8_t
base = 128) {
108 const double centered = (
l - lmin) / (lmax - lmin) *
base;
110 if (centered >=
base - 1)
115 r =
r == 0 ? -1 : -
r;
125 const double centered = (
l - lmin) / (lmax - lmin) * (
base - 1);
126 int8_t
r = round(centered);
127 if (centered >=
base - 1)
132 r =
r == 0 ? -1 : -
r;
139 const double basef =
base;
140 const double l = lmin +
std::abs(
i) / basef * (lmax - lmin);
152 const double basef =
base - 1;
153 double l = lmin +
std::abs(
i) / basef * (lmax - lmin);
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)
constexpr int8_t smallestNegative
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 unpack16logClosed(int16_t i, double lmin, double lmax, uint16_t base=32768)
reverse of pack8logClosed
constexpr int32_t ceil(float num)
double unpack16log(int16_t i, double lmin, double lmax, uint16_t base=32768)
int8_t pack8logCeil(double x, double lmin, double lmax, uint8_t base=128)
constexpr int8_t smallestPositive
int8_t pack8logClosed(double x, double lmin, double lmax, uint8_t base=128)
double unpack8logClosed(int8_t i, double lmin, double lmax, uint8_t base=128)
reverse of pack8logClosed
int16_t pack16logClosed(double x, double lmin, double lmax, uint16_t base=32768)
Abs< T >::type abs(const T &t)