Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2703: lagged_fibonacci_01::seed() bug
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-02-01 15:48:00
#2703: lagged_fibonacci_01::seed() bug
-------------------------------+--------------------------------------------
Reporter: rick68_at_[hidden] | Owner: no-maintainer
Type: Bugs | Status: reopened
Milestone: Boost 1.38.0 | Component: random
Version: Boost 1.37.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+--------------------------------------------
Comment(by rick68_at_[hidden]):
Hi,
In <boost/random/subtract_with_carry.hpp>, I found member fucntion
substract_with_carry::seed(), it is similar lagged_fibonacci_01::seed().
line295: template<class It>[[BR]]
line296: void seed(It& first, It last)[[BR]]
line297: {[[BR]]
line298:#ifndef BOOST_NO_STDC_NAMESPACE[[BR]]
line299: // allow for Koenig lookup[[BR]]
line300: using std::fmod;[[BR]]
line301: using std::pow;[[BR]]
line302:#endif[[BR]]
line303: unsigned long mask = ~((~0u) << (w%32)); // now lowest
(w%32) bits set[[BR]]
line304: RealType two32 = pow(RealType(2), 32);[[BR]]
line305: unsigned int j;[[BR]]
line306: for(j = 0; j < long_lag && first != last; ++j) {[[BR]]
line307: x[j] = RealType(0);[[BR]]
line308: for(int i = 0; i < w/32 && first != last; ++i,
++first)[[BR]]
line309: x[j] += *first / pow(two32,i+1);[[BR]]
line310: if(first != last && mask != 0) {[[BR]]
line311: x[j] += fmod((*first & mask) / _modulus,
RealType(1));[[BR]]
line312: ++first;[[BR]]
line313: }[[BR]]
line314: }[[BR]]
line315: if(first == last && j < long_lag)[[BR]]
line316: throw
std::invalid_argument("subtract_with_carry_01::seed");[[BR]]
line317: carry = (x[long_lag-1] ? 0 : 1 / _modulus);[[BR]]
line318: k = 0;[[BR]]
line319: }[[BR]]
Maybe lagged_fibonacci_01::seed() has mistake.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/2703#comment:3> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC