Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68440 - in trunk: boost/random boost/random/detail libs/random/test
From: steven_at_[hidden]
Date: 2011-01-25 14:16:56


Author: steven_watanabe
Date: 2011-01-25 14:16:54 EST (Tue, 25 Jan 2011)
New Revision: 68440
URL: http://svn.boost.org/trac/boost/changeset/68440

Log:
Add uniform_int_distribution to match C++0x.
Added:
   trunk/boost/random/uniform_int_distribution.hpp (contents, props changed)
   trunk/libs/random/test/test_uniform_int.cpp (contents, props changed)
   trunk/libs/random/test/test_uniform_int_distribution.cpp (contents, props changed)
Text files modified:
   trunk/boost/random/detail/uniform_int_float.hpp | 64 +++++++++++----------------------------
   trunk/libs/random/test/Jamfile.v2 | 2 +
   trunk/libs/random/test/test_distribution.ipp | 39 ++++++++++++++++++++++++
   trunk/libs/random/test/test_real_distribution.ipp | 12 +++---
   4 files changed, 66 insertions(+), 51 deletions(-)

Modified: trunk/boost/random/detail/uniform_int_float.hpp
==============================================================================
--- trunk/boost/random/detail/uniform_int_float.hpp (original)
+++ trunk/boost/random/detail/uniform_int_float.hpp 2011-01-25 14:16:54 EST (Tue, 25 Jan 2011)
@@ -27,54 +27,28 @@
 class uniform_int_float
 {
 public:
- typedef UniformRandomNumberGenerator base_type;
- typedef IntType result_type;
+ typedef UniformRandomNumberGenerator base_type;
+ typedef IntType result_type;
 
- uniform_int_float(base_type rng, IntType min_arg = 0, IntType max_arg = 0xffffffff)
- : _rng(rng), _min(min_arg), _max(max_arg)
- {
- init();
- }
-
- result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; }
- result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; }
- base_type& base() { return _rng.base(); }
- const base_type& base() const { return _rng.base(); }
-
- result_type operator()()
- {
- return static_cast<IntType>(_rng() * _range) + _min;
- }
-
-#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
- template<class CharT, class Traits>
- friend std::basic_ostream<CharT,Traits>&
- operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_int_float& ud)
- {
- os << ud._min << " " << ud._max;
- return os;
- }
-
- template<class CharT, class Traits>
- friend std::basic_istream<CharT,Traits>&
- operator>>(std::basic_istream<CharT,Traits>& is, uniform_int_float& ud)
- {
- is >> std::ws >> ud._min >> std::ws >> ud._max;
- ud.init();
- return is;
- }
-#endif
+ uniform_int_float(base_type rng, IntType min_arg = 0, IntType max_arg = 0xffffffff)
+ : _rng(rng), _min(min_arg), _max(max_arg) {}
+
+ result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; }
+ result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; }
+ base_type& base() { return _rng; }
+ const base_type& base() const { return _rng; }
+
+ result_type operator()()
+ {
+ typedef typename base_type::result_type base_result;
+ base_result range = static_cast<base_result>(_max-_min)+1;
+ uniform_01<typename base_type::result_type> dist;
+ return static_cast<IntType>(dist(_rng) * range) + _min;
+ }
 
 private:
- void init()
- {
- _range = static_cast<base_result>(_max-_min)+1;
- }
-
- typedef typename base_type::result_type base_result;
- uniform_01<base_type> _rng;
- result_type _min, _max;
- base_result _range;
+ base_type _rng;
+ result_type _min, _max;
 };
 
 

Added: trunk/boost/random/uniform_int_distribution.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/random/uniform_int_distribution.hpp 2011-01-25 14:16:54 EST (Tue, 25 Jan 2011)
@@ -0,0 +1,402 @@
+/* boost random/uniform_int_distribution.hpp header file
+ *
+ * Copyright Jens Maurer 2000-2001
+ * Copyright Steven Watanabe 2011
+ * 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)
+ *
+ * See http://www.boost.org for most recent version including documentation.
+ *
+ * $Id$
+ *
+ * Revision history
+ * 2001-04-08 added min<max assertion (N. Becker)
+ * 2001-02-18 moved to individual header files
+ */
+
+#ifndef BOOST_RANDOM_UNIFORM_INT_DISTRIBUTION_HPP
+#define BOOST_RANDOM_UNIFORM_INT_DISTRIBUTION_HPP
+
+#include <cassert>
+#include <iosfwd>
+#include <ios>
+#include <istream>
+#include <boost/config.hpp>
+#include <boost/limits.hpp>
+#include <boost/random/detail/config.hpp>
+#include <boost/random/detail/operators.hpp>
+#include <boost/random/detail/uniform_int_float.hpp>
+#include <boost/random/detail/pass_through_engine.hpp>
+#include <boost/random/detail/signed_unsigned_tools.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
+#include <boost/type_traits/is_integral.hpp>
+
+namespace boost {
+namespace random {
+namespace detail {
+
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+// disable division by zero warning, since we can't
+// actually divide by zero.
+#pragma warning(disable:4723)
+#endif
+
+template<class Engine, class T>
+T generate_uniform_int(
+ Engine& eng, T min_value, T max_value,
+ boost::mpl::true_ /** is_integral<Engine::result_type> */)
+{
+ typedef T result_type;
+ typedef typename make_unsigned<T>::type range_type;
+ typedef typename Engine::result_type base_result;
+ // ranges are always unsigned
+ typedef typename make_unsigned<base_result>::type base_unsigned;
+ const range_type range = random::detail::subtract<result_type>()(max_value, min_value);
+ const base_result bmin = (eng.min)();
+ const base_unsigned brange =
+ random::detail::subtract<base_result>()((eng.max)(), (eng.min)());
+
+ if(range == 0) {
+ return min_value;
+ } else if(brange == range) {
+ // this will probably never happen in real life
+ // basically nothing to do; just take care we don't overflow / underflow
+ base_unsigned v = random::detail::subtract<base_result>()(eng(), bmin);
+ return random::detail::add<base_unsigned, result_type>()(v, min_value);
+ } else if(brange < range) {
+ // use rejection method to handle things like 0..3 --> 0..4
+ for(;;) {
+ // concatenate several invocations of the base RNG
+ // take extra care to avoid overflows
+
+ // limit == floor((range+1)/(brange+1))
+ // Therefore limit*(brange+1) <= range+1
+ range_type limit;
+ if(range == (std::numeric_limits<range_type>::max)()) {
+ limit = range/(range_type(brange)+1);
+ if(range % (range_type(brange)+1) == range_type(brange))
+ ++limit;
+ } else {
+ limit = (range+1)/(range_type(brange)+1);
+ }
+
+ // We consider "result" as expressed to base (brange+1):
+ // For every power of (brange+1), we determine a random factor
+ range_type result = range_type(0);
+ range_type mult = range_type(1);
+
+ // loop invariants:
+ // result < mult
+ // mult <= range
+ while(mult <= limit) {
+ // Postcondition: result <= range, thus no overflow
+ //
+ // limit*(brange+1)<=range+1 def. of limit (1)
+ // eng()-bmin<=brange eng() post. (2)
+ // and mult<=limit. loop condition (3)
+ // Therefore mult*(eng()-bmin+1)<=range+1 by (1),(2),(3) (4)
+ // Therefore mult*(eng()-bmin)+mult<=range+1 rearranging (4) (5)
+ // result<mult loop invariant (6)
+ // Therefore result+mult*(eng()-bmin)<range+1 by (5), (6) (7)
+ //
+ // Postcondition: result < mult*(brange+1)
+ //
+ // result<mult loop invariant (1)
+ // eng()-bmin<=brange eng() post. (2)
+ // Therefore result+mult*(eng()-bmin) <
+ // mult+mult*(eng()-bmin) by (1) (3)
+ // Therefore result+(eng()-bmin)*mult <
+ // mult+mult*brange by (2), (3) (4)
+ // Therefore result+(eng()-bmin)*mult <
+ // mult*(brange+1) by (4)
+ result += static_cast<range_type>(random::detail::subtract<base_result>()(eng(), bmin) * mult);
+
+ // equivalent to (mult * (brange+1)) == range+1, but avoids overflow.
+ if(mult * range_type(brange) == range - mult + 1) {
+ // The destination range is an integer power of
+ // the generator's range.
+ return(result);
+ }
+
+ // Postcondition: mult <= range
+ //
+ // limit*(brange+1)<=range+1 def. of limit (1)
+ // mult<=limit loop condition (2)
+ // Therefore mult*(brange+1)<=range+1 by (1), (2) (3)
+ // mult*(brange+1)!=range+1 preceding if (4)
+ // Therefore mult*(brange+1)<range+1 by (3), (4) (5)
+ //
+ // Postcondition: result < mult
+ //
+ // See the second postcondition on the change to result.
+ mult *= range_type(brange)+range_type(1);
+ }
+ // loop postcondition: range/mult < brange+1
+ //
+ // mult > limit loop condition (1)
+ // Suppose range/mult >= brange+1 Assumption (2)
+ // range >= mult*(brange+1) by (2) (3)
+ // range+1 > mult*(brange+1) by (3) (4)
+ // range+1 > (limit+1)*(brange+1) by (1), (4) (5)
+ // (range+1)/(brange+1) > limit+1 by (5) (6)
+ // limit < floor((range+1)/(brange+1)) by (6) (7)
+ // limit==floor((range+1)/(brange+1)) def. of limit (8)
+ // not (2) reductio (9)
+ //
+ // loop postcondition: (range/mult)*mult+(mult-1) >= range
+ //
+ // (range/mult)*mult + range%mult == range identity (1)
+ // range%mult < mult def. of % (2)
+ // (range/mult)*mult+mult > range by (1), (2) (3)
+ // (range/mult)*mult+(mult-1) >= range by (3) (4)
+ //
+ // Note that the maximum value of result at this point is (mult-1),
+ // so after this final step, we generate numbers that can be
+ // at least as large as range. We have to really careful to avoid
+ // overflow in this final addition and in the rejection. Anything
+ // that overflows is larger than range and can thus be rejected.
+
+ // range/mult < brange+1 -> no endless loop
+ range_type result_increment =
+ generate_uniform_int(
+ eng,
+ static_cast<range_type>(0),
+ static_cast<range_type>(range/mult),
+ boost::mpl::true_());
+ if((std::numeric_limits<range_type>::max)() / mult < result_increment) {
+ // The multiplcation would overflow. Reject immediately.
+ continue;
+ }
+ result_increment *= mult;
+ // unsigned integers are guaranteed to wrap on overflow.
+ result += result_increment;
+ if(result < result_increment) {
+ // The addition overflowed. Reject.
+ continue;
+ }
+ if(result > range) {
+ // Too big. Reject.
+ continue;
+ }
+ return random::detail::add<range_type, result_type>()(result, min_value);
+ }
+ } else { // brange > range
+ base_unsigned bucket_size;
+ // it's safe to add 1 to range, as long as we cast it first,
+ // because we know that it is less than brange. However,
+ // we do need to be careful not to cause overflow by adding 1
+ // to brange.
+ if(brange == (std::numeric_limits<base_unsigned>::max)()) {
+ bucket_size = brange / (static_cast<base_unsigned>(range)+1);
+ if(brange % (static_cast<base_unsigned>(range)+1) == static_cast<base_unsigned>(range)) {
+ ++bucket_size;
+ }
+ } else {
+ bucket_size = (brange+1) / (static_cast<base_unsigned>(range)+1);
+ }
+ for(;;) {
+ base_unsigned result =
+ random::detail::subtract<base_result>()(eng(), bmin);
+ result /= bucket_size;
+ // result and range are non-negative, and result is possibly larger
+ // than range, so the cast is safe
+ if(result <= static_cast<base_unsigned>(range))
+ return random::detail::add<base_unsigned, result_type>()(result, min_value);
+ }
+ }
+}
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+template<class Engine, class T>
+inline T generate_uniform_int(
+ Engine& eng, T min_value, T max_value,
+ boost::mpl::false_ /** is_integral<Engine::result_type> */)
+{
+ pass_through_engine<Engine&> ref_wrapper(eng);
+ uniform_int_float<pass_through_engine<Engine&> > wrapper(ref_wrapper);
+ return generate_uniform_int(wrapper, min_value, max_value, boost::mpl::true_());
+}
+
+template<class Engine, class T>
+inline T generate_uniform_int(Engine& eng, T min_value, T max_value)
+{
+ typedef typename Engine::result_type base_result;
+ return generate_uniform_int(eng, min_value, max_value,
+ boost::is_integral<base_result>());
+}
+
+}
+
+/**
+ * The class template uniform_int_distribution models a \random_distribution.
+ * On each invocation, it returns a random integer value uniformly
+ * distributed in the set of integers {min, min+1, min+2, ..., max}.
+ *
+ * The template parameter IntType shall denote an integer-like value type.
+ */
+template<class IntType = int>
+class uniform_int_distribution
+{
+public:
+ typedef IntType input_type;
+ typedef IntType result_type;
+
+ class param_type
+ {
+ public:
+
+ typedef uniform_int_distribution distribution_type;
+
+ /**
+ * Constructs the parameters of a uniform_int_distribution.
+ *
+ * Requires min <= max
+ */
+ explicit param_type(
+ IntType min_arg = 0,
+ IntType max_arg = (std::numeric_limits<IntType>::max)())
+ : _min(min_arg), _max(max_arg)
+ {
+ assert(_min <= _max);
+ }
+
+ /** Returns the minimum value of the distribution. */
+ IntType a() const { return _min; }
+ /** Returns the maximum value of the distribution. */
+ IntType b() const { return _max; }
+
+ /** Writes the parameters to a @c std::ostream. */
+ BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, param_type, parm)
+ {
+ os << parm._min << " " << parm._max;
+ return os;
+ }
+
+ /** Reads the parameters from a @c std::istream. */
+ BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
+ {
+ IntType min_in, max_in;
+ if(is >> min_in >> std::ws >> max_in) {
+ if(min_in <= max_in) {
+ parm._min = min_in;
+ parm._max = max_in;
+ } else {
+ is.setstate(std::ios_base::failbit);
+ }
+ }
+ return is;
+ }
+
+ /** Returns true if the two sets of parameters are equal. */
+ BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(param_type, lhs, rhs)
+ { return lhs._min == rhs._min && lhs._max == rhs._max; }
+
+ /** Returns true if the two sets of parameters are different. */
+ BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
+
+ private:
+
+ IntType _min;
+ IntType _max;
+ };
+
+ /**
+ * Constructs a uniform_int_distribution. @c min and @c max are
+ * the parameters of the distribution.
+ *
+ * Requires: min <= max
+ */
+ explicit uniform_int_distribution(
+ IntType min_arg = 0,
+ IntType max_arg = (std::numeric_limits<IntType>::max)())
+ : _min(min_arg), _max(max_arg)
+ {
+ assert(min_arg <= max_arg);
+ }
+ /** Constructs a uniform_int_distribution from its parameters. */
+ explicit uniform_int_distribution(const param_type& parm)
+ : _min(parm.a()), _max(parm.b()) {}
+
+ /** Returns the minimum value of the distribution */
+ IntType min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; }
+ /** Returns the maximum value of the distribution */
+ IntType max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; }
+
+ /** Returns the minimum value of the distribution */
+ IntType a() const { return _min; }
+ /** Returns the maximum value of the distribution */
+ IntType b() const { return _max; }
+
+ /** Returns the parameters of the distribution. */
+ param_type param() const { return param_type(_min, _max); }
+ /** Sets the parameters of the distribution. */
+ void param(const param_type& parm)
+ {
+ _min = parm.a();
+ _max = parm.b();
+ }
+
+ /**
+ * Effects: Subsequent uses of the distribution do not depend
+ * on values produced by any engine prior to invoking reset.
+ */
+ void reset() { }
+
+ /** Returns an integer uniformly distributed in the range [min, max]. */
+ template<class Engine>
+ result_type operator()(Engine& eng) const
+ { return detail::generate_uniform_int(eng, _min, _max); }
+
+ /**
+ * Returns an integer uniformly distributed in the range
+ * [param.a(), param.b()].
+ */
+ template<class Engine>
+ result_type operator()(Engine& eng, const param_type& parm) const
+ { return detail::generate_uniform_int(eng, parm.a(), parm.b()); }
+
+ /** Writes the distribution to a @c std::ostream. */
+ BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, uniform_int_distribution, ud)
+ {
+ os << ud.param();
+ return os;
+ }
+
+ /** Reads the distribution from a @c std::istream. */
+ BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, uniform_int_distribution, ud)
+ {
+ param_type parm;
+ if(is >> parm) {
+ ud.param(parm);
+ }
+ return is;
+ }
+
+ /**
+ * Returns true if the two distributions will produce identical sequences
+ * of values given equal generators.
+ */
+ BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(uniform_int_distribution, lhs, rhs)
+ { return lhs._min == rhs._min && lhs._max == rhs._max; }
+
+ /**
+ * Returns true if the two distributions may produce different sequences
+ * of values given equal generators.
+ */
+ BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(uniform_int_distribution)
+
+private:
+ IntType _min;
+ IntType _max;
+};
+
+} // namespace random
+} // namespace boost
+
+#endif // BOOST_RANDOM_UNIFORM_INT_HPP

