Assertion tripped in boost::uniform_int

Hello. I just experienced an assertion failure using the boost::minstd_rand generator: /home/packages/boost_1_29_0/boost/random/uniform_int.hpp:50: boost::uniform_int<UniformRandomNumberGenerator, IntType>::uniform_int (UniformRandomNumberGenerator &, IntType, IntType) [with UniformRandomNumberGenerator = boost::random::linear_congruential<int32_t, 48271, 0, 2147483647, 399268537>, IntType = int]: Assertion `min < max' failed. I use the following code to generate random numbers: typedef boost::minstd_rand RngType; extern RngType pseudo_rng; template <class T> T random(T min, T max) { boost::random_number_generator<RngType, T> rng(pseudo_rng); return rng(max - min + 1) + min; } Am I doing something wrong, or is there a fault in the uniform_int algorithm? Thanks, Matt. ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify mail.administrator@jupiters.com.au ********************************************************************** [Non-text portions of this message have been removed]

Hi, sorry for the delay. --- In Boost-Users@yahoogroups.com, David Pearce <yg-boost-users@m...> wrote:
Well, that's not my intention, but I can't assert that it didn't happen in this case - there are some data-dependent invocations of the random number generator. I would have thought that the generator would return 0 for rng(1). Thanks, Matt.
Dave
Am I doing something wrong, or is there a fault in the
uniform_int

matts_temp_id wrote:
The current code does not handle the case min == max. There have been other people who requested that this should work and do the obvious thing (i.e. always return min). I've checked in to the current CVS a fix that allows min == max for uniform_int. Jens Maurer

I'm not quite following here, I'm sorry. I believe David was asking whether I called my own function with parameters min == max, which would have resulted in a call to boost::random_number_generator<RNG, T>(1). Which min == max condition are you referring to? Is that the internal effect of invoking random_number_generator(1)? Matt. --- In Boost-Users@yahoogroups.com, Jens Maurer <Jens.Maurer@g...> wrote:
participants (4)
-
David Pearce
-
Jens Maurer
-
matts_temp_id
-
mvogt@juptech.com