ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nike::RelativeEpsilonEqualFunctor Class Reference

#include <RelativeEpsilonEqual.h>

Public Member Functions

bool operator() (float lhs, float rhs) const
 

Friends

RelativeEpsilonEqualFunctor relative_epsilon_equal (unsigned)
 

Detailed Description

Definition at line 23 of file RelativeEpsilonEqual.h.

Member Function Documentation

◆ operator()()

bool nike::RelativeEpsilonEqualFunctor::operator() ( float  lhs,
float  rhs 
) const

Definition at line 27 of file RelativeEpsilonEqual.cpp.

28{
29 if (std::isnan(lhs) && std::isnan(rhs))
30 {
31 return true;
32 }
33
34 // TODO How to handle sign difference?
35 auto const delta = std::fabs(lhs - rhs);
36 auto const max = std::max(std::fabs(lhs), std::fabs(rhs));
37
38 return delta <= (max * FLT_EPSILON * _tolerance);
39}

Friends And Related Symbol Documentation

◆ relative_epsilon_equal

RelativeEpsilonEqualFunctor relative_epsilon_equal ( unsigned  tolerance)
friend
Note
RelativeEpsilonEqualFunctor uses its own rule for NaN values.

For example, "NAN == NAN" is false but "relative_epsilon_equal(1)(NAN, NAN)" is true.

Definition at line 41 of file RelativeEpsilonEqual.cpp.

42{
43 return RelativeEpsilonEqualFunctor{tolerance};
44}

The documentation for this class was generated from the following files: