Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56814 - in branches/release: . boost/fusion boost/graph boost/numeric/ublas boost/property_tree boost/random boost/random/detail boost/signals2 boost/system libs/fusion libs/graph_parallel libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/numeric/ublas libs/property_tree libs/random libs/signals2 libs/system libs/utility status tools/regression
From: steven_at_[hidden]
Date: 2009-10-14 00:54:02


Author: steven_watanabe
Date: 2009-10-14 00:54:01 EDT (Wed, 14 Oct 2009)
New Revision: 56814
URL: http://svn.boost.org/trac/boost/changeset/56814

Log:
Merge random from the trunk
Properties modified:
   branches/release/ (props changed)
   branches/release/boost/fusion/ (props changed)
   branches/release/boost/graph/ (props changed)
   branches/release/boost/numeric/ublas/ (props changed)
   branches/release/boost/property_tree/ (props changed)
   branches/release/boost/signals2/ (props changed)
   branches/release/boost/system/ (props changed)
   branches/release/index.html (props changed)
   branches/release/libs/fusion/ (props changed)
   branches/release/libs/graph_parallel/ (props changed)
   branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
   branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
   branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
   branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
   branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
   branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
   branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
   branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
   branches/release/libs/numeric/ublas/ (props changed)
   branches/release/libs/property_tree/ (props changed)
   branches/release/libs/signals2/ (props changed)
   branches/release/libs/system/ (props changed)
   branches/release/libs/utility/swap.html (props changed)
   branches/release/status/ (props changed)
   branches/release/tools/regression/ (props changed)
Text files modified:
   branches/release/boost/random/detail/signed_unsigned_tools.hpp | 4 ++--
   branches/release/boost/random/uniform_int.hpp | 2 +-
   branches/release/boost/random/uniform_real.hpp | 8 +++++---
   branches/release/libs/random/instantiate.cpp | 8 ++++++--
   4 files changed, 14 insertions(+), 8 deletions(-)

Modified: branches/release/boost/random/detail/signed_unsigned_tools.hpp
==============================================================================
--- branches/release/boost/random/detail/signed_unsigned_tools.hpp (original)
+++ branches/release/boost/random/detail/signed_unsigned_tools.hpp 2009-10-14 00:54:01 EDT (Wed, 14 Oct 2009)
@@ -61,7 +61,7 @@
 struct add<T1, T2, /* signed */ false>
 {
   typedef T2 result_type;
- result_type operator()(T1 x, T2 y) { return x + y; }
+ result_type operator()(T1 x, T2 y) { return T2(x) + y; }
 };
 
 template<class T1, class T2>
@@ -71,7 +71,7 @@
   result_type operator()(T1 x, T2 y)
   {
     if (y >= 0)
- return x + y;
+ return T2(x) + y;
     // y < 0
     if (x >= T1(-(y+1))) // result >= 0 after subtraction
       // avoid the nasty two's complement edge case for y == min()

Modified: branches/release/boost/random/uniform_int.hpp
==============================================================================
--- branches/release/boost/random/uniform_int.hpp (original)
+++ branches/release/boost/random/uniform_int.hpp 2009-10-14 00:54:01 EDT (Wed, 14 Oct 2009)
@@ -156,7 +156,7 @@
           // mult+mult*brange by (2), (3) (4)
           // Therefore result+(eng()-bmin)*mult <
           // mult*(brange+1) by (4)
- result += random::detail::subtract<base_result>()(eng(), bmin) * mult;
+ 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) {

Modified: branches/release/boost/random/uniform_real.hpp
==============================================================================
--- branches/release/boost/random/uniform_real.hpp (original)
+++ branches/release/boost/random/uniform_real.hpp 2009-10-14 00:54:01 EDT (Wed, 14 Oct 2009)
@@ -52,9 +52,11 @@
 
   template<class Engine>
   result_type operator()(Engine& eng) {
- return static_cast<result_type>(eng() - eng.min BOOST_PREVENT_MACRO_SUBSTITUTION())
- / static_cast<result_type>(eng.max BOOST_PREVENT_MACRO_SUBSTITUTION() - eng.min BOOST_PREVENT_MACRO_SUBSTITUTION())
- * (_max - _min) + _min;
+ result_type numerator = static_cast<result_type>(eng() - eng.min BOOST_PREVENT_MACRO_SUBSTITUTION());
+ result_type divisor = static_cast<result_type>(eng.max BOOST_PREVENT_MACRO_SUBSTITUTION() - eng.min BOOST_PREVENT_MACRO_SUBSTITUTION());
+ assert(divisor > 0);
+ assert(numerator >= 0 && numerator <= divisor);
+ return numerator / divisor * (_max - _min) + _min;
   }
 
 #ifndef BOOST_RANDOM_NO_STREAM_OPERATORS

Modified: branches/release/libs/random/instantiate.cpp
==============================================================================
--- branches/release/libs/random/instantiate.cpp (original)
+++ branches/release/libs/random/instantiate.cpp 2009-10-14 00:54:01 EDT (Wed, 14 Oct 2009)
@@ -56,6 +56,8 @@
   // this keeps a reference to urng
   boost::variate_generator<URNG&, Dist> genref(urng, dist);
 
+ BOOST_CHECK(gen.engine() == genref.engine());
+
 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
   // and here is a pointer to (a copy of) the urng
   URNG copy = urng;
@@ -69,10 +71,12 @@
     (void) genptr();
 #endif
   }
+ // If the values are not exactly equal, we cannot
+ // rely on them being close...
   typename Dist::result_type g = gen();
- BOOST_CHECK(std::abs(g - genref()) < 1e-6);
+ BOOST_CHECK_EQUAL(g, genref());
 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
- BOOST_CHECK(std::abs(g - genptr()) < 1e-6);
+ BOOST_CHECK_EQUAL(g, genptr());
 #endif
 
   (void) gen.engine();


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