Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2001-09-05 08:02:00


I'm not sure that the checking cost is high enough to worry about.

It is usually only a couple of checks like

if ((prob < 0.) || (prob >1.))
{
        throw std::out_or_range();
}

which doesn't compare to the internal machinations of evaluation of
polynomials etc
inside.

But I take your point that both fast and safe versions might be useful
packaging.

Paul

Dr Paul A Bristow, hetp Chromatography
Prizet Farmhouse
Kendal, Cumbria
LA8 8AB UK
+44 1539 561830
Mobile +44 7714 33 02 04
mailto:pbristow_at_[hidden]

> -----Original Message-----
> From: ross_at_[hidden] [mailto:ross_at_[hidden]]On Behalf Of
> Ross Smith
> Sent: Wednesday, September 05, 2001 12:38 AM
> To: boost_at_[hidden]
> Subject: Re: [boost] Math Functions
>
>
> Jens Maurer wrote:
> >
> > boost_at_[hidden] wrote:
> >
> > > 2 Arguments
> > >
> > > Many need checks on validity of arguments.
> > > For example, probability p must be 0 <= p <= 1.
> > >
> > > What should I do after the check fails?
> > > throw standard exception out_of_range?
> >
> > That's often a longish debate. Documented preconditions
> > (such as the allowed input range) are sometimes checked with
> > "assert". That halts the program on failure. However, I think
> > for the maths functions, I'd rather see an exception instead
> > of an assert(), because it's very tedious to check all
> > preconditions in longish expressions.
>
> There needs to be a way to tell the library (at compile time) to skip
> the checks, because this sort of library is likely to be used in highly
> compute-bound contexts where checking beforehand that all initial values
> are in a known stable region of the problem space, and then running the
> whole thing with no further checking, can be an order of magnitude
> faster than checking along the way. If you insist on checking all
> function arguments, you lose a lot of potential users.
>
> Remember Kanze's Law: You can build a safe library on top of an
> efficient one, but not the other way around.
>
> --
> Ross Smith .......................................... ross.s_at_[hidden]
> Ihug (Auckland, New Zealand) ................... http://www.ihug.co.nz/
>
> +++ Divide by cucumber error - Please reinstall universe and reboot +++
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/


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