Skip to content
Snippets Groups Projects
Commit 205166bb authored by Ke Liu's avatar Ke Liu
Browse files

Fix bug: division by zero for N=1 (line|log)_scan

parent 179e7fb1
No related branches found
No related tags found
No related merge requests found
......@@ -66,7 +66,7 @@ namespace sweep {
bool yield (point_type & point) {
auto it_a = a.begin();
auto it_b = b.begin();
double x = 1. * n / (N - 1);
double x = (N == 1) ? 0. : 1. * n / (N - 1);
for (auto & c : point) {
c = *it_b * x + *it_a * (1. - x);
++it_a, ++it_b;
......
......@@ -78,10 +78,11 @@ namespace sweep {
for (size_t i = 0; i < point_type::label_dim;
++i, ++it_a, ++it_b, ++it)
{
double x = (N == 1) ? 0 : 1. * n / (N - 1);
if (is_log[i])
*it = *it_a * pow(*it_b / *it_a, 1. * n / (N - 1));
*it = *it_a * pow(*it_b / *it_a, x);
else
*it = *it_a + (*it_b - *it_a) * n / (N - 1);
*it = *it_a + (*it_b - *it_a) * x;
}
n = (n + 1) % size();
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment