Boost logo

Boost :

From: Douglas Gregor (dgregor_at_[hidden])
Date: 2004-12-31 11:43:47


On Dec 31, 2004, at 10:51 AM, Jens Maurer wrote:
> Doug Gregor wrote:
>> I'm having a few problems dealing with uniform_real and uniform_01.
>> The basic issue is that uniform_real does not always produce values
>> between its min and its max.
>
> uniform_real was meant to be used with variate_generate<> only.
> Reviewing the language in the ISO C++ TR draft seems to miss
> one requirement: That the Engine used as input for uniform_real()
> always returns numbers in the range [0..1[, if floating-point numbers
> are requested. This is one of the features of variate_generate<>:
> it wraps the original Engine so that this is always the case.

Interesting. Looks like I should be using variate_generator more often.

> Note that the current ISO C++ TR draft already requires
> that the input Engine produce numbers of the "correct" type
> (floating-point or integer).
>
>> Looking at the source to uniform_real, the problem is obvious:
>> result_type operator()(Engine& eng) { return eng() * (_max - _min)
>> + _min; }
>
> Yes. Fixed.

Thanks!

>> However, uniform_01 is also broken in several ways:
>
> uniform_01, at this time, is just an implementation helper
> for variate_generator<> and thus should move to the details
> namespace ASAP. Since it's hideously broken for general
> use right now, I'm inclined to perform the move without
> any deprecation period.

Sounds good to me.

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk