1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright 2011 John Maddock. Distributed under the Boost
3 // Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_MATH_BN_MPFR_HPP
7 #define BOOST_MATH_BN_MPFR_HPP
9 #include <boost/multiprecision/number.hpp>
10 #include <boost/multiprecision/debug_adaptor.hpp>
11 #include <boost/multiprecision/gmp.hpp>
12 #include <boost/math/special_functions/fpclassify.hpp>
13 #include <boost/cstdint.hpp>
14 #include <boost/multiprecision/detail/big_lanczos.hpp>
15 #include <boost/multiprecision/detail/digits.hpp>
20 #ifndef BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION
21 # define BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION 20
25 namespace multiprecision{
27 enum mpfr_allocation_type
35 template <unsigned digits10, mpfr_allocation_type AllocationType = allocate_dynamic>
36 struct mpfr_float_backend;
39 struct mpfr_float_backend<0, allocate_stack>;
41 } // namespace backends
43 template <unsigned digits10, mpfr_allocation_type AllocationType>
44 struct number_category<backends::mpfr_float_backend<digits10, AllocationType> > : public mpl::int_<number_kind_floating_point>{};
56 ~initializer(){ mpfr_free_cache(); }
57 void force_instantiate()const {}
59 static const initializer init;
60 static void force_instantiate() { init.force_instantiate(); }
64 typename mpfr_cleanup<b>::initializer const mpfr_cleanup<b>::init;
67 template <unsigned digits10, mpfr_allocation_type AllocationType>
68 struct mpfr_float_imp;
70 template <unsigned digits10>
71 struct mpfr_float_imp<digits10, allocate_dynamic>
73 #ifdef BOOST_HAS_LONG_LONG
74 typedef mpl::list<long, boost::long_long_type> signed_types;
75 typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types;
77 typedef mpl::list<long> signed_types;
78 typedef mpl::list<unsigned long> unsigned_types;
80 typedef mpl::list<double, long double> float_types;
81 typedef long exponent_type;
85 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
86 mpfr_set_ui(m_data, 0u, GMP_RNDN);
88 mpfr_float_imp(unsigned prec)
90 mpfr_init2(m_data, prec);
91 mpfr_set_ui(m_data, 0u, GMP_RNDN);
94 mpfr_float_imp(const mpfr_float_imp& o)
96 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
97 if(o.m_data[0]._mpfr_d)
98 mpfr_set(m_data, o.m_data, GMP_RNDN);
100 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
101 mpfr_float_imp(mpfr_float_imp&& o) BOOST_NOEXCEPT
103 m_data[0] = o.m_data[0];
104 o.m_data[0]._mpfr_d = 0;
107 mpfr_float_imp& operator = (const mpfr_float_imp& o)
109 if(m_data[0]._mpfr_d == 0)
110 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
111 if(o.m_data[0]._mpfr_d)
112 mpfr_set(m_data, o.m_data, GMP_RNDN);
115 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
116 mpfr_float_imp& operator = (mpfr_float_imp&& o) BOOST_NOEXCEPT
118 mpfr_swap(m_data, o.m_data);
122 #ifdef BOOST_HAS_LONG_LONG
123 #ifdef _MPFR_H_HAVE_INTMAX_T
124 mpfr_float_imp& operator = (boost::ulong_long_type i)
126 if(m_data[0]._mpfr_d == 0)
127 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
128 mpfr_set_uj(m_data, i, GMP_RNDN);
131 mpfr_float_imp& operator = (boost::long_long_type i)
133 if(m_data[0]._mpfr_d == 0)
134 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
135 mpfr_set_sj(m_data, i, GMP_RNDN);
139 mpfr_float_imp& operator = (boost::ulong_long_type i)
141 if(m_data[0]._mpfr_d == 0)
142 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
143 boost::ulong_long_type mask = ((((1uLL << (std::numeric_limits<unsigned long>::digits - 1)) - 1) << 1) | 1uLL);
146 mpfr_init2(t, (std::max)(static_cast<unsigned long>(std::numeric_limits<boost::ulong_long_type>::digits), static_cast<unsigned long>(multiprecision::detail::digits10_2_2(digits10))));
147 mpfr_set_ui(m_data, 0, GMP_RNDN);
150 mpfr_set_ui(t, static_cast<unsigned long>(i & mask), GMP_RNDN);
152 mpfr_mul_2exp(t, t, shift, GMP_RNDN);
153 mpfr_add(m_data, m_data, t, GMP_RNDN);
154 shift += std::numeric_limits<unsigned long>::digits;
155 i >>= std::numeric_limits<unsigned long>::digits;
160 mpfr_float_imp& operator = (boost::long_long_type i)
162 if(m_data[0]._mpfr_d == 0)
163 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
165 *this = boost::multiprecision::detail::unsigned_abs(i);
167 mpfr_neg(m_data, m_data, GMP_RNDN);
172 mpfr_float_imp& operator = (unsigned long i)
174 if(m_data[0]._mpfr_d == 0)
175 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
176 mpfr_set_ui(m_data, i, GMP_RNDN);
179 mpfr_float_imp& operator = (long i)
181 if(m_data[0]._mpfr_d == 0)
182 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
183 mpfr_set_si(m_data, i, GMP_RNDN);
186 mpfr_float_imp& operator = (double d)
188 if(m_data[0]._mpfr_d == 0)
189 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
190 mpfr_set_d(m_data, d, GMP_RNDN);
193 mpfr_float_imp& operator = (long double a)
195 if(m_data[0]._mpfr_d == 0)
196 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
197 mpfr_set_ld(m_data, a, GMP_RNDN);
200 mpfr_float_imp& operator = (const char* s)
202 if(m_data[0]._mpfr_d == 0)
203 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
204 if(mpfr_set_str(m_data, s, 10, GMP_RNDN) != 0)
206 BOOST_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse string \"") + s + std::string("\"as a valid floating point number.")));
210 void swap(mpfr_float_imp& o) BOOST_NOEXCEPT
212 mpfr_swap(m_data, o.m_data);
214 std::string str(std::streamsize digits, std::ios_base::fmtflags f)const
216 BOOST_ASSERT(m_data[0]._mpfr_d);
218 bool scientific = (f & std::ios_base::scientific) == std::ios_base::scientific;
219 bool fixed = (f & std::ios_base::fixed) == std::ios_base::fixed;
221 std::streamsize org_digits(digits);
223 if(scientific && digits)
228 if(mpfr_inf_p(m_data))
230 if(mpfr_sgn(m_data) < 0)
232 else if(f & std::ios_base::showpos)
238 if(mpfr_nan_p(m_data))
243 if(mpfr_zero_p(m_data))
250 char* ps = mpfr_get_str (0, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
251 --e; // To match with what our formatter expects.
254 // Oops we actually need a different number of digits to what we asked for:
259 // We need to get *all* the digits and then possibly round up,
260 // we end up with either "0" or "1" as the result.
261 ps = mpfr_get_str (0, &e, 10, 0, m_data, GMP_RNDN);
263 unsigned offset = *ps == '-' ? 1 : 0;
270 else if(ps[offset] == '5')
272 unsigned i = offset + 1;
273 bool round_up = false;
302 ps = mpfr_get_str (0, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
303 --e; // To match with what our formatter expects.
307 ps = mpfr_get_str (0, &e, 10, 1, m_data, GMP_RNDN);
309 unsigned offset = *ps == '-' ? 1 : 0;
314 result = ps ? ps : "0";
318 boost::multiprecision::detail::format_float_string(result, e, org_digits, f, 0 != mpfr_zero_p(m_data));
321 ~mpfr_float_imp() BOOST_NOEXCEPT
323 if(m_data[0]._mpfr_d)
325 detail::mpfr_cleanup<true>::force_instantiate();
327 void negate() BOOST_NOEXCEPT
329 BOOST_ASSERT(m_data[0]._mpfr_d);
330 mpfr_neg(m_data, m_data, GMP_RNDN);
332 template <mpfr_allocation_type AllocationType>
333 int compare(const mpfr_float_backend<digits10, AllocationType>& o)const BOOST_NOEXCEPT
335 BOOST_ASSERT(m_data[0]._mpfr_d && o.m_data[0]._mpfr_d);
336 return mpfr_cmp(m_data, o.m_data);
338 int compare(long i)const BOOST_NOEXCEPT
340 BOOST_ASSERT(m_data[0]._mpfr_d);
341 return mpfr_cmp_si(m_data, i);
343 int compare(unsigned long i)const BOOST_NOEXCEPT
345 BOOST_ASSERT(m_data[0]._mpfr_d);
346 return mpfr_cmp_ui(m_data, i);
349 int compare(V v)const BOOST_NOEXCEPT
351 mpfr_float_backend<digits10, allocate_dynamic> d;
355 mpfr_t& data() BOOST_NOEXCEPT
357 BOOST_ASSERT(m_data[0]._mpfr_d);
360 const mpfr_t& data()const BOOST_NOEXCEPT
362 BOOST_ASSERT(m_data[0]._mpfr_d);
367 static unsigned& get_default_precision() BOOST_NOEXCEPT
369 static unsigned val = BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION;
375 #pragma warning(push)
376 #pragma warning(disable:4127) // Conditional expression is constant
379 template <unsigned digits10>
380 struct mpfr_float_imp<digits10, allocate_stack>
382 #ifdef BOOST_HAS_LONG_LONG
383 typedef mpl::list<long, boost::long_long_type> signed_types;
384 typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types;
386 typedef mpl::list<long> signed_types;
387 typedef mpl::list<unsigned long> unsigned_types;
389 typedef mpl::list<double, long double> float_types;
390 typedef long exponent_type;
392 static const unsigned digits2 = (digits10 * 1000uL) / 301uL + ((digits10 * 1000uL) % 301 ? 2u : 1u);
393 static const unsigned limb_count = mpfr_custom_get_size(digits2) / sizeof(mp_limb_t);
395 ~mpfr_float_imp() BOOST_NOEXCEPT
397 detail::mpfr_cleanup<true>::force_instantiate();
401 mpfr_custom_init(m_buffer, digits2);
402 mpfr_custom_init_set(m_data, MPFR_NAN_KIND, 0, digits2, m_buffer);
403 mpfr_set_ui(m_data, 0u, GMP_RNDN);
406 mpfr_float_imp(const mpfr_float_imp& o)
408 mpfr_custom_init(m_buffer, digits2);
409 mpfr_custom_init_set(m_data, MPFR_NAN_KIND, 0, digits2, m_buffer);
410 mpfr_set(m_data, o.m_data, GMP_RNDN);
412 mpfr_float_imp& operator = (const mpfr_float_imp& o)
414 mpfr_set(m_data, o.m_data, GMP_RNDN);
417 #ifdef BOOST_HAS_LONG_LONG
418 #ifdef _MPFR_H_HAVE_INTMAX_T
419 mpfr_float_imp& operator = (boost::ulong_long_type i)
421 mpfr_set_uj(m_data, i, GMP_RNDN);
424 mpfr_float_imp& operator = (boost::long_long_type i)
426 mpfr_set_sj(m_data, i, GMP_RNDN);
430 mpfr_float_imp& operator = (boost::ulong_long_type i)
432 boost::ulong_long_type mask = ((((1uLL << (std::numeric_limits<unsigned long>::digits - 1)) - 1) << 1) | 1uL);
435 mp_limb_t t_limbs[limb_count];
436 mpfr_custom_init(t_limbs, digits2);
437 mpfr_custom_init_set(t, MPFR_NAN_KIND, 0, digits2, t_limbs);
438 mpfr_set_ui(m_data, 0, GMP_RNDN);
441 mpfr_set_ui(t, static_cast<unsigned long>(i & mask), GMP_RNDN);
443 mpfr_mul_2exp(t, t, shift, GMP_RNDN);
444 mpfr_add(m_data, m_data, t, GMP_RNDN);
445 shift += std::numeric_limits<unsigned long>::digits;
446 i >>= std::numeric_limits<unsigned long>::digits;
450 mpfr_float_imp& operator = (boost::long_long_type i)
453 *this = boost::multiprecision::detail::unsigned_abs(i);
455 mpfr_neg(m_data, m_data, GMP_RNDN);
460 mpfr_float_imp& operator = (unsigned long i)
462 mpfr_set_ui(m_data, i, GMP_RNDN);
465 mpfr_float_imp& operator = (long i)
467 mpfr_set_si(m_data, i, GMP_RNDN);
470 mpfr_float_imp& operator = (double d)
472 mpfr_set_d(m_data, d, GMP_RNDN);
475 mpfr_float_imp& operator = (long double a)
477 mpfr_set_ld(m_data, a, GMP_RNDN);
480 mpfr_float_imp& operator = (const char* s)
482 if(mpfr_set_str(m_data, s, 10, GMP_RNDN) != 0)
484 BOOST_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse string \"") + s + std::string("\"as a valid floating point number.")));
488 void swap(mpfr_float_imp& o) BOOST_NOEXCEPT
490 // We have to swap by copying:
491 mpfr_float_imp t(*this);
495 std::string str(std::streamsize digits, std::ios_base::fmtflags f)const
497 BOOST_ASSERT(m_data[0]._mpfr_d);
499 bool scientific = (f & std::ios_base::scientific) == std::ios_base::scientific;
500 bool fixed = (f & std::ios_base::fixed) == std::ios_base::fixed;
502 std::streamsize org_digits(digits);
504 if(scientific && digits)
509 if(mpfr_inf_p(m_data))
511 if(mpfr_sgn(m_data) < 0)
513 else if(f & std::ios_base::showpos)
519 if(mpfr_nan_p(m_data))
524 if(mpfr_zero_p(m_data))
531 char* ps = mpfr_get_str (0, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
532 --e; // To match with what our formatter expects.
535 // Oops we actually need a different number of digits to what we asked for:
540 // We need to get *all* the digits and then possibly round up,
541 // we end up with either "0" or "1" as the result.
542 ps = mpfr_get_str (0, &e, 10, 0, m_data, GMP_RNDN);
544 unsigned offset = *ps == '-' ? 1 : 0;
551 else if(ps[offset] == '5')
553 unsigned i = offset + 1;
554 bool round_up = false;
583 ps = mpfr_get_str (0, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
584 --e; // To match with what our formatter expects.
588 ps = mpfr_get_str (0, &e, 10, 1, m_data, GMP_RNDN);
590 unsigned offset = *ps == '-' ? 1 : 0;
595 result = ps ? ps : "0";
599 boost::multiprecision::detail::format_float_string(result, e, org_digits, f, 0 != mpfr_zero_p(m_data));
602 void negate() BOOST_NOEXCEPT
604 mpfr_neg(m_data, m_data, GMP_RNDN);
606 template <mpfr_allocation_type AllocationType>
607 int compare(const mpfr_float_backend<digits10, AllocationType>& o)const BOOST_NOEXCEPT
609 return mpfr_cmp(m_data, o.m_data);
611 int compare(long i)const BOOST_NOEXCEPT
613 return mpfr_cmp_si(m_data, i);
615 int compare(unsigned long i)const BOOST_NOEXCEPT
617 return mpfr_cmp_ui(m_data, i);
620 int compare(V v)const BOOST_NOEXCEPT
622 mpfr_float_backend<digits10, allocate_stack> d;
626 mpfr_t& data() BOOST_NOEXCEPT
630 const mpfr_t& data()const BOOST_NOEXCEPT
636 mp_limb_t m_buffer[limb_count];
643 } // namespace detail
645 template <unsigned digits10, mpfr_allocation_type AllocationType>
646 struct mpfr_float_backend : public detail::mpfr_float_imp<digits10, AllocationType>
648 mpfr_float_backend() : detail::mpfr_float_imp<digits10, AllocationType>() {}
649 mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<digits10, AllocationType>(o) {}
650 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
651 mpfr_float_backend(mpfr_float_backend&& o) BOOST_NOEXCEPT : detail::mpfr_float_imp<digits10, AllocationType>(static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o)) {}
653 template <unsigned D, mpfr_allocation_type AT>
654 mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename enable_if_c<D <= digits10>::type* = 0)
655 : detail::mpfr_float_imp<digits10, AllocationType>()
657 mpfr_set(this->m_data, val.data(), GMP_RNDN);
659 template <unsigned D, mpfr_allocation_type AT>
660 explicit mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename disable_if_c<D <= digits10>::type* = 0)
661 : detail::mpfr_float_imp<digits10, AllocationType>()
663 mpfr_set(this->m_data, val.data(), GMP_RNDN);
665 template <unsigned D>
666 mpfr_float_backend(const gmp_float<D>& val, typename enable_if_c<D <= digits10>::type* = 0)
667 : detail::mpfr_float_imp<digits10, AllocationType>()
669 mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
671 template <unsigned D>
672 mpfr_float_backend(const gmp_float<D>& val, typename disable_if_c<D <= digits10>::type* = 0)
673 : detail::mpfr_float_imp<digits10, AllocationType>()
675 mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
677 mpfr_float_backend(const gmp_int& val)
678 : detail::mpfr_float_imp<digits10, AllocationType>()
680 mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
682 mpfr_float_backend(const gmp_rational& val)
683 : detail::mpfr_float_imp<digits10, AllocationType>()
685 mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
687 mpfr_float_backend(const mpfr_t val)
688 : detail::mpfr_float_imp<digits10, AllocationType>()
690 mpfr_set(this->m_data, val, GMP_RNDN);
692 mpfr_float_backend(const mpf_t val)
693 : detail::mpfr_float_imp<digits10, AllocationType>()
695 mpfr_set_f(this->m_data, val, GMP_RNDN);
697 mpfr_float_backend(const mpz_t val)
698 : detail::mpfr_float_imp<digits10, AllocationType>()
700 mpfr_set_z(this->m_data, val, GMP_RNDN);
702 mpfr_float_backend(const mpq_t val)
703 : detail::mpfr_float_imp<digits10, AllocationType>()
705 mpfr_set_q(this->m_data, val, GMP_RNDN);
707 mpfr_float_backend& operator=(const mpfr_float_backend& o)
709 *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = static_cast<detail::mpfr_float_imp<digits10, AllocationType> const&>(o);
712 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
713 mpfr_float_backend& operator=(mpfr_float_backend&& o) BOOST_NOEXCEPT
715 *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o);
720 mpfr_float_backend& operator=(const V& v)
722 *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = v;
725 mpfr_float_backend& operator=(const mpfr_t val)
727 if(this->m_data[0]._mpfr_d == 0)
728 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
729 mpfr_set(this->m_data, val, GMP_RNDN);
732 mpfr_float_backend& operator=(const mpf_t val)
734 if(this->m_data[0]._mpfr_d == 0)
735 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
736 mpfr_set_f(this->m_data, val, GMP_RNDN);
739 mpfr_float_backend& operator=(const mpz_t val)
741 if(this->m_data[0]._mpfr_d == 0)
742 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
743 mpfr_set_z(this->m_data, val, GMP_RNDN);
746 mpfr_float_backend& operator=(const mpq_t val)
748 if(this->m_data[0]._mpfr_d == 0)
749 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
750 mpfr_set_q(this->m_data, val, GMP_RNDN);
753 // We don't change our precision here, this is a fixed precision type:
754 template <unsigned D, mpfr_allocation_type AT>
755 mpfr_float_backend& operator=(const mpfr_float_backend<D, AT>& val)
757 if(this->m_data[0]._mpfr_d == 0)
758 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
759 mpfr_set(this->m_data, val.data(), GMP_RNDN);
762 template <unsigned D>
763 mpfr_float_backend& operator=(const gmp_float<D>& val)
765 if(this->m_data[0]._mpfr_d == 0)
766 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
767 mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
770 mpfr_float_backend& operator=(const gmp_int& val)
772 if(this->m_data[0]._mpfr_d == 0)
773 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
774 mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
777 mpfr_float_backend& operator=(const gmp_rational& val)
779 if(this->m_data[0]._mpfr_d == 0)
780 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
781 mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
787 struct mpfr_float_backend<0, allocate_dynamic> : public detail::mpfr_float_imp<0, allocate_dynamic>
789 mpfr_float_backend() : detail::mpfr_float_imp<0, allocate_dynamic>() {}
790 mpfr_float_backend(const mpfr_t val)
791 : detail::mpfr_float_imp<0, allocate_dynamic>(mpfr_get_prec(val))
793 mpfr_set(this->m_data, val, GMP_RNDN);
795 mpfr_float_backend(const mpf_t val)
796 : detail::mpfr_float_imp<0, allocate_dynamic>(mpf_get_prec(val))
798 mpfr_set_f(this->m_data, val, GMP_RNDN);
800 mpfr_float_backend(const mpz_t val)
801 : detail::mpfr_float_imp<0, allocate_dynamic>()
803 mpfr_set_z(this->m_data, val, GMP_RNDN);
805 mpfr_float_backend(const mpq_t val)
806 : detail::mpfr_float_imp<0, allocate_dynamic>()
808 mpfr_set_q(this->m_data, val, GMP_RNDN);
810 mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<0, allocate_dynamic>(o) {}
811 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
812 mpfr_float_backend(mpfr_float_backend&& o) BOOST_NOEXCEPT : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast<detail::mpfr_float_imp<0, allocate_dynamic>&&>(o)) {}
814 mpfr_float_backend(const mpfr_float_backend& o, unsigned digits10)
815 : detail::mpfr_float_imp<0, allocate_dynamic>(digits10)
819 template <unsigned D>
820 mpfr_float_backend(const mpfr_float_backend<D>& val)
821 : detail::mpfr_float_imp<0, allocate_dynamic>(mpfr_get_prec(val.data()))
823 mpfr_set(this->m_data, val.data(), GMP_RNDN);
825 template <unsigned D>
826 mpfr_float_backend(const gmp_float<D>& val)
827 : detail::mpfr_float_imp<0, allocate_dynamic>(mpf_get_prec(val.data()))
829 mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
831 mpfr_float_backend(const gmp_int& val)
832 : detail::mpfr_float_imp<0, allocate_dynamic>()
834 mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
836 mpfr_float_backend(const gmp_rational& val)
837 : detail::mpfr_float_imp<0, allocate_dynamic>()
839 mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
842 mpfr_float_backend& operator=(const mpfr_float_backend& o)
846 if(this->m_data[0]._mpfr_d == 0)
847 mpfr_init2(this->m_data, mpfr_get_prec(o.data()));
849 mpfr_set_prec(this->m_data, mpfr_get_prec(o.data()));
850 mpfr_set(this->m_data, o.data(), GMP_RNDN);
854 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
855 mpfr_float_backend& operator=(mpfr_float_backend&& o) BOOST_NOEXCEPT
857 *static_cast<detail::mpfr_float_imp<0, allocate_dynamic>*>(this) = static_cast<detail::mpfr_float_imp<0, allocate_dynamic> &&>(o);
862 mpfr_float_backend& operator=(const V& v)
864 *static_cast<detail::mpfr_float_imp<0, allocate_dynamic>*>(this) = v;
867 mpfr_float_backend& operator=(const mpfr_t val)
869 if(this->m_data[0]._mpfr_d == 0)
870 mpfr_init2(this->m_data, mpfr_get_prec(val));
872 mpfr_set_prec(this->m_data, mpfr_get_prec(val));
873 mpfr_set(this->m_data, val, GMP_RNDN);
876 mpfr_float_backend& operator=(const mpf_t val)
878 if(this->m_data[0]._mpfr_d == 0)
879 mpfr_init2(this->m_data, mpf_get_prec(val));
881 mpfr_set_prec(this->m_data, mpf_get_prec(val));
882 mpfr_set_f(this->m_data, val, GMP_RNDN);
885 mpfr_float_backend& operator=(const mpz_t val)
887 if(this->m_data[0]._mpfr_d == 0)
888 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
889 mpfr_set_z(this->m_data, val, GMP_RNDN);
892 mpfr_float_backend& operator=(const mpq_t val)
894 if(this->m_data[0]._mpfr_d == 0)
895 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
896 mpfr_set_q(this->m_data, val, GMP_RNDN);
899 template <unsigned D>
900 mpfr_float_backend& operator=(const mpfr_float_backend<D>& val)
902 if(this->m_data[0]._mpfr_d == 0)
903 mpfr_init2(this->m_data, mpfr_get_prec(val.data()));
905 mpfr_set_prec(this->m_data, mpfr_get_prec(val.data()));
906 mpfr_set(this->m_data, val.data(), GMP_RNDN);
909 template <unsigned D>
910 mpfr_float_backend& operator=(const gmp_float<D>& val)
912 if(this->m_data[0]._mpfr_d == 0)
913 mpfr_init2(this->m_data, mpf_get_prec(val.data()));
915 mpfr_set_prec(this->m_data, mpf_get_prec(val.data()));
916 mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
919 mpfr_float_backend& operator=(const gmp_int& val)
921 if(this->m_data[0]._mpfr_d == 0)
922 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
923 mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
926 mpfr_float_backend& operator=(const gmp_rational& val)
928 if(this->m_data[0]._mpfr_d == 0)
929 mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
930 mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
933 static unsigned default_precision() BOOST_NOEXCEPT
935 return get_default_precision();
937 static void default_precision(unsigned v) BOOST_NOEXCEPT
939 get_default_precision() = v;
941 unsigned precision()const BOOST_NOEXCEPT
943 return multiprecision::detail::digits2_2_10(mpfr_get_prec(this->m_data));
945 void precision(unsigned digits10) BOOST_NOEXCEPT
947 mpfr_prec_round(this->m_data, multiprecision::detail::digits10_2_2((digits10)), GMP_RNDN);
951 template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
952 inline typename enable_if<is_arithmetic<T>, bool>::type eval_eq(const mpfr_float_backend<digits10, AllocationType>& a, const T& b) BOOST_NOEXCEPT
954 return a.compare(b) == 0;
956 template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
957 inline typename enable_if<is_arithmetic<T>, bool>::type eval_lt(const mpfr_float_backend<digits10, AllocationType>& a, const T& b) BOOST_NOEXCEPT
959 return a.compare(b) < 0;
961 template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
962 inline typename enable_if<is_arithmetic<T>, bool>::type eval_gt(const mpfr_float_backend<digits10, AllocationType>& a, const T& b) BOOST_NOEXCEPT
964 return a.compare(b) > 0;
967 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
968 inline void eval_add(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
970 mpfr_add(result.data(), result.data(), o.data(), GMP_RNDN);
972 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
973 inline void eval_subtract(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
975 mpfr_sub(result.data(), result.data(), o.data(), GMP_RNDN);
977 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
978 inline void eval_multiply(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
980 if((void*)&o == (void*)&result)
981 mpfr_sqr(result.data(), o.data(), GMP_RNDN);
983 mpfr_mul(result.data(), result.data(), o.data(), GMP_RNDN);
985 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
986 inline void eval_divide(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
988 mpfr_div(result.data(), result.data(), o.data(), GMP_RNDN);
990 template <unsigned digits10, mpfr_allocation_type AllocationType>
991 inline void eval_add(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
993 mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
995 template <unsigned digits10, mpfr_allocation_type AllocationType>
996 inline void eval_subtract(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
998 mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
1000 template <unsigned digits10, mpfr_allocation_type AllocationType>
1001 inline void eval_multiply(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
1003 mpfr_mul_ui(result.data(), result.data(), i, GMP_RNDN);
1005 template <unsigned digits10, mpfr_allocation_type AllocationType>
1006 inline void eval_divide(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
1008 mpfr_div_ui(result.data(), result.data(), i, GMP_RNDN);
1010 template <unsigned digits10, mpfr_allocation_type AllocationType>
1011 inline void eval_add(mpfr_float_backend<digits10, AllocationType>& result, long i)
1014 mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
1016 mpfr_sub_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
1018 template <unsigned digits10, mpfr_allocation_type AllocationType>
1019 inline void eval_subtract(mpfr_float_backend<digits10, AllocationType>& result, long i)
1022 mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
1024 mpfr_add_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
1026 template <unsigned digits10, mpfr_allocation_type AllocationType>
1027 inline void eval_multiply(mpfr_float_backend<digits10, AllocationType>& result, long i)
1029 mpfr_mul_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
1031 mpfr_neg(result.data(), result.data(), GMP_RNDN);
1033 template <unsigned digits10, mpfr_allocation_type AllocationType>
1034 inline void eval_divide(mpfr_float_backend<digits10, AllocationType>& result, long i)
1036 mpfr_div_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
1038 mpfr_neg(result.data(), result.data(), GMP_RNDN);
1041 // Specialised 3 arg versions of the basic operators:
1043 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
1044 inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
1046 mpfr_add(a.data(), x.data(), y.data(), GMP_RNDN);
1048 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1049 inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
1051 mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
1053 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1054 inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
1057 mpfr_sub_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
1059 mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
1061 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1062 inline void eval_add(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
1064 mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
1066 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1067 inline void eval_add(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
1071 mpfr_ui_sub(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data(), GMP_RNDN);
1072 mpfr_neg(a.data(), a.data(), GMP_RNDN);
1075 mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
1077 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
1078 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
1080 mpfr_sub(a.data(), x.data(), y.data(), GMP_RNDN);
1082 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1083 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
1085 mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
1087 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1088 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
1091 mpfr_add_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
1093 mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
1095 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1096 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
1098 mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
1100 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1101 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
1105 mpfr_add_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x), GMP_RNDN);
1106 mpfr_neg(a.data(), a.data(), GMP_RNDN);
1109 mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
1112 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
1113 inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
1115 if((void*)&x == (void*)&y)
1116 mpfr_sqr(a.data(), x.data(), GMP_RNDN);
1118 mpfr_mul(a.data(), x.data(), y.data(), GMP_RNDN);
1120 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1121 inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
1123 mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
1125 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1126 inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
1130 mpfr_mul_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
1134 mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
1136 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1137 inline void eval_multiply(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
1139 mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
1141 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1142 inline void eval_multiply(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
1146 mpfr_mul_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x), GMP_RNDN);
1147 mpfr_neg(a.data(), a.data(), GMP_RNDN);
1150 mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
1153 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
1154 inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
1156 mpfr_div(a.data(), x.data(), y.data(), GMP_RNDN);
1158 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1159 inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
1161 mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
1163 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1164 inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
1168 mpfr_div_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
1172 mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
1174 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1175 inline void eval_divide(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
1177 mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
1179 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1180 inline void eval_divide(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
1184 mpfr_ui_div(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data(), GMP_RNDN);
1185 mpfr_neg(a.data(), a.data(), GMP_RNDN);
1188 mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
1191 template <unsigned digits10, mpfr_allocation_type AllocationType>
1192 inline bool eval_is_zero(const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
1194 return 0 != mpfr_zero_p(val.data());
1196 template <unsigned digits10, mpfr_allocation_type AllocationType>
1197 inline int eval_get_sign(const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
1199 return mpfr_sgn(val.data());
1202 template <unsigned digits10, mpfr_allocation_type AllocationType>
1203 inline void eval_convert_to(unsigned long* result, const mpfr_float_backend<digits10, AllocationType>& val)
1205 if(mpfr_nan_p(val.data()))
1207 BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1209 *result = mpfr_get_ui(val.data(), GMP_RNDZ);
1211 template <unsigned digits10, mpfr_allocation_type AllocationType>
1212 inline void eval_convert_to(long* result, const mpfr_float_backend<digits10, AllocationType>& val)
1214 if(mpfr_nan_p(val.data()))
1216 BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1218 *result = mpfr_get_si(val.data(), GMP_RNDZ);
1220 #ifdef _MPFR_H_HAVE_INTMAX_T
1221 template <unsigned digits10, mpfr_allocation_type AllocationType>
1222 inline void eval_convert_to(boost::ulong_long_type* result, const mpfr_float_backend<digits10, AllocationType>& val)
1224 if(mpfr_nan_p(val.data()))
1226 BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1228 *result = mpfr_get_uj(val.data(), GMP_RNDZ);
1230 template <unsigned digits10, mpfr_allocation_type AllocationType>
1231 inline void eval_convert_to(boost::long_long_type* result, const mpfr_float_backend<digits10, AllocationType>& val)
1233 if(mpfr_nan_p(val.data()))
1235 BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1237 *result = mpfr_get_sj(val.data(), GMP_RNDZ);
1240 template <unsigned digits10, mpfr_allocation_type AllocationType>
1241 inline void eval_convert_to(float* result, const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
1243 *result = mpfr_get_flt(val.data(), GMP_RNDN);
1245 template <unsigned digits10, mpfr_allocation_type AllocationType>
1246 inline void eval_convert_to(double* result, const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
1248 *result = mpfr_get_d(val.data(), GMP_RNDN);
1250 template <unsigned digits10, mpfr_allocation_type AllocationType>
1251 inline void eval_convert_to(long double* result, const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
1253 *result = mpfr_get_ld(val.data(), GMP_RNDN);
1257 // Native non-member operations:
1259 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1260 inline void eval_sqrt(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1262 mpfr_sqrt(result.data(), val.data(), GMP_RNDN);
1265 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1266 inline void eval_abs(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1268 mpfr_abs(result.data(), val.data(), GMP_RNDN);
1271 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1272 inline void eval_fabs(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1274 mpfr_abs(result.data(), val.data(), GMP_RNDN);
1276 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1277 inline void eval_ceil(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1279 mpfr_ceil(result.data(), val.data());
1281 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1282 inline void eval_floor(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1284 mpfr_floor(result.data(), val.data());
1286 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1287 inline void eval_trunc(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1289 mpfr_trunc(result.data(), val.data());
1291 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1292 inline void eval_ldexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, long e)
1295 mpfr_mul_2exp(result.data(), val.data(), e, GMP_RNDN);
1297 mpfr_div_2exp(result.data(), val.data(), -e, GMP_RNDN);
1301 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1302 inline void eval_frexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, int* e)
1305 mpfr_get_d_2exp(&v, val.data(), GMP_RNDN);
1307 eval_ldexp(result, val, -v);
1309 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1310 inline void eval_frexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, long* e)
1312 mpfr_get_d_2exp(e, val.data(), GMP_RNDN);
1313 return eval_ldexp(result, val, -*e);
1316 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1317 inline int eval_fpclassify(const mpfr_float_backend<Digits10, AllocateType>& val) BOOST_NOEXCEPT
1319 return mpfr_inf_p(val.data()) ? FP_INFINITE : mpfr_nan_p(val.data()) ? FP_NAN : mpfr_zero_p(val.data()) ? FP_ZERO : FP_NORMAL;
1322 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1323 inline void eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& e)
1325 if(mpfr_zero_p(b.data()) && mpfr_integer_p(e.data()) && (mpfr_signbit(e.data()) == 0) && mpfr_fits_ulong_p(e.data(), GMP_RNDN) && (mpfr_get_ui(e.data(), GMP_RNDN) & 1))
1327 mpfr_set(result.data(), b.data(), GMP_RNDN);
1330 mpfr_pow(result.data(), b.data(), e.data(), GMP_RNDN);
1335 // The enable_if usage below doesn't work with msvc - but only when
1336 // certain other enable_if usages are defined first. It's a capricious
1337 // and rather annoying compiler bug in other words....
1339 # define BOOST_MP_ENABLE_IF_WORKAROUND (Digits10 || !Digits10) &&
1341 #define BOOST_MP_ENABLE_IF_WORKAROUND
1344 template <unsigned Digits10, mpfr_allocation_type AllocateType, class Integer>
1345 inline typename enable_if<mpl::and_<is_signed<Integer>, mpl::bool_<BOOST_MP_ENABLE_IF_WORKAROUND (sizeof(Integer) <= sizeof(long))> > >::type
1346 eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const Integer& e)
1348 mpfr_pow_si(result.data(), b.data(), e, GMP_RNDN);
1351 template <unsigned Digits10, mpfr_allocation_type AllocateType, class Integer>
1352 inline typename enable_if<mpl::and_<is_unsigned<Integer>, mpl::bool_<BOOST_MP_ENABLE_IF_WORKAROUND (sizeof(Integer) <= sizeof(long))> > >::type
1353 eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const Integer& e)
1355 mpfr_pow_ui(result.data(), b.data(), e, GMP_RNDN);
1358 #undef BOOST_MP_ENABLE_IF_WORKAROUND
1360 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1361 inline void eval_exp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1363 mpfr_exp(result.data(), arg.data(), GMP_RNDN);
1366 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1367 inline void eval_exp2(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1369 mpfr_exp2(result.data(), arg.data(), GMP_RNDN);
1372 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1373 inline void eval_log(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1375 mpfr_log(result.data(), arg.data(), GMP_RNDN);
1378 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1379 inline void eval_log10(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1381 mpfr_log10(result.data(), arg.data(), GMP_RNDN);
1384 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1385 inline void eval_sin(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1387 mpfr_sin(result.data(), arg.data(), GMP_RNDN);
1390 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1391 inline void eval_cos(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1393 mpfr_cos(result.data(), arg.data(), GMP_RNDN);
1396 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1397 inline void eval_tan(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1399 mpfr_tan(result.data(), arg.data(), GMP_RNDN);
1402 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1403 inline void eval_asin(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1405 mpfr_asin(result.data(), arg.data(), GMP_RNDN);
1408 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1409 inline void eval_acos(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1411 mpfr_acos(result.data(), arg.data(), GMP_RNDN);
1414 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1415 inline void eval_atan(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1417 mpfr_atan(result.data(), arg.data(), GMP_RNDN);
1420 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1421 inline void eval_atan2(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg1, const mpfr_float_backend<Digits10, AllocateType>& arg2)
1423 mpfr_atan2(result.data(), arg1.data(), arg2.data(), GMP_RNDN);
1426 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1427 inline void eval_sinh(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1429 mpfr_sinh(result.data(), arg.data(), GMP_RNDN);
1432 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1433 inline void eval_cosh(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1435 mpfr_cosh(result.data(), arg.data(), GMP_RNDN);
1438 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1439 inline void eval_tanh(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1441 mpfr_tanh(result.data(), arg.data(), GMP_RNDN);
1444 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1445 inline void eval_log2(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1447 mpfr_log2(result.data(), arg.data(), GMP_RNDN);
1450 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1451 inline void eval_modf(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg, mpfr_float_backend<Digits10, AllocateType>* pipart)
1455 mpfr_float_backend<Digits10, AllocateType> ipart;
1456 mpfr_modf(ipart.data(), result.data(), arg.data(), GMP_RNDN);
1460 mpfr_modf(pipart->data(), result.data(), arg.data(), GMP_RNDN);
1463 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1464 inline void eval_remainder(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
1466 mpfr_remainder(result.data(), a.data(), b.data(), GMP_RNDN);
1468 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1469 inline void eval_remquo(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b, int* pi)
1472 mpfr_remquo(result.data(), &l, a.data(), b.data(), GMP_RNDN);
1476 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1477 inline void eval_fmod(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
1479 mpfr_fmod(result.data(), a.data(), b.data(), GMP_RNDN);
1482 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1483 inline void eval_multiply_add(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
1485 mpfr_fma(result.data(), a.data(), b.data(), result.data(), GMP_RNDN);
1488 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1489 inline void eval_multiply_add(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& c)
1491 mpfr_fma(result.data(), a.data(), b.data(), c.data(), GMP_RNDN);
1494 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1495 inline void eval_multiply_subtract(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
1497 mpfr_fms(result.data(), a.data(), b.data(), result.data(), GMP_RNDN);
1501 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1502 inline void eval_multiply_subtract(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& c)
1504 mpfr_fms(result.data(), a.data(), b.data(), c.data(), GMP_RNDN);
1507 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1508 inline int eval_signbit BOOST_PREVENT_MACRO_SUBSTITUTION(const mpfr_float_backend<Digits10, AllocateType>& arg)
1510 return (arg.data()[0]._mpfr_sign < 0) ? 1 : 0;
1513 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1514 inline std::size_t hash_value(const mpfr_float_backend<Digits10, AllocateType>& val)
1516 std::size_t result = 0;
1517 std::size_t len = val.data()[0]._mpfr_prec / mp_bits_per_limb;
1518 if(val.data()[0]._mpfr_prec % mp_bits_per_limb)
1520 for(std::size_t i = 0; i < len; ++i)
1521 boost::hash_combine(result, val.data()[0]._mpfr_d[i]);
1522 boost::hash_combine(result, val.data()[0]._mpfr_exp);
1523 boost::hash_combine(result, val.data()[0]._mpfr_sign);
1527 } // namespace backends
1529 #ifdef BOOST_NO_SFINAE_EXPR
1533 template<unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1534 struct is_explicitly_convertible<backends::mpfr_float_backend<D1, A1>, backends::mpfr_float_backend<D2, A2> > : public mpl::true_ {};
1541 struct number_category<detail::canonical<mpfr_t, backends::mpfr_float_backend<0> >::type> : public mpl::int_<number_kind_floating_point>{};
1543 using boost::multiprecision::backends::mpfr_float_backend;
1545 typedef number<mpfr_float_backend<50> > mpfr_float_50;
1546 typedef number<mpfr_float_backend<100> > mpfr_float_100;
1547 typedef number<mpfr_float_backend<500> > mpfr_float_500;
1548 typedef number<mpfr_float_backend<1000> > mpfr_float_1000;
1549 typedef number<mpfr_float_backend<0> > mpfr_float;
1551 typedef number<mpfr_float_backend<50, allocate_stack> > static_mpfr_float_50;
1552 typedef number<mpfr_float_backend<100, allocate_stack> > static_mpfr_float_100;
1554 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1555 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> copysign BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& a, const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& b)
1557 return (boost::multiprecision::signbit)(a) != (boost::multiprecision::signbit)(b) ? boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(-a) : a;
1560 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1561 inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> copysign BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& a, const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& b)
1563 return (boost::multiprecision::signbit)(a) != (boost::multiprecision::signbit)(b) ? boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>(-a) : a;
1566 } // namespace multiprecision
1570 using boost::multiprecision::signbit;
1571 using boost::multiprecision::copysign;
1576 inline int digits<boost::multiprecision::mpfr_float>()
1577 #ifdef BOOST_MATH_NOEXCEPT
1581 return multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::default_precision());
1584 inline int digits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
1585 #ifdef BOOST_MATH_NOEXCEPT
1589 return multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::default_precision());
1593 inline boost::multiprecision::mpfr_float
1594 max_value<boost::multiprecision::mpfr_float>()
1596 boost::multiprecision::mpfr_float result(0.5);
1597 mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN);
1598 BOOST_ASSERT(mpfr_number_p(result.backend().data()));
1603 inline boost::multiprecision::mpfr_float
1604 min_value<boost::multiprecision::mpfr_float>()
1606 boost::multiprecision::mpfr_float result(0.5);
1607 mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN);
1608 BOOST_ASSERT(mpfr_number_p(result.backend().data()));
1613 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off>
1614 max_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
1616 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> result(0.5);
1617 mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN);
1618 BOOST_ASSERT(mpfr_number_p(result.backend().data()));
1623 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off>
1624 min_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
1626 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> result(0.5);
1627 mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN);
1628 BOOST_ASSERT(mpfr_number_p(result.backend().data()));
1633 inline int digits<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
1634 #ifdef BOOST_MATH_NOEXCEPT
1638 return multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision());
1641 inline int digits<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
1642 #ifdef BOOST_MATH_NOEXCEPT
1646 return multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision());
1650 inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >
1651 max_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
1653 return max_value<boost::multiprecision::mpfr_float>().backend();
1657 inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >
1658 min_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
1660 return min_value<boost::multiprecision::mpfr_float>().backend();
1664 inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
1665 max_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
1667 return max_value<boost::multiprecision::mpfr_float>().backend();
1671 inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
1672 min_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
1674 return min_value<boost::multiprecision::mpfr_float>().backend();
1677 } // namespace tools
1679 namespace constants{ namespace detail{
1681 template <class T> struct constant_pi;
1682 template <class T> struct constant_ln_two;
1683 template <class T> struct constant_euler;
1684 template <class T> struct constant_catalan;
1688 template <class T, int N>
1689 struct mpfr_constant_initializer
1691 static void force_instantiate()
1693 init.force_instantiate();
1700 T::get(mpl::int_<N>());
1702 void force_instantiate()const{}
1704 static const initializer init;
1707 template <class T, int N>
1708 typename mpfr_constant_initializer<T, N>::initializer const mpfr_constant_initializer<T, N>::init;
1712 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1713 struct constant_pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
1715 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
1717 static inline const result_type& get(const mpl::int_<N>&)
1719 detail::mpfr_constant_initializer<constant_pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
1720 static result_type result;
1721 static bool has_init = false;
1724 mpfr_const_pi(result.backend().data(), GMP_RNDN);
1729 static inline const result_type get(const mpl::int_<0>&)
1732 mpfr_const_pi(result.backend().data(), GMP_RNDN);
1736 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1737 struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
1739 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
1741 static inline const result_type& get(const mpl::int_<N>&)
1743 detail::mpfr_constant_initializer<constant_ln_two<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
1744 static result_type result;
1745 static bool init = false;
1748 mpfr_const_log2(result.backend().data(), GMP_RNDN);
1753 static inline const result_type get(const mpl::int_<0>&)
1756 mpfr_const_log2(result.backend().data(), GMP_RNDN);
1760 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1761 struct constant_euler<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
1763 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
1765 static inline const result_type& get(const mpl::int_<N>&)
1767 detail::mpfr_constant_initializer<constant_euler<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
1768 static result_type result;
1769 static bool init = false;
1772 mpfr_const_euler(result.backend().data(), GMP_RNDN);
1777 static inline const result_type get(const mpl::int_<0>&)
1780 mpfr_const_euler(result.backend().data(), GMP_RNDN);
1784 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1785 struct constant_catalan<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
1787 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
1789 static inline const result_type& get(const mpl::int_<N>&)
1791 detail::mpfr_constant_initializer<constant_catalan<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
1792 static result_type result;
1793 static bool init = false;
1796 mpfr_const_catalan(result.backend().data(), GMP_RNDN);
1801 static inline const result_type get(const mpl::int_<0>&)
1804 mpfr_const_catalan(result.backend().data(), GMP_RNDN);
1809 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1810 struct constant_pi<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
1812 typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
1814 static inline const result_type& get(const mpl::int_<N>&)
1816 detail::mpfr_constant_initializer<constant_pi<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
1817 static result_type result;
1818 static bool has_init = false;
1821 mpfr_const_pi(result.backend().value().data(), GMP_RNDN);
1826 static inline const result_type get(const mpl::int_<0>&)
1829 mpfr_const_pi(result.backend().value().data(), GMP_RNDN);
1833 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1834 struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
1836 typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
1838 static inline const result_type& get(const mpl::int_<N>&)
1840 detail::mpfr_constant_initializer<constant_ln_two<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
1841 static result_type result;
1842 static bool init = false;
1845 mpfr_const_log2(result.backend().value().data(), GMP_RNDN);
1850 static inline const result_type get(const mpl::int_<0>&)
1853 mpfr_const_log2(result.backend().value().data(), GMP_RNDN);
1857 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1858 struct constant_euler<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
1860 typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
1862 static inline const result_type& get(const mpl::int_<N>&)
1864 detail::mpfr_constant_initializer<constant_euler<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
1865 static result_type result;
1866 static bool init = false;
1869 mpfr_const_euler(result.backend().value().data(), GMP_RNDN);
1874 static inline const result_type get(const mpl::int_<0>&)
1877 mpfr_const_euler(result.backend().value().data(), GMP_RNDN);
1881 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1882 struct constant_catalan<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
1884 typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
1886 static inline const result_type& get(const mpl::int_<N>&)
1888 detail::mpfr_constant_initializer<constant_catalan<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
1889 static result_type result;
1890 static bool init = false;
1893 mpfr_const_catalan(result.backend().value().data(), GMP_RNDN);
1898 static inline const result_type get(const mpl::int_<0>&)
1901 mpfr_const_catalan(result.backend().value().data(), GMP_RNDN);
1908 } // namespace multiprecision
1910 namespace multiprecision {
1912 // Overloaded special functions which call native mpfr routines:
1914 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1915 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1917 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1918 mpfr_asinh(result.backend().data(), arg.backend().data(), GMP_RNDN);
1919 return BOOST_MP_MOVE(result);
1921 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1922 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1924 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1925 mpfr_acosh(result.backend().data(), arg.backend().data(), GMP_RNDN);
1926 return BOOST_MP_MOVE(result);
1928 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1929 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1931 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1932 mpfr_atanh(result.backend().data(), arg.backend().data(), GMP_RNDN);
1933 return BOOST_MP_MOVE(result);
1935 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1936 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1938 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1939 mpfr_cbrt(result.backend().data(), arg.backend().data(), GMP_RNDN);
1940 return BOOST_MP_MOVE(result);
1942 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1943 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1945 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1946 mpfr_erf(result.backend().data(), arg.backend().data(), GMP_RNDN);
1947 return BOOST_MP_MOVE(result);
1949 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1950 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1952 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1953 mpfr_erfc(result.backend().data(), arg.backend().data(), GMP_RNDN);
1954 return BOOST_MP_MOVE(result);
1956 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1957 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1959 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1960 mpfr_expm1(result.backend().data(), arg.backend().data(), GMP_RNDN);
1961 return BOOST_MP_MOVE(result);
1963 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1964 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1966 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1967 mpfr_lngamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
1968 return BOOST_MP_MOVE(result);
1970 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1971 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1973 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1974 mpfr_gamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
1975 return BOOST_MP_MOVE(result);
1977 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1978 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1980 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1981 mpfr_log1p(result.backend().data(), arg.backend().data(), GMP_RNDN);
1982 return BOOST_MP_MOVE(result);
1987 } // namespace boost
1992 // numeric_limits [partial] specializations for the types declared in this header:
1994 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1995 class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
1997 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> number_type;
1999 BOOST_STATIC_CONSTEXPR bool is_specialized = true;
2000 static number_type (min)()
2002 initializer.do_nothing();
2003 static std::pair<bool, number_type> value;
2008 mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), -mpfr_get_emin(), GMP_RNDN);
2010 return value.second;
2012 static number_type (max)()
2014 initializer.do_nothing();
2015 static std::pair<bool, number_type> value;
2020 mpfr_mul_2exp(value.second.backend().data(), value.second.backend().data(), mpfr_get_emax(), GMP_RNDN);
2022 return value.second;
2024 BOOST_STATIC_CONSTEXPR number_type lowest()
2028 BOOST_STATIC_CONSTEXPR int digits = static_cast<int>((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301 ? 2 : 1));
2029 BOOST_STATIC_CONSTEXPR int digits10 = Digits10;
2030 // Is this really correct???
2031 BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 3;
2032 BOOST_STATIC_CONSTEXPR bool is_signed = true;
2033 BOOST_STATIC_CONSTEXPR bool is_integer = false;
2034 BOOST_STATIC_CONSTEXPR bool is_exact = false;
2035 BOOST_STATIC_CONSTEXPR int radix = 2;
2036 static number_type epsilon()
2038 initializer.do_nothing();
2039 static std::pair<bool, number_type> value;
2044 mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), std::numeric_limits<number_type>::digits - 1, GMP_RNDN);
2046 return value.second;
2048 // What value should this be????
2049 static number_type round_error()
2051 // returns epsilon/2
2052 initializer.do_nothing();
2053 static std::pair<bool, number_type> value;
2058 mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), 1, GMP_RNDN);
2060 return value.second;
2062 BOOST_STATIC_CONSTEXPR long min_exponent = MPFR_EMIN_DEFAULT;
2063 BOOST_STATIC_CONSTEXPR long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
2064 BOOST_STATIC_CONSTEXPR long max_exponent = MPFR_EMAX_DEFAULT;
2065 BOOST_STATIC_CONSTEXPR long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
2066 BOOST_STATIC_CONSTEXPR bool has_infinity = true;
2067 BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = true;
2068 BOOST_STATIC_CONSTEXPR bool has_signaling_NaN = false;
2069 BOOST_STATIC_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
2070 BOOST_STATIC_CONSTEXPR bool has_denorm_loss = false;
2071 static number_type infinity()
2073 // returns epsilon/2
2074 initializer.do_nothing();
2075 static std::pair<bool, number_type> value;
2080 mpfr_set_inf(value.second.backend().data(), 1);
2082 return value.second;
2084 static number_type quiet_NaN()
2086 // returns epsilon/2
2087 initializer.do_nothing();
2088 static std::pair<bool, number_type> value;
2093 mpfr_set_nan(value.second.backend().data());
2095 return value.second;
2097 BOOST_STATIC_CONSTEXPR number_type signaling_NaN()
2099 return number_type(0);
2101 BOOST_STATIC_CONSTEXPR number_type denorm_min() { return number_type(0); }
2102 BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
2103 BOOST_STATIC_CONSTEXPR bool is_bounded = true;
2104 BOOST_STATIC_CONSTEXPR bool is_modulo = false;
2105 BOOST_STATIC_CONSTEXPR bool traps = true;
2106 BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
2107 BOOST_STATIC_CONSTEXPR float_round_style round_style = round_to_nearest;
2110 struct data_initializer
2114 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::epsilon();
2115 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::round_error();
2116 (std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::min)();
2117 (std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::max)();
2118 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::infinity();
2119 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::quiet_NaN();
2121 void do_nothing()const{}
2123 static const data_initializer initializer;
2126 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2127 const typename numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::data_initializer numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::initializer;
2129 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
2131 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2132 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::digits;
2133 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2134 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::digits10;
2135 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2136 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_digits10;
2137 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2138 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_signed;
2139 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2140 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_integer;
2141 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2142 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_exact;
2143 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2144 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::radix;
2145 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2146 BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::min_exponent;
2147 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2148 BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::min_exponent10;
2149 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2150 BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_exponent;
2151 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2152 BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_exponent10;
2153 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2154 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_infinity;
2155 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2156 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_quiet_NaN;
2157 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2158 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_signaling_NaN;
2159 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2160 BOOST_CONSTEXPR_OR_CONST float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_denorm;
2161 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2162 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_denorm_loss;
2163 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2164 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_iec559;
2165 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2166 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_bounded;
2167 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2168 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_modulo;
2169 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2170 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::traps;
2171 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2172 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::tinyness_before;
2173 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2174 BOOST_CONSTEXPR_OR_CONST float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::round_style;
2179 template<boost::multiprecision::expression_template_option ExpressionTemplates>
2180 class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >
2182 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> number_type;
2184 BOOST_STATIC_CONSTEXPR bool is_specialized = false;
2185 static number_type (min)() { return number_type(0); }
2186 static number_type (max)() { return number_type(0); }
2187 static number_type lowest() { return number_type(0); }
2188 BOOST_STATIC_CONSTEXPR int digits = 0;
2189 BOOST_STATIC_CONSTEXPR int digits10 = 0;
2190 BOOST_STATIC_CONSTEXPR int max_digits10 = 0;
2191 BOOST_STATIC_CONSTEXPR bool is_signed = false;
2192 BOOST_STATIC_CONSTEXPR bool is_integer = false;
2193 BOOST_STATIC_CONSTEXPR bool is_exact = false;
2194 BOOST_STATIC_CONSTEXPR int radix = 0;
2195 static number_type epsilon() { return number_type(0); }
2196 static number_type round_error() { return number_type(0); }
2197 BOOST_STATIC_CONSTEXPR int min_exponent = 0;
2198 BOOST_STATIC_CONSTEXPR int min_exponent10 = 0;
2199 BOOST_STATIC_CONSTEXPR int max_exponent = 0;
2200 BOOST_STATIC_CONSTEXPR int max_exponent10 = 0;
2201 BOOST_STATIC_CONSTEXPR bool has_infinity = false;
2202 BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = false;
2203 BOOST_STATIC_CONSTEXPR bool has_signaling_NaN = false;
2204 BOOST_STATIC_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
2205 BOOST_STATIC_CONSTEXPR bool has_denorm_loss = false;
2206 static number_type infinity() { return number_type(0); }
2207 static number_type quiet_NaN() { return number_type(0); }
2208 static number_type signaling_NaN() { return number_type(0); }
2209 static number_type denorm_min() { return number_type(0); }
2210 BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
2211 BOOST_STATIC_CONSTEXPR bool is_bounded = false;
2212 BOOST_STATIC_CONSTEXPR bool is_modulo = false;
2213 BOOST_STATIC_CONSTEXPR bool traps = false;
2214 BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
2215 BOOST_STATIC_CONSTEXPR float_round_style round_style = round_toward_zero;
2218 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
2220 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2221 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits;
2222 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2223 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits10;
2224 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2225 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_digits10;
2226 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2227 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_signed;
2228 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2229 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_integer;
2230 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2231 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_exact;
2232 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2233 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::radix;
2234 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2235 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::min_exponent;
2236 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2237 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::min_exponent10;
2238 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2239 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent;
2240 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2241 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent10;
2242 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2243 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_infinity;
2244 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2245 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_quiet_NaN;
2246 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2247 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_signaling_NaN;
2248 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2249 BOOST_CONSTEXPR_OR_CONST float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_denorm;
2250 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2251 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_denorm_loss;
2252 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2253 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_iec559;
2254 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2255 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_bounded;
2256 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2257 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_modulo;
2258 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2259 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::traps;
2260 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2261 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::tinyness_before;
2262 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2263 BOOST_CONSTEXPR_OR_CONST float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::round_style;