Changeset 5913 for lang/cplusplus
- Timestamp:
- 01/31/08 01:45:27 (5 years ago)
- Location:
- lang/cplusplus/boost-supplement/trunk
- Files:
-
- 3 modified
-
ChangeLog (modified) (1 diff)
-
boost_supplement/random/discrete_distribution.hpp (modified) (2 diffs)
-
boost_supplement/random/zipf_distribution.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/boost-supplement/trunk/ChangeLog
r5908 r5913 1 1 2008-01-31 Kenta Murata <muraken@gmail.com> 2 3 * boost_supplement/random/zipf_distribution.hpp: Correct the 4 return type of make_dist function, and modify buffer 5 initialization and a for-loop condition. 6 7 * boost_supplement/random/discrete_distribution.hpp: Includes 8 <boost/assert.hpp>. Modifies operator() to correct its wrong 9 algorithm. 2 10 3 11 * boost_supplement/random/zipf_distribution.hpp -
lang/cplusplus/boost-supplement/trunk/boost_supplement/random/discrete_distribution.hpp
r5906 r5913 13 13 #define BOOST_SUPPLEMENT_DISCRETE_DISTRIBUTION_HPP 1 14 14 15 #include <boost/assert.hpp> 15 16 #include <boost/random/uniform_real.hpp> 16 17 #include <boost/concept_check.hpp> … … 166 167 { 167 168 boost::uniform_real<input_type> ud; 168 input_type u = ud(eng) ;169 input_type u = ud(eng)*num(); 169 170 result_type x = result_type(u); 170 171 u -= x; 171 if ( probabilities_[x] < u) return x;172 if (u < probabilities_[x]) return x; 172 173 return aliases_[x]; 173 174 } -
lang/cplusplus/boost-supplement/trunk/boost_supplement/random/zipf_distribution.hpp
r5908 r5913 47 47 dist_type dist_; 48 48 49 voidmake_dist(result_type num, input_type shift, input_type exp)49 dist_type make_dist(result_type num, input_type shift, input_type exp) 50 50 { 51 std::vector<input_type> buffer(num );52 for (result_type k = 1; k < =num; ++k)51 std::vector<input_type> buffer(num + 1, input_type(0)); 52 for (result_type k = 1; k < num; ++k) 53 53 buffer[k] = std::pow(k + shift, -exp); 54 54 return dist_type(buffer.begin(), buffer.end());
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)