Boost logo

Boost :

From: Dave Steffen (dgsteffen_at_[hidden])
Date: 2007-02-16 12:41:42


Hugo Duncan writes:
> 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.

 Well, IIRC BOOST_CHECK_CLOSE does a check for _relative error_. And
 you can't do relative error if one of the numbers is zero. From a
 conceptual point of view, relative error says that two values differ
 by an amount that is small relative to their magnitude. Zero has no
 magnitude, e.g. no information about what's small relative to it, so
 the question is meaningless.

 I'm wrapping a bunch of the BOOST_CHECK macros for my own use, and
 will probably come up with something else to check for "close to
 zero", e.g. an _aboslute_ tolerance; maybe "BOOST_CHECK_SMALL" or
 something.

----------------------------------------------------------------------
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
___________________
Numerica Disclaimer:
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