Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2001-12-07 11:16:53


I like the bool predicates a lot - they are generally useful (and missed -
and I have been tinkering with something - following examples in PJP C
Standard library, chap 7 p 178 approx // test for approx equality, but with
variable tolerance as a member variable as suggested).

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: Fernando Cacciola [mailto:fcacciola_at_[hidden]]
> Sent: Thursday, December 06, 2001 8:32 PM
> To: boost_at_[hidden]
> Subject: RE: [boost] RE: Formal review: New Boost.Test Library
>
>
>
> ----- Original Message -----
> From: Ullrich Koethe <u.koethe_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Thursday, December 06, 2001 5:07 PM
> Subject: Re: [boost] RE: Formal review: New Boost.Test Library
>
>
> > Dave Gomboc wrote:
> > >
> > > > What I suggest is to provide something like:
> > > >
> > > > template<class T> bool fp_equal(T const& l,T const& r) ;
> > > > template<class T> bool fp_equal2(T const& l,T const& r, T
> const& tol)
> > > ;
> > > > template<class T> bool fp_equal32(T const& l,T const& r, T
> const& tol)
> > > ;
> > >
> > > Using a fixed epsilon is bogus for the numerical applications
> that I am
> > > familiar with. What we really need to do is make the third argument a
> > > binary predicate returning bool whose operator() is called with the
> > > first two arguments. That wasn't a great explanation, but I hope you
> > > get what I mean.
> > >
> >
> Actually, the fp_equal() family are *exactly* those predicates. They are
> binary predicates taking *at least* two fp values and returning bool.
> A particular application could have any additional predicate with whatever
> tolerance it requires.
> In other words, the above 'fp_equal' was there only to show precisely that
> what we need is a true 'predicate'.
> We can have an 'object' with bool operator() as well. Such an object could
> even have the tolerance as a member.
>
> > So you mean there should be
> >
> > BOOST_CHECK_PREDICATE1( arg, unary_predicate)
> > and
> > BOOST_CHECK_PREDICATE2( left, right, binary_predicate)
> >
> > along with their relatives? Good idea. The float comparisions could then
> > be written
> >
> > BOOST_CHECK_PREDICATE2(left, right, close_at_tolerance(1.0e-5));
> > BOOST_CHECK_PREDICATE2(left, right, weak_close_at_tolerance(1.0e-5));
> > BOOST_CHECK_PREDICATE2(left, right,
> > close_at_estimated_tolerance(left, right, number_of_operations));
> > etc.
> >
>
> This sounds good.
>
> The macro you are proposing is of the form
> BOOST_CHECK_PREDICATE(X,Y,PRED).
>
> It evaluates PRED(X,Y),
> and the X and Y macro parameters are there only to let them being shown in
> the output.
>
> I like this better than a BOOST_CHECK_CLOSE,etc.. macro family.
>
> Fernando Cacciola
> Sierra s.r.l.
> fcacciola_at_[hidden]
> www.gosierra.com
>
>
>
> Info: http://www.boost.org Send unsubscribe requests to:
> <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