Skip to content

Commit

Permalink
Tweak bugfix and add 1D volume test
Browse files Browse the repository at this point in the history
Force rnum>=2 rather than >=1,
so that all three walk methods succeed for 1D case.
Small rnum's due to larger error or n_threads may fail in other ways
in higher dimensions, e.g., empty balls check
  • Loading branch information
dymil committed Jul 5, 2022
1 parent 9809695 commit 5b29181
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/volume/volume_sequence_of_balls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ double volume_sequence_of_balls(Polytope const& Pin,
c = Point(n);

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

// Perform the procedure for a number of threads and then take the average
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ else ()
add_test(NAME volume_sob_hpolytope_prod_simplex COMMAND volume_sob_hpolytope -tc=prod_simplex)
add_test(NAME volume_sob_hpolytope_simplex COMMAND volume_sob_hpolytope -tc=simplex)
add_test(NAME volume_sob_hpolytope_skinny_cube COMMAND volume_sob_hpolytope -tc=skinny_cube)
add_test(NAME volume_sob_hpolytope_cube_overflow COMMAND volume_sob_hpolytope -tc=cube_overflow)
set_property(TEST volume_sob_hpolytope_cube_overflow PROPERTY TIMEOUT 1)

add_executable (volume_sob_vpolytope volume_sob_vpolytope.cpp $<TARGET_OBJECTS:test_main>)
add_test(NAME volume_sob_vpolytope_cube COMMAND volume_sob_vpolytope -tc=cube)
Expand Down
16 changes: 16 additions & 0 deletions test/volume_sob_hpolytope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,18 @@ void call_test_skinny_cube() {
//test_volume(P, 104857600, 104857600.0);
}

template <typename NT>
void call_test_cube_overflow() {
typedef Cartesian<NT> Kernel;
typedef typename Kernel::Point Point;
typedef HPolytope<Point> Hpolytope;
Hpolytope P;

std::cout << "--- Testing volume of H-cube1" << std::endl;
P = generate_cube<Hpolytope>(1, false);
test_volume(P, 2, 2, 2, 2, 2);
}


TEST_CASE("cube") {
call_test_cube<double>();
Expand All @@ -293,3 +305,7 @@ TEST_CASE("simplex") {
TEST_CASE("skinny_cube") {
call_test_skinny_cube<double>();
}

TEST_CASE("cube_overflow") {
call_test_cube_overflow<double>();
}

0 comments on commit 5b29181

Please sign in to comment.