3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-25 13:53:40 +01:00

arrays: correction of value_type of matrix_expr

- forgot to correct the value_type of matrix_expr, and vector_expr
as was done long ago for arrays...
- also added cases for arrays until dim 10
- TODO : replace this trait in arrays with a tuple tools for any dim..
  not urgent.
This commit is contained in:
Olivier Parcollet 2014-01-30 20:26:19 +01:00
parent 91978da6db
commit eda6eb90a2
3 changed files with 10 additions and 2 deletions

View File

@ -31,6 +31,10 @@ namespace triqs { namespace arrays {
template<typename A> struct get_call_const_return_type<A,3> { typedef decltype(std::declval<A const>()(0,0,0)) type; }; template<typename A> struct get_call_const_return_type<A,3> { typedef decltype(std::declval<A const>()(0,0,0)) type; };
template<typename A> struct get_call_const_return_type<A,4> { typedef decltype(std::declval<A const>()(0,0,0,0)) type; }; template<typename A> struct get_call_const_return_type<A,4> { typedef decltype(std::declval<A const>()(0,0,0,0)) type; };
template<typename A> struct get_call_const_return_type<A,5> { typedef decltype(std::declval<A const>()(0,0,0,0,0)) type; }; template<typename A> struct get_call_const_return_type<A,5> { typedef decltype(std::declval<A const>()(0,0,0,0,0)) type; };
template<typename A> struct get_call_const_return_type<A,6> { typedef decltype(std::declval<A const>()(0,0,0,0,0,0)) type; };
template<typename A> struct get_call_const_return_type<A,7> { typedef decltype(std::declval<A const>()(0,0,0,0,0,0,0)) type; };
template<typename A> struct get_call_const_return_type<A,8> { typedef decltype(std::declval<A const>()(0,0,0,0,0,0,0,0)) type; };
template<typename A> struct get_call_const_return_type<A,9> { typedef decltype(std::declval<A const>()(0,0,0,0,0,0,0,0,0)) type; };
template<typename Tag, typename L, typename R> template<typename Tag, typename L, typename R>
struct array_expr : TRIQS_CONCEPT_TAG_NAME(ImmutableArray) { struct array_expr : TRIQS_CONCEPT_TAG_NAME(ImmutableArray) {

View File

@ -69,10 +69,12 @@ namespace triqs { namespace arrays {
typedef typename std::remove_reference<L>::type L_t; typedef typename std::remove_reference<L>::type L_t;
typedef typename std::remove_reference<R>::type R_t; typedef typename std::remove_reference<R>::type R_t;
static_assert( get_rank<R_t>::value==0 || get_rank<L_t>::value==0 || get_rank<L_t>::value == get_rank<R_t>::value, "rank mismatch in matrix operations"); static_assert( get_rank<R_t>::value==0 || get_rank<L_t>::value==0 || get_rank<L_t>::value == get_rank<R_t>::value, "rank mismatch in matrix operations");
typedef typename std::result_of<utility::operation<Tag>(typename L_t::value_type,typename R_t::value_type)>::type value_type; //typedef typename std::result_of<utility::operation<Tag>(typename L_t::value_type,typename R_t::value_type )>::type value_type;
typedef typename std::remove_cv< typename std::remove_reference<typename std::result_of<combine_domain(L_t,R_t)>::type>::type>::type domain_type; typedef typename std::remove_cv< typename std::remove_reference<typename std::result_of<combine_domain(L_t,R_t)>::type>::type>::type domain_type;
L l; R r; L l; R r;
using value_type = decltype(utility::operation<Tag>()(l(0, 0), r(0, 0)));
template<typename LL, typename RR> matrix_expr(LL && l_, RR && r_) : l(std::forward<LL>(l_)), r(std::forward<RR>(r_)) {} template<typename LL, typename RR> matrix_expr(LL && l_, RR && r_) : l(std::forward<LL>(l_)), r(std::forward<RR>(r_)) {}
domain_type domain() const { return combine_domain()(l,r); } domain_type domain() const { return combine_domain()(l,r); }

View File

@ -29,10 +29,12 @@ namespace triqs { namespace arrays {
typedef typename std::remove_reference<L>::type L_t; typedef typename std::remove_reference<L>::type L_t;
typedef typename std::remove_reference<R>::type R_t; typedef typename std::remove_reference<R>::type R_t;
static_assert( get_rank<R_t>::value==0 || get_rank<L_t>::value==0 || get_rank<L_t>::value == get_rank<R_t>::value, "rank mismatch in array operations"); static_assert( get_rank<R_t>::value==0 || get_rank<L_t>::value==0 || get_rank<L_t>::value == get_rank<R_t>::value, "rank mismatch in array operations");
typedef typename std::result_of<utility::operation<Tag>(typename L_t::value_type,typename R_t::value_type)>::type value_type; //typedef typename std::result_of<utility::operation<Tag>(typename L_t::value_type,typename R_t::value_type)>::type value_type;
typedef typename std::remove_reference<typename std::result_of<combine_domain(L_t,R_t)>::type>::type domain_type; typedef typename std::remove_reference<typename std::result_of<combine_domain(L_t,R_t)>::type>::type domain_type;
L l; R r; L l; R r;
using value_type = decltype(utility::operation<Tag>()(l(0), r(0)));
template<typename LL, typename RR> vector_expr(LL && l_, RR && r_) : l(std::forward<LL>(l_)), r(std::forward<RR>(r_)) {} template<typename LL, typename RR> vector_expr(LL && l_, RR && r_) : l(std::forward<LL>(l_)), r(std::forward<RR>(r_)) {}
domain_type domain() const { return combine_domain()(l,r); } domain_type domain() const { return combine_domain()(l,r); }