dbeurle / neon

A finite element code
Other
10 stars 8 forks source link

approximate equality function #127

Closed shadisharba closed 5 years ago

shadisharba commented 5 years ago

This PR modifies the approximate equality function to use boost::math::relative_difference from https://www.boost.org/doc/libs/1_67_0/libs/math/doc/html/math_toolkit/float_comparison.html in addition to an absolute tolerance similar to https://www.python.org/dev/peps/pep-0485/ that can be used when comparing numbers close to zero.

In static_matrix, when the norm of the displacement or the forces is less than one, then no relative tolerance is used. What do you think?

dbeurle commented 5 years ago

What happens when we use a relative tolerance at values of 0.5 or similar? At which point is it sensible to switch from a relative to an absolute tolerance?

shadisharba commented 5 years ago

I don't think that there's a limit, it'll always be problem dependent. In the case I tried, absolute tolerance of 0.01 worked fine but I thought of making it general by not dividing on any number smaller than one which means not causing the relative tolerance to be bigger than the absolute one.

dbeurle commented 5 years ago

Sounds good to me. Thanks!