Boost logo

Boost :

Subject: Re: [boost] [math][distributions] superfluous checking ofparameters?
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-10-31 09:25:14

>> * If the current policy (a template param) is to throw on domain errors
>> (the default), then the second check in the non-member functions is
>> redundant as any errors will have triggered an exception in the
>> distribution constructor. On the other hand:
>> * If the current policy is to not throw (return NaN on domain errors),
>> then the constructor checks are redundant and the non-member function
>> checks are the required ones.
>> If it really is a performance bottleneck, then we could add a check on
>> the current exception policy so that those two mutually exclusive options
>> get optimized at compile time.
>>From a performance point of view, suppose I wanted to have a Policy
>>mechanism that allows me to eliminate *all* error checking machine
>>instructions from a distribution constructor of distribution non member
> Would it be possible to move the detail::check_scale(d) etc into the
> Policy class? That way I could provide a different policy that get's
> eliminated compile time via an implementation like
> "inline policy::check_scale(d){return;}"

I don't think we could move all the checks inside the policy class as each
distribution is more or less different, but we could pass a compile time
param to the checking functions to have the same effect. In fact can you
file a bug report so I don't forget?

Cheers, John.

Boost list run by bdawes at, gregod at, cpdaniel at, john at