-
+
static_mpfr_float_100
+
+
+-
+
static_mpfr_float_50
+
+
+-
str
diff --git a/doc/html/boost_multiprecision/map/hist.html b/doc/html/boost_multiprecision/map/hist.html
index 7c4b992f..eec38fe9 100644
--- a/doc/html/boost_multiprecision/map/hist.html
+++ b/doc/html/boost_multiprecision/map/hist.html
@@ -59,6 +59,10 @@
Refactored cpp_int_backend
based on review comments with new template parameter structure.
+-
+ Added additional template parameter to
mpfr_float_backend
+ to allow stack-based allocation.
+
diff --git a/doc/html/boost_multiprecision/tut/floats/mpfr_float.html b/doc/html/boost_multiprecision/tut/floats/mpfr_float.html
index 40126cf1..29355351 100644
--- a/doc/html/boost_multiprecision/tut/floats/mpfr_float.html
+++ b/doc/html/boost_multiprecision/tut/floats/mpfr_float.html
@@ -22,7 +22,13 @@
namespace boost{ namespace multiprecision{
-template <unsigned Digits10>
+enum mpfr_allocation_type
+{
+ allocate_stack,
+ allocate_dynamic
+};
+
+template <unsigned Digits10, mpfr_allocation_type AllocateType = allocate_dynamic>
class mpfr_float_backend;
typedef number<mpfr_float_backend<50> > mpfr_float_50;
@@ -31,6 +37,9 @@
typedef number<mpfr_float_backend<1000> > mpfr_float_1000;
typedef number<mpfr_float_backend<0> > mpfr_float;
+typedef number<mpfr_float_backend<50, allocate_stack> > static_mpfr_float_50;
+typedef number<mpfr_float_backend<100, allocate_stack> > static_mpfr_float_100;
+
}}
@@ -51,6 +60,18 @@
whose precision can be controlled via the numbers
member functions.
+
+ In addition the second template parameter lets you choose between dynamic
+ allocation (the default, and uses MPFR's normal allocation routines), or
+ stack allocation (where all the memory required for the underlying data
+ types is stored within mpfr_float_backend).
+ The latter option can result in significantly faster code, at the expense
+ of growing the size of mpfr_float_backend.
+ It can only be used at fixed precision, and should only be used for lower
+ digit counts. Note that we can not guarentee that using allocate_stack
+ won't cause any calls to mpfr's allocation routines, as mpfr may call these
+ inside it's own code.
+
![[Note]](../../../images/note.png) |
diff --git a/doc/html/index.html b/doc/html/index.html
index 3373c51d..0c8517c2 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -124,7 +124,7 @@
-Last revised: November 01, 2012 at 11:12:34 GMT |
+Last revised: November 01, 2012 at 18:56:42 GMT |
|
diff --git a/doc/multiprecision.qbk b/doc/multiprecision.qbk
index d2ff465f..64829ae8 100644
--- a/doc/multiprecision.qbk
+++ b/doc/multiprecision.qbk
@@ -730,7 +730,13 @@ as a valid floating point number.
namespace boost{ namespace multiprecision{
- template
+ enum mpfr_allocation_type
+ {
+ allocate_stack,
+ allocate_dynamic
+ };
+
+ template
class mpfr_float_backend;
typedef number > mpfr_float_50;
@@ -739,6 +745,9 @@ as a valid floating point number.
typedef number > mpfr_float_1000;
typedef number > mpfr_float;
+ typedef number > static_mpfr_float_50;
+ typedef number > static_mpfr_float_100;
+
}} // namespaces
The `mpfr_float_backend` type is used in conjunction with `number`: It acts as a thin wrapper around the [mpfr] `mpfr_t`
@@ -751,6 +760,14 @@ mpfr_float_500, mpfr_float_1000 provide arithmetic types at 50, 100, 500 and 100
respectively. The typedef mpfr_float provides a variable precision type whose precision can be controlled via the
`number`s member functions.
+In addition the second template parameter lets you choose between dynamic allocation (the default,
+and uses MPFR's normal allocation routines),
+or stack allocation (where all the memory required for the underlying data types is stored
+within `mpfr_float_backend`). The latter option can result in significantly faster code, at the
+expense of growing the size of `mpfr_float_backend`. It can only be used at fixed precision, and
+should only be used for lower digit counts. Note that we can not guarentee that using `allocate_stack`
+won't cause any calls to mpfr's allocation routines, as mpfr may call these inside it's own code.
+
[note This type only provides `numeric_limits` support when the precision is fixed at compile time.]
As well as the usual conversions from arithmetic and string types, instances of `number >` are
@@ -2897,6 +2914,7 @@ Windows Vista machine.
* Added support for fused-multiply-add/subtract with GMP support.
* Tweaked expression template unpacking to use fewer temporaries when the LHS also appears in the RHS.
* Refactored `cpp_int_backend` based on review comments with new template parameter structure.
+* Added additional template parameter to `mpfr_float_backend` to allow stack-based allocation.
[h4 Pre-review history]
diff --git a/include/boost/multiprecision/mpfr.hpp b/include/boost/multiprecision/mpfr.hpp
index ec3085c7..7924b414 100644
--- a/include/boost/multiprecision/mpfr.hpp
+++ b/include/boost/multiprecision/mpfr.hpp
@@ -17,17 +17,24 @@
#include
#include
-namespace boost{
+namespace boost{
namespace multiprecision{
+
+enum mpfr_allocation_type
+{
+ allocate_stack,
+ allocate_dynamic
+};
+
namespace backends{
-template
+template
struct mpfr_float_backend;
} // namespace backends
-template
-struct number_category > : public mpl::int_{};
+template
+struct number_category > : public mpl::int_{};
namespace backends{
@@ -35,15 +42,25 @@ namespace detail{
inline long get_default_precision() { return 50; }
+template
+struct mpfr_float_imp;
+
template
-struct mpfr_float_imp
+struct mpfr_float_imp
{
typedef mpl::list signed_types;
typedef mpl::list unsigned_types;
typedef mpl::list float_types;
typedef long exponent_type;
- mpfr_float_imp() BOOST_NOEXCEPT {}
+ mpfr_float_imp()
+ {
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
+ }
+ mpfr_float_imp(unsigned prec)
+ {
+ mpfr_init2(m_data, prec);
+ }
mpfr_float_imp(const mpfr_float_imp& o)
{
@@ -281,7 +298,8 @@ struct mpfr_float_imp
BOOST_ASSERT(m_data[0]._mpfr_d);
mpfr_neg(m_data, m_data, GMP_RNDN);
}
- int compare(const mpfr_float_backend& o)const BOOST_NOEXCEPT
+ template
+ int compare(const mpfr_float_backend& o)const BOOST_NOEXCEPT
{
BOOST_ASSERT(m_data[0]._mpfr_d && o.m_data[0]._mpfr_d);
return mpfr_cmp(m_data, o.m_data);
@@ -299,19 +317,19 @@ struct mpfr_float_imp
template
int compare(V v)const BOOST_NOEXCEPT
{
- mpfr_float_backend d;
+ mpfr_float_backend d;
d = v;
return compare(d);
}
- mpfr_t& data() BOOST_NOEXCEPT
- {
+ mpfr_t& data() BOOST_NOEXCEPT
+ {
BOOST_ASSERT(m_data[0]._mpfr_d);
- return m_data;
+ return m_data;
}
- const mpfr_t& data()const BOOST_NOEXCEPT
- {
+ const mpfr_t& data()const BOOST_NOEXCEPT
+ {
BOOST_ASSERT(m_data[0]._mpfr_d);
- return m_data;
+ return m_data;
}
protected:
mpfr_t m_data;
@@ -322,89 +340,344 @@ protected:
}
};
-} // namespace detail
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4127) // Conditional expression is constant
+#endif
template
-struct mpfr_float_backend : public detail::mpfr_float_imp
+struct mpfr_float_imp
{
- mpfr_float_backend()
+ typedef mpl::list signed_types;
+ typedef mpl::list unsigned_types;
+ typedef mpl::list float_types;
+ typedef long exponent_type;
+
+ static const unsigned digits2 = (digits10 * 1000uL) / 301uL + ((digits10 * 1000uL) % 301 ? 2u : 1u);
+ static const unsigned limb_count = mpfr_custom_get_size(digits2) / sizeof(mp_limb_t);
+
+ mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
+ mpfr_custom_init(m_buffer, digits2);
+ mpfr_custom_init_set(m_data, MPFR_NAN_KIND, 0, digits2, m_buffer);
}
- mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp(o) {}
+
+ mpfr_float_imp(const mpfr_float_imp& o)
+ {
+ mpfr_custom_init(m_buffer, digits2);
+ mpfr_custom_init_set(m_data, MPFR_NAN_KIND, 0, digits2, m_buffer);
+ mpfr_set(m_data, o.m_data, GMP_RNDN);
+ }
+ mpfr_float_imp& operator = (const mpfr_float_imp& o) BOOST_NOEXCEPT
+ {
+ mpfr_set(m_data, o.m_data, GMP_RNDN);
+ return *this;
+ }
+#ifdef _MPFR_H_HAVE_INTMAX_T
+ mpfr_float_imp& operator = (unsigned long long i) BOOST_NOEXCEPT
+ {
+ mpfr_set_uj(m_data, i, GMP_RNDN);
+ return *this;
+ }
+ mpfr_float_imp& operator = (long long i) BOOST_NOEXCEPT
+ {
+ mpfr_set_sj(m_data, i, GMP_RNDN);
+ return *this;
+ }
+#else
+ mpfr_float_imp& operator = (unsigned long long i)
+ {
+ unsigned long long mask = ((1uLL << std::numeric_limits::digits) - 1);
+ unsigned shift = 0;
+ mpfr_t t;
+ mp_limb_t t_limbs[limb_count];
+ mpfr_custom_init(t_limbs, digits2);
+ mpfr_custom_init_set(t, MPFR_NAN_KIND, 0, digits2, t_limbs);
+ mpfr_set_ui(m_data, 0, GMP_RNDN);
+ while(i)
+ {
+ mpfr_set_ui(t, static_cast(i & mask), GMP_RNDN);
+ if(shift)
+ mpfr_mul_2exp(t, t, shift, GMP_RNDN);
+ mpfr_add(m_data, m_data, t, GMP_RNDN);
+ shift += std::numeric_limits::digits;
+ i >>= std::numeric_limits::digits;
+ }
+ return *this;
+ }
+ mpfr_float_imp& operator = (long long i)
+ {
+ BOOST_MP_USING_ABS
+ bool neg = i < 0;
+ *this = static_cast(abs(i));
+ if(neg)
+ mpfr_neg(m_data, m_data, GMP_RNDN);
+ return *this;
+ }
+#endif
+ mpfr_float_imp& operator = (unsigned long i) BOOST_NOEXCEPT
+ {
+ mpfr_set_ui(m_data, i, GMP_RNDN);
+ return *this;
+ }
+ mpfr_float_imp& operator = (long i) BOOST_NOEXCEPT
+ {
+ mpfr_set_si(m_data, i, GMP_RNDN);
+ return *this;
+ }
+ mpfr_float_imp& operator = (double d) BOOST_NOEXCEPT
+ {
+ mpfr_set_d(m_data, d, GMP_RNDN);
+ return *this;
+ }
+ mpfr_float_imp& operator = (long double a) BOOST_NOEXCEPT
+ {
+ mpfr_set_ld(m_data, a, GMP_RNDN);
+ return *this;
+ }
+ mpfr_float_imp& operator = (const char* s)
+ {
+ if(mpfr_set_str(m_data, s, 10, GMP_RNDN) != 0)
+ {
+ BOOST_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse string \"") + s + std::string("\"as a valid floating point number.")));
+ }
+ return *this;
+ }
+ void swap(mpfr_float_imp& o) BOOST_NOEXCEPT
+ {
+ // We have to swap by copying:
+ mpfr_float_imp t(*this);
+ *this = o;
+ o = t;
+ }
+ std::string str(std::streamsize digits, std::ios_base::fmtflags f)const
+ {
+ BOOST_ASSERT(m_data[0]._mpfr_d);
+
+ bool scientific = (f & std::ios_base::scientific) == std::ios_base::scientific;
+ bool fixed = (f & std::ios_base::fixed) == std::ios_base::fixed;
+
+ std::streamsize org_digits(digits);
+
+ if(scientific && digits)
+ ++digits;
+
+ std::string result;
+ mp_exp_t e;
+ if(mpfr_inf_p(m_data))
+ {
+ if(mpfr_sgn(m_data) < 0)
+ result = "-inf";
+ else if(f & std::ios_base::showpos)
+ result = "+inf";
+ else
+ result = "inf";
+ return result;
+ }
+ if(mpfr_nan_p(m_data))
+ {
+ result = "nan";
+ return result;
+ }
+ if(mpfr_zero_p(m_data))
+ {
+ e = 0;
+ result = "0";
+ }
+ else
+ {
+ char* ps = mpfr_get_str (0, &e, 10, static_cast(digits), m_data, GMP_RNDN);
+ --e; // To match with what our formatter expects.
+ if(fixed && e != -1)
+ {
+ // Oops we actually need a different number of digits to what we asked for:
+ mpfr_free_str(ps);
+ digits += e + 1;
+ if(digits == 0)
+ {
+ // We need to get *all* the digits and then possibly round up,
+ // we end up with either "0" or "1" as the result.
+ ps = mpfr_get_str (0, &e, 10, 0, m_data, GMP_RNDN);
+ --e;
+ unsigned offset = *ps == '-' ? 1 : 0;
+ if(ps[offset] > '5')
+ {
+ ++e;
+ ps[offset] = '1';
+ ps[offset + 1] = 0;
+ }
+ else if(ps[offset] == '5')
+ {
+ unsigned i = offset + 1;
+ bool round_up = false;
+ while(ps[i] != 0)
+ {
+ if(ps[i] != '0')
+ {
+ round_up = true;
+ break;
+ }
+ }
+ if(round_up)
+ {
+ ++e;
+ ps[offset] = '1';
+ ps[offset + 1] = 0;
+ }
+ else
+ {
+ ps[offset] = '0';
+ ps[offset + 1] = 0;
+ }
+ }
+ else
+ {
+ ps[offset] = '0';
+ ps[offset + 1] = 0;
+ }
+ }
+ else if(digits > 0)
+ {
+ ps = mpfr_get_str (0, &e, 10, static_cast(digits), m_data, GMP_RNDN);
+ --e; // To match with what our formatter expects.
+ }
+ else
+ {
+ ps = mpfr_get_str (0, &e, 10, 1, m_data, GMP_RNDN);
+ --e;
+ unsigned offset = *ps == '-' ? 1 : 0;
+ ps[offset] = '0';
+ ps[offset + 1] = 0;
+ }
+ }
+ result = ps ? ps : "0";
+ if(ps)
+ mpfr_free_str(ps);
+ }
+ boost::multiprecision::detail::format_float_string(result, e, org_digits, f, 0 != mpfr_zero_p(m_data));
+ return result;
+ }
+ void negate() BOOST_NOEXCEPT
+ {
+ mpfr_neg(m_data, m_data, GMP_RNDN);
+ }
+ template
+ int compare(const mpfr_float_backend& o)const BOOST_NOEXCEPT
+ {
+ return mpfr_cmp(m_data, o.m_data);
+ }
+ int compare(long i)const BOOST_NOEXCEPT
+ {
+ return mpfr_cmp_si(m_data, i);
+ }
+ int compare(unsigned long i)const BOOST_NOEXCEPT
+ {
+ return mpfr_cmp_ui(m_data, i);
+ }
+ template
+ int compare(V v)const BOOST_NOEXCEPT
+ {
+ mpfr_float_backend d;
+ d = v;
+ return compare(d);
+ }
+ mpfr_t& data() BOOST_NOEXCEPT
+ {
+ return m_data;
+ }
+ const mpfr_t& data()const BOOST_NOEXCEPT
+ {
+ return m_data;
+ }
+protected:
+ mpfr_t m_data;
+ mp_limb_t m_buffer[limb_count];
+};
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+} // namespace detail
+
+template
+struct mpfr_float_backend : public detail::mpfr_float_imp
+{
+ mpfr_float_backend() : detail::mpfr_float_imp() {}
+ mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp(o) {}
#ifndef BOOST_NO_RVALUE_REFERENCES
- mpfr_float_backend(mpfr_float_backend&& o) : detail::mpfr_float_imp(static_cast&&>(o)) {}
+ mpfr_float_backend(mpfr_float_backend&& o) : detail::mpfr_float_imp(static_cast&&>(o)) {}
#endif
template
mpfr_float_backend(const mpfr_float_backend& val, typename enable_if_c::type* = 0)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set(this->m_data, val.data(), GMP_RNDN);
}
template
explicit mpfr_float_backend(const mpfr_float_backend& val, typename disable_if_c::type* = 0)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set(this->m_data, val.data(), GMP_RNDN);
}
template
mpfr_float_backend(const gmp_float& val, typename enable_if_c::type* = 0)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
}
template
mpfr_float_backend(const gmp_float& val, typename disable_if_c::type* = 0)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
}
mpfr_float_backend(const gmp_int& val)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
}
mpfr_float_backend(const gmp_rational& val)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
}
mpfr_float_backend(const mpfr_t val)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set(this->m_data, val, GMP_RNDN);
}
mpfr_float_backend(const mpf_t val)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set_f(this->m_data, val, GMP_RNDN);
}
mpfr_float_backend(const mpz_t val)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set_z(this->m_data, val, GMP_RNDN);
}
mpfr_float_backend(const mpq_t val)
+ : detail::mpfr_float_imp()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
mpfr_set_q(this->m_data, val, GMP_RNDN);
}
mpfr_float_backend& operator=(const mpfr_float_backend& o)
{
- *static_cast*>(this) = static_cast const&>(o);
+ *static_cast*>(this) = static_cast const&>(o);
return *this;
}
#ifndef BOOST_NO_RVALUE_REFERENCES
mpfr_float_backend& operator=(mpfr_float_backend&& o) BOOST_NOEXCEPT
{
- *static_cast*>(this) = static_cast&&>(o);
+ *static_cast*>(this) = static_cast&&>(o);
return *this;
}
#endif
template
mpfr_float_backend& operator=(const V& v)
{
- *static_cast*>(this) = v;
+ *static_cast*>(this) = v;
return *this;
}
mpfr_float_backend& operator=(const mpfr_t val)BOOST_NOEXCEPT
@@ -453,80 +726,78 @@ struct mpfr_float_backend : public detail::mpfr_float_imp
};
template <>
-struct mpfr_float_backend<0> : public detail::mpfr_float_imp<0>
+struct mpfr_float_backend<0, allocate_dynamic> : public detail::mpfr_float_imp<0, allocate_dynamic>
{
- mpfr_float_backend()
- {
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
- }
+ mpfr_float_backend() : detail::mpfr_float_imp<0, allocate_dynamic>() {}
mpfr_float_backend(const mpfr_t val)
+ : detail::mpfr_float_imp<0, allocate_dynamic>(mpfr_get_prec(val))
{
- mpfr_init2(this->m_data, mpfr_get_prec(val));
mpfr_set(this->m_data, val, GMP_RNDN);
}
mpfr_float_backend(const mpf_t val)
+ : detail::mpfr_float_imp<0, allocate_dynamic>(mpf_get_prec(val))
{
- mpfr_init2(this->m_data, mpf_get_prec(val));
mpfr_set_f(this->m_data, val, GMP_RNDN);
}
mpfr_float_backend(const mpz_t val)
+ : detail::mpfr_float_imp<0, allocate_dynamic>()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
mpfr_set_z(this->m_data, val, GMP_RNDN);
}
mpfr_float_backend(const mpq_t val)
+ : detail::mpfr_float_imp<0, allocate_dynamic>()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
mpfr_set_q(this->m_data, val, GMP_RNDN);
}
- mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<0>(o) {}
+ mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<0, allocate_dynamic>(o) {}
#ifndef BOOST_NO_RVALUE_REFERENCES
- mpfr_float_backend(mpfr_float_backend&& o) BOOST_NOEXCEPT : detail::mpfr_float_imp<0>(static_cast&&>(o)) {}
+ mpfr_float_backend(mpfr_float_backend&& o) BOOST_NOEXCEPT : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast&&>(o)) {}
#endif
- mpfr_float_backend(const mpfr_float_backend& o, unsigned digits10)
+ mpfr_float_backend(const mpfr_float_backend& o, unsigned digits10)
+ : detail::mpfr_float_imp<0, allocate_dynamic>(digits10)
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
*this = o;
}
template
mpfr_float_backend(const mpfr_float_backend& val)
+ : detail::mpfr_float_imp<0, allocate_dynamic>(mpfr_get_prec(val.data()))
{
- mpfr_init2(this->m_data, mpfr_get_prec(val.data()));
mpfr_set(this->m_data, val.data(), GMP_RNDN);
}
template
mpfr_float_backend(const gmp_float& val)
+ : detail::mpfr_float_imp<0, allocate_dynamic>(mpf_get_prec(val.data()))
{
- mpfr_init2(this->m_data, mpf_get_prec(val.data()));
mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
}
mpfr_float_backend(const gmp_int& val)
+ : detail::mpfr_float_imp<0, allocate_dynamic>()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
}
mpfr_float_backend(const gmp_rational& val)
+ : detail::mpfr_float_imp<0, allocate_dynamic>()
{
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
}
mpfr_float_backend& operator=(const mpfr_float_backend& o)
{
- *static_cast*>(this) = static_cast const&>(o);
+ mpfr_set_prec(this->m_data, mpfr_get_prec(o.data()));
+ mpfr_set(this->m_data, o.data(), GMP_RNDN);
return *this;
}
#ifndef BOOST_NO_RVALUE_REFERENCES
mpfr_float_backend& operator=(mpfr_float_backend&& o) BOOST_NOEXCEPT
{
- *static_cast*>(this) = static_cast &&>(o);
+ *static_cast*>(this) = static_cast &&>(o);
return *this;
}
#endif
template
mpfr_float_backend& operator=(const V& v)
{
- *static_cast*>(this) = v;
+ *static_cast*>(this) = v;
return *this;
}
mpfr_float_backend& operator=(const mpfr_t val) BOOST_NOEXCEPT
@@ -593,87 +864,87 @@ struct mpfr_float_backend<0> : public detail::mpfr_float_imp<0>
}
};
-template
-inline typename enable_if, bool>::type eval_eq(const mpfr_float_backend& a, const T& b) BOOST_NOEXCEPT
+template
+inline typename enable_if, bool>::type eval_eq(const mpfr_float_backend& a, const T& b) BOOST_NOEXCEPT
{
return a.compare(b) == 0;
}
-template
-inline typename enable_if, bool>::type eval_lt(const mpfr_float_backend& a, const T& b) BOOST_NOEXCEPT
+template
+inline typename enable_if, bool>::type eval_lt(const mpfr_float_backend& a, const T& b) BOOST_NOEXCEPT
{
return a.compare(b) < 0;
}
-template
-inline typename enable_if, bool>::type eval_gt(const mpfr_float_backend& a, const T& b) BOOST_NOEXCEPT
+template
+inline typename enable_if, bool>::type eval_gt(const mpfr_float_backend& a, const T& b) BOOST_NOEXCEPT
{
return a.compare(b) > 0;
}
-template
-inline void eval_add(mpfr_float_backend& result, const mpfr_float_backend& o) BOOST_NOEXCEPT
+template
+inline void eval_add(mpfr_float_backend& result, const mpfr_float_backend& o) BOOST_NOEXCEPT
{
mpfr_add(result.data(), result.data(), o.data(), GMP_RNDN);
}
-template
-inline void eval_subtract(mpfr_float_backend& result, const mpfr_float_backend& o) BOOST_NOEXCEPT
+template
+inline void eval_subtract(mpfr_float_backend& result, const mpfr_float_backend& o) BOOST_NOEXCEPT
{
mpfr_sub(result.data(), result.data(), o.data(), GMP_RNDN);
}
-template
-inline void eval_multiply(mpfr_float_backend& result, const mpfr_float_backend& o) BOOST_NOEXCEPT
+template
+inline void eval_multiply(mpfr_float_backend& result, const mpfr_float_backend& o) BOOST_NOEXCEPT
{
mpfr_mul(result.data(), result.data(), o.data(), GMP_RNDN);
}
-template
-inline void eval_divide(mpfr_float_backend& result, const mpfr_float_backend& o)
+template
+inline void eval_divide(mpfr_float_backend& result, const mpfr_float_backend& o)
{
mpfr_div(result.data(), result.data(), o.data(), GMP_RNDN);
}
-template
-inline void eval_add(mpfr_float_backend& result, unsigned long i) BOOST_NOEXCEPT
+template
+inline void eval_add(mpfr_float_backend& result, unsigned long i) BOOST_NOEXCEPT
{
mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
}
-template
-inline void eval_subtract(mpfr_float_backend& result, unsigned long i) BOOST_NOEXCEPT
+template
+inline void eval_subtract(mpfr_float_backend& result, unsigned long i) BOOST_NOEXCEPT
{
mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
}
-template
-inline void eval_multiply(mpfr_float_backend& result, unsigned long i) BOOST_NOEXCEPT
+template
+inline void eval_multiply(mpfr_float_backend& result, unsigned long i) BOOST_NOEXCEPT
{
mpfr_mul_ui(result.data(), result.data(), i, GMP_RNDN);
}
-template
-inline void eval_divide(mpfr_float_backend& result, unsigned long i)
+template
+inline void eval_divide(mpfr_float_backend& result, unsigned long i)
{
mpfr_div_ui(result.data(), result.data(), i, GMP_RNDN);
}
-template
-inline void eval_add(mpfr_float_backend& result, long i) BOOST_NOEXCEPT
+template
+inline void eval_add(mpfr_float_backend& result, long i) BOOST_NOEXCEPT
{
if(i > 0)
mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
else
mpfr_sub_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
}
-template
-inline void eval_subtract(mpfr_float_backend& result, long i) BOOST_NOEXCEPT
+template
+inline void eval_subtract(mpfr_float_backend& result, long i) BOOST_NOEXCEPT
{
if(i > 0)
mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
else
mpfr_add_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
}
-template
-inline void eval_multiply(mpfr_float_backend& result, long i) BOOST_NOEXCEPT
+template
+inline void eval_multiply(mpfr_float_backend& result, long i) BOOST_NOEXCEPT
{
mpfr_mul_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
if(i < 0)
mpfr_neg(result.data(), result.data(), GMP_RNDN);
}
-template
-inline void eval_divide(mpfr_float_backend& result, long i)
+template
+inline void eval_divide(mpfr_float_backend& result, long i)
{
mpfr_div_ui(result.data(), result.data(), std::abs(i), GMP_RNDN);
if(i < 0)
@@ -682,31 +953,31 @@ inline void eval_divide(mpfr_float_backend& result, long i)
//
// Specialised 3 arg versions of the basic operators:
//
-template
-inline void eval_add(mpfr_float_backend& a, const mpfr_float_backend& x, const mpfr_float_backend& y) BOOST_NOEXCEPT
+template
+inline void eval_add(mpfr_float_backend& a, const mpfr_float_backend& x, const mpfr_float_backend& y) BOOST_NOEXCEPT
{
mpfr_add(a.data(), x.data(), y.data(), GMP_RNDN);
}
-template
-inline void eval_add(mpfr_float_backend& a, const mpfr_float_backend& x, unsigned long y) BOOST_NOEXCEPT
+template
+inline void eval_add(mpfr_float_backend& a, const mpfr_float_backend& x, unsigned long y) BOOST_NOEXCEPT
{
mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template
-inline void eval_add(mpfr_float_backend& a, const mpfr_float_backend& x, long y) BOOST_NOEXCEPT
+template
+inline void eval_add(mpfr_float_backend& a, const mpfr_float_backend& x, long y) BOOST_NOEXCEPT
{
if(y < 0)
mpfr_sub_ui(a.data(), x.data(), -y, GMP_RNDN);
else
mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template
-inline void eval_add(mpfr_float_backend& a, unsigned long x, const mpfr_float_backend& y) BOOST_NOEXCEPT
+template
+inline void eval_add(mpfr_float_backend& a, unsigned long x, const mpfr_float_backend& y) BOOST_NOEXCEPT
{
mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
}
-template
-inline void eval_add(mpfr_float_backend& a, long x, const mpfr_float_backend& y) BOOST_NOEXCEPT
+template
+inline void eval_add(mpfr_float_backend& a, long x, const mpfr_float_backend& y) BOOST_NOEXCEPT
{
if(x < 0)
{
@@ -716,31 +987,31 @@ inline void eval_add(mpfr_float_backend& a, long x, const mpfr_float_backend
else
mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
}
-template
-inline void eval_subtract(mpfr_float_backend& a, const mpfr_float_backend& x, const mpfr_float_backend& y) BOOST_NOEXCEPT
+template
+inline void eval_subtract(mpfr_float_backend& a, const mpfr_float_backend& x, const mpfr_float_backend& y) BOOST_NOEXCEPT
{
mpfr_sub(a.data(), x.data(), y.data(), GMP_RNDN);
}
-template
-inline void eval_subtract(mpfr_float_backend& a, const mpfr_float_backend& x, unsigned long y) BOOST_NOEXCEPT
+template
+inline void eval_subtract(mpfr_float_backend& a, const mpfr_float_backend& x, unsigned long y) BOOST_NOEXCEPT
{
mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template
-inline void eval_subtract(mpfr_float_backend& a, const mpfr_float_backend& x, long y) BOOST_NOEXCEPT
+template
+inline void eval_subtract(mpfr_float_backend& a, const mpfr_float_backend& x, long y) BOOST_NOEXCEPT
{
if(y < 0)
mpfr_add_ui(a.data(), x.data(), -y, GMP_RNDN);
else
mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template
-inline void eval_subtract(mpfr_float_backend& a, unsigned long x, const mpfr_float_backend& y) BOOST_NOEXCEPT
+template
+inline void eval_subtract(mpfr_float_backend& a, unsigned long x, const mpfr_float_backend& y) BOOST_NOEXCEPT
{
mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
}
-template
-inline void eval_subtract(mpfr_float_backend& a, long x, const mpfr_float_backend& y) BOOST_NOEXCEPT
+template
+inline void eval_subtract(mpfr_float_backend& a, long x, const mpfr_float_backend& y) BOOST_NOEXCEPT
{
if(x < 0)
{
@@ -751,18 +1022,18 @@ inline void eval_subtract(mpfr_float_backend& a, long x, const mpfr_float_ba
mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
}
-template
-inline void eval_multiply(mpfr_float_backend& a, const mpfr_float_backend& x, const mpfr_float_backend