20 const int n = _coords.size();
23 const double dx = _coords[0] - _coords[1];
24 const double dy = _values[0] - _values[1];
25 const double d = x - _coords[1];
26 T result = (dy / dx) * d + _values[1];
29 pyre::journal::error_t errorChannel(
"isce.core.LUT1d");
31 << pyre::journal::at(__HERE__)
32 <<
"Out of bounds evaluation for LUT1d."
33 << pyre::journal::newline
34 << pyre::journal::endl;
37 }
else if (x > _coords[n-1]) {
39 const double dx = _coords[n-1] - _coords[n-2];
40 const double dy = _values[n-1] - _values[n-2];
41 const double d = x - _coords[n-2];
42 T result = (dy / dx) * d + _values[n-2];
45 pyre::journal::error_t errorChannel(
"isce.core.LUT1d");
47 << pyre::journal::at(__HERE__)
48 <<
"Out of bounds evaluation for LUT1d."
49 << pyre::journal::newline
50 << pyre::journal::endl;
58 int high = _coords.size();
60 const int midpoint = (low + high) / 2;
61 if (_coords[midpoint] < x) {
70 pyre::journal::error_t errorChannel(
"isce.core.LUT1d");
72 << pyre::journal::at(__HERE__)
73 <<
"Binary search did not converge."
74 << pyre::journal::newline
75 << pyre::journal::endl;
80 if (std::abs(_coords[high] - x) < 1.0e-12) {
85 const int j0 = high - 1;
89 double x1 = _coords[j0];
90 double x2 = _coords[j1];
93 T result = (x2 - x) / (x2 - x1) * _values[j0] + (x - x1) / (x2 - x1) * _values[j1];
111 if (axis != 0 && axis != 1) {
112 std::string error_msg =
"ERROR axis not equal to 0 or 1";
113 throw isce3::except::InvalidArgument(ISCE_SRCINFO(), error_msg);
117 if (!lut2d.haveData()) {
122 const auto lut1d_size = (axis == 0) ? lut2d.width() : lut2d.length();
123 const double n_to_sum_f = (axis == 0) ?
static_cast<double>(lut2d.length()) :
124 static_cast<double>(lut2d.width());
130 isce3::core::EArray2D<double> ea_values;
133 ea_values = data.map().colwise().sum();
136 ea_values = data.map().rowwise().sum();
137 ea_values /= n_to_sum_f;
140 std::valarray<double> values(0.0, lut1d_size);
141 std::copy(ea_values.data(), ea_values.data() + ea_values.size(), begin(values));
144 std::valarray<double> coords(lut1d_size);
145 for (
size_t j = 0; j < lut1d_size; ++j) {
147 coords[j] = lut2d.xStart() + j * lut2d.xSpacing();
149 coords[j] = lut2d.yStart() + j * lut2d.ySpacing();