Closed cgyurgyik closed 4 years ago
Thoughts on this @matthewturk ?
N = 100
For reference. The current version uses:
inline bool isKnEqual(double a, double b) noexcept {
const double diff = std::abs(a - b);
if (diff <= ABS_EPSILON) { return true; }
return diff <= std::max(std::abs(a), std::abs(b)) * REL_EPSILON;
}
The optimized version uses:
inline bool isKnEqual(double a, double b) noexcept {
return std::abs(a - b) <= ABS_EPSILON;
}
Genuinely surprised, but in principle I'd say ABS_EPSILON
by itself is fine. yt has a unit system that allows us to scale the values going in, so we can always ensure that ABS_EPSILON
is roughly within an OOM of REL_EPSILON
.
This is currently the performance bottleneck. One consideration would be to only use
return std::abs(a - b) <= ABS_EPSILON
, with degradation in accuracy. FWIW, all our current tests pass using only ABS_EPSILON