16 #ifndef dealii_base_floating_point_copmerator_h
17 #define dealii_base_floating_point_copmerator_h
44 template <
typename Number>
48 typename ::internal::VectorizedArrayTrait<Number>::value_type;
49 static constexpr std::size_t
width =
70 const std::bitset<width> &
mask = std::bitset<width>().flip());
93 compare(
const std::vector<T> &
v1,
const std::vector<T> &v2)
const;
98 template <std::
size_t dim,
typename T>
100 compare(
const std::array<T, dim> &t1,
const std::array<T, dim> &t2)
const;
105 template <
int rank,
int dim,
typename T>
112 template <
int rank,
int dim,
int spacedim,
typename T>
120 template <
typename T>
147 template <
typename Number>
150 const bool use_absolute_tolerance,
151 const std::bitset<width> &mask)
152 : tolerance(tolerance)
153 , use_absolute_tolerance(use_absolute_tolerance)
161 template <
typename Number>
162 template <
typename T>
165 const T &object2)
const
167 return compare(object1, object2) == ComparisonResult::less;
172 template <
typename Number>
173 template <
typename T>
176 const std::vector<T> &v2)
const
178 const unsigned int s1 =
v1.size(), s2 = v2.size();
180 return ComparisonResult::less;
182 return ComparisonResult::greater;
184 for (
unsigned int i = 0; i < s1; ++i)
187 if (result != ComparisonResult::equal)
190 return ComparisonResult::equal;
195 template <
typename Number>
196 template <std::
size_t dim,
typename T>
199 const std::array<T, dim> &t2)
const
201 for (
unsigned int i = 0; i < t1.size(); ++i)
204 if (result != ComparisonResult::equal)
207 return ComparisonResult::equal;
212 template <
typename Number>
213 template <
int rank,
int dim,
typename T>
218 for (
unsigned int i = 0; i < dim; ++i)
221 if (result != ComparisonResult::equal)
224 return ComparisonResult::equal;
229 template <
typename Number>
230 template <
int rank,
int dim,
int spacedim,
typename T>
236 for (
unsigned int i = 0; i < dim; ++i)
239 if (result != ComparisonResult::equal)
242 return ComparisonResult::equal;
247 template <
typename Number>
248 template <
typename T>
256 for (
unsigned int i = 0; i < t1.
size(0); ++i)
257 for (
unsigned int j = 0; j < t1.
size(1); ++j)
260 if (result != ComparisonResult::equal)
263 return ComparisonResult::equal;
268 template <
typename Number>
273 if (width == 1 || mask[0])
276 use_absolute_tolerance ?
278 ((std::abs(s1) + std::abs(s2)) * this->tolerance);
280 if (s1 < s2 - tolerance)
281 return ComparisonResult::less;
282 else if (s1 > s2 + tolerance)
283 return ComparisonResult::greater;
286 return ComparisonResult::equal;
289 template <
typename Number>
295 for (
unsigned int i = 0; i < width; ++i)
299 if (result != ComparisonResult::equal)
303 return ComparisonResult::equal;
size_type size(const unsigned int i) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcMessage(std::string arg1)
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()