YODA::CmpFloats Struct Reference Functor to compare two floating point numbers and return whether they are fuzzily equivalent. More...
Detailed DescriptionFunctor to compare two floating point numbers and return whether they are fuzzily equivalent. The equivalence comparison is of the form dev = |b-a|/refscale. The refscale argument may used to force the reference scale in this, otherwise (or if explicitly set to zero) it will default to (|a| + |b|)/2. The returned boolean is determined by the comparison |dev| < tol. Definition at line 20 of file Predicates.h. Constructor & Destructor Documentation◆ CmpFloats()
Definition at line 21 of file Predicates.h. 21: _tol(tol), _refscale(refscale) {}
Member Function Documentation◆ operator()()
Definition at line 22 of file Predicates.h. 22 {
23 const double div = (_refscale == 0) ? 0.5*(std::abs(a)+std::abs(b)) : _refscale;
24 const double dev = (b-a)/div;
25 // std::cout << "CmpFloats: " << a << " vs. " << b << " -> dev = " << dev << std::endl;
26 return std::abs(dev) < _tol;
27 }
The documentation for this struct was generated from the following file:
Generated on Mon Oct 28 2024 13:47:24 for YODA - Yet more Objects for Data Analysis by 1.9.8 |