23 namespace TrackFindingCDC {
29 enum ESign :
signed short {
45 {
return static_cast<ESign>(-s); }
49 {
return std::abs(s) <= 1; }
63 static_cast<ESign>((not(n1 <= 0) and not(n2 <= 0)) - (not(n1 >= 0) and not(n2 >= 0))));
76 return ((std::isnan(n1) and std::isnan(n2)) ?
78 static_cast<ESign>((not(n1 <= 0) and not(n2 <= 0)) - (not(n1 >= 0) and not(n2 >= 0))));
89 static inline ESign common(
float n1,
float n2,
float n3,
float n4)
91 return ((std::isnan(n1) and std::isnan(n2) and std::isnan(n3) and std::isnan(n4)) ?
93 static_cast<ESign>((not(n1 <= 0) and not(n2 <= 0) and not(n3 <= 0) and not(n4 <= 0)) -
94 (not(n1 >= 0) and not(n2 >= 0) and not(n3 >= 0) and not(n4 >= 0))));
105 template<
class FloatRange>
108 bool allNaN = std::all_of(as.begin(), as.end(), [](
float a) { return std::isnan(a); });
110 return ESign::c_Invalid;
112 return static_cast<ESign>(std::all_of(as.begin(), as.end(), [](
float a) { return not(a <= 0); }) -
113 std::all_of(as.begin(), as.end(), [](
float a) { return not(a >= 0); }));
128 inline ESign sign(
double x)
130 return std::isnan(x) ? ESign::c_Invalid : (std::signbit(x) ? ESign::c_Minus : ESign::c_Plus);
134 inline ESign sign(
int x)
136 return static_cast<ESign>((x > 0) - (x < 0));
140 template<
class Enum, Enum inval
id = Enum::c_Inval
id>
141 inline ESign sign(Enum x)
143 if (x == Enum::c_Invalid)
return ESign::c_Invalid;
144 return sign(
static_cast<int>(x));