7#ifndef BALL_MATHS_COMMON_H
8#define BALL_MATHS_COMMON_H
10#ifndef BALL_CONFIG_CONFIG_H
11# include <BALL/CONFIG/config.h>
16#ifdef BALL_HAS_IEEEFP_H
20#ifndef BALL_COMMON_CONSTANTS_H
24#ifndef BALL_COMMON_GLOBAL_H
28#ifndef BALL_COMMON_MACROS_H
52 return t >= 0 ? t : -t;
75 T
max(
const T& a,
const T& b)
88 T
max(
const T& a,
const T& b,
const T &ct)
90 return a > b ?
max(a, ct) :
max(b, ct);
100 template <
typename T>
102 T
min(
const T& a,
const T& b)
104 return a > b ? b : a;
113 template <
typename T>
115 T
min(
const T& a,
const T& b,
const T &ct)
117 return a < b ?
min(a, ct) :
min(b, ct);
125 template <
typename T>
129 return (T)(t > 0 ? long(t + 0.5) : long(t - 0.5));
136 template <
typename T>
140 return ((t < 0) ? -1 : (t == 0) ? 0 : 1);
147 template <
typename T>
151 return std::isfinite(t);
158 template <
typename T>
162 #ifdef BALL_COMPILER_MSVC
163 return (_isnan(t) != 0);
164 #elif defined(BALL_OS_DARWIN)
165 return ( __inline_isnand(t) != 0);
168 return (isnan(t) != 0);
176 template <
typename T>
187 template <
typename T>
198 template <
typename T>
210 template <
typename T1,
typename T2>
222 template <
typename T1,
typename T2>
234 template <
typename T1,
typename T2>
247 template <
typename T1,
typename T2>
259 template <
typename T1,
typename T2>
271 template <
typename T1,
typename T2>
282 template <
typename T>
293 template <
typename T>
305 template <
typename T1,
typename T2>
318 template <
typename T>
320 bool isNear(
const T& a,
const T& b,
const T& max_diff)
322 return (
abs((
double)a - (
double)b) <
abs((
double)max_diff));
329 if (x < 0.0)
return (
double)(int)(x - 0.5);
330 else return (
double)(int)(x + 0.5);
BALL_EXTERN_VARIABLE double EPSILON
bool isFinite(const T &t)
bool isNear(const T &a, const T &b, const T &max_diff)
T max(const T &a, const T &b)
bool isNotZero(const T &t)
bool isNotEqual(const T1 &a, const T2 &b)
bool isGreater(const T1 &a, const T2 &b)
bool isGreaterOrEqual(const T1 &a, const T2 &b)
bool isLess(const T1 &a, const T2 &b)
double rint(double x)
round to integral value in floating-point format
T min(const T &a, const T &b)
bool isInfinite(const T &t)
bool isLessOrEqual(const T1 &a, const T2 &b)
bool isEqual(const T1 &a, const T2 &b)
Index compare(const T1 &a, const T2 &b)