I'm using gfortran and I'm starting to write a new program that I know will have billions and billions of float equality checks (think "Monte-Carlo simulation"). And I need to know if two real numbers are "close enough".
It could be a simple number (a == b
) or 2D/3D points, and even complex numbers. (I'll mostly do simple numbers, however.)
Are you aware of a gfortran intrinsic that could help me here, or a perhaps a function in BLAS/LAPACK that could do the trick. Or maybe some neat (possibly non portable) trick for blazing fast comparison? An epsilon of 0.0001 should be enough for me, but maybe there is a magic number that gfortran on x86_64 could optimize with bitwise operation.
I don't really know and google couldn't find a solution for me. Can you ?
If you're not aware of a neat trick, what do you think would be the fastest implementation of the traditional abs(a-b) <= epsilon
? Or is it simply the fastest and there is nothing I can do about it? (luckily it's a "pure" function so it will probably be inlined)