20#ifndef EXPRTK_MPFRREAL_ADAPTOR_HPP
21#define EXPRTK_MPFRREAL_ADAPTOR_HPP
40 inline bool is_true (
const mpfr::mpreal& v);
41 inline bool is_false(
const mpfr::mpreal& v);
43 template <
typename Iterator>
48 namespace rtl {
namespace io
52 void print_type(
const std::string&,
const mpfr::mpreal& v, exprtk::details::numeric::details::mpfrreal_type_tag);
69 static const mp_rnd_t
mpfr_round = mpfr::mpreal::get_default_rnd();
80 static const mpfr::mpreal
sqrt2 = mpfr::sqrt(mpfr::mpreal(2.0));
94 static inline mpfr::mpreal
value()
96 static const mpfr::mpreal epsilon =
97 #ifndef exprtk_use_mpfr_epsilon
98 mpfr::mpreal(1.0) / mpfr::mpreal (1e+20);
100 mpfr::machine_epsilon();
108 return mpfr::isnan(v);
111 template <
typename T>
114 return static_cast<int>(v.toLong());
117 template <
typename T>
120 return static_cast<long long int>(v.toLLong());
123 template <
typename T>
126 return static_cast<long long int>(v.toULLong());
175 template <
typename T>
178 return mpfr::expm1(v);
181 template <
typename T>
188 template <
typename T>
195 template <
typename T>
199 const T eps_norm = (mpfr::max(T(1),mpfr::max(mpfr::abs(v0),mpfr::abs(v1))) * epsilon);
200 return (mpfr::abs(v0 - v1) > eps_norm) ? T(1) : T(0);
203 template <
typename T>
206 if (v > T(0))
return T(+1);
207 else if (v < T(0))
return T(-1);
211 template <
typename T>
214 return mpfr::log1p(v);
217 template <
typename T>
223 template <
typename T>
226 return mpfr::erfc(v);
229 template <
typename T>
232 static const T _05 = T(0.5);
236 template <
typename T>
239 return mpfr::fmod(v0,v1);
242 template <
typename T>
245 return mpfr::pow(v0,v1);
248 template <
typename T>
251 return mpfr::log(v0) / mpfr::log(v1);
254 template <
typename T>
258 return(mpfr::sin(v) / v);
263 template <
typename T>
269 template <
typename T>
274 if ((v0_true && v1_true) || (!v0_true && !v1_true))
280 template <
typename T>
284 const T eps_norm = (mpfr::max(T(1),mpfr::max(mpfr::abs(v0),mpfr::abs(v1))) * epsilon);
285 const T diff = mpfr::abs(v0 - v1);
286 return (diff <= eps_norm) ? T(1) : T(0);
289 template <
typename T>
292 return mpfr::round(v);
295 template <
typename T>
298 const T p10 = mpfr::pow(T(10),mpfr::floor(v1));
300 return T(mpfr::ceil ((v0 * p10) - T(0.5)) / p10);
302 return T(mpfr::floor((v0 * p10) + T(0.5)) / p10);
305 template <
typename T>
308 return mpfr::isint(v);
311 template <
typename T>
322 return pow(v0, T(1) / v1);
325 template <
typename T>
328 return mpfr::hypot(v0,v1);
331 template <
typename T>
334 return mpfr::atan2(v0,v1);
337 template <
typename T>
340 return v0 * (T(1) / mpfr::pow(T(2.0),v1));
343 template <
typename T>
346 return v0 * mpfr::pow(T(2.0),v1);
349 template <
typename T>
355 template <
typename T>
361 template <
typename T>
367 template <
typename T>
375 template <
typename Iterator>
378 t = mpfr::mpreal(std::string(itr_external,end));
386 namespace rtl {
namespace io
392 #if defined(__clang__)
393 #pragma clang diagnostic push
394 #pragma clang diagnostic ignored "-Wformat-nonliteral"
395 #elif defined(__GNUC__) || defined(__GNUG__)
396 #pragma GCC diagnostic push
397 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
398 #elif defined(_MSC_VER)
401 printf(
"%s",v.toString().c_str());
403 #if defined(__clang__)
404 #pragma clang diagnostic pop
405 #elif defined(__GNUC__) || defined(__GNUG__)
406 #pragma GCC diagnostic pop
407 #elif defined(_MSC_VER)
static const mp_prec_t mpfr_precision
static const mpfr::mpreal pi
static const mpfr::mpreal pi_180
static const mpfr::mpreal _2_pi
static const mpfr::mpreal e
static const mpfr::mpreal log2
static const mpfr::mpreal sqrt2
static const mpfr::mpreal pi_2
static const mpfr::mpreal _180_pi
static const mpfr::mpreal pi_4
static const mp_rnd_t mpfr_round
static const mpfr::mpreal _1_pi
static const double sqrt2
float erf_impl(const float v)
bool is_nan_impl(const T v, real_type_tag)
T floor_impl(const T v, real_type_tag)
bool is_false_impl(const T v)
T ceil_impl(const T v, real_type_tag)
T shr_impl(const T v0, const T v1, real_type_tag)
T tanh_impl(const T v, real_type_tag)
T acosh_impl(const T v, real_type_tag)
T nor_impl(const T v0, const T v1, real_type_tag)
bool is_integer_impl(const T &v, real_type_tag)
T sinc_impl(const T v, real_type_tag)
T const_pi_impl(real_type_tag)
T asin_impl(const T v, real_type_tag)
T log10_impl(const T v, real_type_tag)
T r2d_impl(const T v, real_type_tag)
T shl_impl(const T v0, const T v1, real_type_tag)
T logn_impl(const T v0, const T v1, real_type_tag)
T sqrt_impl(const T v, real_type_tag)
T xnor_impl(const T v0, const T v1, real_type_tag)
T asinh_impl(const T v, real_type_tag)
float erfc_impl(const float v)
T const_e_impl(real_type_tag)
T d2r_impl(const T v, real_type_tag)
T neg_impl(const T v, real_type_tag)
T root_impl(const T v0, const T v1, real_type_tag)
T and_impl(const T v0, const T v1, real_type_tag)
T pos_impl(const T v, real_type_tag)
T log_impl(const T v, real_type_tag)
_uint64_t to_uint64_impl(const T v, real_type_tag)
T ncdf_impl(const T v, real_type_tag)
T csc_impl(const T v, real_type_tag)
_int64_t to_int64_impl(const T v, real_type_tag)
T log2_impl(const T v, real_type_tag)
T cot_impl(const T v, real_type_tag)
T or_impl(const T v0, const T v1, real_type_tag)
T cos_impl(const T v, real_type_tag)
T sinh_impl(const T v, real_type_tag)
T roundn_impl(const T v0, const T v1, real_type_tag)
T sec_impl(const T v, real_type_tag)
T atan2_impl(const T v0, const T v1, real_type_tag)
T pow_impl(const T v0, const T v1, real_type_tag)
T modulus_impl(const T v0, const T v1, real_type_tag)
T log1p_impl(const T v, real_type_tag)
T trunc_impl(const T v, real_type_tag)
T frac_impl(const T v, real_type_tag)
T hypot_impl(const T v0, const T v1, real_type_tag)
T nand_impl(const T v0, const T v1, real_type_tag)
T min_impl(const T v0, const T v1, real_type_tag)
T equal_impl(const T v0, const T v1, real_type_tag)
T nequal_impl(const T v0, const T v1, real_type_tag)
T g2d_impl(const T v, real_type_tag)
T max_impl(const T v0, const T v1, real_type_tag)
T exp_impl(const T v, real_type_tag)
bool is_true_impl(const T v)
T sin_impl(const T v, real_type_tag)
T round_impl(const T v, real_type_tag)
T abs_impl(const T v, real_type_tag)
T sgn_impl(const T v, real_type_tag)
T d2g_impl(const T v, real_type_tag)
T acos_impl(const T v, real_type_tag)
T tan_impl(const T v, real_type_tag)
T xor_impl(const T v0, const T v1, real_type_tag)
T expm1_impl(const T v, real_type_tag)
int to_int32_impl(const T v, real_type_tag)
T atanh_impl(const T v, real_type_tag)
T atan_impl(const T v, real_type_tag)
T notl_impl(const T v, real_type_tag)
T cosh_impl(const T v, real_type_tag)
T pow(const T v0, const T v1)
T min(const T v0, const T v1)
T max(const T v0, const T v1)
bool is_true(const double v)
bool string_to_real(Iterator &itr_external, const Iterator end, T &t, numeric::details::real_type_tag)
bool is_false(const expression_node< T > *node)
void print_type(const std::string &fmt, const T v, exprtk::details::numeric::details::real_type_tag)
static mpfr::mpreal value()