mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-01-19 04:22:11 +00:00
Update mpfr to allow mixed but equivalent precision arithmetic.
This commit is contained in:
@@ -1105,8 +1105,8 @@ inline void eval_divide(mpfr_float_backend<digits10, AllocationType>& result, lo
|
||||
//
|
||||
// Specialised 3 arg versions of the basic operators:
|
||||
//
|
||||
template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
|
||||
inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
|
||||
template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3, mpfr_allocation_type A3>
|
||||
inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& y)
|
||||
{
|
||||
mpfr_add(a.data(), x.data(), y.data(), GMP_RNDN);
|
||||
}
|
||||
@@ -1139,8 +1139,8 @@ inline void eval_add(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_bac
|
||||
else
|
||||
mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
|
||||
}
|
||||
template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
|
||||
inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
|
||||
template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3, mpfr_allocation_type A3>
|
||||
inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& y)
|
||||
{
|
||||
mpfr_sub(a.data(), x.data(), y.data(), GMP_RNDN);
|
||||
}
|
||||
@@ -1174,8 +1174,8 @@ inline void eval_subtract(mpfr_float_backend<D1, A1>& a, long x, const mpfr_floa
|
||||
mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
|
||||
}
|
||||
|
||||
template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
|
||||
inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
|
||||
template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3, mpfr_allocation_type A3>
|
||||
inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& y)
|
||||
{
|
||||
if ((void*)&x == (void*)&y)
|
||||
mpfr_sqr(a.data(), x.data(), GMP_RNDN);
|
||||
@@ -1215,8 +1215,8 @@ inline void eval_multiply(mpfr_float_backend<D1, A1>& a, long x, const mpfr_floa
|
||||
mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
|
||||
}
|
||||
|
||||
template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
|
||||
inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
|
||||
template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3, mpfr_allocation_type A3>
|
||||
inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& y)
|
||||
{
|
||||
mpfr_div(a.data(), x.data(), y.data(), GMP_RNDN);
|
||||
}
|
||||
@@ -1632,6 +1632,9 @@ template <>
|
||||
struct number_category<detail::canonical<mpfr_t, backends::mpfr_float_backend<0> >::type> : public mpl::int_<number_kind_floating_point>
|
||||
{};
|
||||
|
||||
template <unsigned D, boost::multiprecision::mpfr_allocation_type A1, boost::multiprecision::mpfr_allocation_type A2>
|
||||
struct is_equivalent_number_type<backends::mpfr_float_backend<D, A1>, backends::mpfr_float_backend<D, A2> > : public mpl::true_ {};
|
||||
|
||||
using boost::multiprecision::backends::mpfr_float_backend;
|
||||
|
||||
typedef number<mpfr_float_backend<50> > mpfr_float_50;
|
||||
|
||||
24
test/test_arithmetic_mpfr_50_mixed.cpp
Normal file
24
test/test_arithmetic_mpfr_50_mixed.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012 John Maddock. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <boost/multiprecision/mpfr.hpp>
|
||||
#define TEST_MPFR
|
||||
#include "test_arithmetic.hpp"
|
||||
|
||||
template <>
|
||||
struct related_type<boost::multiprecision::static_mpfr_float_50>
|
||||
{
|
||||
typedef boost::multiprecision::mpfr_float_50 type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::multiprecision::static_mpfr_float_50>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user