Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:24

0001 ///////////////////////////////////////////////////////////////////////////////
0002 //  Copyright 2013 John Maddock. Distributed under the Boost
0003 //  Software License, Version 1.0. (See accompanying file
0004 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_MP_UBLAS_INTEROP_HPP
0007 #define BOOST_MP_UBLAS_INTEROP_HPP
0008 
0009 namespace boost { namespace numeric { namespace ublas {
0010 
0011 template <class V>
0012 class sparse_vector_element;
0013 
0014 template <class V, class Backend, multiprecision::expression_template_option ExpressionTemplates>
0015 inline bool operator==(const sparse_vector_element<V>& a, const ::boost::multiprecision::number<Backend, ExpressionTemplates>& b)
0016 {
0017    using ref_type = typename sparse_vector_element<V>::const_reference;
0018    return static_cast<ref_type>(a) == b;
0019 }
0020 
0021 template <class X, class Y>
0022 struct promote_traits;
0023 
0024 template <class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1, class Backend2, boost::multiprecision::expression_template_option ExpressionTemplates2>
0025 struct promote_traits<boost::multiprecision::number<Backend1, ExpressionTemplates1>, boost::multiprecision::number<Backend2, ExpressionTemplates2> >
0026 {
0027    using number1_t = boost::multiprecision::number<Backend1, ExpressionTemplates1>;
0028    using number2_t = boost::multiprecision::number<Backend2, ExpressionTemplates2>;
0029    using promote_type = typename std::conditional<
0030        std::is_convertible<number1_t, number2_t>::value && !std::is_convertible<number2_t, number1_t>::value,
0031        number2_t, number1_t>::type;
0032 };
0033 
0034 template <class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1, class Arithmetic>
0035 struct promote_traits<boost::multiprecision::number<Backend1, ExpressionTemplates1>, Arithmetic>
0036 {
0037    using promote_type = boost::multiprecision::number<Backend1, ExpressionTemplates1>;
0038 };
0039 
0040 template <class Arithmetic, class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1>
0041 struct promote_traits<Arithmetic, boost::multiprecision::number<Backend1, ExpressionTemplates1> >
0042 {
0043    using promote_type = boost::multiprecision::number<Backend1, ExpressionTemplates1>;
0044 };
0045 
0046 template <class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1, class tag, class Arg1, class Arg2, class Arg3, class Arg4>
0047 struct promote_traits<boost::multiprecision::number<Backend1, ExpressionTemplates1>, boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> >
0048 {
0049    using number1_t = boost::multiprecision::number<Backend1, ExpressionTemplates1>         ;
0050    using expression_type = boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>;
0051    using number2_t = typename expression_type::result_type                                 ;
0052    using promote_type = typename promote_traits<number1_t, number2_t>::promote_type           ;
0053 };
0054 
0055 template <class tag, class Arg1, class Arg2, class Arg3, class Arg4, class Backend1, boost::multiprecision::expression_template_option ExpressionTemplates1>
0056 struct promote_traits<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, boost::multiprecision::number<Backend1, ExpressionTemplates1> >
0057 {
0058    using number1_t = boost::multiprecision::number<Backend1, ExpressionTemplates1>         ;
0059    using expression_type = boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>;
0060    using number2_t = typename expression_type::result_type                                 ;
0061    using promote_type = typename promote_traits<number1_t, number2_t>::promote_type           ;
0062 };
0063 
0064 template <class tag, class Arg1, class Arg2, class Arg3, class Arg4, class tagb, class Arg1b, class Arg2b, class Arg3b, class Arg4b>
0065 struct promote_traits<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, boost::multiprecision::detail::expression<tagb, Arg1b, Arg2b, Arg3b, Arg4b> >
0066 {
0067    using expression1_t = boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>     ;
0068    using number1_t = typename expression1_t::result_type                                        ;
0069    using expression2_t = boost::multiprecision::detail::expression<tagb, Arg1b, Arg2b, Arg3b, Arg4b>;
0070    using number2_t = typename expression2_t::result_type                                        ;
0071 };
0072 
0073 }}} // namespace boost::numeric::ublas
0074 
0075 #endif