Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 // Copyright 2013 John Maddock. Distributed under the Boost
|
Chris@16
|
3 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5
|
Chris@16
|
6 #ifndef BOOST_MP_UBLAS_HPP
|
Chris@16
|
7 #define BOOST_MP_UBLAS_HPP
|
Chris@16
|
8
|
Chris@16
|
9 namespace boost { namespace numeric { namespace ublas {
|
Chris@16
|
10
|
Chris@16
|
11 template<class V>
|
Chris@16
|
12 class sparse_vector_element;
|
Chris@16
|
13
|
Chris@16
|
14 template <class V, class Backend, multiprecision::expression_template_option ExpressionTemplates>
|
Chris@16
|
15 inline bool operator == (const sparse_vector_element<V>& a, const ::boost::multiprecision::number<Backend, ExpressionTemplates>& b)
|
Chris@16
|
16 {
|
Chris@16
|
17 typedef typename sparse_vector_element<V>::const_reference ref_type;
|
Chris@16
|
18 return static_cast<ref_type>(a) == b;
|
Chris@16
|
19 }
|
Chris@16
|
20
|
Chris@16
|
21 template<class X, class Y>
|
Chris@16
|
22 struct promote_traits;
|
Chris@16
|
23
|
Chris@16
|
24 template <class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1, class Backend2, boost::multiprecision::expression_template_option ExpressionTemplates2>
|
Chris@16
|
25 struct promote_traits<boost::multiprecision::number<Backend1, ExpressionTemplates1>, boost::multiprecision::number<Backend2, ExpressionTemplates2> >
|
Chris@16
|
26 {
|
Chris@16
|
27 typedef boost::multiprecision::number<Backend1, ExpressionTemplates1> number1_t;
|
Chris@16
|
28 typedef boost::multiprecision::number<Backend2, ExpressionTemplates2> number2_t;
|
Chris@16
|
29 typedef typename mpl::if_c<
|
Chris@16
|
30 is_convertible<number1_t, number2_t>::value && !is_convertible<number2_t, number1_t>::value,
|
Chris@16
|
31 number2_t, number1_t
|
Chris@16
|
32 >::type promote_type;
|
Chris@16
|
33 };
|
Chris@16
|
34
|
Chris@16
|
35 template <class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1, class tag, class Arg1, class Arg2, class Arg3, class Arg4>
|
Chris@16
|
36 struct promote_traits<boost::multiprecision::number<Backend1, ExpressionTemplates1>, boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> >
|
Chris@16
|
37 {
|
Chris@16
|
38 typedef boost::multiprecision::number<Backend1, ExpressionTemplates1> number1_t;
|
Chris@16
|
39 typedef boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> expression_type;
|
Chris@16
|
40 typedef typename expression_type::result_type number2_t;
|
Chris@16
|
41 typedef typename promote_traits<number1_t, number2_t>::promote_type promote_type;
|
Chris@16
|
42 };
|
Chris@16
|
43
|
Chris@16
|
44 template <class tag, class Arg1, class Arg2, class Arg3, class Arg4, class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1>
|
Chris@16
|
45 struct promote_traits<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, boost::multiprecision::number<Backend1, ExpressionTemplates1> >
|
Chris@16
|
46 {
|
Chris@16
|
47 typedef boost::multiprecision::number<Backend1, ExpressionTemplates1> number1_t;
|
Chris@16
|
48 typedef boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> expression_type;
|
Chris@16
|
49 typedef typename expression_type::result_type number2_t;
|
Chris@16
|
50 typedef typename promote_traits<number1_t, number2_t>::promote_type promote_type;
|
Chris@16
|
51 };
|
Chris@16
|
52
|
Chris@16
|
53 template <class tag, class Arg1, class Arg2, class Arg3, class Arg4, class tagb, class Arg1b, class Arg2b, class Arg3b, class Arg4b>
|
Chris@16
|
54 struct promote_traits<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, boost::multiprecision::detail::expression<tagb, Arg1b, Arg2b, Arg3b, Arg4b> >
|
Chris@16
|
55 {
|
Chris@16
|
56 typedef boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> expression1_t;
|
Chris@16
|
57 typedef typename expression1_t::result_type number1_t;
|
Chris@16
|
58 typedef boost::multiprecision::detail::expression<tagb, Arg1b, Arg2b, Arg3b, Arg4b> expression2_t;
|
Chris@16
|
59 typedef typename expression2_t::result_type number2_t;
|
Chris@16
|
60 };
|
Chris@16
|
61
|
Chris@16
|
62 }}} // namespace
|
Chris@16
|
63
|
Chris@16
|
64 #endif
|
Chris@16
|
65
|