|
Boost : |
From: Glenn Schrader (gschrad_at_[hidden])
Date: 2007-02-16 12:36:15
Hmmm.
An absolute difference is:
BOOST_CHECK_CLOSE( x, y, 1e-5 );
True??
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);
???
-glenn
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.
>
> Hugo
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk