63 #define MPREAL_HAVE_MSVC_DEBUGVIEW // Enable Debugger Visualizer for "Debug" builds in MSVC. 64 #define MPREAL_HAVE_DYNAMIC_STD_NUMERIC_LIMITS // Enable extended std::numeric_limits<mpfr::mpreal> specialization. 69 #define MPREAL_VERSION_MAJOR 3 70 #define MPREAL_VERSION_MINOR 6 71 #define MPREAL_VERSION_PATCHLEVEL 2 72 #define MPREAL_VERSION_STRING "3.6.2" 76 #define IsInf(x) (isinf)(x) // GNU C++/Intel ICC compiler on Linux 77 #elif defined(_MSC_VER) // Microsoft Visual C++ 78 #define IsInf(x) (!_finite(x)) 80 #define IsInf(x) (std::isinf)(x) // GNU C/C++ (and/or other compilers), just hope for C99 conformance 85 #define __has_feature(x) 0 89 #if (__has_feature(cxx_rvalue_references) || \ 90 defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \ 91 (defined(_MSC_VER) && _MSC_VER >= 1600)) 93 #define MPREAL_HAVE_MOVE_SUPPORT 96 #define mpfr_is_initialized(x) (0 != (x)->_mpfr_d) 97 #define mpfr_set_uninitialized(x) ((x)->_mpfr_d = 0 ) 101 #if (__has_feature(cxx_explicit_conversions) || \ 102 (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC_MINOR__ >= 5) || __cplusplus >= 201103L || \ 103 (defined(_MSC_VER) && _MSC_VER >= 1800)) 105 #define MPREAL_HAVE_EXPLICIT_CONVERTERS 108 #define MPFR_USE_INTMAX_T // Enable 64-bit integer types - should be defined before mpfr.h 110 #if defined(MPREAL_HAVE_MSVC_DEBUGVIEW) && defined(_MSC_VER) && defined(_DEBUG) 111 #define MPREAL_MSVC_DEBUGVIEW_CODE DebugView = toString(); 112 #define MPREAL_MSVC_DEBUGVIEW_DATA std::string DebugView; 114 #define MPREAL_MSVC_DEBUGVIEW_CODE 115 #define MPREAL_MSVC_DEBUGVIEW_DATA 120 #if (MPFR_VERSION < MPFR_VERSION_NUM(3,0,0)) 125 #define MPREAL_DOUBLE_BITS_OVERFLOW -1 // Triggers overflow exception during conversion to double if mpreal 132 #define mpfr_set_zero_fast(x) ((x)->_mpfr_exp = __MPFR_EXP_ZERO) 134 #if defined(__GNUC__) 135 #define MPREAL_PERMISSIVE_EXPR __extension__ 137 #define MPREAL_PERMISSIVE_EXPR 149 inline static mp_rnd_t
get_default_rnd() {
return (mp_rnd_t)(mpfr_get_default_rounding_mode()); }
169 mpreal(
const mpfr_t u,
bool shared =
false);
176 #ifdef MPREAL_HAVE_MOVE_SUPPORT 202 template <
typename real_t>
mpreal&
operator= (
const std::complex<real_t>&
z);
289 long toLong (mp_rnd_t mode = GMP_RNDZ)
const;
290 unsigned long toULong (mp_rnd_t mode = GMP_RNDZ)
const;
291 long long toLLong (mp_rnd_t mode = GMP_RNDZ)
const;
292 unsigned long long toULLong (mp_rnd_t mode = GMP_RNDZ)
const;
293 float toFloat (mp_rnd_t mode = GMP_RNDN)
const;
294 double toDouble (mp_rnd_t mode = GMP_RNDN)
const;
295 long double toLDouble (mp_rnd_t mode = GMP_RNDN)
const;
297 #if defined (MPREAL_HAVE_EXPLICIT_CONVERTERS) 298 explicit operator bool ()
const {
return toBool(); }
299 explicit operator int ()
const {
return int(
toLong()); }
300 explicit operator long ()
const {
return toLong(); }
301 explicit operator long long ()
const {
return toLLong(); }
302 explicit operator unsigned ()
const {
return unsigned(
toULong()); }
303 explicit operator unsigned long ()
const {
return toULong(); }
304 explicit operator unsigned long long ()
const {
return toULLong(); }
306 explicit operator double ()
const {
return toDouble(); }
307 explicit operator long double ()
const {
return toLDouble(); }
319 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 320 std::string
toString(
const std::string& format)
const;
323 std::ostream&
output(std::ostream&
os)
const;
328 friend const mpreal sqrt(
const unsigned long int v, mp_rnd_t rnd_mode);
330 friend const mpreal root(
const mpreal& v,
unsigned long int k, mp_rnd_t rnd_mode);
332 friend const mpreal pow (
const mpreal& a,
const mpz_t b, mp_rnd_t rnd_mode);
333 friend const mpreal pow (
const mpreal& a,
const unsigned long int b, mp_rnd_t rnd_mode);
334 friend const mpreal pow (
const mpreal& a,
const long int b, mp_rnd_t rnd_mode);
335 friend const mpreal pow (
const unsigned long int a,
const mpreal& b, mp_rnd_t rnd_mode);
336 friend const mpreal pow (
const unsigned long int a,
const unsigned long int b, mp_rnd_t rnd_mode);
341 friend inline const mpreal mul_2ui(
const mpreal& v,
unsigned long int k, mp_rnd_t rnd_mode);
343 friend inline const mpreal div_2ui(
const mpreal& v,
unsigned long int k, mp_rnd_t rnd_mode);
388 friend const mpreal fac_ui (
unsigned long int v, mp_prec_t prec, mp_rnd_t rnd_mode);
407 friend const mpreal sum (
const mpreal tab[],
const unsigned long int n,
int& status, mp_rnd_t rnd_mode);
411 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 422 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0)) 425 friend const mpreal urandom (gmp_randstate_t& state, mp_rnd_t rnd_mode);
428 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,1,0)) 429 friend const mpreal grandom (gmp_randstate_t& state, mp_rnd_t rnd_mode);
480 #if (MPFR_VERSION <= MPFR_VERSION_NUM(2,4,2)) 493 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0)) 551 void clear(::mpfr_ptr);
558 std::string
why() {
return "inexact conversion from floating point"; }
580 #ifdef MPREAL_HAVE_MOVE_SUPPORT 584 mpfr_swap(
mpfr_ptr(), other.mpfr_ptr());
591 mpfr_swap(
mpfr_ptr(), other.mpfr_ptr());
602 std::memcpy(
mpfr_ptr(), u,
sizeof(mpfr_t));
606 mpfr_init2(
mpfr_ptr(), mpfr_get_prec(u));
615 mpfr_init2(
mpfr_ptr(),(mp_prec_t) mpf_get_prec(u));
641 #if (MPREAL_DOUBLE_BITS_OVERFLOW > -1) 662 inline mpreal::mpreal(
const unsigned long long int u, mp_prec_t prec, mp_rnd_t mode)
713 mpfr_set_str(
mpfr_ptr(), s, base, mode);
721 mpfr_set_str(
mpfr_ptr(), s.c_str(), base, mode);
728 #ifdef MPREAL_HAVE_MOVE_SUPPORT 729 if(mpfr_is_initialized(x))
761 template <
typename Rhs>
765 template <
typename Lhs>
770 template <
typename Rhs>
774 template <
typename Lhs>
779 template <
typename Rhs>
783 template <
typename Lhs>
788 template <
typename Rhs>
792 template <
typename Lhs>
960 #if (MPREAL_DOUBLE_BITS_OVERFLOW > -1) 1068 template <
typename real_t>
1071 return *
this = z.real();
1113 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 1225 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 1279 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 1350 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 1426 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 1500 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 1576 return mul_2ui(v,static_cast<unsigned long int>(k));
1586 return mul_2si(v,static_cast<long int>(k));
1601 return div_2ui(v,static_cast<unsigned long int>(k));
1606 return div_2si(v,static_cast<long int>(k));
1700 inline bool (
isnan) (
const mpreal& op){
return (mpfr_nan_p (op.mpfr_srcptr()) != 0 ); }
1701 inline bool (
isinf) (
const mpreal& op){
return (mpfr_inf_p (op.mpfr_srcptr()) != 0 ); }
1702 inline bool (
isfinite) (
const mpreal& op){
return (mpfr_number_p (op.mpfr_srcptr()) != 0 ); }
1706 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0)) 1726 inline std::string
toString(
T t, std::ios_base & (*
f)(std::ios_base&))
1728 std::ostringstream oss;
1733 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 1740 if( !format.empty() )
1742 if(!(mpfr_asprintf(&s, format.c_str(),
mpfr_srcptr()) < 0))
1744 out = std::string(s);
1761 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 1763 std::ostringstream format;
1767 format <<
"%." << digits <<
"RNg";
1773 char *
s, *ns =
NULL;
1780 if(mpfr_sgn(
mp)>0)
return "+Inf";
1784 if(mpfr_zero_p(
mp))
return "0";
1785 if(mpfr_nan_p(
mp))
return "NaN";
1787 s = mpfr_get_str(
NULL, &exp, b, 0,
mp, mode);
1805 if (exp>0 && static_cast<size_t>(exp)<slen)
1810 char*
ptr = s+slen-1;
1811 while (*ptr==
'0' && ptr>s+exp) ptr--;
1813 if(ptr==s+exp) out = std::string(s,exp+1);
1814 else out = std::string(s,exp+1)+
'.'+std::string(s+exp+1,ptr-(s+exp+1)+1);
1821 char*
ptr = s+slen-1;
1822 while (*ptr==
'0' && ptr>s+exp-1) ptr--;
1824 if(ptr==s+exp-1) out = std::string(s,exp);
1825 else out = std::string(s,exp)+
'.'+std::string(s+exp,ptr-(s+exp)+1);
1834 char*
ptr = s+slen-1;
1835 while (*ptr==
'0' && ptr>s+1) ptr--;
1837 if(ptr==s+1) out = std::string(s,2);
1838 else out = std::string(s,2)+
'.'+std::string(s+2,ptr-(s+2)+1);
1845 char*
ptr = s+slen-1;
1846 while (*ptr==
'0' && ptr>s) ptr--;
1848 if(ptr==s) out = std::string(s,1);
1849 else out = std::string(s,1)+
'.'+std::string(s+1,ptr-(s+1)+1);
1857 if(exp>0) out +=
"e+"+mpfr::toString<mp_exp_t>(
exp,std::dec);
1858 else out +=
"e"+mpfr::toString<mp_exp_t>(
exp,std::dec);
1865 return "conversion error!";
1875 std::ostringstream format;
1876 const std::ios::fmtflags flags = os.flags();
1878 format << ((flags & std::ios::showpos) ?
"%+" :
"%");
1879 if (os.precision() >= 0)
1880 format <<
'.' << os.precision() <<
"R*" 1881 << ((flags & std::ios::floatfield) == std::ios::fixed ?
'f' :
1882 (flags & std::ios::floatfield) == std::ios::scientific ?
'e' :
1888 if(!(mpfr_asprintf(&s, format.str().c_str(),
1893 os << std::string(s);
1920 const double LOG2_10 = 3.3219280948873624;
1922 return mp_prec_t(
std::ceil( d * LOG2_10 ));
1927 const double LOG10_2 = 0.30102999566398119;
1953 mpfr_prec_round(
mpfr_ptr(), Precision, RoundingMode);
1974 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0)) 1977 mpfr_set_si(
mpfr_ptr(), 0, (mpfr_get_default_rounding_mode)());
1992 mpfr_prec_round(
mpfr_ptr(),prec,rnd_mode);
2003 int x = mpfr_set_exp(
mpfr_ptr(), e);
2011 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,1,0)) 2031 return ldexp(v, exp);
2072 return abs(a - b) <= eps;
2106 return mpfr_check_range(
mpfr_ptr(),t,rnd_mode);
2111 int r = mpfr_subnormalize(
mpfr_ptr(),t,rnd_mode);
2118 return mpfr_get_emin();
2123 return mpfr_set_emin(exp);
2128 return mpfr_get_emax();
2133 return mpfr_set_emax(exp);
2138 return mpfr_get_emin_min();
2143 return mpfr_get_emin_max();
2148 return mpfr_get_emax_min();
2153 return mpfr_get_emax_max();
2159 #define MPREAL_UNARY_MATH_FUNCTION_BODY(f) \ 2160 mpreal y(0, mpfr_get_prec(x.mpfr_srcptr())); \ 2161 mpfr_##f(y.mpfr_ptr(), x.mpfr_srcptr(), r); \ 2177 inline const mpreal sqrt(
const unsigned int v, mp_rnd_t rnd_mode)
2179 return sqrt(static_cast<unsigned long int>(v),rnd_mode);
2184 if (v>=0)
return sqrt(static_cast<unsigned long int>(v),rnd_mode);
2185 else return mpreal().setNan();
2190 if (v>=0)
return sqrt(static_cast<unsigned long int>(v),rnd_mode);
2191 else return mpreal().setNan();
2345 a.
set_prec(p3>p2?(p3>p1?p3:p1):(p2>p1?p2:p1));
2347 mpfr_fma(a.
mp,v1.
mp,v2.
mp,v3.
mp,rnd_mode);
2360 a.
set_prec(p3>p2?(p3>p1?p3:p1):(p2>p1?p2:p1));
2362 mpfr_fms(a.
mp,v1.
mp,v2.
mp,v3.
mp,rnd_mode);
2376 mpfr_agm(a.
mp, v1.
mp, v2.
mp, rnd_mode);
2385 for (
unsigned long int i = 0;
i <
n;
i++)
2397 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)) 2401 return mpfr_sinh_cosh(s.
mp,c.
mp,v.
mp,rnd_mode);
2412 return fmod(x, y, rnd_mode);
2431 if(x == y)
return 0;
2450 mpfr_fmod(a.
mp, x.
mp, y.
mp, rnd_mode);
2458 mpfr_rec_sqrt(x.
mp,v.
mp,rnd_mode);
2461 #endif // MPFR 2.4.0 Specifics 2465 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0)) 2468 #endif // MPFR 3.0.0 Specifics 2496 mpfr_const_catalan(x.
mpfr_ptr(), r);
2512 mpfr_ceil(x.
mp,v.
mp);
2519 mpfr_floor(x.
mp,v.
mp);
2526 mpfr_round(x.
mp,v.
mp);
2533 mpfr_trunc(x.
mp,v.
mp);
2553 mpfr_max(a.
mp,x.
mp,y.
mp,rnd_mode);
2560 mpfr_min(a.
mp,x.
mp,y.
mp,rnd_mode);
2567 mpfr_nexttoward(a.
mp,y.
mp);
2574 mpfr_nextabove(a.
mp);
2581 mpfr_nextbelow(a.
mp);
2592 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0)) 2596 mpfr_urandom(x.
mpfr_ptr(), state, rnd_mode);
2601 #if (MPFR_VERSION <= MPFR_VERSION_NUM(2,4,2)) 2616 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0)) 2617 static gmp_randstate_t state;
2622 gmp_randinit_default(state);
2623 gmp_randseed_ui(state,0);
2627 if(seed != 0) gmp_randseed_ui(state,seed);
2631 if(seed != 0) std::srand(seed);
2637 #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,1,0)) 2648 static gmp_randstate_t state;
2653 gmp_randinit_default(state);
2654 gmp_randseed_ui(state,0);
2658 if(seed != 0) gmp_randseed_ui(state,seed);
2668 mpfr_set_default_prec(prec);
2673 mpfr_set_default_rounding_mode(rnd_mode);
2686 mpfr_pow(x.
mp,x.
mp,b.
mp,rnd_mode);
2693 mpfr_pow_z(x.
mp,x.
mp,b,rnd_mode);
2700 mpfr_pow_ui(x.
mp,x.
mp,b,rnd_mode);
2706 return pow(a,static_cast<unsigned long int>(b),rnd_mode);
2712 mpfr_pow_si(x.
mp,x.
mp,b,rnd_mode);
2718 return pow(a,static_cast<long int>(b),rnd_mode);
2734 mpfr_ui_pow(x.
mp,a,b.
mp,rnd_mode);
2740 return pow(static_cast<unsigned long int>(a),b,rnd_mode);
2745 if (a>=0)
return pow(static_cast<unsigned long int>(a),b,rnd_mode);
2751 if (a>=0)
return pow(static_cast<unsigned long int>(a),b,rnd_mode);
2766 inline const mpreal pow(
const unsigned long int a,
const unsigned long int b, mp_rnd_t rnd_mode)
2769 mpfr_ui_pow_ui(x.
mp,a,b,rnd_mode);
2773 inline const mpreal pow(
const unsigned long int a,
const unsigned int b, mp_rnd_t rnd_mode)
2775 return pow(a,static_cast<unsigned long int>(b),rnd_mode);
2778 inline const mpreal pow(
const unsigned long int a,
const long int b, mp_rnd_t rnd_mode)
2780 if(b>0)
return pow(a,static_cast<unsigned long int>(b),rnd_mode);
2784 inline const mpreal pow(
const unsigned long int a,
const int b, mp_rnd_t rnd_mode)
2786 if(b>0)
return pow(a,static_cast<unsigned long int>(b),rnd_mode);
2790 inline const mpreal pow(
const unsigned long int a,
const long double b, mp_rnd_t rnd_mode)
2795 inline const mpreal pow(
const unsigned long int a,
const double b, mp_rnd_t rnd_mode)
2801 inline const mpreal pow(
const unsigned int a,
const unsigned long int b, mp_rnd_t rnd_mode)
2803 return pow(static_cast<unsigned long int>(a),b,rnd_mode);
2806 inline const mpreal pow(
const unsigned int a,
const unsigned int b, mp_rnd_t rnd_mode)
2808 return pow(static_cast<unsigned long int>(a),static_cast<unsigned long int>(b),rnd_mode);
2811 inline const mpreal pow(
const unsigned int a,
const long int b, mp_rnd_t rnd_mode)
2813 if(b>0)
return pow(static_cast<unsigned long int>(a),static_cast<unsigned long int>(b),rnd_mode);
2814 else return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2817 inline const mpreal pow(
const unsigned int a,
const int b, mp_rnd_t rnd_mode)
2819 if(b>0)
return pow(static_cast<unsigned long int>(a),static_cast<unsigned long int>(b),rnd_mode);
2820 else return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2823 inline const mpreal pow(
const unsigned int a,
const long double b, mp_rnd_t rnd_mode)
2825 return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2828 inline const mpreal pow(
const unsigned int a,
const double b, mp_rnd_t rnd_mode)
2830 return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2834 inline const mpreal pow(
const long int a,
const unsigned long int b, mp_rnd_t rnd_mode)
2836 if (a>0)
return pow(static_cast<unsigned long int>(a),b,rnd_mode);
2840 inline const mpreal pow(
const long int a,
const unsigned int b, mp_rnd_t rnd_mode)
2842 if (a>0)
return pow(static_cast<unsigned long int>(a),static_cast<unsigned long int>(b),rnd_mode);
2843 else return pow(
mpreal(a),static_cast<unsigned long int>(b),rnd_mode);
2846 inline const mpreal pow(
const long int a,
const long int b, mp_rnd_t rnd_mode)
2850 if(b>0)
return pow(static_cast<unsigned long int>(a),static_cast<unsigned long int>(b),rnd_mode);
2851 else return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2857 inline const mpreal pow(
const long int a,
const int b, mp_rnd_t rnd_mode)
2861 if(b>0)
return pow(static_cast<unsigned long int>(a),static_cast<unsigned long int>(b),rnd_mode);
2862 else return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2864 return pow(
mpreal(a),static_cast<long int>(b),rnd_mode);
2868 inline const mpreal pow(
const long int a,
const long double b, mp_rnd_t rnd_mode)
2870 if (a>=0)
return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2874 inline const mpreal pow(
const long int a,
const double b, mp_rnd_t rnd_mode)
2876 if (a>=0)
return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2881 inline const mpreal pow(
const int a,
const unsigned long int b, mp_rnd_t rnd_mode)
2883 if (a>0)
return pow(static_cast<unsigned long int>(a),b,rnd_mode);
2887 inline const mpreal pow(
const int a,
const unsigned int b, mp_rnd_t rnd_mode)
2889 if (a>0)
return pow(static_cast<unsigned long int>(a),static_cast<unsigned long int>(b),rnd_mode);
2890 else return pow(
mpreal(a),static_cast<unsigned long int>(b),rnd_mode);
2893 inline const mpreal pow(
const int a,
const long int b, mp_rnd_t rnd_mode)
2897 if(b>0)
return pow(static_cast<unsigned long int>(a),static_cast<unsigned long int>(b),rnd_mode);
2898 else return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2904 inline const mpreal pow(
const int a,
const int b, mp_rnd_t rnd_mode)
2908 if(b>0)
return pow(static_cast<unsigned long int>(a),static_cast<unsigned long int>(b),rnd_mode);
2909 else return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2911 return pow(
mpreal(a),static_cast<long int>(b),rnd_mode);
2915 inline const mpreal pow(
const int a,
const long double b, mp_rnd_t rnd_mode)
2917 if (a>=0)
return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2921 inline const mpreal pow(
const int a,
const double b, mp_rnd_t rnd_mode)
2923 if (a>=0)
return pow(static_cast<unsigned long int>(a),
mpreal(b),rnd_mode);
2928 inline const mpreal pow(
const long double a,
const long double b, mp_rnd_t rnd_mode)
2933 inline const mpreal pow(
const long double a,
const unsigned long int b, mp_rnd_t rnd_mode)
2938 inline const mpreal pow(
const long double a,
const unsigned int b, mp_rnd_t rnd_mode)
2940 return pow(
mpreal(a),static_cast<unsigned long int>(b),rnd_mode);
2943 inline const mpreal pow(
const long double a,
const long int b, mp_rnd_t rnd_mode)
2948 inline const mpreal pow(
const long double a,
const int b, mp_rnd_t rnd_mode)
2950 return pow(
mpreal(a),static_cast<long int>(b),rnd_mode);
2953 inline const mpreal pow(
const double a,
const double b, mp_rnd_t rnd_mode)
2958 inline const mpreal pow(
const double a,
const unsigned long int b, mp_rnd_t rnd_mode)
2963 inline const mpreal pow(
const double a,
const unsigned int b, mp_rnd_t rnd_mode)
2965 return pow(
mpreal(a),static_cast<unsigned long int>(b),rnd_mode);
2968 inline const mpreal pow(
const double a,
const long int b, mp_rnd_t rnd_mode)
2973 inline const mpreal pow(
const double a,
const int b, mp_rnd_t rnd_mode)
2975 return pow(
mpreal(a),static_cast<long int>(b),rnd_mode);
2995 static const bool is_specialized =
true;
2996 static const bool is_signed =
true;
2997 static const bool is_integer =
false;
2998 static const bool is_exact =
false;
3001 static const bool has_infinity =
true;
3002 static const bool has_quiet_NaN =
true;
3003 static const bool has_signaling_NaN =
true;
3005 static const bool is_iec559 =
true;
3006 static const bool is_bounded =
true;
3007 static const bool is_modulo =
false;
3008 static const bool traps =
true;
3009 static const bool tinyness_before =
true;
3011 static const float_denorm_style has_denorm = denorm_absent;
3037 static const int min_exponent = MPFR_EMIN_DEFAULT;
3038 static const int max_exponent = MPFR_EMAX_DEFAULT;
3042 #ifdef MPREAL_HAVE_DYNAMIC_STD_NUMERIC_LIMITS 3056 case GMP_RNDN:
return round_to_nearest;
3057 case GMP_RNDZ:
return round_toward_zero;
3058 case GMP_RNDU:
return round_toward_infinity;
3059 case GMP_RNDD:
return round_toward_neg_infinity;
3060 default:
return round_indeterminate;
3079 return digits10(precision);
3095 static const std::float_round_style round_style = round_to_nearest;
3096 static const int digits = 53;
3097 static const int digits10 = 15;
3098 static const int max_digits10 = 16;
friend const mpreal nexttoward(const mpreal &x, const mpreal &y)
static const mpfr::mpreal infinity()
bool operator>=(const mpreal &a, const mpreal &b)
friend const mpreal tan(const mpreal &v, mp_rnd_t rnd_mode)
mpreal & setInf(int Sign=+1)
friend const mpreal exp2(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t rnd_mode)
friend int sin_cos(mpreal &s, mpreal &c, const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal acosh(const mpreal &v, mp_rnd_t rnd_mode)
friend bool() isinf(const mpreal &v)
friend const mpreal div_2si(const mpreal &v, long int k, mp_rnd_t rnd_mode)
friend const mpreal rint_trunc(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal acoth(const mpreal &v, mp_rnd_t rnd_mode)
friend std::istream & operator>>(std::istream &is, mpreal &v)
friend const mpreal root(const mpreal &v, unsigned long int k, mp_rnd_t rnd_mode)
friend const mpreal remquo(long *q, const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode)
friend const mpreal hypot(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode)
friend const mpreal modf(const mpreal &v, mpreal &n)
friend const mpreal urandomb(gmp_randstate_t &state)
static int set_emax(mp_exp_t exp)
#define EIGEN_NOT_A_MACRO
friend const mpreal operator/(const unsigned long int b, const mpreal &a)
mp_prec_t digits2bits(int d)
const mpreal scalbn(const mpreal &v, mp_exp_t exp)
friend bool isint(const mpreal &v)
friend int sgn(const mpreal &v)
static int max_digits10(mp_prec_t precision=mpfr::mpreal::get_default_prec())
static mp_prec_t get_default_prec()
static mpfr::mpreal epsilon(mp_prec_t precision=mpfr::mpreal::get_default_prec())
void set_prec(mp_prec_t prec, mp_rnd_t rnd_mode=get_default_rnd())
mp_prec_t get_prec() const
friend const mpreal log(const mpreal &v, mp_rnd_t rnd_mode)
friend int cmpabs(const mpreal &a, const mpreal &b)
friend const mpreal rint_ceil(const mpreal &v, mp_rnd_t rnd_mode)
mpreal & operator>>=(const unsigned long int u)
friend bool isnum(const mpreal &v)
const mpreal ldexp(const mpreal &v, mp_exp_t exp)
static const mpfr::mpreal denorm_min()
friend const mpreal mod(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode)
static mpfr::mpreal epsilon(const mpfr::mpreal &x)
friend const mpreal rint_round(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal fmin(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode)
static float_round_style round_style()
double toDouble(mp_rnd_t mode=GMP_RNDN) const
#define MPREAL_DOUBLE_BITS_OVERFLOW
#define MPREAL_MSVC_DEBUGVIEW_CODE
bool signbit(const mpreal &x)
friend const mpreal eint(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal sqrt(const mpreal &v, mp_rnd_t rnd_mode)
static mp_exp_t get_emin(void)
std::ostream & output(std::ostream &os) const
friend const mpreal rint_floor(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal random2(mp_size_t size, mp_exp_t exp)
mpreal & setPrecision(int Precision, mp_rnd_t RoundingMode=get_default_rnd())
bool operator==(const mpreal &a, const mpreal &b)
friend const mpreal atan(const mpreal &v, mp_rnd_t rnd_mode)
const mpreal() max(const mpreal &x, const mpreal &y)
mpreal & setSign(int Sign, mp_rnd_t RoundingMode=get_default_rnd())
bool operator!=(const mpreal &a, const mpreal &b)
friend const mpreal urandom(gmp_randstate_t &state, mp_rnd_t rnd_mode)
friend const mpreal random(unsigned int seed)
friend const mpreal tanh(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal digamma(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal div_2ui(const mpreal &v, unsigned long int k, mp_rnd_t rnd_mode)
#define MPREAL_PERMISSIVE_EXPR
friend const mpreal agm(const mpreal &v1, const mpreal &v2, mp_rnd_t rnd_mode)
friend const mpreal log10(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal lngamma(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal nextabove(const mpreal &x)
friend const mpreal const_pi(mp_prec_t prec, mp_rnd_t rnd_mode)
static int digits10(const mpfr::mpreal &x)
friend const mpreal mul_2si(const mpreal &v, long int k, mp_rnd_t rnd_mode)
friend const mpreal grandom(gmp_randstate_t &state, mp_rnd_t rnd_mode)
static const mpfr::mpreal signaling_NaN()
friend const mpreal besseljn(long n, const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal asec(const mpreal &v, mp_rnd_t rnd_mode)
friend bool() isnan(const mpreal &v)
friend const mpreal remainder(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode)
long long toLLong(mp_rnd_t mode=GMP_RNDZ) const
long double toLDouble(mp_rnd_t mode=GMP_RNDN) const
friend const mpreal fma(const mpreal &v1, const mpreal &v2, const mpreal &v3, mp_rnd_t rnd_mode)
friend const mpreal sinh(const mpreal &v, mp_rnd_t rnd_mode)
void swap(mpreal &a, mpreal &b)
friend bool iszero(const mpreal &v)
std::string toString(int n=-1, int b=10, mp_rnd_t mode=mpreal::get_default_rnd()) const
EIGEN_DEVICE_FUNC const CeilReturnType ceil() const
friend const mpreal sech(const mpreal &v, mp_rnd_t rnd_mode)
friend void swap(mpreal &x, mpreal &y)
friend const mpreal acsch(const mpreal &v, mp_rnd_t rnd_mode)
static mp_exp_t get_emin_min(void)
mpreal copysign(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode=mpreal::get_default_rnd())
const mpreal modf(const mpreal &v, mpreal &n)
static mp_exp_t get_emax(void)
const mpreal operator-() const
friend const mpreal abs(const mpreal &v, mp_rnd_t rnd_mode)
const mpreal urandom(gmp_randstate_t &state, mp_rnd_t rnd_mode=mpreal::get_default_rnd())
EIGEN_DEVICE_FUNC const SignReturnType sign() const
friend const mpreal lgamma(const mpreal &v, int *signp, mp_rnd_t rnd_mode)
friend const mpreal coth(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal fmax(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode)
friend const mpreal gamma(const mpreal &v, mp_rnd_t rnd_mode)
static mp_exp_t get_emax_max(void)
const mpreal() min(const mpreal &x, const mpreal &y)
friend const mpreal csch(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal exp(const mpreal &v, mp_rnd_t rnd_mode)
bool operator>(const mpreal &a, const mpreal &b)
friend bool isregular(const mpreal &v)
static const mpfr::mpreal quiet_NaN()
const mpreal grandom(gmp_randstate_t &state, mp_rnd_t rnd_mode=mpreal::get_default_rnd())
friend const mpreal floor(const mpreal &v)
mpreal maxval(mp_prec_t prec=mpreal::get_default_prec())
friend const mpreal tgamma(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal fmod(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode)
friend const mpreal besselj1(const mpreal &v, mp_rnd_t rnd_mode)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
unsigned long toULong(mp_rnd_t mode=GMP_RNDZ) const
friend const mpreal acos(const mpreal &v, mp_rnd_t rnd_mode)
static void set_default_prec(mp_prec_t prec)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define MPREAL_UNARY_MATH_FUNCTION_BODY(f)
friend const mpreal besselyn(long n, const mpreal &v, mp_rnd_t rnd_mode)
EIGEN_DEVICE_FUNC const Scalar & q
friend const mpreal asech(const mpreal &v, mp_rnd_t rnd_mode)
mpreal & operator=(const mpreal &v)
mpreal minval(mp_prec_t prec=mpreal::get_default_prec())
friend const mpreal const_euler(mp_prec_t prec, mp_rnd_t rnd_mode)
friend const mpreal expm1(const mpreal &v, mp_rnd_t rnd_mode)
mpreal & operator<<=(const unsigned long int u)
friend const mpreal zeta(const mpreal &v, mp_rnd_t rnd_mode)
bool operator<=(const mpreal &a, const mpreal &b)
friend std::ostream & operator<<(std::ostream &os, const mpreal &v)
#define MPREAL_MSVC_DEBUGVIEW_DATA
MPREAL_MSVC_DEBUGVIEW_DATA void clear(::mpfr_ptr)
static int digits(const mpfr::mpreal &x)
::mpfr_srcptr mpfr_srcptr() const
friend const mpreal ai(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal asin(const mpreal &v, mp_rnd_t rnd_mode)
const mpreal frexp(const mpreal &x, mp_exp_t *exp, mp_rnd_t mode=mpreal::get_default_rnd())
friend const mpreal fabs(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal trunc(const mpreal &v)
friend const mpreal atanh(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal asinh(const mpreal &v, mp_rnd_t rnd_mode)
mpreal machine_epsilon(mp_prec_t prec=mpreal::get_default_prec())
mpreal & operator*=(const long long int u)
unsigned long long toULLong(mp_rnd_t mode=GMP_RNDZ) const
bool fits_in_bits(double x, int n)
#define mpfr_set_zero_fast(x)
friend const mpreal mul_2ui(const mpreal &v, unsigned long int k, mp_rnd_t rnd_mode)
friend bool() isfinite(const mpreal &v)
friend const mpreal cot(const mpreal &v, mp_rnd_t rnd_mode)
int subnormalize(int t, mp_rnd_t rnd_mode=get_default_rnd())
EIGEN_DEVICE_FUNC const FloorReturnType floor() const
ofstream os("timeSchurFactors.csv")
const mpreal operator+() const
friend const mpreal round(const mpreal &v)
const internal::result_type< Rhs >::type operator*(const mpreal &lhs, const Rhs &rhs)
friend const mpreal erf(const mpreal &v, mp_rnd_t rnd_mode)
int bits2digits(mp_prec_t b)
bool operator<(const mpreal &a, const mpreal &b)
friend const mpreal acsc(const mpreal &v, mp_rnd_t rnd_mode)
mpreal & setZero(int Sign=+1)
static int set_emin(mp_exp_t exp)
static mpfr::mpreal round_error(mp_prec_t precision=mpfr::mpreal::get_default_prec())
friend const mpreal bessely0(const mpreal &v, mp_rnd_t rnd_mode)
static mp_exp_t get_emax_min(void)
friend const mpreal erfc(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal pow(const mpreal &a, const mpreal &b, mp_rnd_t rnd_mode)
friend const mpreal const_infinity(int sign, mp_prec_t prec)
mpreal & operator+=(const mpreal &v)
friend const mpreal log2(const mpreal &v, mp_rnd_t rnd_mode)
mpreal & operator-=(const long long int u)
friend const mpreal cos(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal sqr(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal exp10(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal logb(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal const_log2(mp_prec_t prec, mp_rnd_t rnd_mode)
friend const mpreal sec(const mpreal &v, mp_rnd_t rnd_mode)
const mpreal const_infinity(int sign=1, mp_prec_t p=mpreal::get_default_prec())
friend const mpreal rint(const mpreal &v, mp_rnd_t rnd_mode)
Annotation indicating that a class derives from another given type.
friend const mpreal acot(const mpreal &v, mp_rnd_t rnd_mode)
static mpfr::mpreal lowest(mp_prec_t precision=mpfr::mpreal::get_default_prec())
friend const mpreal log1p(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal nextbelow(const mpreal &x)
friend const mpreal rec_sqrt(const mpreal &v, mp_rnd_t rnd_mode)
mpreal & operator/=(const long long int u)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
friend const mpreal fms(const mpreal &v1, const mpreal &v2, const mpreal &v3, mp_rnd_t rnd_mode)
friend const mpreal frac(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal sin(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal dim(const mpreal &a, const mpreal &b, mp_rnd_t rnd_mode)
Values initialize(const NonlinearFactorGraph &graph, bool useOdometricPath)
friend const mpreal rem(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode)
bool isEqualFuzzy(const mpreal &a, const mpreal &b, const mpreal &eps)
friend const mpreal const_catalan(mp_prec_t prec, mp_rnd_t rnd_mode)
friend const mpreal ceil(const mpreal &v)
friend const mpreal li2(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal besselj0(const mpreal &v, mp_rnd_t rnd_mode)
static mp_rnd_t get_default_rnd()
float toFloat(mp_rnd_t mode=GMP_RNDN) const
static mp_exp_t get_emin_max(void)
long toLong(mp_rnd_t mode=GMP_RNDZ) const
friend const mpreal cbrt(const mpreal &v, mp_rnd_t rnd_mode)
static void set_default_rnd(mp_rnd_t rnd_mode)
friend const mpreal bessely1(const mpreal &v, mp_rnd_t rnd_mode)
bool isEqualUlps(const mpreal &a, const mpreal &b, int maxUlps)
friend const mpreal fac_ui(unsigned long int v, mp_prec_t prec, mp_rnd_t rnd_mode)
friend const mpreal atan2(const mpreal &y, const mpreal &x, mp_rnd_t rnd_mode)
static int digits10(mp_prec_t precision=mpfr::mpreal::get_default_prec())
friend int sinh_cosh(mpreal &s, mpreal &c, const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal csc(const mpreal &v, mp_rnd_t rnd_mode)
friend const mpreal cosh(const mpreal &v, mp_rnd_t rnd_mode)
int check_range(int t, mp_rnd_t rnd_mode=get_default_rnd())