Skip to content

Commit 88b1877

Browse files
afabrisloriot
authored andcommitted
Replace/remove boost/random code
1 parent 2070190 commit 88b1877

File tree

42 files changed

+131
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+131
-189
lines changed

Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Apollonius_graph_hierarchy_2_impl.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <CGAL/license/Apollonius_graph_2.h>
1717

18-
18+
#include <random>
1919

2020
// class implementation
2121
//---------------------
@@ -425,10 +425,9 @@ int
425425
Apollonius_graph_hierarchy_2<Gt,Agds,LTag>::
426426
random_level()
427427
{
428-
boost::geometric_distribution<> proba(1.0/ag_hierarchy_2__ratio);
429-
boost::variate_generator<boost::rand48&, boost::geometric_distribution<> > die(random, proba);
428+
std::geometric_distribution<> proba(1.0/ag_hierarchy_2__ratio);
430429

431-
return (std::min)(die(), (int)ag_hierarchy_2__maxlevel)-1;
430+
return (std::min)(proba(random), (int)ag_hierarchy_2__maxlevel)-1;
432431
}
433432

434433
template<class Gt, class Agds, class LTag>

Apollonius_graph_2/include/CGAL/Apollonius_graph_hierarchy_2.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818

1919
#include <map>
20-
21-
#include <boost/random/linear_congruential.hpp>
22-
#include <boost/random/geometric_distribution.hpp>
23-
#include <boost/random/variate_generator.hpp>
20+
#include <random>
2421

2522
#include <CGAL/Apollonius_graph_2.h>
2623
#include <CGAL/Triangulation_data_structure_2.h>
@@ -210,7 +207,7 @@ class Apollonius_graph_hierarchy_2
210207
// class variables
211208
// here is the stack of graphs which form the hierarchy
212209
Apollonius_graph_base* hierarchy[ag_hierarchy_2__maxlevel];
213-
boost::rand48 random; // random generator
210+
std::mt19937 random; // random generator
214211

215212
public:
216213
template<class OutputItFaces, class OutputItBoundaryEdges,

Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Approximate_min_ellipsoid_d_debug.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <iostream>
2222
#include <fstream>
2323
#include <sstream>
24+
#include <random>
2425
#include <boost/random/linear_congruential.hpp>
2526

2627
namespace CGAL {
@@ -271,7 +272,7 @@ namespace CGAL {
271272
bool adjust_bb;
272273
double zoom;
273274
std::string filename;
274-
boost::rand48 rng;
275+
std::mt19937 rng;
275276

276277
public: // construction and destruction:
277278

Bounding_volumes/include/CGAL/Min_sphere_of_spheres_d.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <cmath>
2323
#include <vector>
2424
#include <iostream>
25+
#include <random>
2526

2627
#include <CGAL/Min_sphere_of_spheres_d/Min_sphere_of_spheres_d_pair.h>
2728
#include <CGAL/Min_sphere_of_spheres_d/Min_sphere_of_spheres_d_support_set.h>
@@ -59,7 +60,7 @@ namespace CGAL_MINIBALL_NAMESPACE {
5960
// ball has been respected in the miniball computation.
6061
bool is_up_to_date;
6162

62-
boost::rand48 rng;
63+
std::mt19937 rng;
6364

6465
public: // iterators:
6566
typedef const Result *Cartesian_const_iterator; // coordinate iterator

Box_intersection_d/include/CGAL/Box_intersection_d/segment_tree.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include <boost/random/linear_congruential.hpp>
2323
#include <boost/random/uniform_int.hpp>
24-
#include <boost/random/variate_generator.hpp>
2524

2625
#include <algorithm>
2726
#include <iterator>
@@ -30,6 +29,7 @@
3029
#include <cmath>
3130
#include <climits>
3231
#include <cstddef>
32+
#include <random>
3333

3434
namespace CGAL {
3535

@@ -242,9 +242,10 @@ RandomAccessIter
242242
iterative_radon( RandomAccessIter begin, RandomAccessIter end,
243243
Predicate_traits traits, int dim, int num_levels )
244244
{
245-
typedef typename boost::variate_generator<boost::rand48&, boost::uniform_int<std::ptrdiff_t> > Generator;
246-
boost::rand48 rng;
247-
Generator generator(rng, boost::uniform_int<std::ptrdiff_t>(0, (end-begin)-1));
245+
std::mt19937 rng;
246+
// Generator generator(rng, boost::uniform_int<std::ptrdiff_t>(0, (end-begin)-1));
247+
auto generator = std::bind( std::uniform_int<std::ptrdiff_t>(0, (end-begin)-1), rng);
248+
using Generator = decltype(generator);
248249
Iterative_radon<RandomAccessIter, Predicate_traits, Generator> IR(begin, traits, dim, generator);
249250
return IR(num_levels);
250251
}

Generator/doc/Generator/CGAL/Random.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ the same time, even if a fixed seed has been chosen.
2323
2424
\cgalHeading{Implementation}
2525
26-
We use the boost random library function `boost::rand48()` to generate the random
26+
We use the standard library function `std::mt19937()` to generate the random
2727
numbers.
2828
2929
\sa `CGAL::get_default_random()`

Generator/include/CGAL/random_convex_hull_in_disc_2.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ void generate_points_annulus(long n, double a, double b, double small_radius,
5959
GEN& gen) { // generate n points between a and b
6060
if (n > 1) {
6161
std::binomial_distribution<long> bin_distribution(n, .5);
62-
//boost::variate_generator<GEN&, std::binomial_distribution<long> >
63-
// g(gen, bin_distribution);
6462
long nb = bin_distribution(gen);
6563
generate_points_annulus(nb, a, (a + b) / 2.0, small_radius, big_radius, l,
6664
gen);
@@ -73,11 +71,7 @@ void generate_points_annulus(long n, double a, double b, double small_radius,
7371
small_radius * small_radius / (big_radius * big_radius), 1);
7472

7573
std::uniform_real_distribution<double> random_angle_distribution(a, b);
76-
//boost::random::variate_generator<
77-
// GEN&, std::uniform_real_distribution<double> > random_angle(gen, random_angle_distribution);
78-
//boost::random::variate_generator<
79-
// GEN&, std::uniform_real_distribution<double> > random_squared_radius(gen, random_squared_radius_distribution);
80-
74+
8175
double alpha = random_angle_distribution(gen);
8276
double r = big_radius * std::sqrt(random_squared_radius_distribution(gen));
8377
typedef Creator_uniform_2<double, P> Creator;
@@ -219,8 +213,6 @@ void random_convex_hull_in_disc_2(std::size_t n, double radius, std::list<typena
219213
nb = static_cast<long>((std::min)(T, n - simulated_points));
220214
}
221215
std::binomial_distribution<long> dbin(nb, to_double(p_disc));
222-
//boost::variate_generator<
223-
// GEN&, std::binomial_distribution<long> > bin(gen, dbin);
224216

225217
// How many points are falling in the small disc and won't be generated:
226218
long k_disc = dbin(gen);

GraphicsView/demo/Apollonius_graph_2/Apollonius_graph_2.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include <fstream>
2+
#include <random>
3+
24
#include <boost/config.hpp>
35
#include <boost/version.hpp>
46
// CGAL headers
@@ -197,12 +199,11 @@ MainWindow::on_actionInsertRandomPoints_triggered()
197199
QApplication::setOverrideCursor(Qt::WaitCursor);
198200
std::vector<Apollonius_site_2> points;
199201
points.reserve(number_of_points);
200-
boost::rand48 rng;
202+
std::mt19937 rng;
201203
boost::uniform_real<> dist(0.005*width, 0.05*width);
202-
boost::variate_generator<boost::rand48&, boost::uniform_real<> > radius(rng,dist);
203-
204+
204205
for(int i = 0; i < number_of_points; ++i){
205-
points.push_back(Apollonius_site_2(*pg++,radius()));
206+
points.push_back(Apollonius_site_2(*pg++,dist(rng)));
206207
}
207208
ag.insert(points.begin(), points.end());
208209
// default cursor

Hash_map/benchmark/Hash_map/hm.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <fstream>
55
#include <map>
66
#include <algorithm>
7+
#include <random>
78

89
#include <CGAL/Surface_mesh.h>
910
#include <CGAL/Simple_cartesian.h>
@@ -44,8 +45,8 @@ run(const G& g)
4445
V2.push_back(vd);
4546
}
4647

47-
boost::rand48 random;
48-
boost::random_number_generator<boost::rand48> rng(random);
48+
std::mt19937 random;
49+
boost::random_number_generator<std::mt19937> rng(random);
4950
std::random_shuffle(V.begin(), V.end(), rng);
5051

5152
Timer t;

Interval_skip_list/include/CGAL/Interval_skip_list.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
#include <CGAL/basic.h>
2121
#include <list>
2222
#include <iostream>
23+
#include <random>
2324

2425
#include <boost/random/linear_congruential.hpp>
25-
#include <boost/random/geometric_distribution.hpp>
26-
#include <boost/random/variate_generator.hpp>
27-
2826

2927
//#define CGAL_ISL_USE_CCC
3028
#define CGAL_ISL_USE_LIST
@@ -125,7 +123,7 @@ class Interval_for_container : public Interval_
125123
private:
126124
typedef Interval_ Interval;
127125
typedef typename Interval::Value Value;
128-
boost::rand48 random;
126+
std::mt19937 random;
129127

130128
#ifdef CGAL_ISL_USE_LIST
131129
std::list<Interval> container;
@@ -1194,10 +1192,8 @@ template <class Interval>
11941192
int
11951193
Interval_skip_list<Interval>::randomLevel()
11961194
{
1197-
boost::geometric_distribution<> proba(0.5);
1198-
boost::variate_generator<boost::rand48&, boost::geometric_distribution<> > die(random, proba);
1199-
1200-
return (std::min)(die(), (int)maxLevel)+1;
1195+
std::geometric_distribution<> proba(0.5);
1196+
return (std::min)(proba(random), (int)maxLevel)+1;
12011197
}
12021198

12031199

0 commit comments

Comments
 (0)