Specialization of Cmp for checking the ordering of two floating point numbers. More...
#include <Cmp.hh>
Public Member Functions | |
operator CmpState () const | |
Automatically convert to an enum. | |
operator int () const | |
Automatically convert to an integer. | |
template<typename U > | |
const Cmp< double > & | operator|| (const Cmp< U > &c) const |
If this state is equivalent, set this state to the state of c. | |
Standard constructors and destructors. | |
Cmp (const double p1, const double p2) | |
The default constructor. | |
template<typename U > | |
Cmp (const Cmp< U > &x) | |
The copy constructor. | |
~Cmp () | |
The destructor is not virtual since this is not intended to be a base class. | |
template<typename U > | |
const Cmp< double > & | operator= (const Cmp< U > &x) |
The assignment operator. | |
Private Member Functions | |
void | _compare () const |
Perform the actual comparison if necessary. | |
Private Attributes | |
CmpState | _value |
The state of this object. | |
double | _numA |
The objects to be compared. | |
double | _numB |
Specialization of Cmp for checking the ordering of two floating point numbers.
When implicitly converted to an integer the value will be negative if the two objects used in the constructor are ordered and positive if they are not. Zero will be returned if they are equal. This specialization uses the Rivet fuzzyEquals function to indicate equivalence protected from numerical precision effects.
The main usage of the Cmp class is if several variables should be checked for ordering in which case several Cmp objects can be combined as follows: cmp(a1, a2) || cmp(b1, b2) || cmp(c1, c2)
where cmp is a global function for easy creation of Cmp objects.
Definition at line 204 of file Cmp.hh.
Cmp | ( | const double | p1, | |
const double | p2 | |||
) | [inline] |
~Cmp | ( | ) | [inline] |
void _compare | ( | ) | const [inline, private] |
Perform the actual comparison if necessary.
Definition at line 256 of file Cmp.hh.
References Cmp< T >::_value, Rivet::EQUIVALENT, Rivet::fuzzyEquals(), Rivet::ORDERED, Rivet::UNDEFINED, and Rivet::UNORDERED.
operator CmpState | ( | ) | const [inline] |
Automatically convert to an enum.
Definition at line 234 of file Cmp.hh.
References Cmp< T >::_compare(), and Cmp< T >::_value.
00235 : 00236 00237 /// Automatically convert to an enum. operator CmpState() const {
operator int | ( | ) | const [inline] |
If this state is equivalent, set this state to the state of c.
Definition at line 247 of file Cmp.hh.
References Cmp< T >::_compare(), Cmp< T >::_value, and Rivet::EQUIVALENT.
00250 { 00251 _compare();