|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69976 - trunk/boost/random
From: steven_at_[hidden]
Date: 2011-03-14 16:09:39
Author: steven_watanabe
Date: 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
New Revision: 69976
URL: http://svn.boost.org/trac/boost/changeset/69976
Log:
Make sure that discard is always provided by using uintmax_t instead of ulong_long_type.
Text files modified:
trunk/boost/random/additive_combine.hpp | 4 +---
trunk/boost/random/discard_block.hpp | 7 +++----
trunk/boost/random/independent_bits.hpp | 7 +++----
trunk/boost/random/inversive_congruential.hpp | 7 +++----
trunk/boost/random/lagged_fibonacci.hpp | 12 ++++--------
trunk/boost/random/linear_congruential.hpp | 11 ++++-------
trunk/boost/random/linear_feedback_shift.hpp | 7 +++----
trunk/boost/random/mersenne_twister.hpp | 6 ++----
trunk/boost/random/shuffle_order.hpp | 6 ++----
trunk/boost/random/subtract_with_carry.hpp | 16 ++++++----------
trunk/boost/random/xor_combine.hpp | 4 +---
11 files changed, 32 insertions(+), 55 deletions(-)
Modified: trunk/boost/random/additive_combine.hpp
==============================================================================
--- trunk/boost/random/additive_combine.hpp (original)
+++ trunk/boost/random/additive_combine.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -195,14 +195,12 @@
void generate(Iter first, Iter last)
{ detail::generate_from_int(*this, first, last); }
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
_mlcg1.discard(z);
_mlcg2.discard(z);
}
-#endif
/**
* Writes the state of an @c additive_combine_engine to a @c
Modified: trunk/boost/random/discard_block.hpp
==============================================================================
--- trunk/boost/random/discard_block.hpp (original)
+++ trunk/boost/random/discard_block.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -19,6 +19,7 @@
#include <iostream>
#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/random/detail/config.hpp>
@@ -112,14 +113,12 @@
return _rng();
}
-#ifndef BOOST_NO_LONG_LONG
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
- for(boost::ulong_long_type j = 0; j < z; ++j) {
+ for(boost::uintmax_t j = 0; j < z; ++j) {
(*this)();
}
}
-#endif
template<class It>
void generate(It first, It last)
Modified: trunk/boost/random/independent_bits.hpp
==============================================================================
--- trunk/boost/random/independent_bits.hpp (original)
+++ trunk/boost/random/independent_bits.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -19,6 +19,7 @@
#include <boost/assert.hpp>
#include <boost/limits.hpp>
#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
#include <boost/integer/integer_mask.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/random/detail/config.hpp>
@@ -179,15 +180,13 @@
void generate(Iter first, Iter last)
{ detail::generate_from_int(*this, first, last); }
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
- for(boost::ulong_long_type i = 0; i < z; ++i) {
+ for(boost::uintmax_t i = 0; i < z; ++i) {
(*this)();
}
}
-#endif
const base_type& base() const { return _base; }
Modified: trunk/boost/random/inversive_congruential.hpp
==============================================================================
--- trunk/boost/random/inversive_congruential.hpp (original)
+++ trunk/boost/random/inversive_congruential.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -20,6 +20,7 @@
#include <stdexcept>
#include <boost/assert.hpp>
#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
#include <boost/integer/static_log2.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/const_mod.hpp>
@@ -168,15 +169,13 @@
void generate(Iter first, Iter last)
{ detail::generate_from_int(*this, first, last); }
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
- for(boost::ulong_long_type j = 0; j < z; ++j) {
+ for(boost::uintmax_t j = 0; j < z; ++j) {
(*this)();
}
}
-#endif
/**
* Writes the textual representation of the generator to a @c std::ostream.
Modified: trunk/boost/random/lagged_fibonacci.hpp
==============================================================================
--- trunk/boost/random/lagged_fibonacci.hpp (original)
+++ trunk/boost/random/lagged_fibonacci.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -127,15 +127,13 @@
void generate(Iter first, Iter last)
{ detail::generate_from_int(*this, first, last); }
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
- for(boost::ulong_long_type j = 0; j < z; ++j) {
+ for(boost::uintmax_t j = 0; j < z; ++j) {
(*this)();
}
}
-#endif
/**
* Writes the textual representation of the generator to a @c std::ostream.
@@ -343,15 +341,13 @@
void generate(Iter first, Iter last)
{ return detail::generate_from_real(*this, first, last); }
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
- for(boost::ulong_long_type j = 0; j < z; ++j) {
+ for(boost::uintmax_t j = 0; j < z; ++j) {
(*this)();
}
}
-#endif
/**
* Writes the textual representation of the generator to a @c std::ostream.
Modified: trunk/boost/random/linear_congruential.hpp
==============================================================================
--- trunk/boost/random/linear_congruential.hpp (original)
+++ trunk/boost/random/linear_congruential.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -20,6 +20,7 @@
#include <stdexcept>
#include <boost/assert.hpp>
#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/integer/static_log2.hpp>
@@ -186,9 +187,8 @@
void generate(Iter first, Iter last)
{ detail::generate_from_int(*this, first, last); }
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
typedef const_mod<IntType, m> mod_type;
IntType b_inv = mod_type::invert(a-1);
@@ -202,7 +202,7 @@
// we're storing the intermediate result / b_gcd
IntType a_zm1_over_gcd = 0;
IntType a_km1_over_gcd = (a - 1) / b_gcd;
- boost::ulong_long_type exponent = z;
+ boost::uintmax_t exponent = z;
while(exponent != 0) {
if(exponent % 2 == 1) {
a_zm1_over_gcd =
@@ -224,7 +224,6 @@
_x = mod_type::mult_add(a_z, _x, mod_type::mult(b_inv, num));
}
}
-#endif
friend bool operator==(const linear_congruential_engine& x,
const linear_congruential_engine& y)
@@ -402,10 +401,8 @@
/** Returns the next value of the generator. */
uint32_t operator()() { return static_cast<uint32_t>(lcf() >> 17); }
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z) { lcf.discard(z); }
-#endif
+ void discard(boost::uintmax_t z) { lcf.discard(z); }
/** Fills a range with random values */
template<class Iter>
Modified: trunk/boost/random/linear_feedback_shift.hpp
==============================================================================
--- trunk/boost/random/linear_feedback_shift.hpp (original)
+++ trunk/boost/random/linear_feedback_shift.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -18,6 +18,7 @@
#include <iosfwd>
#include <stdexcept>
#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <boost/integer/integer_mask.hpp>
#include <boost/random/detail/config.hpp>
@@ -126,15 +127,13 @@
void generate(Iter first, Iter last)
{ detail::generate_from_int(*this, first, last); }
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
- for(boost::ulong_long_type j = 0; j < z; ++j) {
+ for(boost::uintmax_t j = 0; j < z; ++j) {
(*this)();
}
}
-#endif
/**
* Writes the textual representation of the generator to a @c std::ostream.
Modified: trunk/boost/random/mersenne_twister.hpp
==============================================================================
--- trunk/boost/random/mersenne_twister.hpp (original)
+++ trunk/boost/random/mersenne_twister.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -197,7 +197,6 @@
void generate(Iter first, Iter last)
{ detail::generate_from_int(*this, first, last); }
-#ifndef BOOST_NO_LONG_LONG
/**
* Advances the state of the generator by @c z steps. Equivalent to
*
@@ -207,13 +206,12 @@
* }
* @endcode
*/
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
- for(boost::ulong_long_type j = 0; j < z; ++j) {
+ for(boost::uintmax_t j = 0; j < z; ++j) {
(*this)();
}
}
-#endif
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/** Writes a mersenne_twister_engine to a @c std::ostream */
Modified: trunk/boost/random/shuffle_order.hpp
==============================================================================
--- trunk/boost/random/shuffle_order.hpp (original)
+++ trunk/boost/random/shuffle_order.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -179,15 +179,13 @@
return y;
}
-#ifndef BOOST_NO_LONG_LONG
/** Advances the generator by z steps. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
- for(boost::ulong_long_type j = 0; j < z; ++j) {
+ for(boost::uintmax_t j = 0; j < z; ++j) {
(*this)();
}
}
-#endif
/** Fills a range with pseudo-random values. */
template<class Iter>
Modified: trunk/boost/random/subtract_with_carry.hpp
==============================================================================
--- trunk/boost/random/subtract_with_carry.hpp (original)
+++ trunk/boost/random/subtract_with_carry.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -40,8 +40,8 @@
namespace detail {
-template<class Engine, class UIntType>
-void subtract_with_carry_discard(Engine& eng, UIntType z) {
+template<class Engine>
+void subtract_with_carry_discard(Engine& eng, boost::uintmax_t z) {
typedef typename Engine::result_type IntType;
const std::size_t short_lag = Engine::short_lag;
const std::size_t long_lag = Engine::long_lag;
@@ -204,13 +204,11 @@
return result;
}
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
detail::subtract_with_carry_discard(*this, z);
}
-#endif
/** Fills a range with random values. */
template<class It>
@@ -262,7 +260,7 @@
return x[(k+index) % long_lag];
}
- friend void detail::subtract_with_carry_discard<>(subtract_with_carry_engine&, boost::ulong_long_type);
+ friend void detail::subtract_with_carry_discard<>(subtract_with_carry_engine&, boost::uintmax_t);
IntType do_update(std::size_t current, std::size_t short_index, IntType carry)
{
@@ -448,11 +446,9 @@
return result;
}
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{ detail::subtract_with_carry_discard(*this, z); }
-#endif
/** Fills a range with random values. */
template<class Iter>
@@ -504,7 +500,7 @@
return x[(k+index) % long_lag];
}
- friend void detail::subtract_with_carry_discard<>(subtract_with_carry_01_engine&, boost::ulong_long_type);
+ friend void detail::subtract_with_carry_discard<>(subtract_with_carry_01_engine&, boost::uintmax_t);
RealType do_update(std::size_t current, std::size_t short_index, RealType carry)
{
Modified: trunk/boost/random/xor_combine.hpp
==============================================================================
--- trunk/boost/random/xor_combine.hpp (original)
+++ trunk/boost/random/xor_combine.hpp 2011-03-14 16:09:37 EDT (Mon, 14 Mar 2011)
@@ -126,14 +126,12 @@
void generate(Iter first, Iter last)
{ detail::generate_from_int(*this, first, last); }
-#ifndef BOOST_NO_LONG_LONG
/** Advances the state of the generator by @c z. */
- void discard(boost::ulong_long_type z)
+ void discard(boost::uintmax_t z)
{
_rng1.discard(z);
_rng2.discard(z);
}
-#endif
/** Returns the smallest value that the generator can produce. */
static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return (std::min)((URNG1::min)(), (URNG2::min)()); }
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