Boost logo

Boost :

Subject: Re: [boost] [math distributions] where to check for validity of distribution variables?
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2008-11-22 12:53:13


> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
On
> Behalf Of John Maddock
> Sent: 22 November 2008 09:55
> To: boost_at_[hidden]
> Subject: Re: [boost] [math distributions] where to check for validity of
distribution
> variables?
>
> Thijs van den Berg wrote:
> >>>>> What do you think? We might turn "having valid parameters" into a
> >>>>> property of *all*
> >>>>> distribution. As an alternative, we might add a non member
> >>>>> function bool valid<distributionType...
> >>>>> but that wouldn't allow for caching validation in e.g. a
> >>>>> constructor
> >>>
> >>> Sounds fine to me.
> >> thats great! What's your opinion on the fact that you can only set
> >> parameter in the constructor?
> >> E.g. the normal distribution does a parameter check in the
> >> constructor,
> >> and those parameters
> >> can't change after that.
>
> That's what the existing distributions do. In fact we could omit most of
> the subsequent parameter checking code if we could figure out whether the
> error handlers will throw or not on error (in fact we *can* get this
> information at compile time and make the subsequent checks a no-op if we
> know that the constructor would have thrown on error... we just ran out of
> time on that refinement).

As I recall, we figured that the time it saved compared with the
mega-whirring that would follow was negligible.

What was important was to catch dud parameters, so checking even if
redundantly was worth it.

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal, UK   LA8 8AB
+44 1539 561830, mobile +44 7714330204
pbristow_at_[hidden]

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