
Dear all: Would anyone let me know the usage of the boost::uniform_int combined with the one argument operator() of the variate_generator? I'd like to change the maximum parameter of the distribution at every step. #include <iostream> #include <boost/random.hpp> int main( void ) { boost::variate_generator< boost::mt19937, boost::uniform_int< std::size_t > > gen( boost::mt19937( 3 ), boost::uniform_int< std::size_t >() ); for ( std::size_t i(1); i < 100; ++i ) std::cout << gen( i ) << std::endl; return 0; } The gcc aborted the compile with the following errors: /usr/include/boost/random/variate_generator.hpp: In member function `typename Distribution::result_type boost::variate_generator<Engine, Distribution>::operator()(T) [with T = unsigned int, Engine = boost::mt19937, Distribution = boost::uniform_int<size_t>]': uniform_int.cpp:9: instantiated from here /usr/include/boost/random/variate_generator.hpp:107: error: no match for call to `(boost::uniform_int<size_t>) ( boost::random::detail::pass_through_engine<boost::random::detail::pass_through_engine<boost::mt19937>
&, unsigned int&)'
With regards, Masaki Nomura

Masaki Nomura wrote:
Dear all: Would anyone let me know the usage of the boost::uniform_int combined with the one argument operator() of the variate_generator?
In uniform_int.hpp: template<class Engine> result_type operator()(Engine& eng) The paramenter is engine, not an integer. You pass the mersenne_twister rng here.

In uniform_int.hpp: template<class Engine> result_type operator()(Engine& eng)
The paramenter is engine, not an integer. You pass the mersenne_twister rng here. I checked the header file in my system. As you pointed it out, I did not find
Thanks for your comment. the function; operator()( Engine& eng, int ). I think this is something inconsistent with the online document, http://www.boost.org/libs/random/random-distributions.html#uniform_int, which I read before using the library. Or, I still have further misunderstandings? With best regards, Masaki Nomura
participants (2)
-
Masaki Nomura
-
Neal D. Becker