|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63279 - in trunk: boost/random libs/random/doc libs/random/test
From: steven_at_[hidden]
Date: 2010-06-23 23:57:43
Author: steven_watanabe
Date: 2010-06-23 23:57:42 EDT (Wed, 23 Jun 2010)
New Revision: 63279
URL: http://svn.boost.org/trac/boost/changeset/63279
Log:
Sync ranlux with C++0x.
Text files modified:
trunk/boost/random/ranlux.hpp | 52 ++++++++++++++++++++++++++-------------
trunk/boost/random/subtract_with_carry.hpp | 4 ++
trunk/libs/random/doc/generators.qbk | 4 ++
trunk/libs/random/doc/random.qbk | 20 ++++++++------
trunk/libs/random/test/Jamfile.v2 | 2 +
trunk/libs/random/test/instantiate.cpp | 2 +
trunk/libs/random/test/validate.cpp | 9 ++++++
7 files changed, 65 insertions(+), 28 deletions(-)
Modified: trunk/boost/random/ranlux.hpp
==============================================================================
--- trunk/boost/random/ranlux.hpp (original)
+++ trunk/boost/random/ranlux.hpp 2010-06-23 23:57:42 EDT (Wed, 23 Jun 2010)
@@ -23,12 +23,7 @@
namespace boost {
namespace random {
- typedef subtract_with_carry_engine<int, 24, 10, 24> ranlux_base;
- typedef subtract_with_carry_01_engine<float, 24, 10, 24> ranlux_base_01;
- typedef subtract_with_carry_01_engine<double, 48, 10, 24> ranlux64_base_01;
-}
-namespace random {
namespace detail {
/**
* The ranlux family of generators are described in
@@ -49,33 +44,56 @@
*/
class ranlux_documentation {};
}
-}
+
+typedef subtract_with_carry_engine<int, 24, 10, 24> ranlux_base;
+typedef subtract_with_carry_01_engine<float, 24, 10, 24> ranlux_base_01;
+typedef subtract_with_carry_01_engine<double, 48, 10, 24> ranlux64_base_01;
+
/** @copydoc boost::random::detail::ranlux_documentation */
-typedef random::discard_block_engine<random::ranlux_base, 223, 24> ranlux3;
+typedef discard_block_engine<ranlux_base, 223, 24> ranlux3;
/** @copydoc boost::random::detail::ranlux_documentation */
-typedef random::discard_block_engine<random::ranlux_base, 389, 24> ranlux4;
+typedef discard_block_engine<ranlux_base, 389, 24> ranlux4;
/** @copydoc boost::random::detail::ranlux_documentation */
-typedef random::discard_block_engine<random::ranlux_base_01, 223, 24> ranlux3_01;
+typedef discard_block_engine<ranlux_base_01, 223, 24> ranlux3_01;
/** @copydoc boost::random::detail::ranlux_documentation */
-typedef random::discard_block_engine<random::ranlux_base_01, 389, 24> ranlux4_01;
+typedef discard_block_engine<ranlux_base_01, 389, 24> ranlux4_01;
/** @copydoc boost::random::detail::ranlux_documentation */
-typedef random::discard_block_engine<random::ranlux64_base_01, 223, 24> ranlux64_3_01;
+typedef discard_block_engine<ranlux64_base_01, 223, 24> ranlux64_3_01;
/** @copydoc boost::random::detail::ranlux_documentation */
-typedef random::discard_block_engine<random::ranlux64_base_01, 389, 24> ranlux64_4_01;
+typedef discard_block_engine<ranlux64_base_01, 389, 24> ranlux64_4_01;
#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
-namespace random {
- typedef random::subtract_with_carry_engine<int64_t, 48, 10, 24> ranlux64_base;
-}
+typedef subtract_with_carry_engine<int64_t, 48, 10, 24> ranlux64_base;
/** @copydoc boost::random::detail::ranlux_documentation */
-typedef random::discard_block_engine<random::ranlux64_base, 223, 24> ranlux64_3;
+typedef discard_block_engine<ranlux64_base, 223, 24> ranlux64_3;
/** @copydoc boost::random::detail::ranlux_documentation */
-typedef random::discard_block_engine<random::ranlux64_base, 389, 24> ranlux64_4;
+typedef discard_block_engine<ranlux64_base, 389, 24> ranlux64_4;
#endif /* !BOOST_NO_INT64_T && !BOOST_NO_INTEGRAL_INT64_T */
+
+typedef subtract_with_carry_engine<uint32_t, 24, 10, 24> ranlux24_base;
+typedef subtract_with_carry_engine<uint64_t, 48, 5, 12> ranlux48_base;
+
+typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
+#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
+typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
+#endif
+}
+
+using random::ranlux3;
+using random::ranlux4;
+using random::ranlux3_01;
+using random::ranlux4_01;
+using random::ranlux64_3_01;
+using random::ranlux64_4_01;
+#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
+using random::ranlux64_3;
+using random::ranlux64_4;
+#endif
+
} // namespace boost
#endif // BOOST_RANDOM_LINEAR_CONGRUENTIAL_HPP
Modified: trunk/boost/random/subtract_with_carry.hpp
==============================================================================
--- trunk/boost/random/subtract_with_carry.hpp (original)
+++ trunk/boost/random/subtract_with_carry.hpp 2010-06-23 23:57:42 EDT (Wed, 23 Jun 2010)
@@ -109,7 +109,9 @@
for(std::size_t j = 0; j < long_lag; j++) {
IntType val = 0;
for(std::size_t k = 0; k < (w+31)/32; ++k) {
- val += storage[(w+31)/32*j + k] << 32*k;
+ result_type inc =
+ static_cast<result_type>(storage[(w+31)/32*j + k]);
+ val += inc << 32*k;
}
x[j] = val % modulus;
}
Modified: trunk/libs/random/doc/generators.qbk
==============================================================================
--- trunk/libs/random/doc/generators.qbk (original)
+++ trunk/libs/random/doc/generators.qbk 2010-06-23 23:57:42 EDT (Wed, 23 Jun 2010)
@@ -1,5 +1,5 @@
[/
- / Copyright (c) 2009 Steven Watanabe
+ / Copyright (c) 2009-2010 Steven Watanabe
/
/ Distributed under the Boost Software License, Version 1.0. (See
/ accompanying file LICENSE_1_0.txt or copy at
@@ -70,6 +70,8 @@
[[__ranlux4_01] [~10[sup 171]] [`24*sizeof(float)`] [[ranlux4_speed]] [-]]
[[__ranlux64_3_01] [~10[sup 171]] [`24*sizeof(double)`] [[ranlux64_3_speed]] [-]]
[[__ranlux64_4_01] [~10[sup 171]] [`24*sizeof(double)`] [[ranlux64_4_speed]] [-]]
+ [[__ranlux24] [~10[sup 171]] [`24*sizeof(uint32_t)`] [] [-]]
+ [[__ranlux48] [~10[sup 171]] [`12*sizeof(uint64_t)`] [] [-]]
]
As observable from the table, there is generally a quality/performance/memory
Modified: trunk/libs/random/doc/random.qbk
==============================================================================
--- trunk/libs/random/doc/random.qbk (original)
+++ trunk/libs/random/doc/random.qbk 2010-06-23 23:57:42 EDT (Wed, 23 Jun 2010)
@@ -1,7 +1,7 @@
[library Boost.Random
[quickbook 1.5]
[authors [Maurer, Jens]]
- [copyright 2000-2005 Jens Maurer, 2009 Steven Watanabe]
+ [copyright 2000-2005 Jens Maurer, 2009-2010 Steven Watanabe]
[license
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
@@ -49,14 +49,16 @@
[def __lagged_fibonacci19937 [classref boost::lagged_fibonacci19937 lagged_fibonacci19937]]
[def __lagged_fibonacci23209 [classref boost::lagged_fibonacci23209 lagged_fibonacci23209]]
[def __lagged_fibonacci44497 [classref boost::lagged_fibonacci44497 lagged_fibonacci44497]]
-[def __ranlux3 [classref boost::ranlux3 ranlux3]]
-[def __ranlux4 [classref boost::ranlux4 ranlux4]]
-[def __ranlux64_3 [classref boost::ranlux64_3 ranlux64_3]]
-[def __ranlux64_4 [classref boost::ranlux64_4 ranlux64_4]]
-[def __ranlux3_01 [classref boost::ranlux3_01 ranlux3_01]]
-[def __ranlux4_01 [classref boost::ranlux4_01 ranlux4_01]]
-[def __ranlux64_3_01 [classref boost::ranlux64_3_01 ranlux64_3_01]]
-[def __ranlux64_4_01 [classref boost::ranlux64_4_01 ranlux64_4_01]]
+[def __ranlux3 [classref boost::random::ranlux3 ranlux3]]
+[def __ranlux4 [classref boost::random::ranlux4 ranlux4]]
+[def __ranlux64_3 [classref boost::random::ranlux64_3 ranlux64_3]]
+[def __ranlux64_4 [classref boost::random::ranlux64_4 ranlux64_4]]
+[def __ranlux3_01 [classref boost::random::ranlux3_01 ranlux3_01]]
+[def __ranlux4_01 [classref boost::random::ranlux4_01 ranlux4_01]]
+[def __ranlux64_3_01 [classref boost::random::ranlux64_3_01 ranlux64_3_01]]
+[def __ranlux64_4_01 [classref boost::random::ranlux64_4_01 ranlux64_4_01]]
+[def __ranlux24 [classref boost::random::ranlux24 ranlux24]]
+[def __ranlux48 [classref boost::random::ranlux48 ranlux48]]
[def __uniform_smallint [classref boost::uniform_smallint uniform_smallint]]
[def __uniform_int [classref boost::uniform_int uniform_int]]
Modified: trunk/libs/random/test/Jamfile.v2
==============================================================================
--- trunk/libs/random/test/Jamfile.v2 (original)
+++ trunk/libs/random/test/Jamfile.v2 2010-06-23 23:57:42 EDT (Wed, 23 Jun 2010)
@@ -34,6 +34,8 @@
ranlux4_01
ranlux64_3_01
ranlux64_4_01
+ ranlux24
+ ranlux48
taus88
;
Modified: trunk/libs/random/test/instantiate.cpp
==============================================================================
--- trunk/libs/random/test/instantiate.cpp (original)
+++ trunk/libs/random/test/instantiate.cpp 2010-06-23 23:57:42 EDT (Wed, 23 Jun 2010)
@@ -406,6 +406,8 @@
void instantiate_all()
{
using namespace boost;
+ using boost::random::ranlux24;
+ using boost::random::ranlux48;
typedef boost::random::lagged_fibonacci<boost::uint32_t, 24, 607, 273> lagged_fibonacci;
Modified: trunk/libs/random/test/validate.cpp
==============================================================================
--- trunk/libs/random/test/validate.cpp (original)
+++ trunk/libs/random/test/validate.cpp 2010-06-23 23:57:42 EDT (Wed, 23 Jun 2010)
@@ -89,6 +89,11 @@
bool check_(double x, const boost::ranlux64_4_01&)
{ return std::abs(x-0.59839) < 1e-6; }
+bool check_(boost::uint32_t x, const boost::random::ranlux24&) { return x == 9901578; }
+#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
+bool check_(boost::uint64_t x, const boost::random::ranlux48&) { return x == UINT64_C(249142670248501); }
+#endif
+
template<class PRNG>
void validate(const std::string & name, const PRNG &)
{
@@ -127,6 +132,10 @@
validate("ranlux4_01", ranlux4_01());
validate("ranlux64_3_01", ranlux64_3_01());
validate("ranlux64_4_01", ranlux64_4_01());
+ validate("ranlux24", random::ranlux24());
+#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
+ validate("ranlux48", random::ranlux48());
+#endif
validate("taus88", taus88());
validate("lagged_fibonacci607", lagged_fibonacci607());
}
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