Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2007-02-16 22:15:49


"John Maddock" <john_at_[hidden]> wrote in message
news:003b01c751ee$40ac79e0$d0390252_at_fuji...
> Gennadiy Rozental wrote:
>> Which particular words/statements you are having difficulties with?
>
> The problem for me is that it's too easy to forget that BOOST_CHECK_CLOSE
> refers to a persentage and not a relative error. I've lost count of how
> many times I've made that mistake, even though I do understand what it
> does.
>
> BOOST_CHECK_CLOSE_FRACTION is an improvement, but still doesn't spell out
> what it does.
>
> Personally I would have liked these to have been really explicit:
>
> BOOST_CHECK_PERSENTAGE_DIFFERENCE
> BOOST_CHECK_RELATIVE_DIFFERENCE
> BOOST_CHECK_EPSILON_DIFFERENCE

IMO above names way too wordy. All above tools already exist in boost.Test

BOOST_CHECK_PERSENTAGE_DIFFERENCE = BOOST_CHECK_CLOSE
BOOST_CHECK_RELATIVE_DIFFERENCE = BOOST_CHECK_CLOSE_FRACTION
BOOST_CHECK_EPSILON_DIFFERENCE = BOOST_CHECK_SMALL (unless I
misunderstand the tool purpose)

I guess I could introduce these synonism ifthat will make everyone happy,
but I personally still perfer shorter names.

> so that at double precision then I could use any of:
>
> BOOST_CHECK_PERSENTAGE_DIFFERENCE(x, y, 4e-14); // ~ 2 eps as a percent
>
> BOOST_CHECK_RELATIVE_DIFFERENCE(x, y, 4e-16); // ~ 2eps
>
> BOOST_CHECK_EPSILON_DIFFERENCE(x, y, 2); // 2eps
>
> depending upon my mood :-)
>
> The last option is by far the most readable to me.

I will have to explain to me what expression your most readable tool
corresponds to ;)

> To put things another way: how many people do you expect to thinking in
> terms of persentage differences between floating point numbers?

Let me ask you different question: how many programmers (non-experts in fp
math) do you expect to thinking in
terms of relative error between floating point numbers?

Most developers think: "OK, I need this value to be approximately 5.5".First
impulse of any non-expert is to use formula |a-b|<e. Boost.Test recommeds to
compare relative values instead. But this is much more difficult to grasp.
Persentance difference on the other hand is much more close to what people
are using in real life: values a and b shouldn't differ for more than p%.

> I'm afraid
> we (mostly) all think in terms of epsilon units, and once in that mind
> set,
> converting to persentages just doesn't come naturally.

If under "we" you mean experts in numeric calculation - I totally agree with
you.For general developers population though I am afraid it may not be the
case and probably rather opposite.

Boost.Test still need to satisfy both customers. So I am ready for any
improvements in this regard.

Gennadiy


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