13#ifndef dealii_base_floating_point_copmerator_h
14#define dealii_base_floating_point_copmerator_h
41template <
typename Number>
45 typename ::internal::VectorizedArrayTrait<Number>::value_type;
46 static constexpr std::size_t
width =
67 const std::bitset<width> &
mask = std::bitset<width>().flip());
81 operator()(
const T &object1,
const T &object2)
const;
90 compare(
const std::vector<T> &
v1,
const std::vector<T> &v2)
const;
95 template <std::
size_t dim,
typename T>
97 compare(
const std::array<T, dim> &t1,
const std::array<T, dim> &t2)
const;
102 template <
int rank,
int dim,
typename T>
109 template <
int rank,
int dim,
int spacedim,
typename T>
117 template <
typename T>
144template <
typename Number>
147 const bool use_absolute_tolerance,
148 const std::bitset<width> &mask)
149 : tolerance(tolerance)
150 , use_absolute_tolerance(use_absolute_tolerance)
158template <
typename Number>
162 const T &object2)
const
164 return compare(object1, object2) == ComparisonResult::less;
169template <
typename Number>
173 const std::vector<T> &v2)
const
175 const unsigned int s1 =
v1.size(), s2 = v2.size();
177 return ComparisonResult::less;
179 return ComparisonResult::greater;
181 for (
unsigned int i = 0; i < s1; ++i)
184 if (result != ComparisonResult::equal)
187 return ComparisonResult::equal;
192template <
typename Number>
193template <std::
size_t dim,
typename T>
196 const std::array<T, dim> &t2)
const
198 for (
unsigned int i = 0; i < t1.size(); ++i)
201 if (result != ComparisonResult::equal)
204 return ComparisonResult::equal;
209template <
typename Number>
210template <
int rank,
int dim,
typename T>
215 for (
unsigned int i = 0; i < dim; ++i)
218 if (result != ComparisonResult::equal)
221 return ComparisonResult::equal;
226template <
typename Number>
227template <
int rank,
int dim,
int spacedim,
typename T>
233 for (
unsigned int i = 0; i < spacedim; ++i)
236 if (result != ComparisonResult::equal)
239 return ComparisonResult::equal;
244template <
typename Number>
253 for (
unsigned int i = 0; i < t1.size(0); ++i)
254 for (
unsigned int j = 0; j < t1.size(1); ++j)
257 if (result != ComparisonResult::equal)
260 return ComparisonResult::equal;
265template <
typename Number>
270 if (width == 1 || mask[0])
273 use_absolute_tolerance ?
277 if (s1 < s2 - tolerance)
278 return ComparisonResult::less;
279 else if (s1 > s2 + tolerance)
280 return ComparisonResult::greater;
283 return ComparisonResult::equal;
286template <
typename Number>
292 for (
unsigned int i = 0; i < width; ++i)
296 if (result != ComparisonResult::equal)
300 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()