120 long int a_min = -
std::pow(2, (a_size - 1));
121 long int a_max =
std::pow(2, (a_size - 1)) - 1;
122 long int b_min = -
std::pow(2, (b_size - 1));
123 long int b_max =
std::pow(2, (b_size - 1)) - 1;
125 std::map<int, lut_value> lut;
127 for (
long int x_msb = -(
long int)
std::pow(2, msb_num - 1); x_msb < (
long int)
std::pow(2, msb_num - 1); x_msb++) {
128 int x1 = ((x_msb) << lsb_num);
129 int x2 = ((x_msb + 1) << lsb_num) - 1;
131 double t1 = x1 * in_res - abscissa_0;
132 double t2 = x2 * in_res - abscissa_0;
134 double phi1 =
sgn * atan(t1);
135 double phi2 =
sgn * atan(t2);
137 double y1 = phi1 / out_res;
138 double y2 = phi2 / out_res;
142 double a = (y2 - y1) / (x2 - x1);
152 double t_max_err =
sqrt(
sgn * in_res / out_res / a - 1);
157 double x_max_err = (t_max_err + abscissa_0) / in_res;
158 double phi_max_err =
sgn * atan(t_max_err);
159 double y_max_err = phi_max_err / out_res;
166 double b = (y1 + y_max_err - a * (x_max_err - x1)) / 2;
173 long int a_int = (
long int)(round(a * (
pow(2, a_extra_bits))));
174 long int b_int = (
long int)(round(b * (
pow(2, b_extra_bits))));
177 std::vector<long int> as = {a_min, a_int, a_max};
178 std::vector<long int>
bs = {b_min, b_int, b_max};
180 std::sort(as.begin(), as.end());
181 std::sort(bs.begin(), bs.end());
192 lut[
index] = {a_int, b_int};
int to_two_comp(int val, int size)
Power< A, B >::type pow(const A &a, const B &b)