8 #ifndef IMPALGEBRA_UTILITY_H 
    9 #define IMPALGEBRA_UTILITY_H 
   12 #include <IMP/algebra/algebra_config.h> 
   15 IMPALGEBRA_BEGIN_NAMESPACE
 
   18 inline bool xorT(
bool x, 
bool y) { 
return (((x) && !(y)) || (!(x) && (y))); }
 
   21 inline double get_squared(
double x) { 
return x * x; }
 
   45     return static_cast<int>((x) + 0.5);
 
   47     return static_cast<int>((x) - 0.5);
 
   66   if (x < x0) 
return x0;
 
   67   if (x > xF) 
return xF;
 
   97   if ((x - q) < (p - x)) {
 
  108                                  const double epsilon) {
 
  109   return (std::abs(a - b) < epsilon);
 
  112 IMPALGEBRA_END_NAMESPACE
 
double get_next_larger_power_of_2(double x)
Closest power of 2 that can contain a number x. 
 
Exception definitions and assertions. 
 
int get_sign(const T &x)
Sign of a number. 1 if the number is higher or equal to 0 and -1 otherwise. 
 
int get_rounded(const T &x)
Rounds a number to next integer. 
 
bool get_are_almost_equal(const double a, const double b, const double epsilon)
Compare two values for "almost equal" (intended for doubles) 
 
T get_constrained(const T x, const T x0, const T xF)
Constrain a value between two given limits. 
 
double get_closer_power_of_2(double x)
Closest power of 2 for a number, not necessarily higher.