Tolerance

Declared in lemon/tolerance.h, in the group Miscellaneous Tools; the same class on the Doxygen site.

template< class T >
class Tolerance

A class to provide a basic way to handle the comparison of numbers that are obtained as a result of a probably inexact computation.

Tolerance is a class to provide a basic way to handle the comparison of numbers that are obtained as a result of a probably inexact computation.

The general implementation is suitable only if the data type is exact, like the integer types, otherwise a specialized version must be implemented. These specialized classes like Tolerance< double > may offer additional tuning parameters.

Comparisons

The concept is that these bool functions return true only if the related comparisons hold even if some numerical error appeared during the computations.

static inline bool less( Value a , Value b )

Returns true if a is surely strictly less than b.

static inline bool different( Value a , Value b )

Returns true if a is surely different from b.

static inline bool positive( Value a )

Returns true if a is surely positive.

static inline bool negative( Value a )

Returns true if a is surely negative.

static inline bool nonZero( Value a )

Returns true if a is surely non-zero.

Public Types

typedef T Value

Public Static Functions

static inline Value zero()

Returns the zero value.

template<>
class Tolerance< float >

Float specialization of Tolerance.

See also

Tolerance

Comparisons

See Tolerance for more details.

inline bool less( Value a , Value b ) const

Returns true if a is surely strictly less than b.

inline bool different( Value a , Value b ) const

Returns true if a is surely different from b.

inline bool positive( Value a ) const

Returns true if a is surely positive.

inline bool negative( Value a ) const

Returns true if a is surely negative.

inline bool nonZero( Value a ) const

Returns true if a is surely non-zero.

Public Types

typedef float Value

Public Functions

inline Tolerance()

Constructor setting the epsilon tolerance to the default value.

inline Tolerance( float e )

Constructor setting the epsilon tolerance to the given value.

inline Value epsilon() const

Returns the epsilon value.

inline void epsilon( Value e )

Sets the epsilon value.

Public Static Functions

static inline Value defaultEpsilon()

Returns the default epsilon value.

static inline void defaultEpsilon( Value e )

Sets the default epsilon value.

static inline Value zero()

Returns zero.

template<>
class Tolerance< double >

Double specialization of Tolerance.

See also

Tolerance

Comparisons

See Tolerance for more details.

inline bool less( Value a , Value b ) const

Returns true if a is surely strictly less than b.

inline bool different( Value a , Value b ) const

Returns true if a is surely different from b.

inline bool positive( Value a ) const

Returns true if a is surely positive.

inline bool negative( Value a ) const

Returns true if a is surely negative.

inline bool nonZero( Value a ) const

Returns true if a is surely non-zero.

Public Types

typedef double Value

Public Functions

inline Tolerance()

Constructor setting the epsilon tolerance to the default value.

inline Tolerance( double e )

Constructor setting the epsilon tolerance to the given value.

inline Value epsilon() const

Returns the epsilon value.

inline void epsilon( Value e )

Sets the epsilon value.

Public Static Functions

static inline Value defaultEpsilon()

Returns the default epsilon value.

static inline void defaultEpsilon( Value e )

Sets the default epsilon value.

static inline Value zero()

Returns zero.

template<>
class Tolerance< long double >

Long double specialization of Tolerance.

See also

Tolerance

Comparisons

See Tolerance for more details.

inline bool less( Value a , Value b ) const

Returns true if a is surely strictly less than b.

inline bool different( Value a , Value b ) const

Returns true if a is surely different from b.

inline bool positive( Value a ) const

Returns true if a is surely positive.

inline bool negative( Value a ) const

Returns true if a is surely negative.

inline bool nonZero( Value a ) const

Returns true if a is surely non-zero.

Public Types

typedef long double Value

Public Functions

inline Tolerance()

Constructor setting the epsilon tolerance to the default value.

inline Tolerance( long double e )

Constructor setting the epsilon tolerance to the given value.

inline Value epsilon() const

Returns the epsilon value.

inline void epsilon( Value e )

Sets the epsilon value.

Public Static Functions

static inline Value defaultEpsilon()

Returns the default epsilon value.

static inline void defaultEpsilon( Value e )

Sets the default epsilon value.

static inline Value zero()

Returns zero.