Skip to content

Commit

Permalink
Fixing issue #1959
Browse files Browse the repository at this point in the history
Problem was an overflow (inf) that got converted to 0
by "ceil".
  • Loading branch information
Matthias Koefferlein committed Dec 19, 2024
1 parent 9441024 commit 86d2ee6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/tl/tl/tlDataMapping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,13 @@ DataMappingLookupTable::update_table (double xmin, double xmax, double delta_y,
double dx = fabs (t->first - t[-1].first);
double dy = fabs (t->second - t[-1].second);

if (dx * delta_y < delta_x * dy) {
if (dx > 1e-10 && dy > 1e-10 && dx * delta_y < delta_x * dy) {
delta_x = dx / dy * delta_y;
}

}

size_t nsteps = size_t (ceil((xmax - xmin) / delta_x - 1e-6));
size_t nsteps = size_t (ceil ((xmax - xmin) / delta_x - 1e-6));

// Limit the number of interpolation points (this is an arbitrary number - it could be somewhat else)
nsteps = std::min (size_t (16384), nsteps);
Expand All @@ -422,7 +422,9 @@ DataMappingLookupTable::update_table (double xmin, double xmax, double delta_y,

std::vector< std::pair<double, double> >::const_iterator t = table.begin ();
size_t i = 0;
for (double x = xmin; i < nsteps; ++i, x += delta_x) {
double x;
for ( ; i < nsteps; ++i) {
x = xmin + i * delta_x;
while (t != table.end () && t->first <= x) {
++t;
}
Expand Down

0 comments on commit 86d2ee6

Please sign in to comment.