20#ifndef EXPRTK_MPFRREAL_ADAPTOR_HPP
21#define EXPRTK_MPFRREAL_ADAPTOR_HPP
32 namespace numeric {
namespace details
34 struct mpfrreal_type_tag;
37 template <
typename T>
inline T const_e_impl (mpfrreal_type_tag);
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
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>
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);
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>
314 return mpfr::pow(v0,
T(1) / v1);
317 template <
typename T>
320 return mpfr::hypot(v0,v1);
323 template <
typename T>
326 return mpfr::atan2(v0,v1);
329 template <
typename T>
332 return v0 * (
T(1) / mpfr::pow(
T(2.0),v1));
335 template <
typename T>
338 return v0 * mpfr::pow(
T(2.0),v1);
341 template <
typename T>
347 template <
typename T>
353 template <
typename T>
359 template <
typename T>
367 template <
typename Iterator>
378 namespace rtl {
namespace io
384 #if defined(__clang__)
385 #pragma clang diagnostic push
386 #pragma clang diagnostic ignored "-Wformat-nonliteral"
387 #elif defined(__GNUC__) || defined(__GNUG__)
388 #pragma GCC diagnostic push
389 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
390 #elif defined(_MSC_VER)
393 printf(
"%s",v.toString().c_str());
395 #if defined(__clang__)
396 #pragma clang diagnostic pop
397 #elif defined(__GNUC__) || defined(__GNUG__)
398 #pragma GCC diagnostic pop
399 #elif defined(_MSC_VER)
bool is_true(const complex_t v)
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 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)
bool match_impl(const Iterator pattern_begin, const Iterator pattern_end, const Iterator data_begin, const Iterator data_end, const typename std::iterator_traits< Iterator >::value_type &zero_or_more, const typename std::iterator_traits< Iterator >::value_type &exactly_one)
void print_type(const std::string &fmt, const T v, exprtk::details::numeric::details::real_type_tag)
static mpfr::mpreal value()