1 #ifndef _RHEOLEF_FLOAT_H
2 #define _RHEOLEF_FLOAT_H
59 #include "rheolef/config.h"
107 #include "rheolef/numeric_flags.h"
112 #if defined(_RHEOLEF_HAVE_FLOAT128)
113 #include <boost/multiprecision/float128.hpp>
115 using boost::multiprecision::float128;
116 using namespace boost::multiprecision;
117 static inline float128 sqr (
const float128& x) {
return (x*x); }
118 static inline float128
norm (
const float128& x) {
return fabs(x); }
120 using Float = float128;
127 #elif defined(_RHEOLEF_HAVE_CLN)
128 # include "rheolef/bigfloat.h"
131 typedef bigfloat<_RHEOLEF_DIGITS10>
Float;
134 #elif defined(_RHEOLEF_HAVE_LONG_DOUBLE)
137 typedef long double Float;
148 namespace rheolef {
namespace details {
149 template <
class T,
class Sfinae =
void>
154 typename
std::enable_if<
155 std::is_arithmetic<T>::value
156 || std::is_same<typename std::decay<T>::type,double>::value
160 #ifdef _RHEOLEF_HAVE_FLOAT128
163 typename
std::enable_if<
164 std::is_same<typename std::decay<T>::type,float128>::value
167 #endif // _RHEOLEF_HAVE_FLOAT128
173 namespace rheolef {
namespace details {
174 template<
class T,
class Check = T>
187 #if !defined(_RHEOLEF_HAVE_SQR_DOUBLE)
189 static inline double sqr (
const double& x) {
return (x*x); }
193 #include <functional>
203 template <
class T>
T max (
T x,
int y) {
return x > y ? x :
T(y); }
204 template <
class T>
T max (
int x,
T y) {
return x > y ?
T(x) : y; }
205 template <
class T>
T min (
T x,
int y) {
return x < y ? x :
T(y); }
206 template <
class T>
T min (
int x,
T y) {
return x < y ?
T(x) : y; }
208 template <
class T>
T abs (
T x) {
return (x >
T(0) ? x : -x); }
214 #endif // _RHEOLEF_FLOAT_H