]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright 2013 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) | |
5 | ||
6 | #ifndef BOOST_MP_UBLAS_HPP | |
7 | #define BOOST_MP_UBLAS_HPP | |
8 | ||
9 | namespace boost { namespace numeric { namespace ublas { | |
10 | ||
92f5a8d4 | 11 | template <class V> |
7c673cae FG |
12 | class sparse_vector_element; |
13 | ||
14 | template <class V, class Backend, multiprecision::expression_template_option ExpressionTemplates> | |
92f5a8d4 | 15 | inline bool operator==(const sparse_vector_element<V>& a, const ::boost::multiprecision::number<Backend, ExpressionTemplates>& b) |
7c673cae FG |
16 | { |
17 | typedef typename sparse_vector_element<V>::const_reference ref_type; | |
18 | return static_cast<ref_type>(a) == b; | |
19 | } | |
20 | ||
92f5a8d4 | 21 | template <class X, class Y> |
7c673cae FG |
22 | struct promote_traits; |
23 | ||
24 | template <class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1, class Backend2, boost::multiprecision::expression_template_option ExpressionTemplates2> | |
25 | struct promote_traits<boost::multiprecision::number<Backend1, ExpressionTemplates1>, boost::multiprecision::number<Backend2, ExpressionTemplates2> > | |
26 | { | |
27 | typedef boost::multiprecision::number<Backend1, ExpressionTemplates1> number1_t; | |
28 | typedef boost::multiprecision::number<Backend2, ExpressionTemplates2> number2_t; | |
29 | typedef typename mpl::if_c< | |
92f5a8d4 TL |
30 | is_convertible<number1_t, number2_t>::value && !is_convertible<number2_t, number1_t>::value, |
31 | number2_t, number1_t>::type promote_type; | |
7c673cae FG |
32 | }; |
33 | ||
34 | template <class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1, class Arithmetic> | |
35 | struct promote_traits<boost::multiprecision::number<Backend1, ExpressionTemplates1>, Arithmetic> | |
36 | { | |
37 | typedef boost::multiprecision::number<Backend1, ExpressionTemplates1> promote_type; | |
38 | }; | |
39 | ||
40 | template <class Arithmetic, class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1> | |
41 | struct promote_traits<Arithmetic, boost::multiprecision::number<Backend1, ExpressionTemplates1> > | |
42 | { | |
43 | typedef boost::multiprecision::number<Backend1, ExpressionTemplates1> promote_type; | |
44 | }; | |
45 | ||
46 | template <class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1, class tag, class Arg1, class Arg2, class Arg3, class Arg4> | |
47 | struct promote_traits<boost::multiprecision::number<Backend1, ExpressionTemplates1>, boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> > | |
48 | { | |
92f5a8d4 | 49 | typedef boost::multiprecision::number<Backend1, ExpressionTemplates1> number1_t; |
7c673cae | 50 | typedef boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> expression_type; |
92f5a8d4 TL |
51 | typedef typename expression_type::result_type number2_t; |
52 | typedef typename promote_traits<number1_t, number2_t>::promote_type promote_type; | |
7c673cae FG |
53 | }; |
54 | ||
55 | template <class tag, class Arg1, class Arg2, class Arg3, class Arg4, class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1> | |
56 | struct promote_traits<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, boost::multiprecision::number<Backend1, ExpressionTemplates1> > | |
57 | { | |
92f5a8d4 | 58 | typedef boost::multiprecision::number<Backend1, ExpressionTemplates1> number1_t; |
7c673cae | 59 | typedef boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> expression_type; |
92f5a8d4 TL |
60 | typedef typename expression_type::result_type number2_t; |
61 | typedef typename promote_traits<number1_t, number2_t>::promote_type promote_type; | |
7c673cae FG |
62 | }; |
63 | ||
64 | template <class tag, class Arg1, class Arg2, class Arg3, class Arg4, class tagb, class Arg1b, class Arg2b, class Arg3b, class Arg4b> | |
65 | struct promote_traits<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, boost::multiprecision::detail::expression<tagb, Arg1b, Arg2b, Arg3b, Arg4b> > | |
66 | { | |
92f5a8d4 TL |
67 | typedef boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> expression1_t; |
68 | typedef typename expression1_t::result_type number1_t; | |
7c673cae | 69 | typedef boost::multiprecision::detail::expression<tagb, Arg1b, Arg2b, Arg3b, Arg4b> expression2_t; |
92f5a8d4 | 70 | typedef typename expression2_t::result_type number2_t; |
7c673cae FG |
71 | }; |
72 | ||
92f5a8d4 | 73 | }}} // namespace boost::numeric::ublas |
7c673cae FG |
74 | |
75 | #endif |