Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/multiprecision/mpfr.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
142 mpfr_clear(t); | 142 mpfr_clear(t); |
143 return *this; | 143 return *this; |
144 } | 144 } |
145 mpfr_float_imp& operator = (long long i) | 145 mpfr_float_imp& operator = (long long i) |
146 { | 146 { |
147 BOOST_MP_USING_ABS | |
148 if(m_data[0]._mpfr_d == 0) | 147 if(m_data[0]._mpfr_d == 0) |
149 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision())); | 148 mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision())); |
150 bool neg = i < 0; | 149 bool neg = i < 0; |
151 *this = static_cast<unsigned long long>(abs(i)); | 150 *this = boost::multiprecision::detail::unsigned_abs(i); |
152 if(neg) | 151 if(neg) |
153 mpfr_neg(m_data, m_data, GMP_RNDN); | 152 mpfr_neg(m_data, m_data, GMP_RNDN); |
154 return *this; | 153 return *this; |
155 } | 154 } |
156 #endif | 155 #endif |
425 } | 424 } |
426 return *this; | 425 return *this; |
427 } | 426 } |
428 mpfr_float_imp& operator = (long long i) | 427 mpfr_float_imp& operator = (long long i) |
429 { | 428 { |
430 BOOST_MP_USING_ABS | |
431 bool neg = i < 0; | 429 bool neg = i < 0; |
432 *this = static_cast<unsigned long long>(abs(i)); | 430 *this = boost::multiprecision::detail::unsigned_abs(i); |
433 if(neg) | 431 if(neg) |
434 mpfr_neg(m_data, m_data, GMP_RNDN); | 432 mpfr_neg(m_data, m_data, GMP_RNDN); |
435 return *this; | 433 return *this; |
436 } | 434 } |
437 #endif | 435 #endif |
624 struct mpfr_float_backend : public detail::mpfr_float_imp<digits10, AllocationType> | 622 struct mpfr_float_backend : public detail::mpfr_float_imp<digits10, AllocationType> |
625 { | 623 { |
626 mpfr_float_backend() : detail::mpfr_float_imp<digits10, AllocationType>() {} | 624 mpfr_float_backend() : detail::mpfr_float_imp<digits10, AllocationType>() {} |
627 mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<digits10, AllocationType>(o) {} | 625 mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<digits10, AllocationType>(o) {} |
628 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES | 626 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES |
629 mpfr_float_backend(mpfr_float_backend&& o) : detail::mpfr_float_imp<digits10, AllocationType>(static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o)) {} | 627 mpfr_float_backend(mpfr_float_backend&& o) BOOST_NOEXCEPT : detail::mpfr_float_imp<digits10, AllocationType>(static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o)) {} |
630 #endif | 628 #endif |
631 template <unsigned D, mpfr_allocation_type AT> | 629 template <unsigned D, mpfr_allocation_type AT> |
632 mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename enable_if_c<D <= digits10>::type* = 0) | 630 mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename enable_if_c<D <= digits10>::type* = 0) |
633 : detail::mpfr_float_imp<digits10, AllocationType>() | 631 : detail::mpfr_float_imp<digits10, AllocationType>() |
634 { | 632 { |
986 inline void eval_add(mpfr_float_backend<digits10, AllocationType>& result, long i) | 984 inline void eval_add(mpfr_float_backend<digits10, AllocationType>& result, long i) |
987 { | 985 { |
988 if(i > 0) | 986 if(i > 0) |
989 mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN); | 987 mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN); |
990 else | 988 else |
991 mpfr_sub_ui(result.data(), result.data(), std::abs(i), GMP_RNDN); | 989 mpfr_sub_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN); |
992 } | 990 } |
993 template <unsigned digits10, mpfr_allocation_type AllocationType> | 991 template <unsigned digits10, mpfr_allocation_type AllocationType> |
994 inline void eval_subtract(mpfr_float_backend<digits10, AllocationType>& result, long i) | 992 inline void eval_subtract(mpfr_float_backend<digits10, AllocationType>& result, long i) |
995 { | 993 { |
996 if(i > 0) | 994 if(i > 0) |
997 mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN); | 995 mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN); |
998 else | 996 else |
999 mpfr_add_ui(result.data(), result.data(), std::abs(i), GMP_RNDN); | 997 mpfr_add_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN); |
1000 } | 998 } |
1001 template <unsigned digits10, mpfr_allocation_type AllocationType> | 999 template <unsigned digits10, mpfr_allocation_type AllocationType> |
1002 inline void eval_multiply(mpfr_float_backend<digits10, AllocationType>& result, long i) | 1000 inline void eval_multiply(mpfr_float_backend<digits10, AllocationType>& result, long i) |
1003 { | 1001 { |
1004 mpfr_mul_ui(result.data(), result.data(), std::abs(i), GMP_RNDN); | 1002 mpfr_mul_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN); |
1005 if(i < 0) | 1003 if(i < 0) |
1006 mpfr_neg(result.data(), result.data(), GMP_RNDN); | 1004 mpfr_neg(result.data(), result.data(), GMP_RNDN); |
1007 } | 1005 } |
1008 template <unsigned digits10, mpfr_allocation_type AllocationType> | 1006 template <unsigned digits10, mpfr_allocation_type AllocationType> |
1009 inline void eval_divide(mpfr_float_backend<digits10, AllocationType>& result, long i) | 1007 inline void eval_divide(mpfr_float_backend<digits10, AllocationType>& result, long i) |
1010 { | 1008 { |
1011 mpfr_div_ui(result.data(), result.data(), std::abs(i), GMP_RNDN); | 1009 mpfr_div_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN); |
1012 if(i < 0) | 1010 if(i < 0) |
1013 mpfr_neg(result.data(), result.data(), GMP_RNDN); | 1011 mpfr_neg(result.data(), result.data(), GMP_RNDN); |
1014 } | 1012 } |
1015 // | 1013 // |
1016 // Specialised 3 arg versions of the basic operators: | 1014 // Specialised 3 arg versions of the basic operators: |
1027 } | 1025 } |
1028 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1026 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1029 inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y) | 1027 inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y) |
1030 { | 1028 { |
1031 if(y < 0) | 1029 if(y < 0) |
1032 mpfr_sub_ui(a.data(), x.data(), -y, GMP_RNDN); | 1030 mpfr_sub_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN); |
1033 else | 1031 else |
1034 mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN); | 1032 mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN); |
1035 } | 1033 } |
1036 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1034 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1037 inline void eval_add(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y) | 1035 inline void eval_add(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y) |
1041 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1039 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1042 inline void eval_add(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y) | 1040 inline void eval_add(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y) |
1043 { | 1041 { |
1044 if(x < 0) | 1042 if(x < 0) |
1045 { | 1043 { |
1046 mpfr_ui_sub(a.data(), -x, y.data(), GMP_RNDN); | 1044 mpfr_ui_sub(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data(), GMP_RNDN); |
1047 mpfr_neg(a.data(), a.data(), GMP_RNDN); | 1045 mpfr_neg(a.data(), a.data(), GMP_RNDN); |
1048 } | 1046 } |
1049 else | 1047 else |
1050 mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN); | 1048 mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN); |
1051 } | 1049 } |
1061 } | 1059 } |
1062 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1060 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1063 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y) | 1061 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y) |
1064 { | 1062 { |
1065 if(y < 0) | 1063 if(y < 0) |
1066 mpfr_add_ui(a.data(), x.data(), -y, GMP_RNDN); | 1064 mpfr_add_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN); |
1067 else | 1065 else |
1068 mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN); | 1066 mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN); |
1069 } | 1067 } |
1070 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1068 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1071 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y) | 1069 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y) |
1075 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1073 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1076 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y) | 1074 inline void eval_subtract(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y) |
1077 { | 1075 { |
1078 if(x < 0) | 1076 if(x < 0) |
1079 { | 1077 { |
1080 mpfr_add_ui(a.data(), y.data(), -x, GMP_RNDN); | 1078 mpfr_add_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x), GMP_RNDN); |
1081 mpfr_neg(a.data(), a.data(), GMP_RNDN); | 1079 mpfr_neg(a.data(), a.data(), GMP_RNDN); |
1082 } | 1080 } |
1083 else | 1081 else |
1084 mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN); | 1082 mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN); |
1085 } | 1083 } |
1100 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1098 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1101 inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y) | 1099 inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y) |
1102 { | 1100 { |
1103 if(y < 0) | 1101 if(y < 0) |
1104 { | 1102 { |
1105 mpfr_mul_ui(a.data(), x.data(), -y, GMP_RNDN); | 1103 mpfr_mul_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN); |
1106 a.negate(); | 1104 a.negate(); |
1107 } | 1105 } |
1108 else | 1106 else |
1109 mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN); | 1107 mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN); |
1110 } | 1108 } |
1116 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1114 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1117 inline void eval_multiply(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y) | 1115 inline void eval_multiply(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y) |
1118 { | 1116 { |
1119 if(x < 0) | 1117 if(x < 0) |
1120 { | 1118 { |
1121 mpfr_mul_ui(a.data(), y.data(), -x, GMP_RNDN); | 1119 mpfr_mul_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x), GMP_RNDN); |
1122 mpfr_neg(a.data(), a.data(), GMP_RNDN); | 1120 mpfr_neg(a.data(), a.data(), GMP_RNDN); |
1123 } | 1121 } |
1124 else | 1122 else |
1125 mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN); | 1123 mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN); |
1126 } | 1124 } |
1138 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1136 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1139 inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y) | 1137 inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y) |
1140 { | 1138 { |
1141 if(y < 0) | 1139 if(y < 0) |
1142 { | 1140 { |
1143 mpfr_div_ui(a.data(), x.data(), -y, GMP_RNDN); | 1141 mpfr_div_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN); |
1144 a.negate(); | 1142 a.negate(); |
1145 } | 1143 } |
1146 else | 1144 else |
1147 mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN); | 1145 mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN); |
1148 } | 1146 } |
1154 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> | 1152 template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2> |
1155 inline void eval_divide(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y) | 1153 inline void eval_divide(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y) |
1156 { | 1154 { |
1157 if(x < 0) | 1155 if(x < 0) |
1158 { | 1156 { |
1159 mpfr_ui_div(a.data(), -x, y.data(), GMP_RNDN); | 1157 mpfr_ui_div(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data(), GMP_RNDN); |
1160 mpfr_neg(a.data(), a.data(), GMP_RNDN); | 1158 mpfr_neg(a.data(), a.data(), GMP_RNDN); |
1161 } | 1159 } |
1162 else | 1160 else |
1163 mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN); | 1161 mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN); |
1164 } | 1162 } |