Boost logo

Boost :

Subject: Re: [boost] [math distributions]
From: John Maddock (john_at_[hidden])
Date: 2008-11-28 13:23:18


Thijs van den Berg wrote:
>> Paul, John,
>>
>> Having looked at parts of the code in math:distributions, I have some
>> questions regarding coding in
>>
>>
>> 1) Assignments:
>> shouldn't we replace occurrences like
>> RealType result scale = dist.scale();
>> with
>> RealType result scale(dist.scale());

They are the same thing.

>> 2) The range() and support() non-member function return "*const*
>> pair<>", all others return *non*-const RealType,
>> Shouldn't all of them be const?

Does it actually make any difference given that they return the result by
value? In any case the range and support functions are actually documented
as:

template<class RealType, class Policy>
std::pair<RealType, RealType> support(const Distribution-Type<RealType,
Policy>& dist);

So I'm not sure where the extra "const" came from in the code you're seeing:
you'd probably need a compiler that supports C++0x rvalue-references to
detect the difference, and even then I'm not sure what the utility would be.

>> 3) This is one will have quite a bit of impact...
>> In common_error_handling.hpp
>> in the function inline bool check_XXX(const char* function,
>> RealType
>> const& prob, RealType* result, const Policy& pol)
>> shouldn't we replace
>> RealType* result,
>> with
>> RealType& result,
>> (and adjust all the calls)
>> to ensure that result has a valid address?

Maybe :-)

If we're designing a public interface then yes for sure, but as an
implementation detail it doesn't really make that much difference.

>> PS, I see no LambertW function in math::special_function. I'm sure
>> Knuth
>> is going to be very upset! :)

Well I've never needed it ;-)

Cheers, John.


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