16#ifndef dealii_base_floating_point_copmerator_h
17#define dealii_base_floating_point_copmerator_h
43template <
typename Number>
47 typename ::internal::VectorizedArrayTrait<Number>::value_type;
48 static constexpr std::size_t
width =
69 const std::bitset<width> &
mask = std::bitset<width>().flip());
83 operator()(
const T &object1,
const T &object2)
const;
92 compare(
const std::vector<T> &
v1,
const std::vector<T> &v2)
const;
97 template <std::
size_t dim,
typename T>
99 compare(
const std::array<T, dim> &t1,
const std::array<T, dim> &t2)
const;
104 template <
int rank,
int dim,
typename T>
111 template <
typename T>
138template <
typename Number>
141 const bool use_absolute_tolerance,
142 const std::bitset<width> &mask)
143 : tolerance(tolerance)
144 , use_absolute_tolerance(use_absolute_tolerance)
152template <
typename Number>
156 const T &object2)
const
158 return compare(object1, object2) == ComparisonResult::less;
163template <
typename Number>
167 const std::vector<T> &v2)
const
169 const unsigned int s1 =
v1.size(), s2 = v2.size();
171 return ComparisonResult::less;
173 return ComparisonResult::greater;
175 for (
unsigned int i = 0; i < s1; ++i)
178 if (result != ComparisonResult::equal)
181 return ComparisonResult::equal;
186template <
typename Number>
187template <std::
size_t dim,
typename T>
190 const std::array<T, dim> &t2)
const
192 for (
unsigned int i = 0; i < t1.size(); ++i)
195 if (result != ComparisonResult::equal)
198 return ComparisonResult::equal;
203template <
typename Number>
204template <
int rank,
int dim,
typename T>
209 for (
unsigned int i = 0; i < dim; ++i)
212 if (result != ComparisonResult::equal)
215 return ComparisonResult::equal;
220template <
typename Number>
229 for (
unsigned int i = 0; i < t1.size(0); ++i)
230 for (
unsigned int j = 0; j < t1.size(1); ++j)
233 if (result != ComparisonResult::equal)
236 return ComparisonResult::equal;
241template <
typename Number>
246 if (width == 1 || mask[0])
249 use_absolute_tolerance ?
253 if (s1 < s2 - tolerance)
254 return ComparisonResult::less;
255 else if (s1 > s2 + tolerance)
256 return ComparisonResult::greater;
259 return ComparisonResult::equal;
262template <
typename Number>
268 for (
unsigned int i = 0; i < width; ++i)
272 if (result != ComparisonResult::equal)
276 return ComparisonResult::equal;
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcMessage(std::string arg1)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
bool operator()(const T &object1, const T &object2) const
FloatingPointComparator(const FloatingPointComparator &rhs)=default
const std::bitset< width > mask
FloatingPointComparator(FloatingPointComparator &&rhs) noexcept=default
const ScalarNumber tolerance
static constexpr std::size_t width
typename ::internal::VectorizedArrayTrait< Number >::value_type ScalarNumber
const bool use_absolute_tolerance
ComparisonResult compare(const std::vector< T > &v1, const std::vector< T > &v2) const
FloatingPointComparator(const ScalarNumber tolerance, const bool use_absolute_tolerance=true, const std::bitset< width > &mask=std::bitset< width >().flip())
static constexpr std::size_t width()