Boost logo

Boost :

Subject: Re: [boost] [math distributions]
From: Thijs van den Berg (thijs_at_[hidden])
Date: 2008-11-29 04:59:15


John Maddock wrote:
> 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.
>
if that's try, then the first notation is more readable
>>> 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.
It was just a question. It would be a good idea then to remove the const
and make it in synch with doc's. I could do a regexp search :)
>
>>> 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.
>
I agree, if it's not public and it works, it's low priority. I would
prefer myself to work on more intereting stuff
>>> 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.
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost

-- 
SITMO Quantitative Financial Consultancy - Software Development
M.A. (Thijs) van den Berg
Tel.+31 (0)6 2411 0061
Fax.+31 (0)15 285 1984
thijs_at_[hidden] <mailto:thijs_at_[hidden]> - www.sitmo.com 
<http://www.sitmo.com>


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