From: Dave Steffen (dgsteffen_at_[hidden])
Date: 2007-02-16 12:47:58
Please don't top post. Rearranged:
Glenn Schrader writes:
> Hugo Duncan wrote:
> > Hi,
> > Just to chime in with my problems using BOOST_CHECK_CLOSE ...
> > I always have problems when checking for small numbers or zero.
> > I write something like BOOST_CHECK_CLOSE(0,x,1e-5) and start
> > wondering why it fails, then rewrite the test using an epsilon
> > value.
> > When I know the value is going to be near zero this is ok, but
> > sometimes tests are written for computed values. A possible
> > solution would be to have a check that uses the maximum of a
> > relative and an absolute tolerance.
> An absolute difference is:
> BOOST_CHECK_CLOSE( x, y, 1e-5 );
Uh, no, I don't think so. IIRC BOOST_CHECK_CLOSE does a relative
> so wouldn't a relative difference be:
> BOOST_CHECK_CLOSE( x / y, 1, 1e-5);
> or equivalently
> BOOST_CHECK_CLOSE( x, y, abs(y) * 1e-5);
> or maybe even
> BOOST_CHECK_CLOSE( x, y, max(abs(x),abs(y)) * 1e-5);
No, that's not what BOOST_CHECK_CLOSE does, unless it's changed since
1.33.1 (which is what I'm looking at). The discussion here is, very
approximately, that since it's not immediately obvious _what_ kind of
test is being done in BOOST_CHECK_CLOSE because of the name, and that
this causes confusion.
Dave Steffen, Ph.D. Fools ignore complexity.
Software Engineer IV Pragmatists suffer it.
Numerica Corporation Some can avoid it.
ph (970) 461-2000 x227 Geniuses remove it.
dgsteffen_at_[hidden] -- Alan Perlis
This message and any attachments are intended only for the individual
or entity to which the message is addressed. It is proprietary and
may contain privileged information. If you are neither the intended
recipient nor the agent responsible for delivering the message to the
intended recipient, you are hereby notified that any review,
retransmission, dissemination, or taking of any action in reliance
upon, the information in this communication is strictly prohibited,
and may be unlawful. If you feel you have received this communication
in error, please notify us immediately by returning this Email to the
sender and deleting it from your computer.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk