11 #ifndef LARCORE_COREUTILS_REALCOMPARISONS_H 12 #define LARCORE_COREUTILS_REALCOMPARISONS_H 65 template <
typename RealType>
78 {
return !
zero(value); }
82 {
return zero(a - b); }
86 {
return !
equal(a, b); }
128 return (lower < upper)
129 ?
within(value, lower, upper)
130 :
within(value, upper, lower)
141 template <
typename RealType>
148 : comparer(comparer) {}
160 template <
typename Vect>
161 constexpr
bool zero(Vect
const& v)
const 162 {
return comp().zero(v.X()) && comp().zero(v.Y()); }
165 template <
typename Vect>
169 template <
typename VectA,
typename VectB>
170 constexpr
bool equal(VectA
const& a, VectB
const& b)
const 171 {
return comp().equal(a.X(), b.X()) && comp().equal(a.Y(), b.Y()); }
174 template <
typename VectA,
typename VectB>
175 constexpr
bool nonEqual(VectA
const& a, VectB
const& b)
const 176 {
return !
equal(a, b); }
186 template <
typename RealType>
191 template <
typename RealType>
199 template <
typename RealType>
210 : comparer(comparer) {}
225 template <
typename Vect>
226 constexpr
bool zero(Vect
const& v)
const 227 {
return comp2D().zero(v) && comp().
zero(v.Z()); }
230 template <
typename Vect>
234 template <
typename VectA,
typename VectB>
235 constexpr
bool equal(VectA
const& a, VectB
const& b)
const 236 {
return comp2D().equal(a, b) && comp().
equal(a.Z(), b.Z()); }
239 template <
typename VectA,
typename VectB>
240 constexpr
bool nonEqual(VectA
const& a, VectB
const& b)
const 241 {
return !
equal(a, b); }
251 template <
typename RealType>
256 template <
typename RealType>
269 #endif // LARCORE_COREUTILS_REALCOMPARISONS_H constexpr Vector3DComparison(Comp_t const &comparer)
Copy the specified comparison.
Namespace for general, non-LArSoft-specific utilities.
constexpr bool nonEqual(Value_t a, Value_t b) const
Returns whether a and b are farther than the threshold.
constexpr bool zero(Vect const &v) const
Returns whether the specified vector is null (within tolerance).
Class comparing 2D vectors.
Provides simple real number checks.
constexpr Comp_t comp() const
Returns the basic value comparer.
constexpr bool zero(Value_t value) const
Returns whether the value is no farther from 0 than the threshold.
auto makeVector2DComparison(RealType threshold)
Creates a Vector2DComparison from a RealComparisons object.
Comp_t const comparer
Comparison object.
constexpr Vector3DComparison(RealType threshold)
Use the specified threshold.
constexpr bool equal(VectA const &a, VectB const &b) const
Returns whether the specified vectors match (within tolerance).
constexpr bool withinSorted(Value_t value, Value_t lower, Value_t upper) const
Returns whether value is between bounds (included); bounds are sorted.
constexpr bool nonEqual(VectA const &a, VectB const &b) const
Returns whether the specified vectors do not match (within tolerance).
constexpr RealComparisons(Value_t threshold)
type of values being compered
constexpr bool strictlySmaller(Value_t a, Value_t b) const
Returns whether a is strictly smaller than b.
constexpr bool strictlyGreater(Value_t a, Value_t b) const
Returns whether a is strictly greater than b.
auto makeVector3DComparison(RealType threshold)
Creates a Vector3DComparison from a RealComparisons object.
constexpr Vector2DComparison(Comp_t const &comparer)
Copy the specified comparison.
Vector2DComparison(Comp_t &&comparer)
Steal the specified comparison.
Class comparing 2D vectors.
constexpr bool strictlyNegative(Value_t value) const
Returns whether value is larger than zero beyond tolerance.
constexpr bool nonGreater(Value_t a, Value_t b) const
Returns whether a is smaller than (or equal to) b.
constexpr Comp_t comp() const
Returns the base value comparer.
constexpr bool strictlyPositive(Value_t value) const
Returns whether value is smaller than zero beyond tolerance.
Vector3DComparison(Comp_t &&comparer)
Steal the specified comparison.
std::string value(boost::any const &)
constexpr Vector2DComparison(RealType threshold)
Use the specified threshold.
LArSoft-specific namespace.
constexpr bool nonEqual(VectA const &a, VectB const &b) const
Returns whether the specified vectors do not match (within tolerance).
constexpr bool nonNegative(Value_t value) const
Returns whether value is larger than or equal() to zero.
constexpr bool nonZero(Value_t value) const
Returns whether the value is farther from 0 than the threshold.
constexpr bool zero(Vect const &v) const
Returns whether the specified vector is null (within tolerance).
constexpr bool nonZero(Vect const &v) const
Returns whether the specified vector is not null (within tolerance).
constexpr bool nonSmaller(Value_t a, Value_t b) const
Returns whether a is greater than (or equal to) b.
constexpr Comp2D_t comp2D() const
Returns the 2D vector comparer.
constexpr bool equal(Value_t a, Value_t b) const
Returns whether a and b are no farther than the threshold.
constexpr bool nonPositive(Value_t value) const
Returns whether value is smaller than or equal() to zero.
constexpr bool within(Value_t value, Value_t lower, Value_t upper) const
Returns whether value is between the bounds (included)
constexpr bool equal(VectA const &a, VectB const &b) const
Returns whether the specified vectors match (within tolerance).
constexpr bool nonZero(Vect const &v) const
Returns whether the specified vector is not null (within tolerance).