MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / EqualWithSafeRelError

Function EqualWithSafeRelError

tests/cpu/UnitTestUtils.h:79–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77// avoid large relative differences for small numbers.
78template<typename T>
79inline bool EqualWithSafeRelError(T value,
80 T expected,
81 T eps,
82 T minExpected,
83 T* computedError = nullptr)
84{
85 // If value and expected are infinity, return true.
86 if (value == expected) return true;
87 if (IsNan(value) && IsNan(expected)) return true;
88 const T div = (expected > 0) ?
89 ((expected < minExpected) ? minExpected : expected) :
90 ((-expected < minExpected) ? minExpected : -expected);
91
92 T err = ((value > expected) ? value - expected : expected - value) / div;
93
94 if (computedError)
95 {
96 *computedError = err;
97 }
98
99 return (err <= eps);
100}
101
102// C++20 introduces new strongly typed, UTF-8 based, char8_t and u8string types
103// which are not implicitly convertible to char and std::string respectively.

Callers 9

ApplyCDLFunction · 0.85
TestAntiLogFunction · 0.85
OCIO_ADD_TESTFunction · 0.85
OCIO_ADD_TESTFunction · 0.85
ApplyFixedFunctionFunction · 0.85
ApplyGammaFunction · 0.85
OCIO_ADD_TESTFunction · 0.85
ValidateValuesFunction · 0.85

Calls 1

IsNanFunction · 0.85

Tested by

no test coverage detected