62int main(
int argc,
char* argv[] )
64 int N = argc > 1 ? atoi( argv[ 1 ] ) : 10;
65 int nb = argc > 2 ? atoi( argv[ 2 ] ) : 10;
66 int R = argc > 3 ? atoi( argv[ 3 ] ) : 50;
70 typedef Helper::LatticePolytope Polytope;
71 typedef Polytope::Point
Point;
74 std::vector< Polytope > polytopes;
75 int sum_nb_facets = 0;
76 for (
int i = 0; i < N; i++ )
78 std::vector< Point > V;
79 for (
int i = 0; i < nb; i++ ) {
80 Point p( rand() % (2*R+1) - R, rand() % (2*R+1) - R,
81 rand() % (2*R+1) - R, rand() % (2*R+1) - R );
84 Polytope P = Helper::computeLatticePolytope( V );
85 sum_nb_facets += P.nbHalfSpaces();
86 polytopes.push_back( P );
90 <<
" 4D polytopes with " << ( sum_nb_facets / (double) N )
91 <<
" facets on average, in " << t1 <<
" ms." << std::endl;
94 std::size_t slow_nb = 0;
95 std::vector< Integer > slow_counts;
96 for (
const auto& P : polytopes )
98 const auto nb = P.countByScanning();
100 slow_counts.push_back( nb );
105 std::size_t fast_nb = 0;
106 std::vector< Integer > fast_counts;
107 for (
const auto& P : polytopes )
109 const auto nb = P.count();
111 fast_counts.push_back( nb );
114 bool ok = std::equal( slow_counts.cbegin(), slow_counts.cend(), fast_counts.cbegin() );
115 DGtal::trace.
info() <<
"Computed inside points is " << ( ok ?
"OK" :
"ERROR" ) << std::endl;
117 <<
" points in " << t2 <<
" ms." << std::endl;
119 <<
" points in " << t3 <<
" ms." << std::endl;