We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e28efb4 commit 1251e56Copy full SHA for 1251e56
sycl/test/devicelib/math_utils.hpp
@@ -4,15 +4,19 @@
4
// T must be float-point type
5
template <typename T>
6
bool is_about_FP(T x, T y) {
7
- if (x == y)
8
- return true;
+ // At least one input is nan
+ if (std::isnan(x) || std::isnan(y))
9
+ return std::isnan(x) && std::isnan(y);
10
+ // At least one input is inf
11
+ else if (std::isinf(x) || std::isinf(y))
12
+ return (x == y);
13
+ // two finite
14
else {
15
if (x != 0 && y != 0) {
16
T max_v = std::fmax(std::abs(x), std::abs(y));
17
return (std::abs(x - y) / max_v) <
- std::numeric_limits<T>::epsilon() * 100;
- }
- else {
18
+ std::numeric_limits<T>::epsilon() * 100;
19
+ } else {
20
if (x != 0)
21
return std::abs(x) < std::numeric_limits<T>::epsilon() * 100;
22
else
0 commit comments