Modified: trunk/libs/random/test/Jamfile.v2
==============================================================================
--- trunk/libs/random/test/Jamfile.v2 (original)
+++ trunk/libs/random/test/Jamfile.v2 2011-01-25 14:16:54 EST (Tue, 25 Jan 2011)
@@ -85,6 +85,8 @@
 run test_lognormal_distribution.cpp /boost//unit_test_framework ;
 run test_triangle.cpp ;
 run test_triangle_distribution.cpp /boost//unit_test_framework ;
+run test_uniform_int.cpp ;
+run test_uniform_int_distribution.cpp /boost//unit_test_framework ;
 
 # run nondet_random_speed.cpp ;
 # run random_device.cpp ;

Modified: trunk/libs/random/test/test_distribution.ipp
==============================================================================
--- trunk/libs/random/test/test_distribution.ipp (original)
+++ trunk/libs/random/test/test_distribution.ipp 2011-01-25 14:16:54 EST (Tue, 25 Jan 2011)
@@ -10,6 +10,7 @@
  */
 
 #include <boost/random/linear_congruential.hpp>
+#include <boost/random/lagged_fibonacci.hpp>
 #include <sstream>
 #include "concepts.hpp"
 
@@ -239,3 +240,41 @@
 #endif
     }
 }
+
+BOOST_AUTO_TEST_CASE(test_generation_float) {
+ boost::lagged_fibonacci607 gen;
+ BOOST_RANDOM_DISTRIBUTION dist BOOST_RANDOM_TEST1_PARAMS;
+ BOOST_RANDOM_DISTRIBUTION dist_two BOOST_RANDOM_TEST2_PARAMS;
+ typedef BOOST_RANDOM_DISTRIBUTION::result_type result_type;
+ for(int i = 0; i < 10; ++i) {
+ result_type value = dist(gen);
+#ifdef BOOST_RANDOM_TEST1_MIN
+ BOOST_CHECK_GE(value, BOOST_RANDOM_TEST1_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST1_MAX
+ BOOST_CHECK_LE(value, BOOST_RANDOM_TEST1_MAX);
+#endif
+ result_type value_two = dist_two(gen);
+#ifdef BOOST_RANDOM_TEST2_MIN
+ BOOST_CHECK_GE(value_two, BOOST_RANDOM_TEST2_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST2_MAX
+ BOOST_CHECK_LE(value_two, BOOST_RANDOM_TEST2_MAX);
+#endif
+ result_type value_param = dist_two(gen, dist.param());
+#ifdef BOOST_RANDOM_TEST1_MIN
+ BOOST_CHECK_GE(value_param, BOOST_RANDOM_TEST1_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST1_MAX
+ BOOST_CHECK_LE(value_param, BOOST_RANDOM_TEST1_MAX);
+#endif
+ result_type value_two_param = dist(gen, dist_two.param());
+#ifdef BOOST_RANDOM_TEST2_MIN
+ BOOST_CHECK_GE(value_two_param, BOOST_RANDOM_TEST2_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST2_MAX
+ BOOST_CHECK_LE(value_two_param, BOOST_RANDOM_TEST2_MAX);
+#endif
+ }
+}
+

Modified: trunk/libs/random/test/test_real_distribution.ipp
==============================================================================
--- trunk/libs/random/test/test_real_distribution.ipp (original)
+++ trunk/libs/random/test/test_real_distribution.ipp 2011-01-25 14:16:54 EST (Tue, 25 Jan 2011)
@@ -29,8 +29,8 @@
 #include <boost/lexical_cast.hpp>
 #include <boost/exception/diagnostic_information.hpp>
 #include <boost/preprocessor/stringize.hpp>
+#include <boost/range/numeric.hpp>
 #include <iostream>
-#include <numeric>
 #include <vector>
 
 #include "statistic_tests.hpp"
@@ -57,12 +57,12 @@
 
     BOOST_RANDOM_DISTRIBUTION::result_type max_value = BOOST_RANDOM_DISTRIBUTION_MAX;
 
- std::vector<double> expected_counts(max_value+1);
+ std::vector<double> expected_pdf(max_value+1);
     {
         for(int i = 0; i <= max_value; ++i) {
- expected_counts[i] = pdf(expected, i);
+ expected_pdf[i] = pdf(expected, i);
         }
- expected_counts.back() += 1 - cdf(expected, max_value);
+ expected_pdf.back() += 1 - boost::accumulate(expected_pdf, 0.0);
     }
     
     std::vector<long long> results(max_value + 1);
@@ -70,12 +70,12 @@
         ++results[std::min(dist(gen), max_value)];
     }
 
- long long sum = std::accumulate(results.begin(), results.end(), 0ll);
+ long long sum = boost::accumulate(results, 0ll);
     if(sum != max) {
         std::cout << "*** Failed: incorrect total: " << sum << " ***" << std::endl;
         return false;
     }
- double prob = chi_squared_test(results, expected_counts, max);
+ double prob = chi_squared_test(results, expected_pdf, max);
 
 #else
 

Added: trunk/libs/random/test/test_uniform_int.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_uniform_int.cpp 2011-01-25 14:16:54 EST (Tue, 25 Jan 2011)
@@ -0,0 +1,27 @@
+/* test_uniform_int.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * 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)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_int_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/uniform.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_int_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME uniform_int
+#define BOOST_MATH_DISTRIBUTION boost::math::uniform
+#define BOOST_RANDOM_ARG1_TYPE int
+#define BOOST_RANDOM_ARG1_NAME b
+#define BOOST_RANDOM_ARG1_DEFAULT 1000
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_int<>(0, n)
+#define BOOST_RANDOM_DISTRIBUTION_INIT (0, b)
+#define BOOST_MATH_DISTRIBUTION_INIT (0, b+1)
+#define BOOST_RANDOM_DISTRIBUTION_MAX b
+
+#include "test_real_distribution.ipp"

Added: trunk/libs/random/test/test_uniform_int_distribution.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_uniform_int_distribution.cpp 2011-01-25 14:16:54 EST (Tue, 25 Jan 2011)
@@ -0,0 +1,38 @@
+/* test_uniform_int_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * 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)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_int_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_int_distribution<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 0
+#define BOOST_RANDOM_ARG2_DEFAULT 0x7fffffff
+#define BOOST_RANDOM_ARG1_VALUE 100
+#define BOOST_RANDOM_ARG2_VALUE 250
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX 0x7fffffff
+#define BOOST_RANDOM_DIST1_MIN 100
+#define BOOST_RANDOM_DIST1_MAX 0x7fffffff
+#define BOOST_RANDOM_DIST2_MIN 100
+#define BOOST_RANDOM_DIST2_MAX 250
+
+#define BOOST_RANDOM_TEST1_PARAMS (0, 9)
+#define BOOST_RANDOM_TEST1_MIN 0
+#define BOOST_RANDOM_TEST1_MAX 9
+
+#define BOOST_RANDOM_TEST2_PARAMS (10, 19)
+#define BOOST_RANDOM_TEST2_MIN 10
+#define BOOST_RANDOM_TEST2_MAX 19
+
+#include "test_distribution.ipp"


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