40 #ifndef GEOGRAM_BASIC_NUMERIC
41 #define GEOGRAM_BASIC_NUMERIC
55 #define M_PI 3.14159265358979323846
156 return std::numeric_limits<float32>::max();
173 return std::numeric_limits<float64>::max();
230 template <
class T,
bool is_numeric>
244 static const size_t size =
sizeof(T);
246 static const size_t numbits = 8 *
sizeof(T);
260 LimitsHelper<T, std::numeric_limits<T>::is_specialized> {
279 const T& a_num,
const T& a_denom,
const T& b_num,
const T& b_denom
281 if(a_denom == b_denom) {
285 geo_cmp(a_num*b_denom, b_num*a_denom) *
335 return std::numeric_limits<index_t>::max();
349 return std::numeric_limits<signed_index_t>::max();
356 return std::numeric_limits<signed_index_t>::min();
369 return ((x - floor(x)) > 0.5 ? ceil(x) : floor(x));
unsigned char geo_coord_index_t
Represents dimension (e.g. 3 for 3d, 4 for 4d ...).
unsigned int geo_index_t
Represents indices.
int geo_signed_index_t
Represents possibly negative indices.
Common include file, providing basic definitions. Should be included before anything else by all head...
float64 max_float64()
Gets 64 bits float maximum positive value.
float32 max_float32()
Gets 32 bits float maximum positive value.
float32 random_float32()
Returns a 32 bits float between 0 and 1.
Sign ratio_compare(const T &a_num, const T &a_denom, const T &b_num, const T &b_denom)
Compares two rational numbers given as separate numerators and denominators.
float64 random_float64()
Returns a 64 bits float between 0 and 1.
void optimize_number_representation(T &x)
place holder for optimizing internal number representation
void random_reset()
Resets the random number generator.
int32 random_int32()
Returns a 32 bits integer between 0 and RAND_MAX.
float64 min_float64()
Gets 64 bits float minimum negative value.
float32 min_float32()
Gets 32 bits float minimum negative value.
bool is_nan(float32 x)
Checks whether a 32 bits float is "not a number".
Global Vorpaline namespace.
signed_index_t min_signed_index_t()
Gets the minimum negative value of type signed_index_t.
T geo_sqr(T x)
Gets the square value of a value.
index_t max_index_t()
Gets the maximum positive value of type index_t.
void geo_argused(const T &)
Suppresses compiler warnings about unused parameters.
geo_signed_index_t signed_index_t
The type for storing and manipulating indices differences.
void geo_clamp(T &x, T min, T max)
Clamps a value to a range.
Sign geo_sgn(const T &x)
Gets the sign of a value.
geo_index_t index_t
The type for storing and manipulating indices.
Sign
Integer constants that represent the sign of a value.
Sign geo_cmp(const T &a, const T &b)
Compares two values.
signed_index_t max_signed_index_t()
Gets the maximum positive value of type signed_index_t.
geo_coord_index_t coord_index_t
The type for storing coordinate indices, and iterating on the coordinates of a point.
Limits helper class that extends std::numeric_limits.
Extends std::numeric_limits with additional information.