From: Matthias Troyer (troyer_at_[hidden])
Date: 2007-05-12 21:45:48


On 13 May 2007, at 10:45, Neal Becker wrote:

> Matthias Troyer wrote:
>
>>
>> On 11 May 2007, at 23:13, Neal Becker wrote:
>>
>>> diff -r 5fcada374f41 boost/random/uniform_real.hpp
>>> --- a/boost/random/uniform_real.hpp Thu May 10 08:59:36 2007
>>> -0400
>>> +++ b/boost/random/uniform_real.hpp Fri May 11 11:12:44 2007
>>> -0400
>>> @@ -40,7 +40,7 @@ public:
>>> #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
>>> BOOST_STATIC_ASSERT(!
>>> std::numeric_limits<RealType>::is_integer);
>>> #endif
>>> - assert(min_arg < max_arg);
>>> + assert(min_arg <= max_arg);
>>> }
>>>
>>> // compiler-generated copy ctor and assignment operator are fine
>>
>> This does not make sense to me. uniform_real should create numbers u
>> that are
>>
>> min_arg <= u < maxarg
>>
>> Thus choosing minarg == maxarg does not make sense since the set of
>> possible values would be empty.
>>
> It's a valid limiting case.
>
> Here's the use case:
>
> Your program has a random number generator. The range is set by
> command
> line argument. For test purposes, you set the range to be
> infinitesimal.
> As it is now, you get the assertion failure. There is no good
> reason for
> this to fail, AFAICT. Allowing it is useful and harmless.

Sorry, the range is not infinitesimal but is empty. What value should
the generator return when minarg == maxarg? In that case there is no
legal value. Should the generator check and throw when invoked?

Matthias