|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82820 - in branches/release: boost/random libs/random/test
From: marshall_at_[hidden]
Date: 2013-02-11 11:19:07
Author: marshall
Date: 2013-02-11 11:19:04 EST (Mon, 11 Feb 2013)
New Revision: 82820
URL: http://svn.boost.org/trac/boost/changeset/82820
Log:
Merge Fix for zero seed in Boost.Random; Fixes #7951
Added:
branches/release/libs/random/test/test_zero_seed.cpp (contents, props changed)
Properties modified:
branches/release/boost/random/subtract_with_carry.hpp (contents, props changed)
branches/release/libs/random/test/Jamfile.v2 (contents, props changed)
Text files modified:
branches/release/boost/random/subtract_with_carry.hpp | 4 ++--
branches/release/libs/random/test/Jamfile.v2 | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
Modified: branches/release/boost/random/subtract_with_carry.hpp
==============================================================================
--- branches/release/boost/random/subtract_with_carry.hpp (original)
+++ branches/release/boost/random/subtract_with_carry.hpp 2013-02-11 11:19:04 EST (Mon, 11 Feb 2013)
@@ -161,7 +161,7 @@
IntType, value)
{
typedef linear_congruential_engine<uint32_t,40014,0,2147483563> gen_t;
- gen_t intgen(static_cast<boost::uint32_t>(value));
+ gen_t intgen(static_cast<boost::uint32_t>(value == 0 ? default_seed : value));
detail::generator_seed_seq<gen_t> gen(intgen);
seed(gen);
}
@@ -392,7 +392,7 @@
boost::uint32_t, value)
{
typedef linear_congruential_engine<uint32_t, 40014, 0, 2147483563> gen_t;
- gen_t intgen(value);
+ gen_t intgen(value == 0 ? default_seed : value);
detail::generator_seed_seq<gen_t> gen(intgen);
seed(gen);
}
Modified: branches/release/libs/random/test/Jamfile.v2
==============================================================================
--- branches/release/libs/random/test/Jamfile.v2 (original)
+++ branches/release/libs/random/test/Jamfile.v2 2013-02-11 11:19:04 EST (Mon, 11 Feb 2013)
@@ -53,6 +53,7 @@
run test_lagged_fibonacci19937.cpp /boost//unit_test_framework ;
run test_lagged_fibonacci23209.cpp /boost//unit_test_framework ;
run test_lagged_fibonacci44497.cpp /boost//unit_test_framework ;
+run test_zero_seed.cpp /boost//unit_test_framework ;
# Disable by default. These don't add much and the larger
# ones can overflow the stack.
Added: branches/release/libs/random/test/test_zero_seed.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/random/test/test_zero_seed.cpp 2013-02-11 11:19:04 EST (Mon, 11 Feb 2013)
@@ -0,0 +1,29 @@
+/*
+ Test case for ticket #7951
+ tests whether or not xxx() == xxx(0) for various engines
+ Thanks to Stephen T. Lavavej for his close reading of 26.5.3.3 [rand.eng.sub]/7
+*/
+
+#include <boost/random/ranlux.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/mersenne_twister.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4244)
+#endif
+
+BOOST_AUTO_TEST_CASE(test_zero_seed)
+{
+ BOOST_CHECK(boost::random::ranlux24_base(0) == boost::random::ranlux24_base());
+ BOOST_CHECK(boost::random::minstd_rand0(0) == boost::random::minstd_rand0());
+ BOOST_CHECK(boost::random::mt19937(0) != boost::random::mt19937());
+
+ BOOST_CHECK(boost::random::ranlux48_base(0) == boost::random::ranlux48_base ());
+
+ BOOST_CHECK(boost::random::ranlux_base_01(0) == boost::random::ranlux_base_01 ());
+ BOOST_CHECK(boost::random::ranlux64_base_01(0) == boost::random::ranlux64_base_01 ());
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk