37 #if defined(__GNUC__) && defined(__INTEL_COMPILER)
38 #define IsInf(x) isinf(x) // GNU C/C++ + Intel ICC compiler
40 #elif defined(__GNUC__)
41 #define IsInf(x) std::isinf(x) // GNU C/C++
43 #elif defined(_MSC_VER)
44 #define IsInf(x) (!_finite(x)) // Microsoft Visual C++
47 #define IsInf(x) std::isinf(x) // C99 conformance
57 static mp_rnd_t default_rnd;
58 static mp_prec_t default_prec;
59 static int default_base;
60 static int double_bits;
70 mpreal(
const mpz_t u, mp_prec_t prec = default_prec, mp_rnd_t mode = default_rnd);
71 mpreal(
const mpq_t u, mp_prec_t prec = default_prec, mp_rnd_t mode = default_rnd);
72 mpreal(
const double u, mp_prec_t prec = default_prec, mp_rnd_t mode = default_rnd);
73 mpreal(
const long double u, mp_prec_t prec = default_prec, mp_rnd_t mode = default_rnd);
74 mpreal(
const unsigned long int u, mp_prec_t prec = default_prec, mp_rnd_t mode = default_rnd);
75 mpreal(
const unsigned int u, mp_prec_t prec = default_prec, mp_rnd_t mode = default_rnd);
76 mpreal(
const long int u, mp_prec_t prec = default_prec, mp_rnd_t mode = default_rnd);
77 mpreal(
const int u, mp_prec_t prec = default_prec, mp_rnd_t mode = default_rnd);
78 mpreal(
const char* s, mp_prec_t prec = default_prec,
int base = default_base, mp_rnd_t mode = default_rnd);
90 mpreal& operator=(
const mpf_t v);
91 mpreal& operator=(
const mpz_t v);
92 mpreal& operator=(
const mpq_t v);
93 mpreal& operator=(
const long double v);
94 mpreal& operator=(
const double v);
95 mpreal& operator=(
const unsigned long int v);
96 mpreal& operator=(
const unsigned int v);
97 mpreal& operator=(
const long int v);
98 mpreal& operator=(
const int v);
99 mpreal& operator=(
const char* s);
103 mpreal& operator+=(
const mpf_t v);
104 mpreal& operator+=(
const mpz_t v);
105 mpreal& operator+=(
const mpq_t v);
106 mpreal& operator+=(
const long double u);
107 mpreal& operator+=(
const double u);
108 mpreal& operator+=(
const unsigned long int u);
109 mpreal& operator+=(
const unsigned int u);
110 mpreal& operator+=(
const long int u);
111 mpreal& operator+=(
const int u);
112 const mpreal operator+()
const;
114 const mpreal operator++(
int);
118 mpreal& operator-=(
const mpz_t v);
119 mpreal& operator-=(
const mpq_t v);
120 mpreal& operator-=(
const long double u);
121 mpreal& operator-=(
const double u);
122 mpreal& operator-=(
const unsigned long int u);
123 mpreal& operator-=(
const unsigned int u);
124 mpreal& operator-=(
const long int u);
125 mpreal& operator-=(
const int u);
126 const mpreal operator-()
const;
127 friend const mpreal operator-(
const unsigned long int b,
const mpreal& a);
128 friend const mpreal operator-(
const unsigned int b,
const mpreal& a);
129 friend const mpreal operator-(
const long int b,
const mpreal& a);
130 friend const mpreal operator-(
const int b,
const mpreal& a);
131 friend const mpreal operator-(
const double b,
const mpreal& a);
133 const mpreal operator--(
int);
137 mpreal& operator*=(
const mpz_t v);
138 mpreal& operator*=(
const mpq_t v);
139 mpreal& operator*=(
const long double v);
140 mpreal& operator*=(
const double v);
141 mpreal& operator*=(
const unsigned long int v);
142 mpreal& operator*=(
const unsigned int v);
143 mpreal& operator*=(
const long int v);
144 mpreal& operator*=(
const int v);
148 mpreal& operator/=(
const mpz_t v);
149 mpreal& operator/=(
const mpq_t v);
150 mpreal& operator/=(
const long double v);
151 mpreal& operator/=(
const double v);
152 mpreal& operator/=(
const unsigned long int v);
153 mpreal& operator/=(
const unsigned int v);
154 mpreal& operator/=(
const long int v);
155 mpreal& operator/=(
const int v);
156 friend const mpreal operator/(
const unsigned long int b,
const mpreal& a);
157 friend const mpreal operator/(
const unsigned int b,
const mpreal& a);
158 friend const mpreal operator/(
const long int b,
const mpreal& a);
159 friend const mpreal operator/(
const int b,
const mpreal& a);
160 friend const mpreal operator/(
const double b,
const mpreal& a);
163 mpreal& operator<<=(
const unsigned long int u);
164 mpreal& operator<<=(
const unsigned int u);
165 mpreal& operator<<=(
const long int u);
166 mpreal& operator<<=(
const int u);
169 mpreal& operator>>=(
const unsigned long int u);
170 mpreal& operator>>=(
const unsigned int u);
171 mpreal& operator>>=(
const long int u);
172 mpreal& operator>>=(
const int u);
175 friend bool operator>(
const mpreal& a,
const mpreal& b);
176 friend bool operator >=(
const mpreal& a,
const mpreal& b);
177 friend bool operator<(
const mpreal& a,
const mpreal& b);
178 friend bool operator <=(
const mpreal& a,
const mpreal& b);
179 friend bool operator ==(
const mpreal& a,
const mpreal& b);
180 friend bool operator !=(
const mpreal& a,
const mpreal& b);
183 operator long double()
const;
184 operator double()
const;
185 operator float()
const;
186 operator unsigned long()
const;
187 operator unsigned int()
const;
188 operator long()
const;
189 operator std::string()
const;
193 friend const mpreal sqr(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
194 friend const mpreal sqrt(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
195 friend const mpreal sqrt(
const unsigned long int v, mp_rnd_t rnd_mode = mpreal::default_rnd);
196 friend const mpreal cbrt(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
197 friend const mpreal root(
const mpreal& v,
unsigned long int k, mp_rnd_t rnd_mode = mpreal::default_rnd);
198 friend const mpreal pow(
const mpreal& a,
const mpreal& b, mp_rnd_t rnd_mode = mpreal::default_rnd);
199 friend const mpreal pow(
const mpreal& a,
const mpz_t b, mp_rnd_t rnd_mode = mpreal::default_rnd);
200 friend const mpreal pow(
const mpreal& a,
const unsigned long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
201 friend const mpreal pow(
const mpreal& a,
const long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
202 friend const mpreal pow(
const unsigned long int a,
const mpreal& b, mp_rnd_t rnd_mode = mpreal::default_rnd);
203 friend const mpreal pow(
const unsigned long int a,
const unsigned long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
204 friend const mpreal fabs(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
205 friend const mpreal abs(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
206 friend const mpreal dim(
const mpreal& a,
const mpreal& b, mp_rnd_t rnd_mode = mpreal::default_rnd);
207 friend const mpreal mul_2ui(
const mpreal& v,
unsigned long int k, mp_rnd_t rnd_mode = mpreal::default_rnd);
208 friend const mpreal mul_2si(
const mpreal& v,
long int k, mp_rnd_t rnd_mode = mpreal::default_rnd);
209 friend const mpreal div_2ui(
const mpreal& v,
unsigned long int k, mp_rnd_t rnd_mode = mpreal::default_rnd);
210 friend const mpreal div_2si(
const mpreal& v,
long int k, mp_rnd_t rnd_mode = mpreal::default_rnd);
213 friend const mpreal log(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
214 friend const mpreal log2(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
215 friend const mpreal log10(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
216 friend const mpreal exp(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
217 friend const mpreal exp2(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
218 friend const mpreal exp10(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
220 friend const mpreal cos(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
221 friend const mpreal sin(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
222 friend const mpreal tan(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
223 friend const mpreal sec(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
224 friend const mpreal csc(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
225 friend const mpreal cot(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
226 friend int sin_cos(
mpreal& s,
mpreal& c,
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
228 friend const mpreal acos(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
229 friend const mpreal asin(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
230 friend const mpreal atan(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
231 friend const mpreal atan2(
const mpreal& y,
const mpreal& x, mp_rnd_t rnd_mode = mpreal::default_rnd);
232 friend const mpreal cosh(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
233 friend const mpreal sinh(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
234 friend const mpreal tanh(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
235 friend const mpreal sech(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
236 friend const mpreal csch(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
237 friend const mpreal coth(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
239 friend const mpreal acosh(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
240 friend const mpreal asinh(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
241 friend const mpreal atanh(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
242 friend const mpreal fac_ui(
unsigned long int v, mp_rnd_t rnd_mode = mpreal::default_rnd);
243 friend const mpreal log1p(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
244 friend const mpreal expm1(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
245 friend const mpreal eint(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
247 friend const mpreal gamma(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
248 friend const mpreal lngamma(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
249 friend const mpreal lgamma(
const mpreal& v,
int *signp, mp_rnd_t rnd_mode = mpreal::default_rnd);
250 friend const mpreal zeta(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
251 friend const mpreal erf(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
252 friend const mpreal erfc(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
253 friend const mpreal _j0(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
254 friend const mpreal _j1(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
255 friend const mpreal _jn(
long n,
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
256 friend const mpreal _y0(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
257 friend const mpreal _y1(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
258 friend const mpreal _yn(
long n,
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
259 friend const mpreal fma(
const mpreal& v1,
const mpreal& v2,
const mpreal& v3, mp_rnd_t rnd_mode = mpreal::default_rnd);
260 friend const mpreal fms(
const mpreal& v1,
const mpreal& v2,
const mpreal& v3, mp_rnd_t rnd_mode = mpreal::default_rnd);
261 friend const mpreal agm(
const mpreal& v1,
const mpreal& v2, mp_rnd_t rnd_mode = mpreal::default_rnd);
262 friend const mpreal hypot(
const mpreal& x,
const mpreal& y, mp_rnd_t rnd_mode = mpreal::default_rnd);
263 friend const mpreal sum(
const mpreal tab[],
unsigned long int n, mp_rnd_t rnd_mode = mpreal::default_rnd);
264 friend int sgn(
const mpreal& v);
267 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
268 friend int sinh_cosh(
mpreal& s,
mpreal& c,
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
269 friend const mpreal li2(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
270 friend const mpreal fmod(
const mpreal& x,
const mpreal& y, mp_rnd_t rnd_mode = mpreal::default_rnd);
271 friend const mpreal rec_sqrt(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
275 friend const mpreal frexp(
const mpreal& v, mp_exp_t* exp);
276 friend const mpreal ldexp(
const mpreal& v, mp_exp_t exp);
284 friend const mpreal const_log2(mp_prec_t prec = mpreal::default_prec, mp_rnd_t rnd_mode = mpreal::default_rnd);
285 friend const mpreal const_pi(mp_prec_t prec = mpreal::default_prec, mp_rnd_t rnd_mode = mpreal::default_rnd);
286 friend const mpreal const_euler(mp_prec_t prec = mpreal::default_prec, mp_rnd_t rnd_mode = mpreal::default_rnd);
287 friend const mpreal const_catalan(mp_prec_t prec = mpreal::default_prec, mp_rnd_t rnd_mode = mpreal::default_rnd);
290 friend std::ostream& operator<<(std::ostream& os,
const mpreal& v);
291 friend std::istream& operator>>(std::istream& is,
mpreal& v);
294 friend const mpreal rint(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
299 friend const mpreal rint_ceil(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
300 friend const mpreal rint_floor(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
301 friend const mpreal rint_round(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
302 friend const mpreal rint_trunc(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
303 friend const mpreal frac(
const mpreal& v, mp_rnd_t rnd_mode = mpreal::default_rnd);
304 friend const mpreal remainder(
const mpreal& x,
const mpreal& y, mp_rnd_t rnd_mode = mpreal::default_rnd);
305 friend const mpreal remquo(
long* q,
const mpreal& x,
const mpreal& y, mp_rnd_t rnd_mode = mpreal::default_rnd);
313 friend const mpreal urandomb(gmp_randstate_t& state);
314 friend const mpreal random2(mp_size_t size, mp_exp_t exp);
317 friend bool _isnan(
const mpreal& v);
318 friend bool _isinf(
const mpreal& v);
319 friend bool _isnum(
const mpreal& v);
320 friend bool _iszero(
const mpreal& v);
321 friend bool _isint(
const mpreal& v);
324 mp_prec_t get_prec()
const;
325 void set_prec(mp_prec_t prec, mp_rnd_t rnd_mode = default_rnd);
328 void set_inf(
int sign = +1);
332 void set_sign(
int sign, mp_rnd_t rnd_mode = default_rnd);
336 int set_exp(mp_exp_t e);
337 int check_range(
int t, mp_rnd_t rnd_mode = default_rnd);
338 int subnormalize(
int t, mp_rnd_t rnd_mode = default_rnd);
341 bool fits_in_bits(
double x,
int n);
344 static void set_default_prec(mp_prec_t prec);
345 static mp_prec_t get_default_prec();
346 static void set_default_base(
int base);
347 static int get_default_base();
348 static void set_double_bits(
int dbits);
349 static int get_double_bits();
350 static void set_default_rnd(mp_rnd_t rnd_mode);
351 static mp_rnd_t get_default_rnd();
352 static mp_exp_t get_emin(
void);
353 static mp_exp_t get_emax(
void);
354 static mp_exp_t get_emin_min(
void);
355 static mp_exp_t get_emin_max(
void);
356 static mp_exp_t get_emax_min(
void);
357 static mp_exp_t get_emax_max(
void);
358 static int set_emin(mp_exp_t exp);
359 static int set_emax(mp_exp_t exp);
364 std::string to_string(
size_t n = 0,
int b = default_base, mp_rnd_t mode = default_rnd)
const;
387 return "inexact conversion from floating point";
398 const mpreal operator+(
const mpreal& a,
const long double b);
399 const mpreal operator+(
const mpreal& a,
const double b);
400 const mpreal operator+(
const mpreal& a,
const unsigned long int b);
401 const mpreal operator+(
const mpreal& a,
const unsigned int b);
402 const mpreal operator+(
const mpreal& a,
const long int b);
406 const std::string operator+(
const mpreal& a,
const std::string b);
407 const std::string operator+(
const std::string a,
const mpreal& b);
411 const mpreal operator+(
const long double b,
const mpreal& a);
412 const mpreal operator+(
const double b,
const mpreal& a);
413 const mpreal operator+(
const unsigned long int b,
const mpreal& a);
414 const mpreal operator+(
const unsigned int b,
const mpreal& a);
415 const mpreal operator+(
const long int b,
const mpreal& a);
425 const mpreal operator-(
const mpreal& a,
const long double b);
426 const mpreal operator-(
const mpreal& a,
const double b);
427 const mpreal operator-(
const mpreal& a,
const unsigned long int b);
428 const mpreal operator-(
const mpreal& a,
const unsigned int b);
429 const mpreal operator-(
const mpreal& a,
const long int b);
436 const mpreal operator-(
const long double b,
const mpreal& a);
446 const mpreal operator*(
const mpreal& a,
const long double b);
447 const mpreal operator*(
const mpreal& a,
const double b);
448 const mpreal operator*(
const mpreal& a,
const unsigned long int b);
449 const mpreal operator*(
const mpreal& a,
const unsigned int b);
450 const mpreal operator*(
const mpreal& a,
const long int b);
455 const mpreal operator*(
const long double b,
const mpreal& a);
456 const mpreal operator*(
const double b,
const mpreal& a);
457 const mpreal operator*(
const unsigned long int b,
const mpreal& a);
458 const mpreal operator*(
const unsigned int b,
const mpreal& a);
459 const mpreal operator*(
const long int b,
const mpreal& a);
469 const mpreal operator/(
const mpreal& a,
const long double b);
470 const mpreal operator/(
const mpreal& a,
const double b);
471 const mpreal operator/(
const mpreal& a,
const unsigned long int b);
472 const mpreal operator/(
const mpreal& a,
const unsigned int b);
473 const mpreal operator/(
const mpreal& a,
const long int b);
476 const mpreal operator/(
const long double b,
const mpreal& a);
480 const mpreal operator<<(
const mpreal& v,
const unsigned long int k);
481 const mpreal operator<<(
const mpreal& v,
const unsigned int k);
482 const mpreal operator<<(
const mpreal& v,
const long int k);
485 const mpreal operator>>(
const mpreal& v,
const unsigned long int k);
486 const mpreal operator>>(
const mpreal& v,
const unsigned int k);
487 const mpreal operator>>(
const mpreal& v,
const long int k);
492 bool operator<(
const mpreal& a,
const unsigned long int b);
493 bool operator<(
const mpreal& a,
const unsigned int b);
494 bool operator<(
const mpreal& a,
const long int b);
495 bool operator<(
const mpreal& a,
const int b);
496 bool operator<(
const mpreal& a,
const long double b);
497 bool operator<(
const mpreal& a,
const double b);
499 bool operator<(
const unsigned long int a,
const mpreal& b);
500 bool operator<(
const unsigned int a,
const mpreal& b);
501 bool operator<(
const long int a,
const mpreal& b);
502 bool operator<(
const int a,
const mpreal& b);
503 bool operator<(
const long double a,
const mpreal& b);
504 bool operator<(
const double a,
const mpreal& b);
506 bool operator>(
const mpreal& a,
const unsigned long int b);
507 bool operator>(
const mpreal& a,
const unsigned int b);
508 bool operator>(
const mpreal& a,
const long int b);
509 bool operator>(
const mpreal& a,
const int b);
510 bool operator>(
const mpreal& a,
const long double b);
511 bool operator>(
const mpreal& a,
const double b);
513 bool operator>(
const unsigned long int a,
const mpreal& b);
514 bool operator>(
const unsigned int a,
const mpreal& b);
515 bool operator>(
const long int a,
const mpreal& b);
516 bool operator>(
const int a,
const mpreal& b);
517 bool operator>(
const long double a,
const mpreal& b);
518 bool operator>(
const double a,
const mpreal& b);
520 bool operator >=(
const mpreal& a,
const unsigned long int b);
521 bool operator >=(
const mpreal& a,
const unsigned int b);
522 bool operator >=(
const mpreal& a,
const long int b);
523 bool operator >=(
const mpreal& a,
const int b);
524 bool operator >=(
const mpreal& a,
const long double b);
525 bool operator >=(
const mpreal& a,
const double b);
527 bool operator >=(
const unsigned long int a,
const mpreal& b);
528 bool operator >=(
const unsigned int a,
const mpreal& b);
529 bool operator >=(
const long int a,
const mpreal& b);
530 bool operator >=(
const int a,
const mpreal& b);
531 bool operator >=(
const long double a,
const mpreal& b);
532 bool operator >=(
const double a,
const mpreal& b);
534 bool operator <=(
const mpreal& a,
const unsigned long int b);
535 bool operator <=(
const mpreal& a,
const unsigned int b);
536 bool operator <=(
const mpreal& a,
const long int b);
537 bool operator <=(
const mpreal& a,
const int b);
538 bool operator <=(
const mpreal& a,
const long double b);
539 bool operator <=(
const mpreal& a,
const double b);
541 bool operator <=(
const unsigned long int a,
const mpreal& b);
542 bool operator <=(
const unsigned int a,
const mpreal& b);
543 bool operator <=(
const long int a,
const mpreal& b);
544 bool operator <=(
const int a,
const mpreal& b);
545 bool operator <=(
const long double a,
const mpreal& b);
546 bool operator <=(
const double a,
const mpreal& b);
548 bool operator ==(
const mpreal& a,
const unsigned long int b);
549 bool operator ==(
const mpreal& a,
const unsigned int b);
550 bool operator ==(
const mpreal& a,
const long int b);
551 bool operator ==(
const mpreal& a,
const int b);
552 bool operator ==(
const mpreal& a,
const long double b);
553 bool operator ==(
const mpreal& a,
const double b);
555 bool operator ==(
const unsigned long int a,
const mpreal& b);
556 bool operator ==(
const unsigned int a,
const mpreal& b);
557 bool operator ==(
const long int a,
const mpreal& b);
558 bool operator ==(
const int a,
const mpreal& b);
559 bool operator ==(
const long double a,
const mpreal& b);
560 bool operator ==(
const double a,
const mpreal& b);
562 bool operator !=(
const mpreal& a,
const unsigned long int b);
563 bool operator !=(
const mpreal& a,
const unsigned int b);
564 bool operator !=(
const mpreal& a,
const long int b);
565 bool operator !=(
const mpreal& a,
const int b);
566 bool operator !=(
const mpreal& a,
const long double b);
567 bool operator !=(
const mpreal& a,
const double b);
569 bool operator !=(
const unsigned long int a,
const mpreal& b);
570 bool operator !=(
const unsigned int a,
const mpreal& b);
571 bool operator !=(
const long int a,
const mpreal& b);
572 bool operator !=(
const int a,
const mpreal& b);
573 bool operator !=(
const long double a,
const mpreal& b);
574 bool operator !=(
const double a,
const mpreal& b);
578 const mpreal sqrt(
const unsigned int v, mp_rnd_t rnd_mode = mpreal::default_rnd);
579 const mpreal sqrt(
const long int v, mp_rnd_t rnd_mode = mpreal::default_rnd);
580 const mpreal sqrt(
const int v, mp_rnd_t rnd_mode = mpreal::default_rnd);
581 const mpreal sqrt(
const long double v, mp_rnd_t rnd_mode = mpreal::default_rnd);
582 const mpreal sqrt(
const double v, mp_rnd_t rnd_mode = mpreal::default_rnd);
586 const mpreal pow(
const mpreal& a,
const unsigned int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
587 const mpreal pow(
const mpreal& a,
const int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
588 const mpreal pow(
const mpreal& a,
const long double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
589 const mpreal pow(
const mpreal& a,
const double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
591 const mpreal pow(
const unsigned int a,
const mpreal& b, mp_rnd_t rnd_mode = mpreal::default_rnd);
592 const mpreal pow(
const long int a,
const mpreal& b, mp_rnd_t rnd_mode = mpreal::default_rnd);
593 const mpreal pow(
const int a,
const mpreal& b, mp_rnd_t rnd_mode = mpreal::default_rnd);
594 const mpreal pow(
const long double a,
const mpreal& b, mp_rnd_t rnd_mode = mpreal::default_rnd);
595 const mpreal pow(
const double a,
const mpreal& b, mp_rnd_t rnd_mode = mpreal::default_rnd);
597 const mpreal pow(
const unsigned long int a,
const unsigned int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
598 const mpreal pow(
const unsigned long int a,
const long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
599 const mpreal pow(
const unsigned long int a,
const int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
600 const mpreal pow(
const unsigned long int a,
const long double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
601 const mpreal pow(
const unsigned long int a,
const double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
603 const mpreal pow(
const unsigned int a,
const unsigned long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
604 const mpreal pow(
const unsigned int a,
const unsigned int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
605 const mpreal pow(
const unsigned int a,
const long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
606 const mpreal pow(
const unsigned int a,
const int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
607 const mpreal pow(
const unsigned int a,
const long double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
608 const mpreal pow(
const unsigned int a,
const double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
610 const mpreal pow(
const long int a,
const unsigned long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
611 const mpreal pow(
const long int a,
const unsigned int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
612 const mpreal pow(
const long int a,
const long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
613 const mpreal pow(
const long int a,
const int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
614 const mpreal pow(
const long int a,
const long double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
615 const mpreal pow(
const long int a,
const double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
617 const mpreal pow(
const int a,
const unsigned long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
618 const mpreal pow(
const int a,
const unsigned int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
619 const mpreal pow(
const int a,
const long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
620 const mpreal pow(
const int a,
const int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
621 const mpreal pow(
const int a,
const long double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
622 const mpreal pow(
const int a,
const double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
624 const mpreal pow(
const long double a,
const long double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
625 const mpreal pow(
const long double a,
const unsigned long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
626 const mpreal pow(
const long double a,
const unsigned int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
627 const mpreal pow(
const long double a,
const long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
628 const mpreal pow(
const long double a,
const int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
630 const mpreal pow(
const double a,
const double b, mp_rnd_t rnd_mode = mpreal::default_rnd);
631 const mpreal pow(
const double a,
const unsigned long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
632 const mpreal pow(
const double a,
const unsigned int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
633 const mpreal pow(
const double a,
const long int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
634 const mpreal pow(
const double a,
const int b, mp_rnd_t rnd_mode = mpreal::default_rnd);
644 if (
this != &v) mpfr_set(mp, v.mp, default_rnd);
648 inline mpreal& mpreal::operator=(
const mpf_t v) {
649 mpfr_set_f(mp, v, default_rnd);
653 inline mpreal& mpreal::operator=(
const mpz_t v) {
654 mpfr_set_z(mp, v, default_rnd);
658 inline mpreal& mpreal::operator=(
const mpq_t v) {
659 mpfr_set_q(mp, v, default_rnd);
663 inline mpreal& mpreal::operator=(
const long double v) {
664 mpfr_set_ld(mp, v, default_rnd);
668 inline mpreal& mpreal::operator=(
const double v) {
669 if (double_bits == -1 || fits_in_bits(v, double_bits)) {
670 mpfr_set_d(mp, v, default_rnd);
672 throw conversion_overflow();
677 inline mpreal& mpreal::operator=(
const unsigned long int v) {
678 mpfr_set_ui(mp, v, default_rnd);
682 inline mpreal& mpreal::operator=(
const unsigned int v) {
683 mpfr_set_ui(mp, v, default_rnd);
687 inline mpreal& mpreal::operator=(
const long int v) {
688 mpfr_set_si(mp, v, default_rnd);
692 inline mpreal& mpreal::operator=(
const int v) {
693 mpfr_set_si(mp, v, default_rnd);
700 inline mpreal& mpreal::operator+=(
const mpreal& v) {
701 mpfr_add(mp, mp, v.mp, default_rnd);
705 inline mpreal& mpreal::operator+=(
const mpf_t u) {
710 inline mpreal& mpreal::operator+=(
const mpz_t u) {
711 mpfr_add_z(mp, mp, u, default_rnd);
715 inline mpreal& mpreal::operator+=(
const mpq_t u) {
716 mpfr_add_q(mp, mp, u, default_rnd);
720 inline mpreal& mpreal::operator+=(
const long double u) {
721 return *
this += mpreal(u);
724 inline mpreal& mpreal::operator+=(
const double u) {
725 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
726 mpfr_add_d(mp, mp, u, default_rnd);
729 return *
this += mpreal(u);
733 inline mpreal& mpreal::operator+=(
const unsigned long int u) {
734 mpfr_add_ui(mp, mp, u, default_rnd);
738 inline mpreal& mpreal::operator+=(
const unsigned int u) {
739 mpfr_add_ui(mp, mp, u, default_rnd);
743 inline mpreal& mpreal::operator+=(
const long int u) {
744 mpfr_add_si(mp, mp, u, default_rnd);
748 inline mpreal& mpreal::operator+=(
const int u) {
749 mpfr_add_si(mp, mp, u, default_rnd);
753 inline const mpreal mpreal::operator+()
const {
754 return mpreal(*
this);
757 inline const mpreal operator+(
const mpreal& a,
const mpreal& b) {
759 if (a.get_prec() > b.get_prec())
return mpreal(a) += b;
760 else return mpreal(b) += a;
763 inline const std::string operator+(
const mpreal& a,
const std::string b) {
764 return (std::string)a + b;
767 inline const std::string operator+(
const std::string a,
const mpreal& b) {
768 return a + (std::string)b;
771 inline const mpreal operator+(
const mpreal& a,
const mpz_t b) {
772 return mpreal(a) += b;
775 inline const mpreal operator+(
const mpreal& a,
const char* b) {
776 return a + mpreal(b);
779 inline const mpreal operator+(
const char* a,
const mpreal& b) {
780 return mpreal(a) + b;
784 inline const mpreal operator+(
const mpreal& a,
const mpq_t b) {
785 return mpreal(a) += b;
788 inline const mpreal operator+(
const mpreal& a,
const long double b) {
789 return mpreal(a) += b;
792 inline const mpreal operator+(
const mpreal& a,
const double b) {
793 return mpreal(a) += b;
796 inline const mpreal operator+(
const mpreal& a,
const unsigned long int b) {
797 return mpreal(a) += b;
800 inline const mpreal operator+(
const mpreal& a,
const unsigned int b) {
801 return mpreal(a) += b;
804 inline const mpreal operator+(
const mpreal& a,
const long int b) {
805 return mpreal(a) += b;
808 inline const mpreal operator+(
const mpreal& a,
const int b) {
809 return mpreal(a) += b;
812 inline const mpreal operator+(
const mpz_t b,
const mpreal& a) {
813 return mpreal(a) += b;
816 inline const mpreal operator+(
const mpq_t b,
const mpreal& a) {
817 return mpreal(a) += b;
820 inline const mpreal operator+(
const long double b,
const mpreal& a) {
821 return mpreal(a) += b;
824 inline const mpreal operator+(
const double b,
const mpreal& a) {
825 return mpreal(a) += b;
828 inline const mpreal operator+(
const unsigned long int b,
const mpreal& a) {
829 return mpreal(a) += b;
832 inline const mpreal operator+(
const unsigned int b,
const mpreal& a) {
833 return mpreal(a) += b;
836 inline const mpreal operator+(
const long int b,
const mpreal& a) {
837 return mpreal(a) += b;
840 inline const mpreal operator+(
const int b,
const mpreal& a) {
841 return mpreal(a) += b;
844 inline mpreal& mpreal::operator++() {
849 inline const mpreal mpreal::operator++(
int) {
855 inline mpreal& mpreal::operator--() {
860 inline const mpreal mpreal::operator--(
int) {
869 inline mpreal& mpreal::operator-=(
const mpreal& v) {
870 mpfr_sub(mp, mp, v.mp, default_rnd);
874 inline mpreal& mpreal::operator-=(
const mpz_t v) {
875 mpfr_sub_z(mp, mp, v, default_rnd);
879 inline mpreal& mpreal::operator-=(
const mpq_t v) {
880 mpfr_sub_q(mp, mp, v, default_rnd);
884 inline mpreal& mpreal::operator-=(
const long double v) {
885 return *
this -= mpreal(v);
888 inline mpreal& mpreal::operator-=(
const double v) {
889 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
890 mpfr_sub_d(mp, mp, v, default_rnd);
893 return *
this -= mpreal(v);
897 inline mpreal& mpreal::operator-=(
const unsigned long int v) {
898 mpfr_sub_ui(mp, mp, v, default_rnd);
902 inline mpreal& mpreal::operator-=(
const unsigned int v) {
903 mpfr_sub_ui(mp, mp, v, default_rnd);
907 inline mpreal& mpreal::operator-=(
const long int v) {
908 mpfr_sub_si(mp, mp, v, default_rnd);
912 inline mpreal& mpreal::operator-=(
const int v) {
913 mpfr_sub_si(mp, mp, v, default_rnd);
917 inline const mpreal mpreal::operator-()
const {
919 mpfr_neg(u.mp, u.mp, default_rnd);
923 inline const mpreal operator-(
const mpreal& a,
const mpreal& b) {
925 if (a.get_prec() > b.get_prec())
return mpreal(a) -= b;
926 else return -(mpreal(b) -= a);
929 inline const mpreal operator-(
const mpreal& a,
const mpz_t b) {
930 return mpreal(a) -= b;
933 inline const mpreal operator-(
const mpreal& a,
const mpq_t b) {
934 return mpreal(a) -= b;
937 inline const mpreal operator-(
const mpreal& a,
const long double b) {
938 return mpreal(a) -= b;
941 inline const mpreal operator-(
const mpreal& a,
const double b) {
942 return mpreal(a) -= b;
945 inline const mpreal operator-(
const mpreal& a,
const unsigned long int b) {
946 return mpreal(a) -= b;
949 inline const mpreal operator-(
const mpreal& a,
const unsigned int b) {
950 return mpreal(a) -= b;
953 inline const mpreal operator-(
const mpreal& a,
const long int b) {
954 return mpreal(a) -= b;
957 inline const mpreal operator-(
const mpreal& a,
const int b) {
958 return mpreal(a) -= b;
961 inline const mpreal operator-(
const mpz_t b,
const mpreal& a) {
962 return -(mpreal(a) -= b);
965 inline const mpreal operator-(
const mpq_t b,
const mpreal& a) {
966 return -(mpreal(a) -= b);
969 inline const mpreal operator-(
const long double b,
const mpreal& a) {
970 return -(mpreal(a) -= b);
973 inline const mpreal operator-(
const double b,
const mpreal& a) {
974 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
976 mpfr_d_sub(x.mp, b, a.mp, mpreal::default_rnd);
979 return -(mpreal(a) -= b);
983 inline const mpreal operator-(
const unsigned long int b,
const mpreal& a) {
985 mpfr_ui_sub(x.mp, b, a.mp, mpreal::default_rnd);
989 inline const mpreal operator-(
const unsigned int b,
const mpreal& a) {
991 mpfr_ui_sub(x.mp, b, a.mp, mpreal::default_rnd);
995 inline const mpreal operator-(
const long int b,
const mpreal& a) {
997 mpfr_si_sub(x.mp, b, a.mp, mpreal::default_rnd);
1001 inline const mpreal operator-(
const int b,
const mpreal& a) {
1003 mpfr_si_sub(x.mp, b, a.mp, mpreal::default_rnd);
1007 inline const mpreal operator-(
const mpreal& a,
const char* b) {
1008 return a - mpreal(b);
1011 inline const mpreal operator-(
const char* a,
const mpreal& b) {
1012 return mpreal(a) - b;
1018 inline mpreal& mpreal::operator*=(
const mpreal& v) {
1019 mpfr_mul(mp, mp, v.mp, default_rnd);
1023 inline mpreal& mpreal::operator*=(
const mpz_t v) {
1024 mpfr_mul_z(mp, mp, v, default_rnd);
1028 inline mpreal& mpreal::operator*=(
const mpq_t v) {
1029 mpfr_mul_q(mp, mp, v, default_rnd);
1033 inline mpreal& mpreal::operator*=(
const long double v) {
1034 return *
this *= mpreal(v);
1037 inline mpreal& mpreal::operator*=(
const double v) {
1038 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
1039 mpfr_mul_d(mp, mp, v, default_rnd);
1042 return *
this *= mpreal(v);
1046 inline mpreal& mpreal::operator*=(
const unsigned long int v) {
1047 mpfr_mul_ui(mp, mp, v, default_rnd);
1051 inline mpreal& mpreal::operator*=(
const unsigned int v) {
1052 mpfr_mul_ui(mp, mp, v, default_rnd);
1056 inline mpreal& mpreal::operator*=(
const long int v) {
1057 mpfr_mul_si(mp, mp, v, default_rnd);
1061 inline mpreal& mpreal::operator*=(
const int v) {
1062 mpfr_mul_si(mp, mp, v, default_rnd);
1066 inline const mpreal operator*(
const mpreal& a,
const mpreal& b) {
1068 if (a.get_prec() > b.get_prec())
return mpreal(a) *= b;
1069 else return mpreal(b) *= a;
1072 inline const mpreal operator*(
const mpreal& a,
const mpz_t b) {
1073 return mpreal(a) *= b;
1076 inline const mpreal operator*(
const mpreal& a,
const mpq_t b) {
1077 return mpreal(a) *= b;
1080 inline const mpreal operator*(
const mpreal& a,
const long double b) {
1081 return mpreal(a) *= b;
1084 inline const mpreal operator*(
const mpreal& a,
const double b) {
1085 return mpreal(a) *= b;
1088 inline const mpreal operator*(
const mpreal& a,
const unsigned long int b) {
1089 return mpreal(a) *= b;
1092 inline const mpreal operator*(
const mpreal& a,
const unsigned int b) {
1093 return mpreal(a) *= b;
1096 inline const mpreal operator*(
const mpreal& a,
const long int b) {
1097 return mpreal(a) *= b;
1100 inline const mpreal operator*(
const mpreal& a,
const int b) {
1101 return mpreal(a) *= b;
1104 inline const mpreal operator*(
const mpz_t b,
const mpreal& a) {
1105 return mpreal(a) *= b;
1108 inline const mpreal operator*(
const mpq_t b,
const mpreal& a) {
1109 return mpreal(a) *= b;
1112 inline const mpreal operator*(
const long double b,
const mpreal& a) {
1113 return mpreal(a) *= b;
1116 inline const mpreal operator*(
const double b,
const mpreal& a) {
1117 return mpreal(a) *= b;
1120 inline const mpreal operator*(
const unsigned long int b,
const mpreal& a) {
1121 return mpreal(a) *= b;
1124 inline const mpreal operator*(
const unsigned int b,
const mpreal& a) {
1125 return mpreal(a) *= b;
1128 inline const mpreal operator*(
const long int b,
const mpreal& a) {
1129 return mpreal(a) *= b;
1132 inline const mpreal operator*(
const int b,
const mpreal& a) {
1133 return mpreal(a) *= b;
1139 inline mpreal& mpreal::operator/=(
const mpreal& v) {
1140 mpfr_div(mp, mp, v.mp, default_rnd);
1144 inline mpreal& mpreal::operator/=(
const mpz_t v) {
1145 mpfr_div_z(mp, mp, v, default_rnd);
1149 inline mpreal& mpreal::operator/=(
const mpq_t v) {
1150 mpfr_div_q(mp, mp, v, default_rnd);
1154 inline mpreal& mpreal::operator/=(
const long double v) {
1155 return *
this /= mpreal(v);
1158 inline mpreal& mpreal::operator/=(
const double v) {
1159 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
1160 mpfr_div_d(mp, mp, v, default_rnd);
1163 return *
this /= mpreal(v);
1167 inline mpreal& mpreal::operator/=(
const unsigned long int v) {
1168 mpfr_div_ui(mp, mp, v, default_rnd);
1172 inline mpreal& mpreal::operator/=(
const unsigned int v) {
1173 mpfr_div_ui(mp, mp, v, default_rnd);
1177 inline mpreal& mpreal::operator/=(
const long int v) {
1178 mpfr_div_si(mp, mp, v, default_rnd);
1182 inline mpreal& mpreal::operator/=(
const int v) {
1183 mpfr_div_si(mp, mp, v, default_rnd);
1187 inline const mpreal operator/(
const mpreal& a,
const mpreal& b) {
1195 if (pb > pa) x.set_prec(pb);
1200 inline const mpreal operator/(
const mpreal& a,
const mpz_t b) {
1201 return mpreal(a) /= b;
1204 inline const mpreal operator/(
const mpreal& a,
const mpq_t b) {
1205 return mpreal(a) /= b;
1208 inline const mpreal operator/(
const mpreal& a,
const long double b) {
1209 return mpreal(a) /= b;
1212 inline const mpreal operator/(
const mpreal& a,
const double b) {
1213 return mpreal(a) /= b;
1216 inline const mpreal operator/(
const mpreal& a,
const unsigned long int b) {
1217 return mpreal(a) /= b;
1220 inline const mpreal operator/(
const mpreal& a,
const unsigned int b) {
1221 return mpreal(a) /= b;
1224 inline const mpreal operator/(
const mpreal& a,
const long int b) {
1225 return mpreal(a) /= b;
1228 inline const mpreal operator/(
const mpreal& a,
const int b) {
1229 return mpreal(a) /= b;
1232 inline const mpreal operator/(
const unsigned long int b,
const mpreal& a) {
1234 mpfr_ui_div(x.mp, b, a.mp, mpreal::default_rnd);
1238 inline const mpreal operator/(
const unsigned int b,
const mpreal& a) {
1240 mpfr_ui_div(x.mp, b, a.mp, mpreal::default_rnd);
1244 inline const mpreal operator/(
const long int b,
const mpreal& a) {
1246 mpfr_si_div(x.mp, b, a.mp, mpreal::default_rnd);
1250 inline const mpreal operator/(
const int b,
const mpreal& a) {
1252 mpfr_si_div(x.mp, b, a.mp, mpreal::default_rnd);
1256 inline const mpreal operator/(
const long double b,
const mpreal& a) {
1261 inline const mpreal operator/(
const double b,
const mpreal& a) {
1262 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
1264 mpfr_d_div(x.mp, b, a.mp, mpreal::default_rnd);
1275 inline mpreal& mpreal::operator<<=(
const unsigned long int u) {
1276 mpfr_mul_2ui(mp, mp, u, default_rnd);
1280 inline mpreal& mpreal::operator<<=(
const unsigned int u) {
1281 mpfr_mul_2ui(mp, mp, static_cast<unsigned long int> (u), default_rnd);
1285 inline mpreal& mpreal::operator<<=(
const long int u) {
1286 mpfr_mul_2si(mp, mp, u, default_rnd);
1290 inline mpreal& mpreal::operator<<=(
const int u) {
1291 mpfr_mul_2si(mp, mp, static_cast<long int> (u), default_rnd);
1295 inline mpreal& mpreal::operator>>=(
const unsigned long int u) {
1296 mpfr_div_2ui(mp, mp, u, default_rnd);
1300 inline mpreal& mpreal::operator>>=(
const unsigned int u) {
1301 mpfr_div_2ui(mp, mp, static_cast<unsigned long int> (u), default_rnd);
1305 inline mpreal& mpreal::operator>>=(
const long int u) {
1306 mpfr_div_2si(mp, mp, u, default_rnd);
1310 inline mpreal& mpreal::operator>>=(
const int u) {
1311 mpfr_div_2si(mp, mp, static_cast<long int> (u), default_rnd);
1315 inline const mpreal operator<<(
const mpreal& v,
const unsigned long int k) {
1316 return mul_2ui(v, k);
1319 inline const mpreal operator<<(
const mpreal& v,
const unsigned int k) {
1320 return mul_2ui(v, static_cast<unsigned long int> (k));
1323 inline const mpreal operator<<(
const mpreal& v,
const long int k) {
1324 return mul_2si(v, k);
1327 inline const mpreal operator<<(
const mpreal& v,
const int k) {
1328 return mul_2si(v, static_cast<long int> (k));
1331 inline const mpreal operator>>(
const mpreal& v,
const unsigned long int k) {
1332 return div_2ui(v, k);
1335 inline const mpreal operator>>(
const mpreal& v,
const long int k) {
1336 return div_2si(v, k);
1339 inline const mpreal operator>>(
const mpreal& v,
const unsigned int k) {
1340 return div_2ui(v, static_cast<unsigned long int> (k));
1343 inline const mpreal operator>>(
const mpreal& v,
const int k) {
1344 return div_2si(v, static_cast<long int> (k));
1349 inline const mpreal mul_2ui(
const mpreal& v,
unsigned long int k, mp_rnd_t rnd_mode) {
1351 mpfr_mul_2ui(x.mp, v.mp, k, rnd_mode);
1357 inline const mpreal mul_2si(
const mpreal& v,
long int k, mp_rnd_t rnd_mode) {
1359 mpfr_mul_2si(x.mp, v.mp, k, rnd_mode);
1363 inline const mpreal div_2ui(
const mpreal& v,
unsigned long int k, mp_rnd_t rnd_mode) {
1365 mpfr_div_2ui(x.mp, v.mp, k, rnd_mode);
1369 inline const mpreal div_2si(
const mpreal& v,
long int k, mp_rnd_t rnd_mode) {
1371 mpfr_div_2si(x.mp, v.mp, k, rnd_mode);
1378 inline bool operator>(
const mpreal& a,
const mpreal& b) {
1379 return (mpfr_greater_p(a.mp, b.mp) != 0);
1382 inline bool operator>(
const mpreal& a,
const unsigned long int b) {
1383 return a > mpreal(b);
1386 inline bool operator>(
const mpreal& a,
const unsigned int b) {
1387 return a > mpreal(b);
1390 inline bool operator>(
const mpreal& a,
const long int b) {
1391 return a > mpreal(b);
1394 inline bool operator>(
const mpreal& a,
const int b) {
1395 return a > mpreal(b);
1398 inline bool operator>(
const mpreal& a,
const long double b) {
1399 return a > mpreal(b);
1402 inline bool operator>(
const mpreal& a,
const double b) {
1403 return a > mpreal(b);
1406 inline bool operator>(
const unsigned long int a,
const mpreal& b) {
1407 return mpreal(a) > b;
1410 inline bool operator>(
const unsigned int a,
const mpreal& b) {
1411 return mpreal(a) > b;
1414 inline bool operator>(
const long int a,
const mpreal& b) {
1415 return mpreal(a) > b;
1418 inline bool operator>(
const int a,
const mpreal& b) {
1419 return mpreal(a) > b;
1422 inline bool operator>(
const long double a,
const mpreal& b) {
1423 return mpreal(a) > b;
1426 inline bool operator>(
const double a,
const mpreal& b) {
1427 return mpreal(a) > b;
1430 inline bool operator >=(
const mpreal& a,
const mpreal& b) {
1431 return (mpfr_greaterequal_p(a.mp, b.mp) != 0);
1434 inline bool operator >=(
const mpreal& a,
const unsigned long int b) {
1435 return a >= mpreal(b);
1438 inline bool operator >=(
const mpreal& a,
const unsigned int b) {
1439 return a >= mpreal(b);
1442 inline bool operator >=(
const mpreal& a,
const long int b) {
1443 return a >= mpreal(b);
1446 inline bool operator >=(
const mpreal& a,
const int b) {
1447 return a >= mpreal(b);
1450 inline bool operator >=(
const mpreal& a,
const long double b) {
1451 return a >= mpreal(b);
1454 inline bool operator >=(
const mpreal& a,
const double b) {
1455 return a >= mpreal(b);
1458 inline bool operator >=(
const unsigned long int a,
const mpreal& b) {
1459 return mpreal(a) >= b;
1462 inline bool operator >=(
const unsigned int a,
const mpreal& b) {
1463 return mpreal(a) >= b;
1466 inline bool operator >=(
const long int a,
const mpreal& b) {
1467 return mpreal(a) >= b;
1470 inline bool operator >=(
const int a,
const mpreal& b) {
1471 return mpreal(a) >= b;
1474 inline bool operator >=(
const long double a,
const mpreal& b) {
1475 return mpreal(a) >= b;
1478 inline bool operator >=(
const double a,
const mpreal& b) {
1479 return mpreal(a) >= b;
1482 inline bool operator<(
const mpreal& a,
const mpreal& b) {
1483 return (mpfr_less_p(a.mp, b.mp) != 0);
1486 inline bool operator<(
const mpreal& a,
const unsigned long int b) {
1487 return a < mpreal(b);
1490 inline bool operator<(
const mpreal& a,
const unsigned int b) {
1491 return a < mpreal(b);
1494 inline bool operator<(
const mpreal& a,
const long int b) {
1495 return a < mpreal(b);
1498 inline bool operator<(
const mpreal& a,
const int b) {
1499 return a < mpreal(b);
1502 inline bool operator<(
const mpreal& a,
const long double b) {
1503 return a < mpreal(b);
1506 inline bool operator<(
const mpreal& a,
const double b) {
1507 return a < mpreal(b);
1510 inline bool operator<(
const unsigned long int a,
const mpreal& b) {
1511 return mpreal(a) < b;
1514 inline bool operator<(
const unsigned int a,
const mpreal& b) {
1515 return mpreal(a) < b;
1518 inline bool operator<(
const long int a,
const mpreal& b) {
1519 return mpreal(a) < b;
1522 inline bool operator<(
const int a,
const mpreal& b) {
1523 return mpreal(a) < b;
1526 inline bool operator<(
const long double a,
const mpreal& b) {
1527 return mpreal(a) < b;
1530 inline bool operator<(
const double a,
const mpreal& b) {
1531 return mpreal(a) < b;
1534 inline bool operator <=(
const mpreal& a,
const mpreal& b) {
1535 return (mpfr_lessequal_p(a.mp, b.mp) != 0);
1538 inline bool operator <=(
const mpreal& a,
const unsigned long int b) {
1539 return a <= mpreal(b);
1542 inline bool operator <=(
const mpreal& a,
const unsigned int b) {
1543 return a <= mpreal(b);
1546 inline bool operator <=(
const mpreal& a,
const long int b) {
1547 return a <= mpreal(b);
1550 inline bool operator <=(
const mpreal& a,
const int b) {
1551 return a <= mpreal(b);
1554 inline bool operator <=(
const mpreal& a,
const long double b) {
1555 return a <= mpreal(b);
1558 inline bool operator <=(
const mpreal& a,
const double b) {
1559 return a <= mpreal(b);
1562 inline bool operator <=(
const unsigned long int a,
const mpreal& b) {
1563 return mpreal(a) <= b;
1566 inline bool operator <=(
const unsigned int a,
const mpreal& b) {
1567 return mpreal(a) <= b;
1570 inline bool operator <=(
const long int a,
const mpreal& b) {
1571 return mpreal(a) <= b;
1574 inline bool operator <=(
const int a,
const mpreal& b) {
1575 return mpreal(a) <= b;
1578 inline bool operator <=(
const long double a,
const mpreal& b) {
1579 return mpreal(a) <= b;
1582 inline bool operator <=(
const double a,
const mpreal& b) {
1583 return mpreal(a) <= b;
1586 inline bool operator ==(
const mpreal& a,
const mpreal& b) {
1587 return (mpfr_equal_p(a.mp, b.mp) != 0);
1590 inline bool operator ==(
const mpreal& a,
const unsigned long int b) {
1591 return a == mpreal(b);
1594 inline bool operator ==(
const mpreal& a,
const unsigned int b) {
1595 return a == mpreal(b);
1598 inline bool operator ==(
const mpreal& a,
const long int b) {
1599 return a == mpreal(b);
1602 inline bool operator ==(
const mpreal& a,
const int b) {
1603 return a == mpreal(b);
1606 inline bool operator ==(
const mpreal& a,
const long double b) {
1607 return a == mpreal(b);
1610 inline bool operator ==(
const mpreal& a,
const double b) {
1611 return a == mpreal(b);
1614 inline bool operator ==(
const unsigned long int a,
const mpreal& b) {
1615 return mpreal(a) == b;
1618 inline bool operator ==(
const unsigned int a,
const mpreal& b) {
1619 return mpreal(a) == b;
1622 inline bool operator ==(
const long int a,
const mpreal& b) {
1623 return mpreal(a) == b;
1626 inline bool operator ==(
const int a,
const mpreal& b) {
1627 return mpreal(a) == b;
1630 inline bool operator ==(
const long double a,
const mpreal& b) {
1631 return mpreal(a) == b;
1634 inline bool operator ==(
const double a,
const mpreal& b) {
1635 return mpreal(a) == b;
1638 inline bool operator !=(
const mpreal& a,
const mpreal& b) {
1639 return (mpfr_lessgreater_p(a.mp, b.mp) != 0);
1642 inline bool operator !=(
const mpreal& a,
const unsigned long int b) {
1643 return a != mpreal(b);
1646 inline bool operator !=(
const mpreal& a,
const unsigned int b) {
1647 return a != mpreal(b);
1650 inline bool operator !=(
const mpreal& a,
const long int b) {
1651 return a != mpreal(b);
1654 inline bool operator !=(
const mpreal& a,
const int b) {
1655 return a != mpreal(b);
1658 inline bool operator !=(
const mpreal& a,
const long double b) {
1659 return a != mpreal(b);
1662 inline bool operator !=(
const mpreal& a,
const double b) {
1663 return a != mpreal(b);
1666 inline bool operator !=(
const unsigned long int a,
const mpreal& b) {
1667 return mpreal(a) != b;
1670 inline bool operator !=(
const unsigned int a,
const mpreal& b) {
1671 return mpreal(a) != b;
1674 inline bool operator !=(
const long int a,
const mpreal& b) {
1675 return mpreal(a) != b;
1678 inline bool operator !=(
const int a,
const mpreal& b) {
1679 return mpreal(a) != b;
1682 inline bool operator !=(
const long double a,
const mpreal& b) {
1683 return mpreal(a) != b;
1686 inline bool operator !=(
const double a,
const mpreal& b) {
1687 return mpreal(a) != b;
1690 inline bool _isnan(
const mpreal& v) {
1691 return (mpfr_nan_p(v.mp) != 0);
1694 inline bool _isinf(
const mpreal& v) {
1695 return (mpfr_inf_p(v.mp) != 0);
1698 inline bool _isnum(
const mpreal& v) {
1699 return (mpfr_number_p(v.mp) != 0);
1702 inline bool _iszero(
const mpreal& v) {
1703 return (mpfr_zero_p(v.mp) != 0);
1706 inline bool _isint(
const mpreal& v) {
1707 return (mpfr_integer_p(v.mp) != 0);
1713 inline mpreal::operator double()
const {
1714 return mpfr_get_d(mp, default_rnd);
1717 inline mpreal::operator float()
const {
1718 return (
float) mpfr_get_d(mp, default_rnd);
1721 inline mpreal::operator
long double()
const {
1722 return mpfr_get_ld(mp, default_rnd);
1725 inline mpreal::operator
unsigned long()
const {
1726 return mpfr_get_ui(mp, default_rnd);
1729 inline mpreal::operator
unsigned int()
const {
1730 return mpfr_get_ui(mp, default_rnd);
1733 inline mpreal::operator long()
const {
1734 return mpfr_get_si(mp, default_rnd);
1737 inline mpreal::operator std::string()
const {
1741 inline mpreal::operator mpfr_ptr() {
1748 inline int sgn(
const mpreal& v) {
1749 int r = mpfr_signbit(v.mp);
1750 return (r > 0 ? -1 : 1);
1753 inline void mpreal::set_sign(
int sign, mp_rnd_t rnd_mode) {
1754 mpfr_setsign(mp, mp, (sign < 0 ? 1 : 0), rnd_mode);
1757 inline mp_prec_t mpreal::get_prec()
const {
1758 return mpfr_get_prec(mp);
1761 inline void mpreal::set_prec(mp_prec_t prec, mp_rnd_t rnd_mode) {
1762 mpfr_prec_round(mp, prec, rnd_mode);
1765 inline void mpreal::set_inf(
int sign) {
1766 mpfr_set_inf(mp, sign);
1769 inline void mpreal::set_nan() {
1773 inline mp_exp_t mpreal::get_exp() {
1774 return mpfr_get_exp(mp);
1777 inline int mpreal::set_exp(mp_exp_t e) {
1778 return mpfr_set_exp(mp, e);
1781 inline const mpreal frexp(
const mpreal& v, mp_exp_t* exp) {
1788 inline const mpreal ldexp(
const mpreal& v, mp_exp_t exp) {
1792 mpfr_mul_2si(x.mp, x.mp, exp, mpreal::default_rnd);
1796 inline const mpreal modf(
const mpreal& v, mpreal& n) {
1800 mpfr_frac(frac.mp, frac.mp, mpreal::default_rnd);
1801 mpfr_trunc(n.mp, v.mp);
1805 inline int mpreal::check_range(
int t, mp_rnd_t rnd_mode) {
1806 return mpfr_check_range(mp, t, rnd_mode);
1809 inline int mpreal::subnormalize(
int t, mp_rnd_t rnd_mode) {
1810 return mpfr_subnormalize(mp, t, rnd_mode);
1813 inline mp_exp_t mpreal::get_emin(
void) {
1814 return mpfr_get_emin();
1817 inline int mpreal::set_emin(mp_exp_t exp) {
1818 return mpfr_set_emin(exp);
1821 inline mp_exp_t mpreal::get_emax(
void) {
1822 return mpfr_get_emax();
1825 inline int mpreal::set_emax(mp_exp_t exp) {
1826 return mpfr_set_emax(exp);
1829 inline mp_exp_t mpreal::get_emin_min(
void) {
1830 return mpfr_get_emin_min();
1833 inline mp_exp_t mpreal::get_emin_max(
void) {
1834 return mpfr_get_emin_max();
1837 inline mp_exp_t mpreal::get_emax_min(
void) {
1838 return mpfr_get_emax_min();
1841 inline mp_exp_t mpreal::get_emax_max(
void) {
1842 return mpfr_get_emax_max();
1849 inline const mpreal sqr(
const mpreal& v, mp_rnd_t rnd_mode) {
1851 mpfr_sqr(x.mp, x.mp, rnd_mode);
1855 inline const mpreal sqrt(
const mpreal& v, mp_rnd_t rnd_mode) {
1857 mpfr_sqrt(x.mp, x.mp, rnd_mode);
1861 inline const mpreal sqrt(
const unsigned long int v, mp_rnd_t rnd_mode) {
1863 mpfr_sqrt_ui(x.mp, v, rnd_mode);
1867 inline const mpreal sqrt(
const unsigned int v, mp_rnd_t rnd_mode) {
1868 return sqrt(static_cast<unsigned long int> (v), rnd_mode);
1871 inline const mpreal sqrt(
const long int v, mp_rnd_t rnd_mode) {
1872 if (v >= 0)
return sqrt(static_cast<unsigned long int> (v), rnd_mode);
1873 else return mpreal();
1876 inline const mpreal sqrt(
const int v, mp_rnd_t rnd_mode) {
1877 if (v >= 0)
return sqrt(static_cast<unsigned long int> (v), rnd_mode);
1878 else return mpreal();
1881 inline const mpreal sqrt(
const long double v, mp_rnd_t rnd_mode) {
1882 return sqrt(mpreal(v), rnd_mode);
1885 inline const mpreal sqrt(
const double v, mp_rnd_t rnd_mode) {
1886 return sqrt(mpreal(v), rnd_mode);
1889 inline const mpreal cbrt(
const mpreal& v, mp_rnd_t rnd_mode) {
1891 mpfr_cbrt(x.mp, x.mp, rnd_mode);
1895 inline const mpreal root(
const mpreal& v,
unsigned long int k, mp_rnd_t rnd_mode) {
1897 mpfr_root(x.mp, x.mp, k, rnd_mode);
1901 inline const mpreal fabs(
const mpreal& v, mp_rnd_t rnd_mode) {
1903 mpfr_abs(x.mp, x.mp, rnd_mode);
1907 inline const mpreal abs(
const mpreal& v, mp_rnd_t rnd_mode) {
1909 mpfr_abs(x.mp, x.mp, rnd_mode);
1913 inline const mpreal dim(
const mpreal& a,
const mpreal& b, mp_rnd_t rnd_mode) {
1915 mpfr_dim(x.mp, a.mp, b.mp, rnd_mode);
1919 inline int cmpabs(
const mpreal& a,
const mpreal& b) {
1920 return mpfr_cmpabs(a.mp, b.mp);
1923 inline const mpreal log(
const mpreal& v, mp_rnd_t rnd_mode) {
1925 mpfr_log(x.mp, v.mp, rnd_mode);
1929 inline const mpreal log2(
const mpreal& v, mp_rnd_t rnd_mode) {
1931 mpfr_log2(x.mp, v.mp, rnd_mode);
1935 inline const mpreal log10(
const mpreal& v, mp_rnd_t rnd_mode) {
1937 mpfr_log10(x.mp, v.mp, rnd_mode);
1941 inline const mpreal exp(
const mpreal& v, mp_rnd_t rnd_mode) {
1943 mpfr_exp(x.mp, v.mp, rnd_mode);
1947 inline const mpreal exp2(
const mpreal& v, mp_rnd_t rnd_mode) {
1949 mpfr_exp2(x.mp, v.mp, rnd_mode);
1953 inline const mpreal exp10(
const mpreal& v, mp_rnd_t rnd_mode) {
1955 mpfr_exp10(x.mp, v.mp, rnd_mode);
1959 inline const mpreal cos(
const mpreal& v, mp_rnd_t rnd_mode) {
1961 mpfr_cos(x.mp, v.mp, rnd_mode);
1965 inline const mpreal sin(
const mpreal& v, mp_rnd_t rnd_mode) {
1967 mpfr_sin(x.mp, v.mp, rnd_mode);
1971 inline const mpreal tan(
const mpreal& v, mp_rnd_t rnd_mode) {
1973 mpfr_tan(x.mp, v.mp, rnd_mode);
1977 inline const mpreal sec(
const mpreal& v, mp_rnd_t rnd_mode) {
1979 mpfr_sec(x.mp, v.mp, rnd_mode);
1983 inline const mpreal csc(
const mpreal& v, mp_rnd_t rnd_mode) {
1985 mpfr_csc(x.mp, v.mp, rnd_mode);
1989 inline const mpreal cot(
const mpreal& v, mp_rnd_t rnd_mode) {
1991 mpfr_cot(x.mp, v.mp, rnd_mode);
1995 inline int sin_cos(mpreal& s, mpreal& c,
const mpreal& v, mp_rnd_t rnd_mode) {
1996 return mpfr_sin_cos(s.mp, c.mp, v.mp, rnd_mode);
1999 inline const mpreal acos(
const mpreal& v, mp_rnd_t rnd_mode) {
2001 mpfr_acos(x.mp, v.mp, rnd_mode);
2005 inline const mpreal asin(
const mpreal& v, mp_rnd_t rnd_mode) {
2007 mpfr_asin(x.mp, v.mp, rnd_mode);
2011 inline const mpreal atan(
const mpreal& v, mp_rnd_t rnd_mode) {
2013 mpfr_atan(x.mp, v.mp, rnd_mode);
2017 inline const mpreal atan2(
const mpreal& y,
const mpreal& x, mp_rnd_t rnd_mode) {
2024 a.set_prec(yp > xp ? yp : xp);
2026 mpfr_atan2(a.mp, y.mp, x.mp, rnd_mode);
2031 inline const mpreal cosh(
const mpreal& v, mp_rnd_t rnd_mode) {
2033 mpfr_cosh(x.mp, v.mp, rnd_mode);
2037 inline const mpreal sinh(
const mpreal& v, mp_rnd_t rnd_mode) {
2039 mpfr_sinh(x.mp, v.mp, rnd_mode);
2043 inline const mpreal tanh(
const mpreal& v, mp_rnd_t rnd_mode) {
2045 mpfr_tanh(x.mp, v.mp, rnd_mode);
2049 inline const mpreal sech(
const mpreal& v, mp_rnd_t rnd_mode) {
2051 mpfr_sech(x.mp, v.mp, rnd_mode);
2055 inline const mpreal csch(
const mpreal& v, mp_rnd_t rnd_mode) {
2057 mpfr_csch(x.mp, v.mp, rnd_mode);
2061 inline const mpreal coth(
const mpreal& v, mp_rnd_t rnd_mode) {
2063 mpfr_coth(x.mp, v.mp, rnd_mode);
2067 inline const mpreal acosh(
const mpreal& v, mp_rnd_t rnd_mode) {
2069 mpfr_acosh(x.mp, v.mp, rnd_mode);
2073 inline const mpreal asinh(
const mpreal& v, mp_rnd_t rnd_mode) {
2075 mpfr_asinh(x.mp, v.mp, rnd_mode);
2079 inline const mpreal atanh(
const mpreal& v, mp_rnd_t rnd_mode) {
2081 mpfr_atanh(x.mp, v.mp, rnd_mode);
2085 inline const mpreal fac_ui(
unsigned long int v, mp_rnd_t rnd_mode) {
2087 mpfr_fac_ui(x.mp, v, rnd_mode);
2091 inline const mpreal log1p(
const mpreal& v, mp_rnd_t rnd_mode) {
2093 mpfr_log1p(x.mp, v.mp, rnd_mode);
2097 inline const mpreal expm1(
const mpreal& v, mp_rnd_t rnd_mode) {
2099 mpfr_expm1(x.mp, v.mp, rnd_mode);
2103 inline const mpreal eint(
const mpreal& v, mp_rnd_t rnd_mode) {
2105 mpfr_eint(x.mp, v.mp, rnd_mode);
2109 inline const mpreal gamma(
const mpreal& v, mp_rnd_t rnd_mode) {
2111 mpfr_gamma(x.mp, v.mp, rnd_mode);
2115 inline const mpreal lngamma(
const mpreal& v, mp_rnd_t rnd_mode) {
2117 mpfr_lngamma(x.mp, v.mp, rnd_mode);
2121 inline const mpreal lgamma(
const mpreal& v,
int *signp, mp_rnd_t rnd_mode) {
2123 mpfr_lgamma(x.mp, signp, v.mp, rnd_mode);
2127 inline const mpreal zeta(
const mpreal& v, mp_rnd_t rnd_mode) {
2129 mpfr_zeta(x.mp, v.mp, rnd_mode);
2133 inline const mpreal erf(
const mpreal& v, mp_rnd_t rnd_mode) {
2135 mpfr_erf(x.mp, v.mp, rnd_mode);
2139 inline const mpreal erfc(
const mpreal& v, mp_rnd_t rnd_mode) {
2141 mpfr_erfc(x.mp, v.mp, rnd_mode);
2145 inline const mpreal _j0(
const mpreal& v, mp_rnd_t rnd_mode) {
2147 mpfr_j0(x.mp, v.mp, rnd_mode);
2151 inline const mpreal _j1(
const mpreal& v, mp_rnd_t rnd_mode) {
2153 mpfr_j1(x.mp, v.mp, rnd_mode);
2157 inline const mpreal _jn(
long n,
const mpreal& v, mp_rnd_t rnd_mode) {
2159 mpfr_jn(x.mp, n, v.mp, rnd_mode);
2163 inline const mpreal _y0(
const mpreal& v, mp_rnd_t rnd_mode) {
2165 mpfr_y0(x.mp, v.mp, rnd_mode);
2169 inline const mpreal _y1(
const mpreal& v, mp_rnd_t rnd_mode) {
2171 mpfr_y1(x.mp, v.mp, rnd_mode);
2175 inline const mpreal _yn(
long n,
const mpreal& v, mp_rnd_t rnd_mode) {
2177 mpfr_yn(x.mp, n, v.mp, rnd_mode);
2183 #if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
2185 inline int sinh_cosh(mpreal& s, mpreal& c,
const mpreal& v, mp_rnd_t rnd_mode) {
2186 return mpfr_sinh_cosh(s.mp, c.mp, v.mp, rnd_mode);
2189 inline const mpreal li2(
const mpreal& v, mp_rnd_t rnd_mode) {
2191 mpfr_li2(x.mp, v.mp, rnd_mode);
2195 inline const mpreal fmod(
const mpreal& x,
const mpreal& y, mp_rnd_t rnd_mode) {
2202 a.set_prec(yp > xp ? yp : xp);
2204 mpfr_fmod(a.mp, x.mp, y.mp, rnd_mode);
2209 inline const mpreal rec_sqrt(
const mpreal& v, mp_rnd_t rnd_mode) {
2211 mpfr_rec_sqrt(x.mp, v.mp, rnd_mode);
2220 inline const mpreal const_log2(mp_prec_t prec, mp_rnd_t rnd_mode) {
2223 mpfr_const_log2(x.mp, rnd_mode);
2227 inline const mpreal const_pi(mp_prec_t prec, mp_rnd_t rnd_mode) {
2230 mpfr_const_pi(x.mp, rnd_mode);
2234 inline const mpreal const_euler(mp_prec_t prec, mp_rnd_t rnd_mode) {
2237 mpfr_const_euler(x.mp, rnd_mode);
2241 inline const mpreal const_catalan(mp_prec_t prec, mp_rnd_t rnd_mode) {
2244 mpfr_const_catalan(x.mp, rnd_mode);
2251 inline const mpreal rint(
const mpreal& v, mp_rnd_t rnd_mode) {
2253 mpfr_rint(x.mp, v.mp, rnd_mode);
2257 inline const mpreal ceil(
const mpreal& v) {
2259 mpfr_ceil(x.mp, v.mp);
2264 inline const mpreal floor(
const mpreal& v) {
2266 mpfr_floor(x.mp, v.mp);
2270 inline const mpreal round(
const mpreal& v) {
2272 mpfr_round(x.mp, v.mp);
2276 inline const mpreal trunc(
const mpreal& v) {
2278 mpfr_trunc(x.mp, v.mp);
2282 inline const mpreal rint_ceil(
const mpreal& v, mp_rnd_t rnd_mode) {
2284 mpfr_rint_ceil(x.mp, v.mp, rnd_mode);
2288 inline const mpreal rint_floor(
const mpreal& v, mp_rnd_t rnd_mode) {
2290 mpfr_rint_floor(x.mp, v.mp, rnd_mode);
2294 inline const mpreal rint_round(
const mpreal& v, mp_rnd_t rnd_mode) {
2296 mpfr_rint_round(x.mp, v.mp, rnd_mode);
2300 inline const mpreal rint_trunc(
const mpreal& v, mp_rnd_t rnd_mode) {
2302 mpfr_rint_trunc(x.mp, v.mp, rnd_mode);
2306 inline const mpreal frac(
const mpreal& v, mp_rnd_t rnd_mode) {
2308 mpfr_frac(x.mp, v.mp, rnd_mode);
2315 inline void swap(mpreal& a, mpreal& b) {
2316 mpfr_swap(a.mp, b.mp);
2321 inline const mpreal max(
const mpreal& x,
const mpreal& y) {
2322 return (x > y ? x : y);
2328 inline const mpreal min(
const mpreal& x,
const mpreal& y) {
2329 return (x < y ? x : y);
2333 inline const mpreal nexttoward(
const mpreal& x,
const mpreal& y) {
2335 mpfr_nexttoward(a.mp, y.mp);
2339 inline const mpreal nextabove(
const mpreal& x) {
2341 mpfr_nextabove(a.mp);
2345 inline const mpreal nextbelow(
const mpreal& x) {
2347 mpfr_nextbelow(a.mp);
2351 inline const mpreal urandomb(gmp_randstate_t& state) {
2353 mpfr_urandomb(x.mp, state);
2367 inline void mpreal::set_default_prec(mp_prec_t prec) {
2368 default_prec = prec;
2369 mpfr_set_default_prec(prec);
2372 inline mp_prec_t mpreal::get_default_prec() {
2373 return mpfr_get_default_prec();
2376 inline void mpreal::set_default_base(
int base) {
2377 default_base = base;
2380 inline int mpreal::get_default_base() {
2381 return default_base;
2384 inline void mpreal::set_default_rnd(mp_rnd_t rnd_mode) {
2385 default_rnd = rnd_mode;
2386 mpfr_set_default_rounding_mode(rnd_mode);
2389 inline mp_rnd_t mpreal::get_default_rnd() {
2390 return mpfr_get_default_rounding_mode();
2393 inline void mpreal::set_double_bits(
int dbits) {
2394 double_bits = dbits;
2397 inline int mpreal::get_double_bits() {
2401 inline bool mpreal::fits_in_bits(
double x,
int n) {
2404 return IsInf(x) || (std::modf(std::ldexp(std::frexp(x, &i), n), &t) == 0.0);
2407 inline const mpreal pow(
const mpreal& a,
const mpreal& b, mp_rnd_t rnd_mode) {
2409 mpfr_pow(x.mp, x.mp, b.mp, rnd_mode);
2413 inline const mpreal pow(
const mpreal& a,
const mpz_t b, mp_rnd_t rnd_mode) {
2415 mpfr_pow_z(x.mp, x.mp, b, rnd_mode);
2419 inline const mpreal pow(
const mpreal& a,
const unsigned long int b, mp_rnd_t rnd_mode) {
2421 mpfr_pow_ui(x.mp, x.mp, b, rnd_mode);
2425 inline const mpreal pow(
const mpreal& a,
const unsigned int b, mp_rnd_t rnd_mode) {
2426 return pow(a, static_cast<unsigned long int> (b), rnd_mode);
2429 inline const mpreal pow(
const mpreal& a,
const long int b, mp_rnd_t rnd_mode) {
2431 mpfr_pow_si(x.mp, x.mp, b, rnd_mode);
2435 inline const mpreal pow(
const mpreal& a,
const int b, mp_rnd_t rnd_mode) {
2436 return pow(a, static_cast<long int> (b), rnd_mode);
2439 inline const mpreal pow(
const mpreal& a,
const long double b, mp_rnd_t rnd_mode) {
2440 return pow(a, mpreal(b), rnd_mode);
2443 inline const mpreal pow(
const mpreal& a,
const double b, mp_rnd_t rnd_mode) {
2444 return pow(a, mpreal(b), rnd_mode);
2447 inline const mpreal pow(
const unsigned long int a,
const mpreal& b, mp_rnd_t rnd_mode) {
2449 mpfr_ui_pow(x.mp, a, b.mp, rnd_mode);
2453 inline const mpreal pow(
const unsigned int a,
const mpreal& b, mp_rnd_t rnd_mode) {
2454 return pow(static_cast<unsigned long int> (a), b, rnd_mode);
2457 inline const mpreal pow(
const long int a,
const mpreal& b, mp_rnd_t rnd_mode) {
2458 if (a >= 0)
return pow(static_cast<unsigned long int> (a), b, rnd_mode);
2459 else return pow(mpreal(a), b, rnd_mode);
2462 inline const mpreal pow(
const int a,
const mpreal& b, mp_rnd_t rnd_mode) {
2463 if (a >= 0)
return pow(static_cast<unsigned long int> (a), b, rnd_mode);
2464 else return pow(mpreal(a), b, rnd_mode);
2467 inline const mpreal pow(
const long double a,
const mpreal& b, mp_rnd_t rnd_mode) {
2468 return pow(mpreal(a), b, rnd_mode);
2471 inline const mpreal pow(
const double a,
const mpreal& b, mp_rnd_t rnd_mode) {
2472 return pow(mpreal(a), b, rnd_mode);
2477 inline const mpreal pow(
const unsigned long int a,
const unsigned long int b, mp_rnd_t rnd_mode) {
2479 mpfr_ui_pow_ui(x.mp, a, b, rnd_mode);
2483 inline const mpreal pow(
const unsigned long int a,
const unsigned int b, mp_rnd_t rnd_mode) {
2484 return pow(a, static_cast<unsigned long int> (b), rnd_mode);
2487 inline const mpreal pow(
const unsigned long int a,
const long int b, mp_rnd_t rnd_mode) {
2488 if (b > 0)
return pow(a, static_cast<unsigned long int> (b), rnd_mode);
2489 else return pow(a, mpreal(b), rnd_mode);
2492 inline const mpreal pow(
const unsigned long int a,
const int b, mp_rnd_t rnd_mode) {
2493 if (b > 0)
return pow(a, static_cast<unsigned long int> (b), rnd_mode);
2494 else return pow(a, mpreal(b), rnd_mode);
2497 inline const mpreal pow(
const unsigned long int a,
const long double b, mp_rnd_t rnd_mode) {
2498 return pow(a, mpreal(b), rnd_mode);
2501 inline const mpreal pow(
const unsigned long int a,
const double b, mp_rnd_t rnd_mode) {
2502 return pow(a, mpreal(b), rnd_mode);
2507 inline const mpreal pow(
const unsigned int a,
const unsigned long int b, mp_rnd_t rnd_mode) {
2508 return pow(static_cast<unsigned long int> (a), b, rnd_mode);
2511 inline const mpreal pow(
const unsigned int a,
const unsigned int b, mp_rnd_t rnd_mode) {
2512 return pow(static_cast<unsigned long int> (a), static_cast<unsigned long int> (b), rnd_mode);
2515 inline const mpreal pow(
const unsigned int a,
const long int b, mp_rnd_t rnd_mode) {
2516 if (b > 0)
return pow(static_cast<unsigned long int> (a), static_cast<unsigned long int> (b), rnd_mode);
2517 else return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2520 inline const mpreal pow(
const unsigned int a,
const int b, mp_rnd_t rnd_mode) {
2521 if (b > 0)
return pow(static_cast<unsigned long int> (a), static_cast<unsigned long int> (b), rnd_mode);
2522 else return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2525 inline const mpreal pow(
const unsigned int a,
const long double b, mp_rnd_t rnd_mode) {
2526 return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2529 inline const mpreal pow(
const unsigned int a,
const double b, mp_rnd_t rnd_mode) {
2530 return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2535 inline const mpreal pow(
const long int a,
const unsigned long int b, mp_rnd_t rnd_mode) {
2536 if (a > 0)
return pow(static_cast<unsigned long int> (a), b, rnd_mode);
2537 else return pow(mpreal(a), b, rnd_mode);
2540 inline const mpreal pow(
const long int a,
const unsigned int b, mp_rnd_t rnd_mode) {
2541 if (a > 0)
return pow(static_cast<unsigned long int> (a), static_cast<unsigned long int> (b), rnd_mode);
2542 else return pow(mpreal(a), static_cast<unsigned long int> (b), rnd_mode);
2545 inline const mpreal pow(
const long int a,
const long int b, mp_rnd_t rnd_mode) {
2547 if (b > 0)
return pow(static_cast<unsigned long int> (a), static_cast<unsigned long int> (b), rnd_mode);
2548 else return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2550 return pow(mpreal(a), b, rnd_mode);
2554 inline const mpreal pow(
const long int a,
const int b, mp_rnd_t rnd_mode) {
2556 if (b > 0)
return pow(static_cast<unsigned long int> (a), static_cast<unsigned long int> (b), rnd_mode);
2557 else return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2559 return pow(mpreal(a), static_cast<long int> (b), rnd_mode);
2563 inline const mpreal pow(
const long int a,
const long double b, mp_rnd_t rnd_mode) {
2564 if (a >= 0)
return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2565 else return pow(mpreal(a), mpreal(b), rnd_mode);
2568 inline const mpreal pow(
const long int a,
const double b, mp_rnd_t rnd_mode) {
2569 if (a >= 0)
return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2570 else return pow(mpreal(a), mpreal(b), rnd_mode);
2575 inline const mpreal pow(
const int a,
const unsigned long int b, mp_rnd_t rnd_mode) {
2576 if (a > 0)
return pow(static_cast<unsigned long int> (a), b, rnd_mode);
2577 else return pow(mpreal(a), b, rnd_mode);
2580 inline const mpreal pow(
const int a,
const unsigned int b, mp_rnd_t rnd_mode) {
2581 if (a > 0)
return pow(static_cast<unsigned long int> (a), static_cast<unsigned long int> (b), rnd_mode);
2582 else return pow(mpreal(a), static_cast<unsigned long int> (b), rnd_mode);
2585 inline const mpreal pow(
const int a,
const long int b, mp_rnd_t rnd_mode) {
2587 if (b > 0)
return pow(static_cast<unsigned long int> (a), static_cast<unsigned long int> (b), rnd_mode);
2588 else return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2590 return pow(mpreal(a), b, rnd_mode);
2594 inline const mpreal pow(
const int a,
const int b, mp_rnd_t rnd_mode) {
2596 if (b > 0)
return pow(static_cast<unsigned long int> (a), static_cast<unsigned long int> (b), rnd_mode);
2597 else return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2599 return pow(mpreal(a), static_cast<long int> (b), rnd_mode);
2603 inline const mpreal pow(
const int a,
const long double b, mp_rnd_t rnd_mode) {
2604 if (a >= 0)
return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2605 else return pow(mpreal(a), mpreal(b), rnd_mode);
2608 inline const mpreal pow(
const int a,
const double b, mp_rnd_t rnd_mode) {
2609 if (a >= 0)
return pow(static_cast<unsigned long int> (a), mpreal(b), rnd_mode);
2610 else return pow(mpreal(a), mpreal(b), rnd_mode);
2615 inline const mpreal pow(
const long double a,
const long double b, mp_rnd_t rnd_mode) {
2616 return pow(mpreal(a), mpreal(b), rnd_mode);
2619 inline const mpreal pow(
const long double a,
const unsigned long int b, mp_rnd_t rnd_mode) {
2620 return pow(mpreal(a), b, rnd_mode);
2623 inline const mpreal pow(
const long double a,
const unsigned int b, mp_rnd_t rnd_mode) {
2624 return pow(mpreal(a), static_cast<unsigned long int> (b), rnd_mode);
2627 inline const mpreal pow(
const long double a,
const long int b, mp_rnd_t rnd_mode) {
2628 return pow(mpreal(a), b, rnd_mode);
2631 inline const mpreal pow(
const long double a,
const int b, mp_rnd_t rnd_mode) {
2632 return pow(mpreal(a), static_cast<long int> (b), rnd_mode);
2635 inline const mpreal pow(
const double a,
const double b, mp_rnd_t rnd_mode) {
2636 return pow(mpreal(a), mpreal(b), rnd_mode);
2639 inline const mpreal pow(
const double a,
const unsigned long int b, mp_rnd_t rnd_mode) {
2640 return pow(mpreal(a), b, rnd_mode);
2643 inline const mpreal pow(
const double a,
const unsigned int b, mp_rnd_t rnd_mode) {
2644 return pow(mpreal(a), static_cast<unsigned long int> (b), rnd_mode);
2647 inline const mpreal pow(
const double a,
const long int b, mp_rnd_t rnd_mode) {
2648 return pow(mpreal(a), b, rnd_mode);
2651 inline const mpreal pow(
const double a,
const int b, mp_rnd_t rnd_mode) {
2652 return pow(mpreal(a), static_cast<long int> (b), rnd_mode);
2663 return mpfr::swap(x, y);