#include "rangemap.h" #include #ifdef _MSC_VER #include #define isnan(x) _isnan(x) #define INFINITY (DBL_MAX+DBL_MAX) #define NAN (INFINITY-INFINITY) #else #define isnan(x) std::isnan(x) #endif /****************************************************************************************************************************** * Specializations for Range ******************************************************************************************************************************/ template<> Range::Range(): r_first(0), r_last(NAN) {} template<> bool Range::empty() const { return isnan(r_last); } template<> void Range::clear() { r_last = NAN; } template<> // DQ (9/3/2015): Intel v14 compiler warns that use of "const" is meaningless. // I think this is correct since this is being returned by value. // const double double Range::relaxed_first() const { return r_first; } template<> double Range::size() const { return empty() ? 0 : r_last-r_first; } template<> void Range::resize(const double &new_size) { assert(!empty()); if (new_size<0) { clear(); } else { r_last = r_first + new_size; } } template<> void Range::relaxed_resize(const double &new_size) { if (new_size<0) { clear(); } else { r_last = r_first + new_size; } } template<> Range::Pair Range::split_range_at(const double &at) const { assert(!empty()); assert(at>=first() && at<=last()); Range left = Range::inin(first(), at); Range right = Range::inin(at, last()); return std::make_pair(left, right); } template<> double Range::minimum() { return -INFINITY; } template<> double Range::maximum() { return INFINITY; } /****************************************************************************************************************************** * Specializations for Range ******************************************************************************************************************************/ template<> Range::Range(): r_first(0), r_last(NAN) {} template<> bool Range::empty() const { return isnan(r_last); } template<> void Range::clear() { r_last = NAN; } template<> // DQ (9/3/2015): Intel v14 compiler warns that use of "const" is meaningless. // I think this is correct since this is being returned by value. // const float float Range::relaxed_first() const { return r_first; } template<> float Range::size() const { return empty() ? 0 : r_last-r_first; } template<> void Range::resize(const float &new_size) { assert(!empty()); if (new_size<0) { clear(); } else { r_last = r_first + new_size; } } template<> void Range::relaxed_resize(const float &new_size) { if (new_size<0) { clear(); } else { r_last = r_first + new_size; } } template<> Range::Pair Range::split_range_at(const float &at) const { assert(!empty()); assert(at>=first() && at<=last()); Range left = Range::inin(first(), at); Range right = Range::inin(at, last()); return std::make_pair(left, right); } template<> float Range::minimum() { return -INFINITY; } template<> float Range::maximum() { return INFINITY; }