My Project
|
In the namespace cmp are implemented functions for approximate comparison of double values based on absolute and relative difference. More...
Variables | |
const double | default_abs_epsilon = 1e-8 |
const double | default_rel_epsilon = 1e-5 |
In the namespace cmp are implemented functions for approximate comparison of double values based on absolute and relative difference.
There are three functions:
scalar_equal<T>() : Compare two <T> values.
ptr_equal<T>(): This compares all the element in the two T * pointers.
vector_equal<T>(): This compares all the elements in two std::vector<T> instances.
For both vector_equal<T>() and ptr_equal<T>() the actual comparison is based on the scalar_equal<T>() function. All functions exist as two overloads, one which takes explicit input values for the absolute and relative epsilon, and one which uses default values.
The comparison functions are implemented as templates, with the following caveats:
For more details of floating point comparison please consult this reference:
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/