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 if(0 == mpfr_number_p(val.data()))
1291 result = boost::math::policies::raise_rounding_error("boost::multiprecision::trunc<%1%>(%1%)", 0, number<mpfr_float_backend<Digits10, AllocateType> >(val), number<mpfr_float_backend<Digits10, AllocateType> >(val), boost::math::policies::policy<>()).backend();
1294 mpfr_trunc(result.data(), val.data());
1296 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1297 inline void eval_ldexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, long e)
1300 mpfr_mul_2exp(result.data(), val.data(), e, GMP_RNDN);
1302 mpfr_div_2exp(result.data(), val.data(), -e, GMP_RNDN);
1306 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1307 inline void eval_frexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, int* e)
1310 mpfr_get_d_2exp(&v, val.data(), GMP_RNDN);
1312 eval_ldexp(result, val, -v);
1314 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1315 inline void eval_frexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, long* e)
1317 mpfr_get_d_2exp(e, val.data(), GMP_RNDN);
1318 return eval_ldexp(result, val, -*e);
1321 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1322 inline int eval_fpclassify(const mpfr_float_backend<Digits10, AllocateType>& val) BOOST_NOEXCEPT
1324 return mpfr_inf_p(val.data()) ? FP_INFINITE : mpfr_nan_p(val.data()) ? FP_NAN : mpfr_zero_p(val.data()) ? FP_ZERO : FP_NORMAL;
1327 template <unsigned Digits10, mpfr_allocation_type AllocateType>
1328 inline void eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& e)
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 std::size_t hash_value(const mpfr_float_backend<Digits10, AllocateType>& val)
1510 std::size_t result = 0;
1511 std::size_t len = val.data()[0]._mpfr_prec / mp_bits_per_limb;
1512 if(val.data()[0]._mpfr_prec % mp_bits_per_limb)
1514 for(int i = 0; i < len; ++i)
1515 boost::hash_combine(result, val.data()[0]._mpfr_d[i]);
1516 boost::hash_combine(result, val.data()[0]._mpfr_exp);
1517 boost::hash_combine(result, val.data()[0]._mpfr_sign);
1521 } // namespace backends
1523 #ifdef BOOST_NO_SFINAE_EXPR
1527 template<unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1528 struct is_explicitly_convertible<backends::mpfr_float_backend<D1, A1>, backends::mpfr_float_backend<D2, A2> > : public mpl::true_ {};
1535 struct number_category<detail::canonical<mpfr_t, backends::mpfr_float_backend<0> >::type> : public mpl::int_<number_kind_floating_point>{};
1537 using boost::multiprecision::backends::mpfr_float_backend;
1539 typedef number<mpfr_float_backend<50> > mpfr_float_50;
1540 typedef number<mpfr_float_backend<100> > mpfr_float_100;
1541 typedef number<mpfr_float_backend<500> > mpfr_float_500;
1542 typedef number<mpfr_float_backend<1000> > mpfr_float_1000;
1543 typedef number<mpfr_float_backend<0> > mpfr_float;
1545 typedef number<mpfr_float_backend<50, allocate_stack> > static_mpfr_float_50;
1546 typedef number<mpfr_float_backend<100, allocate_stack> > static_mpfr_float_100;
1548 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1549 inline int signbit BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
1551 return (arg.backend().data()[0]._mpfr_sign < 0) ? 1 : 0;
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 int signbit BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
1563 return (arg.backend().value().data()[0]._mpfr_sign < 0) ? 1 : 0;
1566 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1567 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)
1569 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;
1572 } // namespace multiprecision
1576 using boost::multiprecision::signbit;
1577 using boost::multiprecision::copysign;
1582 inline int digits<boost::multiprecision::mpfr_float>()
1583 #ifdef BOOST_MATH_NOEXCEPT
1587 return multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::default_precision());
1590 inline int digits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
1591 #ifdef BOOST_MATH_NOEXCEPT
1595 return multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::default_precision());
1599 inline boost::multiprecision::mpfr_float
1600 max_value<boost::multiprecision::mpfr_float>()
1602 boost::multiprecision::mpfr_float result(0.5);
1603 mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN);
1604 BOOST_ASSERT(mpfr_number_p(result.backend().data()));
1609 inline boost::multiprecision::mpfr_float
1610 min_value<boost::multiprecision::mpfr_float>()
1612 boost::multiprecision::mpfr_float result(0.5);
1613 mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN);
1614 BOOST_ASSERT(mpfr_number_p(result.backend().data()));
1619 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off>
1620 max_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
1622 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> result(0.5);
1623 mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN);
1624 BOOST_ASSERT(mpfr_number_p(result.backend().data()));
1629 inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off>
1630 min_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
1632 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> result(0.5);
1633 mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN);
1634 BOOST_ASSERT(mpfr_number_p(result.backend().data()));
1639 inline int digits<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
1640 #ifdef BOOST_MATH_NOEXCEPT
1644 return multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision());
1647 inline int digits<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
1648 #ifdef BOOST_MATH_NOEXCEPT
1652 return multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision());
1656 inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >
1657 max_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
1659 return max_value<boost::multiprecision::mpfr_float>().backend();
1663 inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >
1664 min_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
1666 return min_value<boost::multiprecision::mpfr_float>().backend();
1670 inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
1671 max_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
1673 return max_value<boost::multiprecision::mpfr_float>().backend();
1677 inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
1678 min_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
1680 return min_value<boost::multiprecision::mpfr_float>().backend();
1683 } // namespace tools
1685 namespace constants{ namespace detail{
1687 template <class T> struct constant_pi;
1688 template <class T> struct constant_ln_two;
1689 template <class T> struct constant_euler;
1690 template <class T> struct constant_catalan;
1694 template <class T, int N>
1695 struct mpfr_constant_initializer
1697 static void force_instantiate()
1699 init.force_instantiate();
1706 T::get(mpl::int_<N>());
1708 void force_instantiate()const{}
1710 static const initializer init;
1713 template <class T, int N>
1714 typename mpfr_constant_initializer<T, N>::initializer const mpfr_constant_initializer<T, N>::init;
1718 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1719 struct constant_pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
1721 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
1723 static inline const result_type& get(const mpl::int_<N>&)
1725 detail::mpfr_constant_initializer<constant_pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
1726 static result_type result;
1727 static bool has_init = false;
1730 mpfr_const_pi(result.backend().data(), GMP_RNDN);
1735 static inline const result_type get(const mpl::int_<0>&)
1738 mpfr_const_pi(result.backend().data(), GMP_RNDN);
1742 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1743 struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
1745 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
1747 static inline const result_type& get(const mpl::int_<N>&)
1749 detail::mpfr_constant_initializer<constant_ln_two<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
1750 static result_type result;
1751 static bool init = false;
1754 mpfr_const_log2(result.backend().data(), GMP_RNDN);
1759 static inline const result_type get(const mpl::int_<0>&)
1762 mpfr_const_log2(result.backend().data(), GMP_RNDN);
1766 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1767 struct constant_euler<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
1769 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
1771 static inline const result_type& get(const mpl::int_<N>&)
1773 detail::mpfr_constant_initializer<constant_euler<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
1774 static result_type result;
1775 static bool init = false;
1778 mpfr_const_euler(result.backend().data(), GMP_RNDN);
1783 static inline const result_type get(const mpl::int_<0>&)
1786 mpfr_const_euler(result.backend().data(), GMP_RNDN);
1790 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1791 struct constant_catalan<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
1793 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
1795 static inline const result_type& get(const mpl::int_<N>&)
1797 detail::mpfr_constant_initializer<constant_catalan<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
1798 static result_type result;
1799 static bool init = false;
1802 mpfr_const_catalan(result.backend().data(), GMP_RNDN);
1807 static inline const result_type get(const mpl::int_<0>&)
1810 mpfr_const_catalan(result.backend().data(), GMP_RNDN);
1815 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1816 struct constant_pi<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
1818 typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
1820 static inline const result_type& get(const mpl::int_<N>&)
1822 detail::mpfr_constant_initializer<constant_pi<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
1823 static result_type result;
1824 static bool has_init = false;
1827 mpfr_const_pi(result.backend().value().data(), GMP_RNDN);
1832 static inline const result_type get(const mpl::int_<0>&)
1835 mpfr_const_pi(result.backend().value().data(), GMP_RNDN);
1839 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1840 struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
1842 typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
1844 static inline const result_type& get(const mpl::int_<N>&)
1846 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();
1847 static result_type result;
1848 static bool init = false;
1851 mpfr_const_log2(result.backend().value().data(), GMP_RNDN);
1856 static inline const result_type get(const mpl::int_<0>&)
1859 mpfr_const_log2(result.backend().value().data(), GMP_RNDN);
1863 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1864 struct constant_euler<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
1866 typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
1868 static inline const result_type& get(const mpl::int_<N>&)
1870 detail::mpfr_constant_initializer<constant_euler<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
1871 static result_type result;
1872 static bool init = false;
1875 mpfr_const_euler(result.backend().value().data(), GMP_RNDN);
1880 static inline const result_type get(const mpl::int_<0>&)
1883 mpfr_const_euler(result.backend().value().data(), GMP_RNDN);
1887 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1888 struct constant_catalan<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
1890 typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
1892 static inline const result_type& get(const mpl::int_<N>&)
1894 detail::mpfr_constant_initializer<constant_catalan<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
1895 static result_type result;
1896 static bool init = false;
1899 mpfr_const_catalan(result.backend().value().data(), GMP_RNDN);
1904 static inline const result_type get(const mpl::int_<0>&)
1907 mpfr_const_catalan(result.backend().value().data(), GMP_RNDN);
1914 } // namespace multiprecision
1916 namespace multiprecision {
1918 // Overloaded special functions which call native mpfr routines:
1920 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1921 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)
1923 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1924 mpfr_asinh(result.backend().data(), arg.backend().data(), GMP_RNDN);
1925 return BOOST_MP_MOVE(result);
1927 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1928 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)
1930 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1931 mpfr_acosh(result.backend().data(), arg.backend().data(), GMP_RNDN);
1932 return BOOST_MP_MOVE(result);
1934 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1935 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)
1937 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1938 mpfr_atanh(result.backend().data(), arg.backend().data(), GMP_RNDN);
1939 return BOOST_MP_MOVE(result);
1941 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1942 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)
1944 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1945 mpfr_cbrt(result.backend().data(), arg.backend().data(), GMP_RNDN);
1946 return BOOST_MP_MOVE(result);
1948 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1949 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)
1951 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1952 mpfr_erf(result.backend().data(), arg.backend().data(), GMP_RNDN);
1953 return BOOST_MP_MOVE(result);
1955 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1956 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)
1958 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1959 mpfr_erfc(result.backend().data(), arg.backend().data(), GMP_RNDN);
1960 return BOOST_MP_MOVE(result);
1962 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1963 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)
1965 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1966 mpfr_expm1(result.backend().data(), arg.backend().data(), GMP_RNDN);
1967 return BOOST_MP_MOVE(result);
1969 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1970 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)
1972 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1973 mpfr_lngamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
1974 return BOOST_MP_MOVE(result);
1976 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1977 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)
1979 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1980 mpfr_gamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
1981 return BOOST_MP_MOVE(result);
1983 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
1984 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)
1986 boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
1987 mpfr_log1p(result.backend().data(), arg.backend().data(), GMP_RNDN);
1988 return BOOST_MP_MOVE(result);
1993 } // namespace boost
1998 // numeric_limits [partial] specializations for the types declared in this header:
2000 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2001 class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
2003 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> number_type;
2005 BOOST_STATIC_CONSTEXPR bool is_specialized = true;
2006 static number_type (min)()
2008 initializer.do_nothing();
2009 static std::pair<bool, number_type> value;
2014 mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), -mpfr_get_emin(), GMP_RNDN);
2016 return value.second;
2018 static number_type (max)()
2020 initializer.do_nothing();
2021 static std::pair<bool, number_type> value;
2026 mpfr_mul_2exp(value.second.backend().data(), value.second.backend().data(), mpfr_get_emax(), GMP_RNDN);
2028 return value.second;
2030 BOOST_STATIC_CONSTEXPR number_type lowest()
2034 BOOST_STATIC_CONSTEXPR int digits = static_cast<int>((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301 ? 2 : 1));
2035 BOOST_STATIC_CONSTEXPR int digits10 = Digits10;
2036 // Is this really correct???
2037 BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 3;
2038 BOOST_STATIC_CONSTEXPR bool is_signed = true;
2039 BOOST_STATIC_CONSTEXPR bool is_integer = false;
2040 BOOST_STATIC_CONSTEXPR bool is_exact = false;
2041 BOOST_STATIC_CONSTEXPR int radix = 2;
2042 static number_type epsilon()
2044 initializer.do_nothing();
2045 static std::pair<bool, number_type> value;
2050 mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), std::numeric_limits<number_type>::digits - 1, GMP_RNDN);
2052 return value.second;
2054 // What value should this be????
2055 static number_type round_error()
2057 // returns epsilon/2
2058 initializer.do_nothing();
2059 static std::pair<bool, number_type> value;
2064 mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), 1, GMP_RNDN);
2066 return value.second;
2068 BOOST_STATIC_CONSTEXPR long min_exponent = MPFR_EMIN_DEFAULT;
2069 BOOST_STATIC_CONSTEXPR long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
2070 BOOST_STATIC_CONSTEXPR long max_exponent = MPFR_EMAX_DEFAULT;
2071 BOOST_STATIC_CONSTEXPR long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
2072 BOOST_STATIC_CONSTEXPR bool has_infinity = true;
2073 BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = true;
2074 BOOST_STATIC_CONSTEXPR bool has_signaling_NaN = false;
2075 BOOST_STATIC_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
2076 BOOST_STATIC_CONSTEXPR bool has_denorm_loss = false;
2077 static number_type infinity()
2079 // returns epsilon/2
2080 initializer.do_nothing();
2081 static std::pair<bool, number_type> value;
2086 mpfr_set_inf(value.second.backend().data(), 1);
2088 return value.second;
2090 static number_type quiet_NaN()
2092 // returns epsilon/2
2093 initializer.do_nothing();
2094 static std::pair<bool, number_type> value;
2099 mpfr_set_nan(value.second.backend().data());
2101 return value.second;
2103 BOOST_STATIC_CONSTEXPR number_type signaling_NaN()
2105 return number_type(0);
2107 BOOST_STATIC_CONSTEXPR number_type denorm_min() { return number_type(0); }
2108 BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
2109 BOOST_STATIC_CONSTEXPR bool is_bounded = true;
2110 BOOST_STATIC_CONSTEXPR bool is_modulo = false;
2111 BOOST_STATIC_CONSTEXPR bool traps = true;
2112 BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
2113 BOOST_STATIC_CONSTEXPR float_round_style round_style = round_to_nearest;
2116 struct data_initializer
2120 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::epsilon();
2121 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::round_error();
2122 (std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::min)();
2123 (std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::max)();
2124 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::infinity();
2125 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::quiet_NaN();
2127 void do_nothing()const{}
2129 static const data_initializer initializer;
2132 template<unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2133 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;
2135 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
2137 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2138 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::digits;
2139 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2140 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::digits10;
2141 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2142 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_digits10;
2143 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2144 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_signed;
2145 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2146 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_integer;
2147 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2148 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_exact;
2149 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2150 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::radix;
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> >::min_exponent;
2153 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2154 BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::min_exponent10;
2155 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2156 BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_exponent;
2157 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2158 BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_exponent10;
2159 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2160 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_infinity;
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_quiet_NaN;
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> >::has_signaling_NaN;
2165 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2166 BOOST_CONSTEXPR_OR_CONST float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_denorm;
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> >::has_denorm_loss;
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> >::is_iec559;
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> >::is_bounded;
2173 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2174 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_modulo;
2175 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2176 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::traps;
2177 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2178 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::tinyness_before;
2179 template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2180 BOOST_CONSTEXPR_OR_CONST float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::round_style;
2185 template<boost::multiprecision::expression_template_option ExpressionTemplates>
2186 class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >
2188 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> number_type;
2190 BOOST_STATIC_CONSTEXPR bool is_specialized = false;
2191 static number_type (min)() { return number_type(0); }
2192 static number_type (max)() { return number_type(0); }
2193 static number_type lowest() { return number_type(0); }
2194 BOOST_STATIC_CONSTEXPR int digits = 0;
2195 BOOST_STATIC_CONSTEXPR int digits10 = 0;
2196 BOOST_STATIC_CONSTEXPR int max_digits10 = 0;
2197 BOOST_STATIC_CONSTEXPR bool is_signed = false;
2198 BOOST_STATIC_CONSTEXPR bool is_integer = false;
2199 BOOST_STATIC_CONSTEXPR bool is_exact = false;
2200 BOOST_STATIC_CONSTEXPR int radix = 0;
2201 static number_type epsilon() { return number_type(0); }
2202 static number_type round_error() { return number_type(0); }
2203 BOOST_STATIC_CONSTEXPR int min_exponent = 0;
2204 BOOST_STATIC_CONSTEXPR int min_exponent10 = 0;
2205 BOOST_STATIC_CONSTEXPR int max_exponent = 0;
2206 BOOST_STATIC_CONSTEXPR int max_exponent10 = 0;
2207 BOOST_STATIC_CONSTEXPR bool has_infinity = false;
2208 BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = false;
2209 BOOST_STATIC_CONSTEXPR bool has_signaling_NaN = false;
2210 BOOST_STATIC_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
2211 BOOST_STATIC_CONSTEXPR bool has_denorm_loss = false;
2212 static number_type infinity() { return number_type(0); }
2213 static number_type quiet_NaN() { return number_type(0); }
2214 static number_type signaling_NaN() { return number_type(0); }
2215 static number_type denorm_min() { return number_type(0); }
2216 BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
2217 BOOST_STATIC_CONSTEXPR bool is_bounded = false;
2218 BOOST_STATIC_CONSTEXPR bool is_modulo = false;
2219 BOOST_STATIC_CONSTEXPR bool traps = false;
2220 BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
2221 BOOST_STATIC_CONSTEXPR float_round_style round_style = round_toward_zero;
2224 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
2226 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2227 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits;
2228 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2229 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits10;
2230 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2231 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_digits10;
2232 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2233 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_signed;
2234 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2235 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_integer;
2236 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2237 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_exact;
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> >::radix;
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> >::min_exponent;
2242 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2243 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::min_exponent10;
2244 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2245 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent;
2246 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2247 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent10;
2248 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2249 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_infinity;
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_quiet_NaN;
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> >::has_signaling_NaN;
2254 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2255 BOOST_CONSTEXPR_OR_CONST float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_denorm;
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> >::has_denorm_loss;
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> >::is_iec559;
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> >::is_bounded;
2262 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2263 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_modulo;
2264 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2265 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::traps;
2266 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2267 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::tinyness_before;
2268 template <boost::multiprecision::expression_template_option ExpressionTemplates>
2269 BOOST_CONSTEXPR_OR_CONST float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::round_style;