3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-24 13:23:37 +01:00

arrays: clean dead code

This commit is contained in:
Olivier Parcollet 2013-10-21 10:32:59 +02:00
parent 9002c1e456
commit 445f7d42e1
2 changed files with 3 additions and 81 deletions

View File

@ -24,9 +24,6 @@
#include "../indexmaps/cuboid/foreach.hpp"
#include "../storages/memcopy.hpp"
// two ways of doing things... optimal one depends on compiler ? To be checked...
#define TRIQS_ARRAYS_ASSIGN_ISP_WITH_FOREACH
namespace triqs { namespace arrays {
namespace Tag {struct indexmap_storage_pair{}; }// defined here since needed below...
@ -97,18 +94,7 @@ namespace triqs { namespace arrays {
if (( (OP=='E') && indexmaps::raw_copy_possible(lhs.indexmap(), rhs.indexmap()))) {
storages::memcopy(lhs.data_start(), rhs.data_start(), rhs.indexmap().domain().number_of_elements());
}
else {
#ifdef TRIQS_ARRAYS_ASSIGN_ISP_WITH_FOREACH
foreach(lhs,*this);
//indexmaps::foreach_v(*this,lhs);
#else
typename RHS::const_iterator it_rhs = rhs.begin();
typedef typename RHS::const_iterator::indexmap_iterator_type RHS_mapit;
typedef typename LHS::indexmap_type::iterator IT;
iterator_adapter<false, IT, typename LHS::storage_type > it_lhs(lhs.indexmap(),lhs.storage());
for (;it_lhs; ++it_lhs, ++it_rhs) { assert(it_rhs); _ops_<value_type, typename RHS::value_type, OP>::invoke(*it_lhs , *it_rhs); }
#endif
}
else { foreach(lhs,*this); }
}
};
@ -119,17 +105,9 @@ namespace triqs { namespace arrays {
TRIQS_REJECT_MATRIX_COMPOUND_MUL_DIV_NON_SCALAR;
typedef typename LHS::value_type value_type;
LHS & lhs; const RHS & rhs;
//value_type & restrict p;
impl(LHS & lhs_, const RHS & rhs_): lhs(lhs_), rhs(rhs_) {} //, p(*(lhs_.data_start())) {}
template<typename ... Args> void operator()(Args const & ... args) const { _ops_<value_type, typename RHS::value_type, OP>::invoke(lhs(args...),rhs(args...));}
void invoke() {
#ifdef TRIQS_ARRAYS_ASSIGN_ISP_WITH_FOREACH
foreach(lhs,*this);
#else
typename LHS::storage_type & S(lhs.storage());
for (auto it= lhs.indexmap();it; ++it) _ops_<value_type, typename RHS::value_type, OP>::invoke(S[*it] , rhs[it.indices()] );
#endif
}
void invoke() { foreach(lhs,*this); }
};
// ----------------- assignment for scalar RHS, except some matrix case --------------------------------------------------
@ -138,17 +116,9 @@ namespace triqs { namespace arrays {
TRIQS_REJECT_ASSIGN_TO_CONST;
typedef typename LHS::value_type value_type;
LHS & lhs; const RHS & rhs;
//value_type & restrict p;
impl(LHS & lhs_, const RHS & rhs_): lhs(lhs_), rhs(rhs_){}//, p(*(lhs_.data_start())) {}
template<typename ... Args> void operator()(Args const & ...args) const {_ops_<value_type, RHS, OP>::invoke(lhs(args...), rhs);}
void invoke() {
#ifdef TRIQS_ARRAYS_ASSIGN_ISP_WITH_FOREACH
foreach(lhs,*this); // if contiguous : plain loop else foreach...
#else
typename LHS::storage_type & S(lhs.storage());
for (auto it = lhs.indexmap();it; ++it) _ops_<value_type, RHS, OP>::invoke(S[*it], rhs);
#endif
}
void invoke() { foreach(lhs,*this); }
};
// ----------------- assignment for scalar RHS for Matrices --------------------------------------------------
@ -162,7 +132,6 @@ namespace triqs { namespace arrays {
TRIQS_REJECT_ASSIGN_TO_CONST;
typedef typename LHS::value_type value_type;
LHS & lhs; const RHS & rhs;
//value_type & restrict p;
impl(LHS & lhs_, const RHS & rhs_): lhs(lhs_), rhs(rhs_){} //, p(*(lhs_.data_start())) {}
template<typename ... Args>
void operator()(Args const & ... args) const {_ops_<value_type, RHS, OP>::invoke(lhs(args...), (kronecker(args...) ? rhs : RHS()));}

View File

@ -195,8 +195,6 @@ namespace triqs { namespace arrays {
typedef typename ISPViewType<V2,IM2::domain_type::rank, OptionFlags, IM2::traversal_order_in_template, ViewTag, ForceBorrowed || StorageType::is_weak, is_const >::type type;
};
// simplify this ?
#ifndef TRIQS_ARRAYS_SLICE_DEFAUT_IS_SHARED
template<typename... Args> // non const version
typename boost::lazy_enable_if_c<
(!clef::is_any_lazy<Args...>::value) && (indexmaps::slicer<indexmap_type,Args...>::r_type::domain_type::rank!=0) && (!IsConst)
@ -259,51 +257,6 @@ namespace triqs { namespace arrays {
return make_expr_call(std::move(*this),args...);
}
#else
template<typename... Args> // non const version
typename boost::lazy_enable_if_c<
(!clef::is_any_lazy<Args...>::value) && (indexmaps::slicer<indexmap_type,Args...>::r_type::domain_type::rank!=0)
, result_of_call_as_view<false,false,Args...>
>::type // enable_if
operator()(Args const & ... args) {
return typename result_of_call_as_view<false,false,Args...>::type ( indexmaps::slicer<indexmap_type,Args...>::invoke(indexmap_,args...), storage()); }
template<typename... Args> // const version
typename boost::lazy_enable_if_c<
(!clef::is_any_lazy<Args...>::value) && (indexmaps::slicer<indexmap_type,Args...>::r_type::domain_type::rank!=0)
, result_of_call_as_view<true,false,Args...>
>::type // enable_if
operator()(Args const & ... args) const {
return typename result_of_call_as_view<true,false,Args...>::type ( indexmaps::slicer<indexmap_type,Args...>::invoke(indexmap_,args...), storage()); }
/// Equivalent to make_view
//typename ISPViewType<typename std::add_const<value_type>::type,domain_type::rank, OptionFlags, TraversalOrder, ViewTag >::type
typename ISPViewType<value_type,domain_type::rank, OptionFlags, TraversalOrder, ViewTag, false >::type
operator()() const { return *this; }
typename ISPViewType<value_type,domain_type::rank, OptionFlags, TraversalOrder, ViewTag, false >::type
operator()() { return *this; }
// Interaction with the CLEF library : calling with any clef expression as argument build a new clef expression
// NB : this is ok because indexmap_storage_pair has a shallow copy constructor ...
// Correction : no copy, just a ref...
// so A(i_) if A is an array will NOT copy the data....
template< typename... Args>
typename clef::_result_of::make_expr_call<indexmap_storage_pair const &,Args...>::type
operator()( Args&&... args ) const {
static_assert(sizeof...(Args) <= indexmap_type::rank, "Incorrect number of variable in call");// not perfect : ellipsis ...
return make_expr_call(*this,args...);
}
template< typename... Args>
typename clef::_result_of::make_expr_call<indexmap_storage_pair &,Args...>::type
operator()( Args&&... args ) {
static_assert(sizeof...(Args) <= indexmap_type::rank, "Incorrect number of variable in call");// not perfect : ellipsis ...
return make_expr_call(*this,args...);
}
#endif
template<typename Fnt> friend void triqs_clef_auto_assign (indexmap_storage_pair & x, Fnt f) { assign_foreach(x,f);}
// ------------------------------- Iterators --------------------------------------------