1 #ifndef LIB2GEOM_UTILS_HEADER
2 #define LIB2GEOM_UTILS_HEADER
39 inline bool logical_xor (
bool a,
bool b) {
return (a || b) && !(a && b); }
45 template <
class T>
inline int sgn(
const T& x) {
return (x < 0 ? -1 : (x > 0 ? 1 : 0) );}
47 template <
class T>
inline T sqr(
const T& x) {
return x * x;}
48 template <
class T>
inline T cube(
const T& x) {
return x * x * x;}
53 template <
class T>
inline const T&
between (
const T& min,
const T& max,
const T& x)
54 {
return min < x && max > x; }
60 inline double round(
double const x) {
return std::floor(x + .5); }
75 double const multiplier = std::pow(10.0, places);
76 return round( x * multiplier ) / multiplier;
double decimal_round(double const x, int const places)
Definition: utils.h:73
double round(double const x)
Definition: utils.h:60
const T & between(const T &min, const T &max, const T &x)
Definition: utils.h:53
int sgn(const T &x)
Definition: utils.h:45