Skip to content

Commit

Permalink
Fix rnum=0 causing integer overflow in SoB volume
Browse files Browse the repository at this point in the history
rnum-1 is passed into RandomPointGenerator::apply a few lines later
  • Loading branch information
dymil authored Jun 30, 2022
1 parent 59cd27e commit 9809695
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/volume/volume_sequence_of_balls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ double volume_sequence_of_balls(Polytope const& Pin,
P.shift(c.getCoefficients());
c = Point(n);

rnum = rnum/n_threads;
// Scale by number of threads and prevent edge case rnum=0 from producing overflow later
rnum = rnum >= n_threads ? rnum/n_threads : 1u;
NT vol = NT(0);

// Perform the procedure for a number of threads and then take the average
Expand Down

0 comments on commit 9809695

Please sign in to comment.