Dear Boosters, dear Jens,


After some debugging I realized another bug in the new version of the Boost random number library. uniform_real has the following operator():

result_type operator()(Engine& eng) { return eng() * (_max - _min) + _min; }

This does not work if the underlying engine does not give random numbers in an interval other than [0,1), and thus fails with all of the integer based engines in the Boost random library. Is it necessary to wrap the engine in a uniform_01 object? But then it would fail for the uniform_integer distributions? Either I am missing something here or the Boost random library is in an inconsistent and broken state. Could Jens or somebody else help me?

Matthias


Hi Matthias,

Before using the new Boost::random it is important to FORGET everything you new about the old library. I spent a day being confused. The interface really has changed!! Certainly the new interface has its advantages, but for oldtimers the changes are confusing.

The distributions all expect to be called with random numbers in the [0,1) range. In general you should always marry up a Engine (integer or whaterever) with a Distribution using variate_generator. This results in a function object that can used in the same way as the old distributions.

The other big change is to the meaning of template parameters. The user now has the ability to control if the types use references to sub objects or values. Previously they always stored sub objects as references. This change requires some tricky template type handling in variate_generator. This has the side effect of breaking compatibilty with compilers lacking partial template specialisation when the template parameters are references.

GCC 2.95.3 also seems to be broken by the changes but I unsure at the moment of the root cause.

Hopefully Jens can update the boost documentation to match the new code.

One minor bug report of my own. variate_generator.hpp line 97 has an extra trailing ";". See

 variate_generator(Engine e, Distribution d)
   : _eng(decorated_engine(e)), _dist(d) { };

I also have one question uniform_01 no longer fits, and is not part of the standard proposal. Will this be dropped from Boost to match?

All the best,
   Michael



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to