21 namespace TrackFindingCDC {
43 {
return static_cast<ESign>(-s); }
47 {
return std::abs(s) <= 1; }
61 static_cast<ESign>((not(n1 <= 0) and not(n2 <= 0)) - (not(n1 >= 0) and not(n2 >= 0))));
74 return ((std::isnan(n1) and std::isnan(n2)) ?
76 static_cast<ESign>((not(n1 <= 0) and not(n2 <= 0)) - (not(n1 >= 0) and not(n2 >= 0))));
87 static inline ESign common(
float n1,
float n2,
float n3,
float n4)
89 return ((std::isnan(n1) and std::isnan(n2) and std::isnan(n3) and std::isnan(n4)) ?
91 static_cast<ESign>((not(n1 <= 0) and not(n2 <= 0) and not(n3 <= 0) and not(n4 <= 0)) -
92 (not(n1 >= 0) and not(n2 >= 0) and not(n3 >= 0) and not(n4 >= 0))));
103 template<
class FloatRange>
106 bool allNaN = std::all_of(as.begin(), as.end(), [](
float a) { return std::isnan(a); });
108 return ESign::c_Invalid;
110 return static_cast<ESign>(std::all_of(as.begin(), as.end(), [](
float a) { return not(a <= 0); }) -
111 std::all_of(as.begin(), as.end(), [](
float a) { return not(a >= 0); }));
126 inline ESign sign(
double x)
128 return std::isnan(x) ? ESign::c_Invalid : (std::signbit(x) ? ESign::c_Minus : ESign::c_Plus);
132 inline ESign sign(
int x)
134 return static_cast<ESign
>((x > 0) - (x < 0));
138 template<
class Enum, Enum inval
id = Enum::c_Inval
id>
139 inline ESign sign(Enum x)
141 if (x == Enum::c_Invalid)
return ESign::c_Invalid;
142 return sign(
static_cast<int>(x));
ESign
Enumeration for the distinct sign values of floating point variables.
@ c_Invalid
Constant for invalid sign, e.g. the sign of NAN.
@ c_Zero
Constant for undefined sign.
@ c_Minus
Constant for minus sign.
@ c_Plus
Constant for plus sign.
ESign opposite(ESign s)
Return the opposite sign. Leaves ESign::c_Invalid the same.
bool isValid(ESign s)
Returns true if sign is ESign::c_Plus, ESign::c_Minus or ESign::c_Zero.
static ESign common(ESign n1, ESign n2)
Check if two values have a common sign.
Abstract base class for different kinds of events.