Giter VIP home page Giter VIP logo

Comments (4)

raffienficiaud avatar raffienficiaud commented on August 26, 2024

Hi,

There were many bug fixes since 1.60 (see here for more details).

Would you please try again with the latest version of Boost?

from test.

raffienficiaud avatar raffienficiaud commented on August 26, 2024

Sorry for the late investigation. It turns out that you cannot use BOOST_CHECK_CLOSE to compare to the value 0, as it would use the algorithm described here.

You have 2 options:

  • either use BOOST_CHECK_SMALL(-4.37113883e-08, 1.) (note . in the 1.)
  • or use BOOST_TEST(-4.37113883e-08 == 0, 1. % tt::tolerance()) (for percentage tolerance)

Hope that helps!

from test.

WilliamTambellini avatar WilliamTambellini commented on August 26, 2024

Thank you @raffienficiaud
I have retried with 1.69 and the same behavior.
Could nt find a better perf than writing my own CHECK macro doing :
CHECK_CLOSE(result, ref)
if (result == 0 || ref == 0)
BOOST_CHECK_SMALL(result - ref, 0.01f);
else
BOOST_CHECK_CLOSE(result, ref, 0.01f);

Mathematically speaking, it is legit to wonder if 0.0000001 is "close" to 0 (within a range).
Should nt it be illogic to expect BOOST_CHECK_CLOSE() to work even if left or right are 0 ?

from test.

raffienficiaud avatar raffienficiaud commented on August 26, 2024

If you look at the equations for comparison here, then only equation (1) can work when one of the arguments u or v is 0. This is why there exists BOOST_CHECK_SMALL and BOOST_CHECK_CLOSE.

On the other hand, this is done automatically with BOOST_TEST if

  • one of the arguments is floating point (since 1.70, otherwise the two arguments should be floating points)
  • and one of the argument is zero,

so you should not be needing to write your own logic.

from test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.