diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 6fa7af5..b4f667f 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -3,7 +3,7 @@ # Copyright (c) 2009 # Steven Watanabe # -# Distributed under the Boost Sofware License, Version 1.0. (See +# Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/concepts.qbk b/doc/concepts.qbk index 5c8d560..f3407d3 100644 --- a/doc/concepts.qbk +++ b/doc/concepts.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [section Introduction] Random numbers are required in a number of different problem domains, such as diff --git a/doc/distribution_performance_linux.qbk b/doc/distribution_performance_linux.qbk index a9ad37f..165530b 100644 --- a/doc/distribution_performance_linux.qbk +++ b/doc/distribution_performance_linux.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [table Distributions (Linux) [[\[M rn/sec\]][minstd_rand][kreutzer1986][mt19937][lagged_fibonacci607]] [[uniform_int][31.25][30.581][11.5607][16.0514]] diff --git a/doc/distribution_performance_windows.qbk b/doc/distribution_performance_windows.qbk index 6ddc602..676459b 100644 --- a/doc/distribution_performance_windows.qbk +++ b/doc/distribution_performance_windows.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [table Distributions (Windows) [[\[M rn/sec\]][minstd_rand][kreutzer1986][mt19937][lagged_fibonacci607]] [[uniform_int][14.7449][27.465][6.65292][28.5714]] diff --git a/doc/distributions.qbk b/doc/distributions.qbk index 22f50c2..ec0462b 100644 --- a/doc/distributions.qbk +++ b/doc/distributions.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + In addition to the [link boost_random.reference.generators random number generators], this library provides distribution functions which map one distribution (often a uniform distribution provided by some generator) to another. diff --git a/doc/generator_defs.qbk b/doc/generator_defs.qbk index 592049a..abc9d3d 100644 --- a/doc/generator_defs.qbk +++ b/doc/generator_defs.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [template rand48_speed[] 68%] [template lrand48_run_time_speed[] 12%] [template minstd_rand0_speed[] 32%] diff --git a/doc/generator_performance_linux.qbk b/doc/generator_performance_linux.qbk index 4b69a21..38176b3 100644 --- a/doc/generator_performance_linux.qbk +++ b/doc/generator_performance_linux.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [table Basic Generators (Linux) [[generator] [M rn/sec] [time per random number \[nsec\]] [relative speed compared to fastest \[percent\]]] [[rand48][312.5][3.2][100%]] diff --git a/doc/generator_performance_windows.qbk b/doc/generator_performance_windows.qbk index 0414116..c4a3362 100644 --- a/doc/generator_performance_windows.qbk +++ b/doc/generator_performance_windows.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [table Basic Generators (Windows) [[generator] [M rn/sec] [time per random number \[nsec\]] [relative speed compared to fastest \[percent\]]] [[rand48][98.5222][10.15][67%]] diff --git a/doc/generators.qbk b/doc/generators.qbk index 0fb4979..553c533 100644 --- a/doc/generators.qbk +++ b/doc/generators.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + This library provides several [prng pseudo-random number generators]. The quality of a [prng pseudo random number generator] crucially depends on both the algorithm and its parameters. This library implements the algorithms as diff --git a/doc/nondet_random.qbk b/doc/nondet_random.qbk index 21bbe95..edfa635 100644 --- a/doc/nondet_random.qbk +++ b/doc/nondet_random.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [section Header Synopsis] namespace boost { diff --git a/doc/performance.qbk b/doc/performance.qbk index 6097b6a..347bb97 100644 --- a/doc/performance.qbk +++ b/doc/performance.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + For some people, performance of random number generation is an important consideration when choosing a random number generator or a particular distribution function. This page provides numerous performance tests with diff --git a/doc/performance_data.qbk b/doc/performance_data.qbk index 4eddac0..5b5b96e 100644 --- a/doc/performance_data.qbk +++ b/doc/performance_data.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [template rand48_speed[] 100%] [template lrand48_run_time_speed[] 96%] [template lrand48__C_library__speed[] 21%] diff --git a/doc/random_number_generator.qbk b/doc/random_number_generator.qbk index 84054a7..74b1d2b 100644 --- a/doc/random_number_generator.qbk +++ b/doc/random_number_generator.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [section Synopsis of miscellaneous decorators in header ] namespace boost { diff --git a/doc/tutorial.qbk b/doc/tutorial.qbk index 4deebf2..9bed113 100644 --- a/doc/tutorial.qbk +++ b/doc/tutorial.qbk @@ -1,3 +1,11 @@ +[/ + / Copyright (c) 2009 Steven Watanabe + / + / Distributed under the Boost Software License, Version 1.0. (See + / accompanying file LICENSE_1_0.txt or copy at + / http://www.boost.org/LICENSE_1_0.txt) +] + [section Generating integers in a range] [import ../example/die.cpp] diff --git a/example/die.cpp b/example/die.cpp index 0fb051c..1df89d3 100644 --- a/example/die.cpp +++ b/example/die.cpp @@ -1,3 +1,12 @@ +// die.cpp +// +// Copyright (c) 2009 +// Steven Watanabe +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + //[die /*` For the source of this example see diff --git a/example/weighted_die.cpp b/example/weighted_die.cpp index ab0f64f..4a0b5a8 100644 --- a/example/weighted_die.cpp +++ b/example/weighted_die.cpp @@ -1,3 +1,12 @@ +// weighted_die.cpp +// +// Copyright (c) 2009 +// Steven Watanabe +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + //[weighted_die /*` For the source of this example see diff --git a/src/random_device.cpp b/src/random_device.cpp index 1688d2f..8989ea0 100644 --- a/src/random_device.cpp +++ b/src/random_device.cpp @@ -111,7 +111,7 @@ const char * const boost::random_device::default_token = "/dev/urandom"; #if defined(__GNUC__) && defined(_CXXRT_STD_NAME) // I have severe difficulty to get the POSIX includes to work with -// -fhonor-std and Dietmar Kühl's standard C++ library. Hack around that +// -fhonor-std and Dietmar Kuhl's standard C++ library. Hack around that // problem for now. extern "C" { static const int O_RDONLY = 0; diff --git a/test/random_test.cpp b/test/random_test.cpp index 6a7078e..b6a8887 100644 --- a/test/random_test.cpp +++ b/test/random_test.cpp @@ -163,7 +163,7 @@ INSTANT(boost::mt11213b) #endif #if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T) -// testcase by Mario R�tti +// testcase by Mario Rutti class ruetti_gen { public: diff --git a/test/statistic_tests.cpp b/test/statistic_tests.cpp index 4faba4e..717985b 100644 --- a/test/statistic_tests.cpp +++ b/test/statistic_tests.cpp @@ -41,7 +41,7 @@ class test_base { protected: explicit test_base(test_environment & env) : environment(env) { } - void check(double val) const; + void check_(double val) const; private: test_environment & environment; }; @@ -62,9 +62,9 @@ public: std::cout << "equidistribution: " << std::flush; equidistribution_experiment equi(classes); variate_generator > uint_linear(rng, uniform_smallint<>(0, classes-1)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(equi, uint_linear, n1), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(equi, uint_linear, n1), 2*n2)); std::cout << " 2D: " << std::flush; @@ -72,9 +72,9 @@ public: unsigned int root = static_cast(std::sqrt(double(classes))); assert(root * root == classes); variate_generator > uint_square(rng, uniform_smallint<>(0, root-1)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(equi_2d, uint_square, n1), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(equi_2d, uint_square, n1), 2*n2)); std::cout << std::endl; } @@ -104,9 +104,9 @@ public: using namespace boost; std::cout << "KS: " << std::flush; kolmogorov_experiment ks(n1); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, ks_experiment_generator(ks, rng, dist), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, ks_experiment_generator(ks, rng, dist), 2*n2)); std::cout << std::endl; } @@ -130,16 +130,16 @@ public: std::cout << "runs: up: " << std::flush; runs_experiment r_up(classes); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(r_up, rng, n1), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(r_up, rng, n1), 2*n2)); std::cout << " down: " << std::flush; runs_experiment r_down(classes); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(r_down, rng, n1), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(r_down, rng, n1), 2*n2)); std::cout << std::endl; @@ -175,9 +175,9 @@ public: std::cout << "gaps: " << std::flush; gap_experiment gap(classes, dist, 0.2, 0.8); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(gap, rng, n1), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(gap, rng, n1), 2*n2)); std::cout << std::endl; @@ -203,9 +203,9 @@ public: std::cout << "poker: " << std::flush; poker_experiment poker(8, classes); variate_generator > usmall(rng, uniform_smallint<>(0, 7)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(poker, usmall, n1), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(poker, usmall, n1), 2*n2)); std::cout << std::endl; } @@ -231,9 +231,9 @@ public: coupon_collector_experiment coupon(5, classes); variate_generator > usmall(rng, uniform_smallint<>(0, 4)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(coupon, usmall, n1), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(coupon, usmall, n1), 2*n2)); std::cout << std::endl; } @@ -261,9 +261,9 @@ public: // generator_reference_t gen_ref(rng); RNG& gen_ref(rng); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(perm, gen_ref, n1), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(perm, gen_ref, n1), 2*n2)); std::cout << std::endl; } @@ -287,8 +287,8 @@ public: using namespace boost; std::cout << "maximum-of-t: " << std::flush; maximum_experiment mx(rng, n1, 5); - check(run_experiment(test_distrib_chi_square, mx, n2)); - check(run_experiment(test_distrib_chi_square, mx, 2*n2)); + check_(run_experiment(test_distrib_chi_square, mx, n2)); + check_(run_experiment(test_distrib_chi_square, mx, 2*n2)); std::cout << std::endl; } private: @@ -310,9 +310,9 @@ public: std::cout << "birthday spacing: " << std::flush; boost::variate_generator > uni(rng, boost::uniform_int<>(0, (1<<25)-1)); birthday_spacing_experiment bsp(4, 512, (1<<25)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(bsp, uni, n1), n2)); - check(run_experiment(test_distrib_chi_square, + check_(run_experiment(test_distrib_chi_square, experiment_generator(bsp, uni, n1), 2*n2)); std::cout << std::endl; } @@ -365,7 +365,7 @@ public: return result; } - bool check(double chi_square_value) const + bool check_(double chi_square_value) const { return check_confidence(chi_square_value, confidence_chi_square_quantil); } @@ -425,9 +425,9 @@ private: birthday_test bday_test; }; -void test_base::check(double val) const +void test_base::check_(double val) const { - environment.check(val); + environment.check_(val); } class program_args @@ -439,7 +439,7 @@ public: names.insert(argv + 1, argv + argc); } } - bool check(const std::string & test_name) const + bool check_(const std::string & test_name) const { return(names.empty() || names.find(test_name) != names.end()); } @@ -453,7 +453,7 @@ int main(int argc, char* argv[]) test_environment env(0.99); #define TEST(name) \ - if(args.check(#name)) \ + if(args.check_(#name)) \ env.run_test(#name) TEST(minstd_rand0); @@ -487,17 +487,17 @@ int main(int argc, char* argv[]) TEST(ranlux64_3_01); TEST(ranlux64_4_01); - if(args.check("normal")) + if(args.check_("normal")) env.run_test("normal", boost::normal_distribution<>(), boost::math::normal()); - if(args.check("triangle")) + if(args.check_("triangle")) env.run_test("triangle", boost::triangle_distribution<>(0, 1, 3), boost::math::triangular(0, 1, 3)); - if(args.check("cauchy")) + if(args.check_("cauchy")) env.run_test("cauchy", boost::cauchy_distribution<>(), boost::math::cauchy()); - if(args.check("gamma")) + if(args.check_("gamma")) env.run_test("gamma", boost::gamma_distribution<>(1), boost::math::gamma_distribution<>(1)); - if(args.check("exponential")) + if(args.check_("exponential")) env.run_test("exponential", boost::exponential_distribution<>(), boost::math::exponential()); - if(args.check("lognormal")) + if(args.check_("lognormal")) env.run_test("lognormal", boost::lognormal_distribution<>(1, 1), boost::math::lognormal(std::log(1.0/std::sqrt(2.0)), std::sqrt(std::log(2.0)))); } diff --git a/test/validate.cpp b/test/validate.cpp index 3ea1edb..2a38cf2 100644 --- a/test/validate.cpp +++ b/test/validate.cpp @@ -44,45 +44,45 @@ */ // own run -bool check(unsigned long x, const boost::mt11213b&) { return x == 3809585648U; } +bool check_(unsigned long x, const boost::mt11213b&) { return x == 3809585648U; } // validation by experiment from mt19937.c -bool check(unsigned long x, const boost::mt19937&) { return x == 4123659995U; } +bool check_(unsigned long x, const boost::mt19937&) { return x == 4123659995U; } // validation values from the publications -bool check(int x, const boost::minstd_rand0&) { return x == 1043618065; } +bool check_(int x, const boost::minstd_rand0&) { return x == 1043618065; } // validation values from the publications -bool check(int x, const boost::minstd_rand&) { return x == 399268537; } +bool check_(int x, const boost::minstd_rand&) { return x == 399268537; } #if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T) // by experiment from lrand48() -bool check(unsigned long x, const boost::rand48&) { return x == 1993516219; } +bool check_(unsigned long x, const boost::rand48&) { return x == 1993516219; } #endif // ???? -bool check(unsigned long x, const boost::taus88&) { return x == 3535848941U; } +bool check_(unsigned long x, const boost::taus88&) { return x == 3535848941U; } // ???? -bool check(int x, const boost::ecuyer1988&) { return x == 2060321752; } +bool check_(int x, const boost::ecuyer1988&) { return x == 2060321752; } // validation by experiment from Harry Erwin's generator.h (private e-mail) -bool check(unsigned int x, const boost::kreutzer1986&) { return x == 139726; } +bool check_(unsigned int x, const boost::kreutzer1986&) { return x == 139726; } -bool check(double x, const boost::lagged_fibonacci607&) { return std::abs(x-0.401269) < 1e-5; } +bool check_(double x, const boost::lagged_fibonacci607&) { return std::abs(x-0.401269) < 1e-5; } // principal operation validated with CLHEP, values by experiment -bool check(unsigned long x, const boost::ranlux3&) { return x == 5957620; } -bool check(unsigned long x, const boost::ranlux4&) { return x == 8587295; } +bool check_(unsigned long x, const boost::ranlux3&) { return x == 5957620; } +bool check_(unsigned long x, const boost::ranlux4&) { return x == 8587295; } -bool check(float x, const boost::ranlux3_01&) +bool check_(float x, const boost::ranlux3_01&) { return std::abs(x-5957620/std::pow(2.0f,24)) < 1e-6; } -bool check(float x, const boost::ranlux4_01&) +bool check_(float x, const boost::ranlux4_01&) { return std::abs(x-8587295/std::pow(2.0f,24)) < 1e-6; } -bool check(double x, const boost::ranlux64_3_01&) +bool check_(double x, const boost::ranlux64_3_01&) { return std::abs(x-0.838413) < 1e-6; } -bool check(double x, const boost::ranlux64_4_01&) +bool check_(double x, const boost::ranlux64_4_01&) { return std::abs(x-0.59839) < 1e-6; } template @@ -94,7 +94,7 @@ void validate(const std::string & name, const PRNG &) rng(); typename PRNG::result_type val = rng(); // make sure the validation function is a static member - bool result = check(val, rng); + bool result = check_(val, rng); // allow for a simple eyeball check for MSVC instantiation brokenness // (if the numbers for all generators are the same, it's obviously broken)