Reference documentation for deal.II version 9.6.0
|
#include <deal.II/base/floating_point_comparator.h>
Public Types | |
enum class | ComparisonResult { less , equal , greater } |
using | ScalarNumber |
Public Member Functions | |
FloatingPointComparator (const ScalarNumber tolerance, const bool use_absolute_tolerance=true, const std::bitset< width > &mask=std::bitset< width >().flip()) | |
FloatingPointComparator (const FloatingPointComparator &rhs)=default | |
FloatingPointComparator (FloatingPointComparator &&rhs) noexcept=default | |
template<typename T > | |
bool | operator() (const T &object1, const T &object2) const |
template<typename T > | |
ComparisonResult | compare (const std::vector< T > &v1, const std::vector< T > &v2) const |
template<std::size_t dim, typename T > | |
ComparisonResult | compare (const std::array< T, dim > &t1, const std::array< T, dim > &t2) const |
template<int rank, int dim, typename T > | |
ComparisonResult | compare (const Tensor< rank, dim, T > &t1, const Tensor< rank, dim, T > &t2) const |
template<int rank, int dim, int spacedim, typename T > | |
ComparisonResult | compare (const DerivativeForm< rank, dim, spacedim, T > &t1, const DerivativeForm< rank, dim, spacedim, T > &t2) const |
template<typename T > | |
ComparisonResult | compare (const Table< 2, T > &t1, const Table< 2, T > &t2) const |
ComparisonResult | compare (const ScalarNumber s1, const ScalarNumber s2) const |
ComparisonResult | compare (const VectorizedArray< ScalarNumber, width > &v1, const VectorizedArray< ScalarNumber, width > &v2) const |
Static Public Attributes | |
static constexpr std::size_t | width |
Private Attributes | |
const ScalarNumber | tolerance |
const bool | use_absolute_tolerance |
const std::bitset< width > | mask |
A class that is used to compare floating point arrays (e.g. std::vector, Tensor<1,dim>, etc.). The most common use case of this comparator is for detecting arrays with the same content for the sake of compression. The idea of this class is to consider two arrays as equal if they are the same within a given tolerance. We use this comparator class within a std::map<> of the given arrays. Note that this comparison operator does not satisfy all the mathematical properties one usually wants to have (consider e.g. the numbers a=0, b=0.1, c=0.2 with tolerance 0.15; the operator gives a<c, but neither a<b? nor b<c? is satisfied). This is not a problem in the use cases for this class, but be careful when using it in other contexts.
Definition at line 44 of file floating_point_comparator.h.
using FloatingPointComparator< Number >::ScalarNumber |
Definition at line 46 of file floating_point_comparator.h.
|
strong |
An enum to decode whether a particular comparison returns less, larger, or equal. This is needed beyond the regular operator() because of efficiency reasons in nested checks as supported by this class.
Enumerator | |
---|---|
less | |
equal | |
greater |
Definition at line 56 of file floating_point_comparator.h.
FloatingPointComparator< Number >::FloatingPointComparator | ( | const ScalarNumber | tolerance, |
const bool | use_absolute_tolerance = true, | ||
const std::bitset< width > & | mask = std::bitset<width>().flip() ) |
Constructor.
Definition at line 147 of file floating_point_comparator.h.
|
default |
|
defaultnoexcept |
bool FloatingPointComparator< Number >::operator() | ( | const T & | object1, |
const T & | object2 ) const |
Compare two objects of the same type and return true
in case the first object is less than the second one. This function calls the compare() functions below, so only types supported by compare() will work with this function.
Definition at line 163 of file floating_point_comparator.h.
FloatingPointComparator< Number >::ComparisonResult FloatingPointComparator< Number >::compare | ( | const std::vector< T > & | v1, |
const std::vector< T > & | v2 ) const |
Compare two vectors of numbers (not necessarily of the same length), where vectors of different lengths are first sorted by their length and then by the entries.
Definition at line 174 of file floating_point_comparator.h.
FloatingPointComparator< Number >::ComparisonResult FloatingPointComparator< Number >::compare | ( | const std::array< T, dim > & | t1, |
const std::array< T, dim > & | t2 ) const |
Compare two arrays.
Definition at line 197 of file floating_point_comparator.h.
FloatingPointComparator< Number >::ComparisonResult FloatingPointComparator< Number >::compare | ( | const Tensor< rank, dim, T > & | t1, |
const Tensor< rank, dim, T > & | t2 ) const |
Compare two tensors.
Definition at line 214 of file floating_point_comparator.h.
FloatingPointComparator< Number >::ComparisonResult FloatingPointComparator< Number >::compare | ( | const DerivativeForm< rank, dim, spacedim, T > & | t1, |
const DerivativeForm< rank, dim, spacedim, T > & | t2 ) const |
Compare two derivative forms.
Definition at line 231 of file floating_point_comparator.h.
FloatingPointComparator< Number >::ComparisonResult FloatingPointComparator< Number >::compare | ( | const Table< 2, T > & | t1, |
const Table< 2, T > & | t2 ) const |
Compare two tables.
Definition at line 249 of file floating_point_comparator.h.
FloatingPointComparator< Number >::ComparisonResult FloatingPointComparator< Number >::compare | ( | const ScalarNumber | s1, |
const ScalarNumber | s2 ) const |
Compare two scalar numbers.
Definition at line 269 of file floating_point_comparator.h.
FloatingPointComparator< Number >::ComparisonResult FloatingPointComparator< Number >::compare | ( | const VectorizedArray< ScalarNumber, width > & | v1, |
const VectorizedArray< ScalarNumber, width > & | v2 ) const |
Compare two VectorizedArray instances.
Definition at line 290 of file floating_point_comparator.h.
|
staticconstexpr |
Definition at line 48 of file floating_point_comparator.h.
|
private |
Definition at line 137 of file floating_point_comparator.h.
|
private |
Definition at line 138 of file floating_point_comparator.h.
|
private |
Definition at line 139 of file floating_point_comparator.h.