From ebc4300334b3d22c71e1cec7c09bccea56a659ba Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Fri, 14 Nov 2014 14:20:26 +0100 Subject: [PATCH] Header only for random.cpp. For the header only version, the global variable default_random no more exist => we need to replace all occurences of default_random by a call to the global function get_default_random(). As usual, no modification for the non header only version. --- Bounding_volumes/include/CGAL/Min_circle_2.h | 4 +- Bounding_volumes/include/CGAL/Min_ellipse_2.h | 4 +- .../rectangular_p_center_2_random1_test.cpp | 5 +- .../rectangular_p_center_2_random2_test.cpp | 5 +- .../Bounding_volumes/test_Min_annulus_d_2.cpp | 4 +- .../Bounding_volumes/test_Min_annulus_d_3.cpp | 6 +- .../Bounding_volumes/test_Min_annulus_d_d.cpp | 2 +- .../test_trilinear_interpolation.cpp | 2 +- .../Convex_hull_d/chull_dd-geomview-demo.cpp | 2 +- .../demo/Convex_hull_d/chull_dd-runtime.cpp | 2 +- .../Convex_hull_d/delaunay_dd-runtime.cpp | 2 +- .../Generator/random_degenerate_point_set.cpp | 2 +- Generator/include/CGAL/generators.h | 4 +- Generator/include/CGAL/point_generators_2.h | 18 +-- Generator/include/CGAL/point_generators_3.h | 6 +- Generator/include/CGAL/point_generators_d.h | 6 +- Generator/include/CGAL/random_selection.h | 2 +- Generator/test/Generator/test_generators.cpp | 2 +- Kernel_23/test/Kernel_23/Kernel_checker.cpp | 2 +- .../test/Kernel_d/Linear_algebra-test.cpp | 120 +++++++++--------- Mesh_2/test/Mesh_2/test_double_map.cpp | 2 +- Mesh_2/test/Mesh_2/test_filtred_container.cpp | 2 +- Number_types/test/Number_types/MP_Float.cpp | 16 +-- .../include/CGAL/Polygon_2/Polygon_2_impl.h | 2 +- ...hedron_demo_remeshing_plugin_cgal_code.cpp | 2 +- .../test_Polytope_distance_d_2.cpp | 16 +-- .../test_Polytope_distance_d_3.cpp | 20 +-- .../test_Polytope_distance_d_d.cpp | 4 +- .../CGAL/QP_solver/QP_partial_exact_pricing.h | 2 +- .../QP_solver/QP_partial_filtered_pricing.h | 2 +- Random_numbers/include/CGAL/Random.h | 8 +- Random_numbers/include/CGAL/Random_impl.h | 105 +++++++++++++++ Random_numbers/src/CGAL/Random.cpp | 62 +-------- .../test/Random_numbers/test_Random.cpp | 52 ++++---- .../STL_Extension/test_Compact_container.cpp | 2 +- .../test_Concurrent_compact_container.cpp | 2 +- .../Triangulation_benchmark_3.cpp | 2 +- .../Triangulation_3/fast_location_3.cpp | 6 +- .../Triangulation_3/test_static_filters.cpp | 2 +- cppfiles.txt | 3 +- 40 files changed, 283 insertions(+), 229 deletions(-) create mode 100644 Random_numbers/include/CGAL/Random_impl.h diff --git a/Bounding_volumes/include/CGAL/Min_circle_2.h b/Bounding_volumes/include/CGAL/Min_circle_2.h index 856317940b8..d59566ac0a5 100644 --- a/Bounding_volumes/include/CGAL/Min_circle_2.h +++ b/Bounding_volumes/include/CGAL/Min_circle_2.h @@ -58,7 +58,7 @@ class Min_circle_2 { Min_circle_2( InputIterator first, InputIterator last, bool randomize = false, - Random& random = default_random, + Random& random = get_default_random(), const Traits& traits = Traits()); Min_circle_2( const Traits& traits = Traits()); @@ -302,7 +302,7 @@ class Min_circle_2 { = false #endif , - Random& random = default_random, + Random& random = get_default_random(), const Traits& traits = Traits()) : tco( traits) { diff --git a/Bounding_volumes/include/CGAL/Min_ellipse_2.h b/Bounding_volumes/include/CGAL/Min_ellipse_2.h index 274ab47e8c0..31e766e02e1 100644 --- a/Bounding_volumes/include/CGAL/Min_ellipse_2.h +++ b/Bounding_volumes/include/CGAL/Min_ellipse_2.h @@ -57,7 +57,7 @@ class Min_ellipse_2 { Min_ellipse_2( InputIterator first, InputIterator last, bool randomize = false, - Random& random = default_random, + Random& random = get_default_random(), const Traits& traits = Traits()); Min_ellipse_2( const Traits& traits = Traits()); @@ -328,7 +328,7 @@ class Min_ellipse_2 { = false #endif , - Random& random = default_random, + Random& random = get_default_random(), const Traits& traits = Traits()) : tco( traits) { diff --git a/Bounding_volumes/test/Bounding_volumes/rectangular_p_center_2_random1_test.cpp b/Bounding_volumes/test/Bounding_volumes/rectangular_p_center_2_random1_test.cpp index dfef6980a5e..60122b18196 100644 --- a/Bounding_volumes/test/Bounding_volumes/rectangular_p_center_2_random1_test.cpp +++ b/Bounding_volumes/test/Bounding_volumes/rectangular_p_center_2_random1_test.cpp @@ -45,7 +45,6 @@ using CGAL::Creator_uniform_2; using CGAL::Random_points_in_square_2; using CGAL::Random; using CGAL::Timer; -using CGAL::default_random; using CGAL::rectangular_p_center_2; #ifndef CGAL_PCENTER_NO_OUTPUT using std::ostream; @@ -108,7 +107,7 @@ public: Random_p_clusters_2(int n_, double c_size_, double r = 1, - Random& rnd = default_random) + Random& rnd = CGAL::get_default_random()) : Base(r - c_size_, rnd), n(n_), c_size(c_size_), @@ -163,7 +162,7 @@ main(int argc, char* argv[]) #endif // CGAL_PCENTER_NO_OUTPUT // generate random seed - random_seed = default_random.get_int(0, (1 << 30)); + random_seed = CGAL::get_default_random().get_int(0, (1 << 30)); } else random_seed = atoi(argv[2]); diff --git a/Bounding_volumes/test/Bounding_volumes/rectangular_p_center_2_random2_test.cpp b/Bounding_volumes/test/Bounding_volumes/rectangular_p_center_2_random2_test.cpp index 3b9bedddae7..22b280152d1 100644 --- a/Bounding_volumes/test/Bounding_volumes/rectangular_p_center_2_random2_test.cpp +++ b/Bounding_volumes/test/Bounding_volumes/rectangular_p_center_2_random2_test.cpp @@ -50,7 +50,6 @@ using CGAL::Creator_uniform_2; using CGAL::Random_points_in_square_2; using CGAL::Random; using CGAL::Timer; -using CGAL::default_random; using CGAL::rectangular_p_center_2; #ifndef CGAL_PCENTER_NO_OUTPUT using std::ostream; @@ -110,7 +109,7 @@ public: Random_p_clusters_2(int n_, double c_size_, double r = 1, - Random& rnd = default_random) + Random& rnd = CGAL::get_default_random()) : Base(r - c_size_, rnd), n(n_), c_size(c_size_), @@ -165,7 +164,7 @@ main(int argc, char* argv[]) #endif // CGAL_PCENTER_NO_OUTPUT // generate random seed - random_seed = default_random.get_int(0, (1 << 30)); + random_seed = CGAL::get_default_random().get_int(0, (1 << 30)); } else random_seed = std::atoi(argv[2]); diff --git a/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_2.cpp b/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_2.cpp index 7515da92efa..6032734721e 100644 --- a/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_2.cpp +++ b/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_2.cpp @@ -73,8 +73,8 @@ void process () for ( int i = 0; i < 100; ++i) { points.push_back (typename K::Point_2 - (CGAL::default_random( 0x100000), - CGAL::default_random( 0x100000), + (CGAL::get_default_random()( 0x100000), + CGAL::get_default_random()( 0x100000), hom)); } diff --git a/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_3.cpp b/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_3.cpp index 3f6fa8b8f85..9a333abc68f 100644 --- a/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_3.cpp +++ b/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_3.cpp @@ -73,9 +73,9 @@ void process () for ( int i = 0; i < 100; ++i) { points.push_back (typename K::Point_3 - (CGAL::default_random( 0x100000), - CGAL::default_random( 0x100000), - CGAL::default_random( 0x100000), + (CGAL::get_default_random()( 0x100000), + CGAL::get_default_random()( 0x100000), + CGAL::get_default_random()( 0x100000), hom)); } diff --git a/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_d.cpp b/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_d.cpp index e4db5fffeab..2eeb684def3 100644 --- a/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_d.cpp +++ b/Bounding_volumes/test/Bounding_volumes/test_Min_annulus_d_d.cpp @@ -75,7 +75,7 @@ void process () double hom = 2.0; for ( i = 0; i < 100; ++i) { for (j=0; j random_point_in_range(int d,int l,int h, { std::vector V(d+1); V[d]=1; for(int i = 0; i(d,V.begin(),V.end()); } diff --git a/Convex_hull_d/demo/Convex_hull_d/chull_dd-runtime.cpp b/Convex_hull_d/demo/Convex_hull_d/chull_dd-runtime.cpp index daa073d92e7..e9b947124b6 100644 --- a/Convex_hull_d/demo/Convex_hull_d/chull_dd-runtime.cpp +++ b/Convex_hull_d/demo/Convex_hull_d/chull_dd-runtime.cpp @@ -59,7 +59,7 @@ CGAL::Timer timer; void random_d_tuple_in_range(p_int V, int d, int l, int h) { for(int i = 0; i random_point_in_range(int d,int l,int h, { std::vector V(d+1); V[d]=1; for(int i = 0; i(d,V.begin(),V.end()); } diff --git a/Generator/examples/Generator/random_degenerate_point_set.cpp b/Generator/examples/Generator/random_degenerate_point_set.cpp index b9e32d1f952..d1bc4325cf9 100644 --- a/Generator/examples/Generator/random_degenerate_point_set.cpp +++ b/Generator/examples/Generator/random_degenerate_point_set.cpp @@ -40,7 +40,7 @@ int main() { // Use a random permutation to hide the creation history // of the point set. - std::random_shuffle( points.begin(), points.end(), default_random); + std::random_shuffle( points.begin(), points.end(), get_default_random()); // Check range of values. for ( Vector::iterator i = points.begin(); i != points.end(); i++){ diff --git a/Generator/include/CGAL/generators.h b/Generator/include/CGAL/generators.h index 3e38f593bc8..b30c40433d1 100644 --- a/Generator/include/CGAL/generators.h +++ b/Generator/include/CGAL/generators.h @@ -68,7 +68,7 @@ protected: public: typedef Random_generator_base This; - Random_generator_base() : _rnd( default_random) {} + Random_generator_base() : _rnd( get_default_random()) {} Random_generator_base( double range, Random& rnd) : Generator_base( range), _rnd( rnd) {} Random_generator_base( const T& item, double range, Random& rnd) @@ -83,7 +83,7 @@ class Random_double_in_interval : public Random_generator_base { public: typedef Random_double_in_interval This; - Random_double_in_interval(double a = 1, Random& rnd = default_random) + Random_double_in_interval(double a = 1, Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed in the half-open square with side length a, // centered around the origin, i.e. \forall p = `*g': -\frac{a}{2} diff --git a/Generator/include/CGAL/point_generators_2.h b/Generator/include/CGAL/point_generators_2.h index cce5d767385..098c563b574 100644 --- a/Generator/include/CGAL/point_generators_2.h +++ b/Generator/include/CGAL/point_generators_2.h @@ -36,7 +36,7 @@ class Random_points_in_disc_2 : public Random_generator_base

{ void generate_point(); public: typedef Random_points_in_disc_2 This; - Random_points_in_disc_2( double r = 1, Random& rnd = default_random) + Random_points_in_disc_2( double r = 1, Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed in the open disc with radius r, i.e. |`*g'| < r . // Two random numbers are needed from `rnd' for each point. @@ -71,7 +71,7 @@ class Random_points_on_circle_2 : public Random_generator_base

{ void generate_point(); public: typedef Random_points_on_circle_2 This; - Random_points_on_circle_2( double r = 1, Random& rnd = default_random) + Random_points_on_circle_2( double r = 1, Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed on the circle with radius r, i.e. |`*g'| == r . A // single random number is needed from `rnd' for each point. @@ -105,7 +105,7 @@ class Random_points_in_square_2 : public Random_generator_base

{ void generate_point(); public: typedef Random_points_in_square_2 This; - Random_points_in_square_2( double a = 1, Random& rnd = default_random) + Random_points_in_square_2( double a = 1, Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed in the half-open square with side length a, // centered around the origin, i.e. \forall p = `*g': -\frac{a}{2} @@ -141,7 +141,7 @@ class Random_points_on_square_2 : public Random_generator_base

{ void generate_point(); public: typedef Random_points_on_square_2 This; - Random_points_on_square_2( double a = 1, Random& rnd = default_random) + Random_points_on_square_2( double a = 1, Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed on the boundary of the square with side length a, // centered around the origin, i.e. \forall p = `*g': one @@ -194,7 +194,7 @@ class Random_points_in_iso_rectangle_2 : public Random_generator_base

{ void generate_point(); public: typedef Random_points_in_iso_rectangle_2 This; - Random_points_in_iso_rectangle_2( const P&p, const P& q, Random& rnd = default_random) + Random_points_in_iso_rectangle_2( const P&p, const P& q, Random& rnd = get_default_random()) : Random_generator_base

( 1.0 , rnd) { left = (std::min)(to_double(p.x()), to_double(q.x())); @@ -238,7 +238,7 @@ public: typedef Random_points_on_segment_2 This; Random_points_on_segment_2( const P& p = P( -1, 0), const P& q = P( 1, 0), - Random& rnd = default_random) + Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed on the segment from p to q except q, i.e. `*g' == // \lambda p + (1-\lambda)\, q where 0 <= \lambda < 1 . A single @@ -423,7 +423,7 @@ void perturb_points_2( ForwardIterator first, double xeps, double yeps) { - perturb_points_2( first, last, xeps, yeps, default_random); + perturb_points_2( first, last, xeps, yeps, get_default_random()); } template @@ -431,7 +431,7 @@ void perturb_points_2( ForwardIterator first, ForwardIterator last, double xeps) { - perturb_points_2( first, last, xeps, xeps, default_random); + perturb_points_2( first, last, xeps, xeps, get_default_random()); } template OutputIterator random_collinear_points_2( @@ -489,7 +489,7 @@ OutputIterator random_collinear_points_2( OutputIterator first2) { return random_collinear_points_2( first, last, n, first2, - default_random); + get_default_random()); } diff --git a/Generator/include/CGAL/point_generators_3.h b/Generator/include/CGAL/point_generators_3.h index 7a262e50a86..e4806182e60 100644 --- a/Generator/include/CGAL/point_generators_3.h +++ b/Generator/include/CGAL/point_generators_3.h @@ -36,7 +36,7 @@ class Random_points_in_sphere_3 : public Random_generator_base

{ void generate_point(); public: typedef Random_points_in_sphere_3 This; - Random_points_in_sphere_3( double r = 1, Random& rnd = default_random) + Random_points_in_sphere_3( double r = 1, Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed in the open sphere with radius r, i.e. |`*g'| < r . // Three random numbers are needed from `rnd' for each point @@ -75,7 +75,7 @@ class Random_points_on_sphere_3 : public Random_generator_base

{ void generate_point(); public: typedef Random_points_on_sphere_3 This; - Random_points_on_sphere_3( double r = 1, Random& rnd = default_random) + Random_points_on_sphere_3( double r = 1, Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed on the sphere with radius r, i.e. |`*g'| == r . A // two random numbers are needed from `rnd' for each point. @@ -113,7 +113,7 @@ class Random_points_in_cube_3 : public Random_generator_base

{ void generate_point(); public: typedef Random_points_in_cube_3 This; - Random_points_in_cube_3( double a = 1, Random& rnd = default_random) + Random_points_in_cube_3( double a = 1, Random& rnd = get_default_random()) : Random_generator_base

( a, rnd) { generate_point(); } This& operator++() { generate_point(); diff --git a/Generator/include/CGAL/point_generators_d.h b/Generator/include/CGAL/point_generators_d.h index f946ea126d0..59d11fd6bc3 100644 --- a/Generator/include/CGAL/point_generators_d.h +++ b/Generator/include/CGAL/point_generators_d.h @@ -35,7 +35,7 @@ class Random_points_in_ball_d : public Random_generator_base

{ public: typedef Random_points_in_ball_d

This; Random_points_in_ball_d( int dim, double a = 1, - Random& rnd = default_random) + Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed in the open sphere with radius r, i.e. |`*g'| < r . : Random_generator_base

( a, rnd), dimension(dim) { generate_point(); } @@ -84,7 +84,7 @@ class Random_points_on_sphere_d : public Random_generator_base

{ public: typedef Random_points_on_sphere_d

This; Random_points_on_sphere_d( int dim, double a = 1, - Random& rnd = default_random) + Random& rnd = get_default_random()) // g is an input iterator creating points of type `P' uniformly // distributed on the sphere with radius r, i.e. |`*g'| == r . : Random_generator_base

( a, rnd), dimension(dim) { generate_point(); } @@ -129,7 +129,7 @@ class Random_points_in_cube_d : public Random_generator_base

{ public: typedef Random_points_in_cube_d

This; Random_points_in_cube_d( int dim, double a = 1, - Random& rnd = default_random) + Random& rnd = get_default_random()) : Random_generator_base

( a, rnd), dimension(dim) { generate_point(); } This& operator++() { generate_point(); diff --git a/Generator/include/CGAL/random_selection.h b/Generator/include/CGAL/random_selection.h index 0a4283b1279..b671b19e910 100644 --- a/Generator/include/CGAL/random_selection.h +++ b/Generator/include/CGAL/random_selection.h @@ -57,7 +57,7 @@ OutputIterator random_selection( RandomAccessIterator first, Size n, OutputIterator result) { - return random_selection( first, last, n, result, default_random); + return random_selection( first, last, n, result, get_default_random()); } } //namespace CGAL diff --git a/Generator/test/Generator/test_generators.cpp b/Generator/test/Generator/test_generators.cpp index addc06c7eea..9c4788ee9e3 100644 --- a/Generator/test/Generator/test_generators.cpp +++ b/Generator/test/Generator/test_generators.cpp @@ -97,7 +97,7 @@ void test_point_generators_2() { perturb_points_2( i1, i2, 10.0); // Create a random permutation. - std::random_shuffle( points.begin(), points.end(), default_random); + std::random_shuffle( points.begin(), points.end(), get_default_random()); assert( points.size() == 1000); for ( std::vector::iterator i = points.begin(); diff --git a/Kernel_23/test/Kernel_23/Kernel_checker.cpp b/Kernel_23/test/Kernel_23/Kernel_checker.cpp index 4c7c34a790d..001cda3219f 100644 --- a/Kernel_23/test/Kernel_23/Kernel_checker.cpp +++ b/Kernel_23/test/Kernel_23/Kernel_checker.cpp @@ -24,7 +24,7 @@ typedef CGAL::Delaunay_triangulation_3 Delaunay3d; int my_rand() { - return int(CGAL::default_random.get_double()*(1<<31)); + return int(CGAL::get_default_random().get_double()*(1<<31)); } int main() diff --git a/Kernel_d/test/Kernel_d/Linear_algebra-test.cpp b/Kernel_d/test/Kernel_d/Linear_algebra-test.cpp index eefecd03070..af5a3cad1be 100644 --- a/Kernel_d/test/Kernel_d/Linear_algebra-test.cpp +++ b/Kernel_d/test/Kernel_d/Linear_algebra-test.cpp @@ -39,7 +39,7 @@ int main(int argc, char* argv[]) typedef LA::Matrix Matrix; typedef LA::Vector Vector; bool IOTEST = true; - { + { int vec_dim; if (argc == 2) vec_dim = std::atoi(argv[1]); else vec_dim = VEC_DIM; @@ -48,7 +48,7 @@ int main(int argc, char* argv[]) Vector v0(vec_dim), v1(vec_dim), v2(vec_dim); int F[] = { 1,2,3,4,5 }; Vector v11(F,F+2), v12(F,F+3), v13(F,F+4), v14(F,F+5), - v15(v13.begin(),v13.end()), + v15(v13.begin(),v13.end()), v16(vec_dim,NT(1)); CGAL_TEST(v13==v15){} CGAL_TEST(v0==v1){} @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) v1 -= v2; v1 = -v1; CGAL_TEST((v1*v1 == NT(vec_dim*vec_dim*vec_dim))){} - /* squared length of (v1 + v2) = v1*v1 + /* squared length of (v1 + v2) = v1*v1 should be equal to dim*dim*dim */ NT res1 = (v1*v1 - v2*v2); NT res2 = ((v1-v2)*(v1+v2)); @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) if (IOTEST) CGAL_IO_TEST(v1,v2,CGAL::IO::ASCII); } - { + { int mat_dim; if (argc == 2) mat_dim = std::atoi(argv[1]); else mat_dim = MAT_DIM; @@ -86,16 +86,16 @@ int main(int argc, char* argv[]) /* some construction and access ops */ Matrix::Identity ID; Matrix A(mat_dim,mat_dim), B(mat_dim), - I(mat_dim,ID), One(mat_dim,mat_dim,NT(2)); + I(mat_dim,ID), One(mat_dim,mat_dim,NT(2)); CGAL_TEST(A==B){} CGAL_TEST(One*I==One){} std::vector F(mat_dim); - int i,j; + int i,j; for (i = 0; i < mat_dim; i++) { Vector v(mat_dim); - for (j = 0; j < mat_dim; j++) { - A(i,j) = i; + for (j = 0; j < mat_dim; j++) { + A(i,j) = i; B(i,j) = j; v[j] = j; } @@ -115,7 +115,7 @@ int main(int argc, char* argv[]) (0,1,2,3...) (0,1,2,3...) ... - C = A = D = E; + C = A = D = E; */ Matrix::iterator it; @@ -130,15 +130,15 @@ int main(int argc, char* argv[]) CGAL_TEST(A.row(1)*B.column(1)==NT(mat_dim)){} /* some basic arithmetic testing */ - C = A; C += A; - C -= NT(3)*A; - C = -C; + C = A; C += A; + C -= NT(3)*A; + C = -C; CGAL_TEST(C==A){} /* row sum test: */ - Vector ones(mat_dim), row_sum_vec(mat_dim); + Vector ones(mat_dim), row_sum_vec(mat_dim); for (i = 0; i < mat_dim; i++) { - ones[i] = 1; + ones[i] = 1; row_sum_vec[i] = i*mat_dim; } CGAL_TEST(A*ones==row_sum_vec){} @@ -147,16 +147,16 @@ int main(int argc, char* argv[]) /* matrix operations + ,* and |transpose|, |rank| */ CGAL_TEST(C==LA::transpose(C)){} C = C-B; - CGAL_TEST(C==A){} + CGAL_TEST(C==A){} C = I+A; CGAL_TEST(LA::rank(C)==mat_dim){} - + /* matrix operations 2* , |determinant| */ C = NT(2) * I; C = C * NT(2); - Matrix L,U; - Vector c; - std::vector q; + Matrix L,U; + Vector c; + std::vector q; NT det = LA::determinant(C, L, U, q, c); // det must be 2^{2*mat_dim} NT pot = 1; for (i=0; i 0.0; f-=0.1) { Matrix E = C; for (i = 0; i< mat_dim; ++i) for (j = 0; j < mat_dim; ++j) - if ( CGAL::default_random.get_double() > f ) E(i,j)=0; + if ( CGAL::get_default_random().get_double() > f ) E(i,j)=0; if (LA::linear_solver(E, b, x, denom, A, e)) { CGAL_TEST(E*x == b*denom){} @@ -212,10 +212,10 @@ int main(int argc, char* argv[]) if (mat_dim > 1) { // ueberbestimmt: Matrix N(mat_dim,mat_dim-1); - for (i = 0; i < mat_dim; i++) { - for (j = 0; j < mat_dim-1; j++) - N(i,j) = CGAL::default_random.get_int(-mat_dim,mat_dim); - b[i] = CGAL::default_random.get_int(-mat_dim,mat_dim); + for (i = 0; i < mat_dim; i++) { + for (j = 0; j < mat_dim-1; j++) + N(i,j) = CGAL::get_default_random().get_int(-mat_dim,mat_dim); + b[i] = CGAL::get_default_random().get_int(-mat_dim,mat_dim); } if (LA::linear_solver(N,b,x,denom,e)) { CGAL_TEST(N*x == b*denom){} @@ -235,7 +235,7 @@ int main(int argc, char* argv[]) typedef LA::Matrix Matrix; typedef LA::Vector Vector; bool IOTEST = false; - { + { int vec_dim; if (argc == 2) vec_dim = std::atoi(argv[1]); else vec_dim = VEC_DIM; @@ -245,7 +245,7 @@ int main(int argc, char* argv[]) Vector v0(vec_dim), v1(vec_dim), v2(vec_dim); int F[] = { 1,2,3,4,5 }; Vector v11(F,F+2), v12(F,F+3), v13(F,F+4), v14(F,F+5), - v15(v13.begin(),v13.end()), + v15(v13.begin(),v13.end()), v16(vec_dim,NT(1)); CGAL_TEST(v13==v15){} CGAL_TEST(v0==v1){} @@ -261,7 +261,7 @@ int main(int argc, char* argv[]) v1 -= v2; v1 = -v1; CGAL_TEST((v1*v1 == NT(vec_dim*vec_dim*vec_dim))){} - /* squared length of (v1 + v2) = v1*v1 + /* squared length of (v1 + v2) = v1*v1 should be equal to dim*dim*dim */ NT res1 = (v1*v1 - v2*v2); NT res2 = ((v1-v2)*(v1+v2)); @@ -276,7 +276,7 @@ int main(int argc, char* argv[]) if (IOTEST) CGAL_IO_TEST(v1,v2,CGAL::IO::ASCII); } - { + { int mat_dim; if (argc == 2) mat_dim = std::atoi(argv[1]); else mat_dim = MAT_DIM; @@ -284,16 +284,16 @@ int main(int argc, char* argv[]) /* some construction and access ops */ Matrix::Identity ID; Matrix A(mat_dim,mat_dim), B(mat_dim), - I(mat_dim,ID), One(mat_dim,mat_dim,NT(2)); + I(mat_dim,ID), One(mat_dim,mat_dim,NT(2)); CGAL_TEST(A==B){} CGAL_TEST(One*I==One){} std::vector F(mat_dim); - int i,j; + int i,j; for (i = 0; i < mat_dim; i++) { Vector v(mat_dim); - for (j = 0; j < mat_dim; j++) { - A(i,j) = i; + for (j = 0; j < mat_dim; j++) { + A(i,j) = i; B(i,j) = j; v[j] = j; } @@ -313,7 +313,7 @@ int main(int argc, char* argv[]) (0,1,2,3...) (0,1,2,3...) ... - C = A = D = E; + C = A = D = E; */ Matrix::iterator it; @@ -328,15 +328,15 @@ int main(int argc, char* argv[]) CGAL_TEST(A.row(1)*B.column(1)==NT(mat_dim)){} /* some basic arithmetic testing */ - C = A; C += A; - C -= NT(3)*A; - C = -C; + C = A; C += A; + C -= NT(3)*A; + C = -C; CGAL_TEST(C==A){} /* row sum test: */ - Vector ones(mat_dim), row_sum_vec(mat_dim); + Vector ones(mat_dim), row_sum_vec(mat_dim); for (i = 0; i < mat_dim; i++) { - ones[i] = 1; + ones[i] = 1; row_sum_vec[i] = i*mat_dim; } CGAL_TEST(A*ones==row_sum_vec){} @@ -345,16 +345,16 @@ int main(int argc, char* argv[]) /* matrix operations + ,* and |transpose|, |rank| */ CGAL_TEST(C==LA::transpose(C)){} C = C-B; - CGAL_TEST(C==A){} + CGAL_TEST(C==A){} C = I+A; CGAL_TEST(LA::rank(C)==mat_dim){} - + /* matrix operations 2* , |determinant| */ C = NT(2) * I; C = C * NT(2); - Matrix L,U; - Vector c; - std::vector q; + Matrix L,U; + Vector c; + std::vector q; NT det = LA::determinant(C, L, U, q, c); // det must be 2^{2*mat_dim} NT pot = 1; for (i=0; i 0.0; f-=0.1) { Matrix E = C; for (i = 0; i< mat_dim; ++i) for (j = 0; j < mat_dim; ++j) - if ( CGAL::default_random.get_double() > f ) E(i,j)=0; + if ( CGAL::get_default_random().get_double() > f ) E(i,j)=0; if (LA::linear_solver(E, b, x, denom, A, e)) { CGAL_TEST(E*x == b*denom){} @@ -409,10 +409,10 @@ int main(int argc, char* argv[]) if (mat_dim > 1) { // ueberbestimmt: Matrix N(mat_dim,mat_dim-1); - for (i = 0; i < mat_dim; i++) { - for (j = 0; j < mat_dim-1; j++) - N(i,j) = CGAL::default_random.get_int(-mat_dim,mat_dim); - b[i] = CGAL::default_random.get_int(-mat_dim,mat_dim); + for (i = 0; i < mat_dim; i++) { + for (j = 0; j < mat_dim-1; j++) + N(i,j) = CGAL::get_default_random().get_int(-mat_dim,mat_dim); + b[i] = CGAL::get_default_random().get_int(-mat_dim,mat_dim); } if (LA::linear_solver(N,b,x,denom,e)) { CGAL_TEST(N*x == b*denom){} diff --git a/Mesh_2/test/Mesh_2/test_double_map.cpp b/Mesh_2/test/Mesh_2/test_double_map.cpp index 465160ec548..a8e1597cf75 100644 --- a/Mesh_2/test/Mesh_2/test_double_map.cpp +++ b/Mesh_2/test/Mesh_2/test_double_map.cpp @@ -61,7 +61,7 @@ int main(int argc, char** argv) std::cerr << "Filling f with " << number_of_elements << " random integers...\n"; for(unsigned int n=0; n QMPF; double non_zero_double(){ double d; do { - d = CGAL::default_random.get_double(); + d = CGAL::get_default_random().get_double(); if(d ==0) { std::cout << "generated zero" << std::endl; } @@ -130,7 +130,7 @@ void square_test() { for (int i = 0; i<1000; ++i) { - double d = CGAL::default_random.get_double(); + double d = CGAL::get_default_random().get_double(); MPF D(d); assert(D*D == CGAL_NTS square(D)); } @@ -274,8 +274,8 @@ int main(int argc, char **argv) std::cout << "Checking MP_Float(float) constructor." << std::endl; for (int i = 0; i < loops; ++i) { - float d = (float)CGAL::default_random.get_double(); - int exp = int((CGAL::default_random.get_double()-.5)*256); + float d = (float)CGAL::get_default_random().get_double(); + int exp = int((CGAL::get_default_random().get_double()-.5)*256); d = std::ldexp(d, exp); // std::cout << d << std::endl; // std::cout << MPF(d) << std::endl; @@ -289,8 +289,8 @@ int main(int argc, char **argv) std::cout << "Checking MP_Float(double) constructor." << std::endl; MPF y = 0.5000000000000001; // see bug-report on cgal-discuss (2006-06-23). for (int i = 0; i < loops; ++i) { - double d = CGAL::default_random.get_double(); - int exp = int((CGAL::default_random.get_double()-.5)*1024); + double d = CGAL::get_default_random().get_double(); + int exp = int((CGAL::get_default_random().get_double()-.5)*1024); d = std::ldexp(d, exp); // std::cout << d << std::endl; // std::cout << MPF(d) << std::endl; @@ -303,9 +303,9 @@ int main(int argc, char **argv) std::cout << "Checking MP_Float(long double) constructor." << std::endl; for (int i = 0; i < loops; ++i) { - long double d = CGAL::default_random.get_double(); + long double d = CGAL::get_default_random().get_double(); d = d*d; // to get more bits - int exp = int((CGAL::default_random.get_double()-.5)*1024); + int exp = int((CGAL::get_default_random().get_double()-.5)*1024); d = d * std::ldexp(1.0, exp); //std::cout << d << std::endl; //std::cout << MPF(d) << std::endl; diff --git a/Polygon/include/CGAL/Polygon_2/Polygon_2_impl.h b/Polygon/include/CGAL/Polygon_2/Polygon_2_impl.h index add348aad03..be890c5720e 100644 --- a/Polygon/include/CGAL/Polygon_2/Polygon_2_impl.h +++ b/Polygon/include/CGAL/Polygon_2/Polygon_2_impl.h @@ -116,7 +116,7 @@ operator<<(std::ostream &os, const Polygon_2& p) { typename Polygon_2::Vertex_const_iterator i; - switch(os.iword(IO::mode)) { + switch(get_mode(os)) { case IO::ASCII : os << p.size() << ' '; for (i = p.vertices_begin(); i != p.vertices_end(); ++i) { diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp index 071120a6711..3f46420eb02 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp @@ -285,7 +285,7 @@ Scene_item* cgal_code_remesh(QWidget* parent, triangulation.dimension() < 3 ); n = triangulation.number_of_vertices()) { - const int pos = CGAL::default_random.get_int(0, (int)polyhedron_points.size()); + const int pos = CGAL::get_default_random().get_int(0, (int)polyhedron_points.size()); triangulation.insert(polyhedron_points[pos]); } } diff --git a/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_2.cpp b/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_2.cpp index 4f7e0714fee..d90c48ac530 100644 --- a/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_2.cpp +++ b/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_2.cpp @@ -55,7 +55,7 @@ typedef CGAL::Polytope_distance_d_traits_2 HTraits1; #include "test_Polytope_distance_d.h" template -void process () +void process () { // generate point set std::vector p_points, q_points; @@ -67,26 +67,26 @@ void process () for ( i = 0; i < 50; ++i) { p_points.push_back (typename K::Point_2( - CGAL::default_random( 0x100000), - CGAL::default_random( 0x100000), + CGAL::get_default_random()( 0x100000), + CGAL::get_default_random()( 0x100000), hom)); } hom = 3.0; for ( i = 0; i < 50; ++i) { q_points.push_back (typename K::Point_2( - -CGAL::default_random( 0x100000), - -CGAL::default_random( 0x100000), + -CGAL::get_default_random()( 0x100000), + -CGAL::get_default_random()( 0x100000), hom)); } } - + // call test function CGAL::test_Polytope_distance_d( p_points.begin(), p_points.end(), q_points.begin(), q_points.end(), Traits(), 1); } - + // main // ---- int @@ -95,5 +95,5 @@ main() process(); process(); } - + // ===== EOF ================================================================== diff --git a/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_3.cpp b/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_3.cpp index 769b3a60c68..0e19f181359 100644 --- a/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_3.cpp +++ b/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_3.cpp @@ -55,7 +55,7 @@ typedef CGAL::Polytope_distance_d_traits_3 HTraits1; #include "test_Polytope_distance_d.h" template -void process () +void process () { // generate point set std::vector p_points, q_points; @@ -67,28 +67,28 @@ void process () for ( i = 0; i < 50; ++i) { p_points.push_back (typename K::Point_3( - CGAL::default_random( 0x100000), - CGAL::default_random( 0x100000), - CGAL::default_random( 0x100000), + CGAL::get_default_random()( 0x100000), + CGAL::get_default_random()( 0x100000), + CGAL::get_default_random()( 0x100000), hom)); } hom = 3.0; for ( i = 0; i < 50; ++i) { q_points.push_back (typename K::Point_3( - -CGAL::default_random( 0x100000), - -CGAL::default_random( 0x100000), - -CGAL::default_random( 0x100000), + -CGAL::get_default_random()( 0x100000), + -CGAL::get_default_random()( 0x100000), + -CGAL::get_default_random()( 0x100000), hom)); } } - + // call test function CGAL::test_Polytope_distance_d( p_points.begin(), p_points.end(), q_points.begin(), q_points.end(), Traits(), 1); } - + // main // ---- int @@ -97,5 +97,5 @@ main() process(); process(); } - + // ===== EOF ================================================================== diff --git a/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_d.cpp b/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_d.cpp index bdc760d965e..3c1e66de7a5 100644 --- a/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_d.cpp +++ b/Polytope_distance_d/test/Polytope_distance_d/test_Polytope_distance_d_d.cpp @@ -68,7 +68,7 @@ void process () double hom = 2.0; for ( i = 0; i < 50; ++i) { for (j=0; j { // creation QP_partial_exact_pricing( bool randomize = false, - Random& random = default_random); + Random& random = get_default_random()); // operations int pricing(int& direction ); diff --git a/QP_solver/include/CGAL/QP_solver/QP_partial_filtered_pricing.h b/QP_solver/include/CGAL/QP_solver/QP_partial_filtered_pricing.h index 5395e6ace14..e1c13cd6158 100644 --- a/QP_solver/include/CGAL/QP_solver/QP_partial_filtered_pricing.h +++ b/QP_solver/include/CGAL/QP_solver/QP_partial_filtered_pricing.h @@ -78,7 +78,7 @@ class QP_partial_filtered_pricing // creation QP_partial_filtered_pricing( bool randomize = false, - Random& random = default_random, + Random& random = get_default_random(), ET2NT et2nt = ET2NT()); // operations diff --git a/Random_numbers/include/CGAL/Random.h b/Random_numbers/include/CGAL/Random.h index b6ea695da1f..22cddd1d164 100644 --- a/Random_numbers/include/CGAL/Random.h +++ b/Random_numbers/include/CGAL/Random.h @@ -222,12 +222,16 @@ public: boost::rand48 rng; }; +#ifndef CGAL_HEADER_ONLY // Global variables // ================ CGAL_EXPORT extern Random default_random; +#endif // CGAL_HEADER_ONLY } //namespace CGAL +#ifdef CGAL_HEADER_ONLY +#include +#endif // CGAL_HEADER_ONLY + #endif // CGAL_RANDOM_H - - diff --git a/Random_numbers/include/CGAL/Random_impl.h b/Random_numbers/include/CGAL/Random_impl.h new file mode 100644 index 00000000000..c620df02ab0 --- /dev/null +++ b/Random_numbers/include/CGAL/Random_impl.h @@ -0,0 +1,105 @@ +// Copyright (c) 1997-2001 +// Utrecht University (The Netherlands), +// ETH Zurich (Switzerland), +// INRIA Sophia-Antipolis (France), +// Max-Planck-Institute Saarbruecken (Germany), +// and Tel-Aviv University (Israel). All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Sven Schönherr + +#ifdef CGAL_HEADER_ONLY +#define CGAL_INLINE_FUNCTION inline +#else +#define CGAL_INLINE_FUNCTION +#endif + +#include +#include + +namespace CGAL { + +#ifdef CGAL_HEADER_ONLY +inline Random& get_default_random() +{ + static Random default_random; + return default_random; +} +#else // CGAL_HEADER_ONLY +inline Random& get_default_random() +{ return Random::default_random; } +#endif // CGAL_HEADER_ONLY + +// Class implementation (continued) +// ================================ + +// constructors +CGAL_INLINE_FUNCTION +Random:: +Random( ) + : val(0) +{ + // get system's time + std::time_t s; + std::time( &s); + seed = (unsigned int)s; + + // initialize random numbers generator + rng.seed(static_cast(seed)); + random_value = get_int(0, 1<<15); +} + +CGAL_INLINE_FUNCTION +Random:: +Random( unsigned int seed) + : val(0), seed(seed) +{ + // initialize random numbers generator + rng.seed(static_cast(seed)); + random_value = get_int(0, 1<<15); +} + +// seed +CGAL_INLINE_FUNCTION +unsigned int +Random::get_seed () const +{ + return seed; +} + +// state +CGAL_INLINE_FUNCTION +void +Random::save_state( Random::State& state) const +{ + std::ostringstream os; + os << rng; + state = Random::State(os.str(),random_value, val, seed); +} + +CGAL_INLINE_FUNCTION +void +Random::restore_state( const Random::State& state) +{ + std::istringstream is(state.rng); + is >> rng; + random_value = state.random_value; + val = state.val; + seed = state.seed; +} + +} //namespace CGAL diff --git a/Random_numbers/src/CGAL/Random.cpp b/Random_numbers/src/CGAL/Random.cpp index 9a5887a1b15..471accc5128 100644 --- a/Random_numbers/src/CGAL/Random.cpp +++ b/Random_numbers/src/CGAL/Random.cpp @@ -22,67 +22,15 @@ // // Author(s) : Sven Schönherr +#ifndef CGAL_HEADER_ONLY + #include -#include -#include +#include namespace CGAL { -// Class implementation (continued) -// ================================ - -// constructors -Random:: -Random( ) - : val(0) -{ - // get system's time - std::time_t s; - std::time( &s); - seed = (unsigned int)s; - - // initialize random numbers generator - rng.seed(static_cast(seed)); - random_value = get_int(0, 1<<15); -} - -Random:: -Random( unsigned int seed) - : val(0), seed(seed) -{ - // initialize random numbers generator - rng.seed(static_cast(seed)); - random_value = get_int(0, 1<<15); -} - -// seed -unsigned int -Random::get_seed () const -{ - return seed; -} - -// state -void -Random::save_state( Random::State& state) const -{ - std::ostringstream os; - os << rng; - state = Random::State(os.str(),random_value, val, seed); -} - -void -Random::restore_state( const Random::State& state) -{ - std::istringstream is(state.rng); - is >> rng; - random_value = state.random_value; - val = state.val; - seed = state.seed; -} - -// Global variables -// ================ Random default_random; } //namespace CGAL + +#endif diff --git a/Random_numbers/test/Random_numbers/test_Random.cpp b/Random_numbers/test/Random_numbers/test_Random.cpp index c09a960a4d3..ae46b8ee517 100644 --- a/Random_numbers/test/Random_numbers/test_Random.cpp +++ b/Random_numbers/test/Random_numbers/test_Random.cpp @@ -32,33 +32,33 @@ main() { // test get_bool { - bool b = CGAL::default_random.get_bool(); + bool b = CGAL::get_default_random().get_bool(); assert( ! b || b); } // test get_int { - int l = CGAL::default_random.get_int( -100, 0); - int u = CGAL::default_random.get_int( 0, 1000); - int i = CGAL::default_random.get_int( l, u); + int l = CGAL::get_default_random().get_int( -100, 0); + int u = CGAL::get_default_random().get_int( 0, 1000); + int i = CGAL::get_default_random().get_int( l, u); assert( ( l <= i) && ( i < u)); { std::size_t l = 0, u = 10; - std::size_t i = CGAL::default_random.uniform_int(l,u); + std::size_t i = CGAL::get_default_random().uniform_int(l,u); assert( ( l <= i) && ( i <= u)); } { std::ptrdiff_t l = 0, u = 10; - std::ptrdiff_t i = CGAL::default_random.uniform_int(l,u); + std::ptrdiff_t i = CGAL::get_default_random().uniform_int(l,u); assert( ( l <= i) && ( i <= u)); } { std::ptrdiff_t l = 0, u = 10; - std::ptrdiff_t i = CGAL::default_random.uniform_smallint(l,u); + std::ptrdiff_t i = CGAL::get_default_random().uniform_smallint(l,u); assert( ( l <= i) && ( i <= u)); } @@ -67,39 +67,39 @@ main() // test get_double { - double l = CGAL::default_random.get_double( -123.45, -0.99); - double u = CGAL::default_random.get_double( 22.0/7.0, 33.3); - double d = CGAL::default_random.get_double( l, u); + double l = CGAL::get_default_random().get_double( -123.45, -0.99); + double u = CGAL::get_default_random().get_double( 22.0/7.0, 33.3); + double d = CGAL::get_default_random().get_double( l, u); assert( ( l <= d) && ( d < u)); - double ho = CGAL::default_random.get_double(0.5); + double ho = CGAL::get_default_random().get_double(0.5); assert( (0.5 <= ho) && (ho < 1.0)); - double zo = CGAL::default_random.get_double(); + double zo = CGAL::get_default_random().get_double(); assert( (0 <= zo) && (zo < 1.0)); } // test uniform_real { - double d = CGAL::default_random.uniform_real(-10.0, 10.0); + double d = CGAL::get_default_random().uniform_real(-10.0, 10.0); assert( (d >= -10.0) && (d < 10.0) ); - d = CGAL::default_random.uniform_real(0.2); + d = CGAL::get_default_random().uniform_real(0.2); assert( (d >= 0.2) && (d < 1.0) ); - d = CGAL::default_random.uniform_real(); + d = CGAL::get_default_random().uniform_real(); assert( (d >= 0) && (d < 1) ); - d = CGAL::default_random.uniform_01(); + d = CGAL::get_default_random().uniform_01(); assert( (d >= 0) && (d < 1) ); } { - float d = CGAL::default_random.uniform_real(-10.0f, 10.0f); + float d = CGAL::get_default_random().uniform_real(-10.0f, 10.0f); assert( (d >= -10.0f) && (d < 10.0f) ); - d = CGAL::default_random.uniform_real(0.2f); + d = CGAL::get_default_random().uniform_real(0.2f); assert( (d >= 0.2) && (d < 1.0) ); - d = CGAL::default_random.uniform_real(); + d = CGAL::get_default_random().uniform_real(); assert( (d >= 0) && (d < 1) ); - d = CGAL::default_random.uniform_01(); + d = CGAL::get_default_random().uniform_01(); assert( (d >= 0) && (d < 1) ); } @@ -110,10 +110,10 @@ main() int p3[8] = {0,}; int p4[16] = {0,}; for (int loops=0; loops < (1<<16); ++loops) { - unsigned int l1 = CGAL::default_random.get_bits<1>(); - unsigned int l2 = CGAL::default_random.get_bits<2>(); - unsigned int l3 = CGAL::default_random.get_bits<3>(); - unsigned int l4 = CGAL::default_random.get_bits<4>(); + unsigned int l1 = CGAL::get_default_random().get_bits<1>(); + unsigned int l2 = CGAL::get_default_random().get_bits<2>(); + unsigned int l3 = CGAL::get_default_random().get_bits<3>(); + unsigned int l4 = CGAL::get_default_random().get_bits<4>(); assert(l1 < 2); assert(l2 < 4); assert(l3 < 8); @@ -138,7 +138,7 @@ main() // test operator() { - int i = CGAL::default_random( 5555); + int i = CGAL::get_default_random()( 5555); assert( ( 0 <= i) && ( i < 5555)); } @@ -160,7 +160,7 @@ main() std::vector numbers; numbers.push_back(1); - std::random_shuffle(numbers.begin(), numbers.end(), CGAL::default_random); + std::random_shuffle(numbers.begin(), numbers.end(), CGAL::get_default_random()); return( 0); } diff --git a/STL_Extension/test/STL_Extension/test_Compact_container.cpp b/STL_Extension/test/STL_Extension/test_Compact_container.cpp index 04e365e2a0e..567e78c872f 100644 --- a/STL_Extension/test/STL_Extension/test_Compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Compact_container.cpp @@ -63,7 +63,7 @@ class Node_2 public: Node_2() - : p(NULL), rnd(CGAL::default_random.get_int(0, 100)) {} + : p(NULL), rnd(CGAL::get_default_random().get_int(0, 100)) {} bool operator==(const Node_2 &n) const { return rnd == n.rnd; } bool operator!=(const Node_2 &n) const { return rnd != n.rnd; } diff --git a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp index 5794411d442..b4f6ede8654 100644 --- a/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp +++ b/STL_Extension/test/STL_Extension/test_Concurrent_compact_container.cpp @@ -47,7 +47,7 @@ public: int rnd; Node_2() - : p(NULL), rnd(CGAL::default_random.get_int(0, 100)) {} + : p(NULL), rnd(CGAL::get_default_random().get_int(0, 100)) {} bool operator==(const Node_2 &n) const { return rnd == n.rnd; } bool operator!=(const Node_2 &n) const { return rnd != n.rnd; } diff --git a/Triangulation_3/benchmark/Triangulation_3/Triangulation_benchmark_3.cpp b/Triangulation_3/benchmark/Triangulation_3/Triangulation_benchmark_3.cpp index 9532bb7c2af..2910a3f983e 100644 --- a/Triangulation_3/benchmark/Triangulation_3/Triangulation_benchmark_3.cpp +++ b/Triangulation_3/benchmark/Triangulation_3/Triangulation_benchmark_3.cpp @@ -153,7 +153,7 @@ public: ~Time_accumulator() { timer.stop(); accumulator += timer.time(); } }; -#define drand48 CGAL::default_random.get_double +#define drand48 CGAL::get_default_random().get_double Point rnd_point() { diff --git a/Triangulation_3/examples/Triangulation_3/fast_location_3.cpp b/Triangulation_3/examples/Triangulation_3/fast_location_3.cpp index 1d2ce0ccc77..b6a86304ba5 100644 --- a/Triangulation_3/examples/Triangulation_3/fast_location_3.cpp +++ b/Triangulation_3/examples/Triangulation_3/fast_location_3.cpp @@ -27,9 +27,9 @@ int main() // performing nearest vertex queries to a series of random points, // which is a case where the Fast_location policy is beneficial. for (int i=0; i<10000; ++i) - T.nearest_vertex(Point(CGAL::default_random.get_double(0, 20), - CGAL::default_random.get_double(0, 20), - CGAL::default_random.get_double(0, 20))); + T.nearest_vertex(Point(CGAL::get_default_random().get_double(0, 20), + CGAL::get_default_random().get_double(0, 20), + CGAL::get_default_random().get_double(0, 20))); return 0; } diff --git a/Triangulation_3/test/Triangulation_3/test_static_filters.cpp b/Triangulation_3/test/Triangulation_3/test_static_filters.cpp index 80a325054fd..c1c657f29dd 100644 --- a/Triangulation_3/test/Triangulation_3/test_static_filters.cpp +++ b/Triangulation_3/test/Triangulation_3/test_static_filters.cpp @@ -218,7 +218,7 @@ int main(int argc, char **argv) int loops = (argc < 2) ? 2000 : std::atoi(argv[1]); - int seed = (argc < 3) ? CGAL::default_random.get_int(0, 1<<30) + int seed = (argc < 3) ? CGAL::get_default_random().get_int(0, 1<<30) : std::atoi(argv[2]); std::cout << "Initializing random generator with seed = " << seed diff --git a/cppfiles.txt b/cppfiles.txt index 1ead35fbe1f..a52ee011013 100644 --- a/cppfiles.txt +++ b/cppfiles.txt @@ -7,8 +7,6 @@ Clement: #include "/home/gdamiand/sources/CGAL/Kinetic_data_structures/src/CGAL/numeric_solvers_support.cpp" #include "/home/gdamiand/sources/CGAL/Kinetic_data_structures/src/CGAL/Turkowski_numeric_solver.cpp" -#include "/home/gdamiand/sources/CGAL/Random_numbers/src/CGAL/Random.cpp" // static mais doit pouvoir se remplacer en membre - #include "/home/gdamiand/sources/CGAL/Modular_arithmetic/src/CGAL/Residue_type.cpp" #include "/home/gdamiand/sources/CGAL/Modular_arithmetic/src/CGAL/primes.cpp" @@ -22,6 +20,7 @@ DONE #include "/home/gdamiand/sources/CGAL/Number_types/src/CGAL/Interval_arithm DONE #include "/home/gdamiand/sources/CGAL/Number_types/src/CGAL/test_FPU_rounding_mode.cpp" // static const (ok car utilisé que pour debug) DONE #include "/home/gdamiand/sources/CGAL/Profiling_tools/src/CGAL/Timer.cpp" // variable statique de classe DONE #include "/home/gdamiand/sources/CGAL/Profiling_tools/src/CGAL/Real_timer.cpp" // variable statique de classe +DONE #include "/home/gdamiand/sources/CGAL/Random_numbers/src/CGAL/Random.cpp" // variable globale; utilisée directement (donc pb pour header only) -> we need to replace the use of CGAL::default_random by CGAL::get_default_random(). DONE #include "/home/gdamiand/sources/CGAL/Geomview/src/CGAL/Geomview_stream.cpp" DONE #include "/home/gdamiand/sources/CGAL/Intersections_2/src/CGAL/Bbox_2_intersections.cpp"