Changeset 5906
- Timestamp:
- 01/31/08 00:09:35 (5 years ago)
- Location:
- lang/cplusplus/boost-supplement/trunk
- Files:
-
- 2 modified
-
ChangeLog (modified) (1 diff)
-
boost_supplement/random/discrete_distribution.hpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/boost-supplement/trunk/ChangeLog
r5902 r5906 1 2008-01-31 Kenta Murata <muraken@gmail.com> 2 3 * boost_supplement/random/discrete_distribution.hpp 4 (boost_supplement::discrete_distribution): Adds a comment about 5 Walker's original paper of the algorithm for this class. 6 Some lines are moved for easy reading. An assertion is added. 7 1 8 2008-01-30 Kenta Murata <muraken@gmail.com> 2 9 -
lang/cplusplus/boost-supplement/trunk/boost_supplement/random/discrete_distribution.hpp
r5902 r5906 21 21 22 22 namespace boost_supplement { 23 24 /* Alastair J. Walker. An Efficient Method for Generating Discrete 25 * Random Variables With General Distributions. ACM TOMS 3(3), 26 * 253--256 (1977). */ 23 27 template<class IntType = long, class RealType = double> 24 28 class discrete_distribution … … 28 32 typedef IntType result_type; 29 33 34 #if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) && !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300) 35 BOOST_STATIC_ASSERT(std::numeric_limits<IntType>::is_integer); 36 BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer); 37 #endif 38 30 39 typedef typename std::vector<input_type>::const_iterator probability_iterator; 31 40 typedef typename std::vector<input_type>::const_reverse_iterator probability_reverse_iterator; … … 33 42 typedef typename std::vector<result_type>::const_iterator alias_iterator; 34 43 typedef typename std::vector<result_type>::const_reverse_iterator alias_reverse_iterator; 35 36 #if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) && !(defined(BOOST_MSVC) && BOOST_MSVC <= 1300)37 BOOST_STATIC_ASSERT(std::numeric_limits<IntType>::is_integer);38 BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer);39 #endif40 44 41 45 private: … … 51 55 52 56 result_type n = std::distance(first, last); 53 aliases_.resize(n,n);57 BOOST_ASSERT(0 < n); 54 58 55 59 while (first != last) { … … 57 61 ++first; 58 62 } 63 BOOST_ASSERT(n == probabilities_.size()); 59 64 60 BOOST_ASSERT(n == probabilities_.size());65 aliases_.resize(n, n); 61 66 62 67 for (result_type i = 0; i < n; ++i) {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)