diff options
Diffstat (limited to 'boost/multiprecision/detail')
-rw-r--r-- | boost/multiprecision/detail/default_ops.hpp | 73 | ||||
-rw-r--r-- | boost/multiprecision/detail/float_string_cvt.hpp | 4 | ||||
-rw-r--r-- | boost/multiprecision/detail/number_base.hpp | 34 | ||||
-rw-r--r-- | boost/multiprecision/detail/number_compare.hpp | 24 |
4 files changed, 106 insertions, 29 deletions
diff --git a/boost/multiprecision/detail/default_ops.hpp b/boost/multiprecision/detail/default_ops.hpp index 97ae1a279d..bf51a58295 100644 --- a/boost/multiprecision/detail/default_ops.hpp +++ b/boost/multiprecision/detail/default_ops.hpp @@ -1561,6 +1561,71 @@ inline long long llround(const number<T, ExpressionTemplates>& v) return llround(v, boost::math::policies::policy<>()); } #endif +// +// frexp does not return an expression template since we require the +// integer argument to be evaluated even if the returned value is +// not assigned to anything... +// +template <class T, expression_template_option ExpressionTemplates> +inline typename enable_if_c<number_category<T>::value == number_kind_floating_point, number<T, ExpressionTemplates> >::type frexp(const number<T, ExpressionTemplates>& v, short* pint) +{ + using default_ops::eval_frexp; + number<T, ExpressionTemplates> result; + eval_frexp(result.backend(), v.backend(), pint); + return BOOST_MP_MOVE(result); +} +template <class tag, class A1, class A2, class A3, class A4> +inline typename enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_floating_point, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::type + frexp(const detail::expression<tag, A1, A2, A3, A4>& v, short* pint) +{ + typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type; + return BOOST_MP_MOVE(frexp(static_cast<number_type>(v), pint)); +} +template <class T, expression_template_option ExpressionTemplates> +inline typename enable_if_c<number_category<T>::value == number_kind_floating_point, number<T, ExpressionTemplates> >::type frexp(const number<T, ExpressionTemplates>& v, int* pint) +{ + using default_ops::eval_frexp; + number<T, ExpressionTemplates> result; + eval_frexp(result.backend(), v.backend(), pint); + return BOOST_MP_MOVE(result); +} +template <class tag, class A1, class A2, class A3, class A4> +inline typename enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_floating_point, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::type +frexp(const detail::expression<tag, A1, A2, A3, A4>& v, int* pint) +{ + typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type; + return BOOST_MP_MOVE(frexp(static_cast<number_type>(v), pint)); +} +template <class T, expression_template_option ExpressionTemplates> +inline typename enable_if_c<number_category<T>::value == number_kind_floating_point, number<T, ExpressionTemplates> >::type frexp(const number<T, ExpressionTemplates>& v, long* pint) +{ + using default_ops::eval_frexp; + number<T, ExpressionTemplates> result; + eval_frexp(result.backend(), v.backend(), pint); + return BOOST_MP_MOVE(result); +} +template <class tag, class A1, class A2, class A3, class A4> +inline typename enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_floating_point, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::type +frexp(const detail::expression<tag, A1, A2, A3, A4>& v, long* pint) +{ + typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type; + return BOOST_MP_MOVE(frexp(static_cast<number_type>(v), pint)); +} +template <class T, expression_template_option ExpressionTemplates> +inline typename enable_if_c<number_category<T>::value == number_kind_floating_point, number<T, ExpressionTemplates> >::type frexp(const number<T, ExpressionTemplates>& v, long long* pint) +{ + using default_ops::eval_frexp; + number<T, ExpressionTemplates> result; + eval_frexp(result.backend(), v.backend(), pint); + return BOOST_MP_MOVE(result); +} +template <class tag, class A1, class A2, class A3, class A4> +inline typename enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_floating_point, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::type +frexp(const detail::expression<tag, A1, A2, A3, A4>& v, long long* pint) +{ + typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type; + return BOOST_MP_MOVE(frexp(static_cast<number_type>(v), pint)); +} template <class B, expression_template_option ExpressionTemplates> inline typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, ExpressionTemplates> >::type @@ -2034,13 +2099,13 @@ UNARY_OP_FUNCTOR(sinh, number_kind_floating_point) UNARY_OP_FUNCTOR(tanh, number_kind_floating_point) HETERO_BINARY_OP_FUNCTOR(ldexp, short, number_kind_floating_point) -HETERO_BINARY_OP_FUNCTOR(frexp, short*, number_kind_floating_point) +//HETERO_BINARY_OP_FUNCTOR(frexp, short*, number_kind_floating_point) HETERO_BINARY_OP_FUNCTOR_B(ldexp, int, number_kind_floating_point) -HETERO_BINARY_OP_FUNCTOR_B(frexp, int*, number_kind_floating_point) +//HETERO_BINARY_OP_FUNCTOR_B(frexp, int*, number_kind_floating_point) HETERO_BINARY_OP_FUNCTOR_B(ldexp, long, number_kind_floating_point) -HETERO_BINARY_OP_FUNCTOR_B(frexp, long*, number_kind_floating_point) +//HETERO_BINARY_OP_FUNCTOR_B(frexp, long*, number_kind_floating_point) HETERO_BINARY_OP_FUNCTOR_B(ldexp, long long, number_kind_floating_point) -HETERO_BINARY_OP_FUNCTOR_B(frexp, long long*, number_kind_floating_point) +//HETERO_BINARY_OP_FUNCTOR_B(frexp, long long*, number_kind_floating_point) BINARY_OP_FUNCTOR(pow, number_kind_floating_point) BINARY_OP_FUNCTOR(fmod, number_kind_floating_point) BINARY_OP_FUNCTOR(atan2, number_kind_floating_point) diff --git a/boost/multiprecision/detail/float_string_cvt.hpp b/boost/multiprecision/detail/float_string_cvt.hpp index 7ce246a240..9b5774f1af 100644 --- a/boost/multiprecision/detail/float_string_cvt.hpp +++ b/boost/multiprecision/detail/float_string_cvt.hpp @@ -24,7 +24,7 @@ inline void round_string_up_at(std::string& s, int pos, I& expon) // if(pos < 0) { - s.insert(0, 1, '1'); + s.insert(static_cast<std::string::size_type>(0), 1, '1'); s.erase(s.size() - 1); ++expon; } @@ -182,7 +182,7 @@ std::string convert_to_string(Backend b, std::streamsize digits, std::ios_base:: } BOOST_ASSERT(org_digits >= 0); if(isneg) - result.insert(0, 1, '-'); + result.insert(static_cast<std::string::size_type>(0), 1, '-'); format_float_string(result, expon, org_digits, f, iszero); return result; diff --git a/boost/multiprecision/detail/number_base.hpp b/boost/multiprecision/detail/number_base.hpp index 9353082d37..09c86e6ce0 100644 --- a/boost/multiprecision/detail/number_base.hpp +++ b/boost/multiprecision/detail/number_base.hpp @@ -145,6 +145,18 @@ struct canonical_imp<number<B, et_off>, Backend, Tag> { typedef B type; }; +#ifdef __SUNPRO_CC +template <class B, class Backend> +struct canonical_imp<number<B, et_on>, Backend, mpl::int_<3> > +{ + typedef B type; +}; +template <class B, class Backend> +struct canonical_imp<number<B, et_off>, Backend, mpl::int_<3> > +{ + typedef B type; +}; +#endif template <class Val, class Backend> struct canonical_imp<Val, Backend, mpl::int_<0> > { @@ -606,9 +618,9 @@ void format_float_string(S& str, boost::intmax_t my_exp, boost::intmax_t digits, } } if(neg) - str.insert(0, 1, '-'); + str.insert(static_cast<std::string::size_type>(0), 1, '-'); else if(showpos) - str.insert(0, 1, '+'); + str.insert(static_cast<std::string::size_type>(0), 1, '+'); return; } @@ -653,8 +665,8 @@ void format_float_string(S& str, boost::intmax_t my_exp, boost::intmax_t digits, { if(my_exp < 0) { - str.insert(0, static_cast<std::string::size_type>(-1 - my_exp), '0'); - str.insert(0, "0."); + str.insert(static_cast<std::string::size_type>(0), static_cast<std::string::size_type>(-1 - my_exp), '0'); + str.insert(static_cast<std::string::size_type>(0), "0."); } else { @@ -679,21 +691,21 @@ void format_float_string(S& str, boost::intmax_t my_exp, boost::intmax_t digits, BOOST_MP_USING_ABS // Scientific format: if(showpoint || (str.size() > 1)) - str.insert(1, 1, '.'); - str.append(1, 'e'); + str.insert(static_cast<std::string::size_type>(1u), 1, '.'); + str.append(static_cast<std::string::size_type>(1u), 'e'); S e = boost::lexical_cast<S>(abs(my_exp)); if(e.size() < BOOST_MP_MIN_EXPONENT_DIGITS) - e.insert(0, BOOST_MP_MIN_EXPONENT_DIGITS-e.size(), '0'); + e.insert(static_cast<std::string::size_type>(0), BOOST_MP_MIN_EXPONENT_DIGITS - e.size(), '0'); if(my_exp < 0) - e.insert(0, 1, '-'); + e.insert(static_cast<std::string::size_type>(0), 1, '-'); else - e.insert(0, 1, '+'); + e.insert(static_cast<std::string::size_type>(0), 1, '+'); str.append(e); } if(neg) - str.insert(0, 1, '-'); + str.insert(static_cast<std::string::size_type>(0), 1, '-'); else if(showpos) - str.insert(0, 1, '+'); + str.insert(static_cast<std::string::size_type>(0), 1, '+'); } template <class V> diff --git a/boost/multiprecision/detail/number_compare.hpp b/boost/multiprecision/detail/number_compare.hpp index bd01c3d6bb..d1606ad73d 100644 --- a/boost/multiprecision/detail/number_compare.hpp +++ b/boost/multiprecision/detail/number_compare.hpp @@ -93,8 +93,8 @@ struct is_valid_mixed_compare<expression<tag, Arg1, Arg2, Arg3, Arg4>, number<B, } -template <class Backend, expression_template_option ExpressionTemplates> -inline bool operator == (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b) +template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2> +inline bool operator == (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b) { using default_ops::eval_eq; return eval_eq(a.backend(), b.backend()); @@ -141,8 +141,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A return eval_eq(t.backend(), t2.backend()); } -template <class Backend, expression_template_option ExpressionTemplates> -inline bool operator != (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b) +template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2> +inline bool operator != (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b) { using default_ops::eval_eq; return !eval_eq(a.backend(), b.backend()); @@ -189,8 +189,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A return !eval_eq(t.backend(), t2.backend()); } -template <class Backend, expression_template_option ExpressionTemplates> -inline bool operator < (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b) +template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2> +inline bool operator < (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b) { using default_ops::eval_lt; return eval_lt(a.backend(), b.backend()); @@ -237,8 +237,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A return eval_lt(t.backend(), t2.backend()); } -template <class Backend, expression_template_option ExpressionTemplates> -inline bool operator > (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b) +template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2> +inline bool operator > (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b) { using default_ops::eval_gt; return eval_gt(a.backend(), b.backend()); @@ -285,8 +285,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A return eval_gt(t.backend(), t2.backend()); } -template <class Backend, expression_template_option ExpressionTemplates> -inline bool operator <= (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b) +template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2> +inline bool operator <= (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b) { using default_ops::eval_gt; return !eval_gt(a.backend(), b.backend()); @@ -333,8 +333,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A return !eval_gt(t.backend(), t2.backend()); } -template <class Backend, expression_template_option ExpressionTemplates> -inline bool operator >= (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b) +template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2> +inline bool operator >= (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b) { using default_ops::eval_lt; return !eval_lt(a.backend(), b.backend()); |