15#ifndef dealii_base_floating_point_copmerator_h
16#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 <
int rank,
int dim,
int spacedim,
typename T>
119 template <
typename T>
146template <
typename Number>
149 const bool use_absolute_tolerance,
150 const std::bitset<width> &mask)
151 : tolerance(tolerance)
152 , use_absolute_tolerance(use_absolute_tolerance)
160template <
typename Number>
164 const T &object2)
const
166 return compare(object1, object2) == ComparisonResult::less;
171template <
typename Number>
175 const std::vector<T> &v2)
const
177 const unsigned int s1 =
v1.size(), s2 = v2.size();
179 return ComparisonResult::less;
181 return ComparisonResult::greater;
183 for (
unsigned int i = 0; i < s1; ++i)
186 if (result != ComparisonResult::equal)
189 return ComparisonResult::equal;
194template <
typename Number>
195template <std::
size_t dim,
typename T>
198 const std::array<T, dim> &t2)
const
200 for (
unsigned int i = 0; i < t1.size(); ++i)
203 if (result != ComparisonResult::equal)
206 return ComparisonResult::equal;
211template <
typename Number>
212template <
int rank,
int dim,
typename T>
217 for (
unsigned int i = 0; i < dim; ++i)
220 if (result != ComparisonResult::equal)
223 return ComparisonResult::equal;
228template <
typename Number>
229template <
int rank,
int dim,
int spacedim,
typename T>
235 for (
unsigned int i = 0; i < spacedim; ++i)
238 if (result != ComparisonResult::equal)
241 return ComparisonResult::equal;
246template <
typename Number>
255 for (
unsigned int i = 0; i < t1.size(0); ++i)
256 for (
unsigned int j = 0; j < t1.size(1); ++j)
259 if (result != ComparisonResult::equal)
262 return ComparisonResult::equal;
267template <
typename Number>
272 if (width == 1 || mask[0])
275 use_absolute_tolerance ?
279 if (s1 < s2 - tolerance)
280 return ComparisonResult::less;
281 else if (s1 > s2 + tolerance)
282 return ComparisonResult::greater;
285 return ComparisonResult::equal;
288template <
typename Number>
294 for (
unsigned int i = 0; i < width; ++i)
298 if (result != ComparisonResult::equal)
302 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
typename ::internal::VectorizedArrayTrait< Number >::value_type ScalarNumber
const ScalarNumber tolerance
static constexpr std::size_t width
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()