mirror of
https://github.com/triqs/dft_tools
synced 2025-01-12 05:58:18 +01:00
arrays : renaming concept name
CuboidArray <-> Array added make_cuboid_domain
This commit is contained in:
parent
ab5b95bc4e
commit
3b29e9bf9d
@ -37,7 +37,7 @@ namespace triqs { namespace arrays {
|
||||
storages::shared_block<ValueType, Borrowed>, Opt, TraversalOrder, Tag::array_view >
|
||||
|
||||
template <typename ValueType, int Rank, ull_t Opt, ull_t TraversalOrder, bool Borrowed>
|
||||
class array_view : Tag::array_view, TRIQS_CONCEPT_TAG_NAME(MutableCuboidArray), public IMPL_TYPE {
|
||||
class array_view : Tag::array_view, TRIQS_CONCEPT_TAG_NAME(MutableArray), public IMPL_TYPE {
|
||||
static_assert( Rank>0, " Rank must be >0");
|
||||
public:
|
||||
typedef typename IMPL_TYPE::indexmap_type indexmap_type;
|
||||
@ -99,7 +99,7 @@ namespace triqs { namespace arrays {
|
||||
storages::shared_block<ValueType>, Opt, TraversalOrder, Tag::array_view >
|
||||
|
||||
template <typename ValueType, int Rank, ull_t Opt, ull_t TraversalOrder>
|
||||
class array: Tag::array, TRIQS_CONCEPT_TAG_NAME(MutableCuboidArray), public IMPL_TYPE {
|
||||
class array: Tag::array, TRIQS_CONCEPT_TAG_NAME(MutableArray), public IMPL_TYPE {
|
||||
public:
|
||||
typedef typename IMPL_TYPE::value_type value_type;
|
||||
typedef typename IMPL_TYPE::storage_type storage_type;
|
||||
@ -139,7 +139,7 @@ namespace triqs { namespace arrays {
|
||||
* - a expression : e.g. array<int> A = B+ 2*C;
|
||||
*/
|
||||
template <typename T>
|
||||
array(const T & X, TYPE_ENABLE_IF(memory_layout<Rank>, ImmutableArray<T>) ml = memory_layout<Rank>(IMPL_TYPE::indexmap_type::traversal_order)):
|
||||
array(const T & X, TYPE_ENABLE_IF(memory_layout<Rank>, ImmutableCuboidArray<T>) ml = memory_layout<Rank>(IMPL_TYPE::indexmap_type::traversal_order)):
|
||||
IMPL_TYPE(indexmap_type(X.domain(),ml)) { triqs_arrays_assign_delegation(*this,X); }
|
||||
|
||||
#ifdef TRIQS_WITH_PYTHON_SUPPORT
|
||||
@ -189,7 +189,7 @@ namespace triqs { namespace arrays {
|
||||
*/
|
||||
template<typename RHS>
|
||||
array & operator=(const RHS & X) {
|
||||
static_assert(ImmutableArray<RHS>::value, "Assignment : RHS not supported");
|
||||
static_assert(ImmutableCuboidArray<RHS>::value, "Assignment : RHS not supported");
|
||||
IMPL_TYPE::resize(X.domain());
|
||||
triqs_arrays_assign_delegation(*this,X);
|
||||
return *this;
|
||||
|
@ -24,7 +24,7 @@
|
||||
namespace triqs { namespace arrays {
|
||||
|
||||
template<typename Tag, typename L, typename R>
|
||||
struct array_expr : TRIQS_CONCEPT_TAG_NAME(ImmutableCuboidArray) {
|
||||
struct array_expr : TRIQS_CONCEPT_TAG_NAME(ImmutableArray) {
|
||||
typedef typename keeper_type<L>::type L_t;
|
||||
typedef typename keeper_type<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");
|
||||
@ -43,7 +43,7 @@ namespace triqs { namespace arrays {
|
||||
|
||||
// a special case : the unary operator !
|
||||
|
||||
template<typename L> struct array_unary_m_expr : TRIQS_CONCEPT_TAG_NAME(ImmutableCuboidArray) {
|
||||
template<typename L> struct array_unary_m_expr : TRIQS_CONCEPT_TAG_NAME(ImmutableArray) {
|
||||
typedef typename keeper_type<L>::type L_t;
|
||||
typedef typename L_t::value_type value_type;
|
||||
typedef typename L_t::domain_type domain_type;
|
||||
@ -64,18 +64,18 @@ namespace triqs { namespace arrays {
|
||||
typename std::enable_if<TRAIT1<A1>::value && TRAIT2 <A2>::value, array_expr<tags::TAG, A1,A2>>::type\
|
||||
operator OP (A1 const & a1, A2 const & a2) { return array_expr<tags::TAG, A1,A2>(a1,a2);}
|
||||
|
||||
DEFINE_OPERATOR(plus, +, ImmutableCuboidArray,ImmutableCuboidArray);
|
||||
DEFINE_OPERATOR(minus, -, ImmutableCuboidArray,ImmutableCuboidArray);
|
||||
DEFINE_OPERATOR(multiplies, *, ImmutableCuboidArray,ImmutableCuboidArray);
|
||||
DEFINE_OPERATOR(multiplies, *, is_in_ZRC,ImmutableCuboidArray);
|
||||
DEFINE_OPERATOR(multiplies, *, ImmutableCuboidArray,is_in_ZRC);
|
||||
DEFINE_OPERATOR(divides, /, ImmutableCuboidArray,ImmutableCuboidArray);
|
||||
DEFINE_OPERATOR(divides, /, is_in_ZRC,ImmutableCuboidArray);
|
||||
DEFINE_OPERATOR(divides, /, ImmutableCuboidArray,is_in_ZRC);
|
||||
DEFINE_OPERATOR(plus, +, ImmutableArray,ImmutableArray);
|
||||
DEFINE_OPERATOR(minus, -, ImmutableArray,ImmutableArray);
|
||||
DEFINE_OPERATOR(multiplies, *, ImmutableArray,ImmutableArray);
|
||||
DEFINE_OPERATOR(multiplies, *, is_in_ZRC,ImmutableArray);
|
||||
DEFINE_OPERATOR(multiplies, *, ImmutableArray,is_in_ZRC);
|
||||
DEFINE_OPERATOR(divides, /, ImmutableArray,ImmutableArray);
|
||||
DEFINE_OPERATOR(divides, /, is_in_ZRC,ImmutableArray);
|
||||
DEFINE_OPERATOR(divides, /, ImmutableArray,is_in_ZRC);
|
||||
#undef DEFINE_OPERATOR
|
||||
|
||||
// the unary is special
|
||||
template<typename A1> typename std::enable_if<ImmutableCuboidArray<A1>::value, array_unary_m_expr<A1>>::type
|
||||
template<typename A1> typename std::enable_if<ImmutableArray<A1>::value, array_unary_m_expr<A1>>::type
|
||||
operator - (A1 const & a1) { return {a1};}
|
||||
|
||||
template<typename Expr > array<typename Expr::value_type, Expr::domain_type::rank>
|
||||
|
@ -48,7 +48,7 @@ namespace triqs { namespace arrays {
|
||||
|
||||
template<typename A, typename Enable = void> class m_result;
|
||||
|
||||
template<typename A> class m_result<A,typename boost::enable_if<ImmutableCuboidArray<A> >::type> : TRIQS_CONCEPT_TAG_NAME(ImmutableCuboidArray) {
|
||||
template<typename A> class m_result<A,typename boost::enable_if<ImmutableArray<A> >::type> : TRIQS_CONCEPT_TAG_NAME(ImmutableArray) {
|
||||
public:
|
||||
typedef typename std::result_of<F(typename A::value_type)>::type value_type;
|
||||
typedef typename A::domain_type domain_type;
|
||||
@ -88,7 +88,7 @@ namespace triqs { namespace arrays {
|
||||
template<typename This, typename A> struct result<This(A)> { typedef m_result<A> type;};
|
||||
|
||||
template< class A > m_result<A> operator()(A const & a) const {
|
||||
//static_assert( (ImmutableArray<A>::value), "map : A does not model ImmutableArray");
|
||||
//static_assert( (ImmutableCuboidArray<A>::value), "map : A does not model ImmutableCuboidArray");
|
||||
return m_result<A>(f,a);
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ namespace triqs { namespace arrays {
|
||||
map_impl(map_impl const &) = default;
|
||||
//map_impl(map_impl &&) = default;
|
||||
|
||||
template<class A, class B> class m_result : TRIQS_CONCEPT_TAG_NAME(ImmutableArray) {
|
||||
template<class A, class B> class m_result : TRIQS_CONCEPT_TAG_NAME(ImmutableCuboidArray) {
|
||||
static_assert( (std::is_same<typename A::domain_type, typename B::domain_type>::value), "type mismatch");
|
||||
public:
|
||||
typedef typename std::result_of<F(typename A::value_type,typename B::value_type)>::type value_type;
|
||||
@ -122,8 +122,8 @@ namespace triqs { namespace arrays {
|
||||
template<typename This, typename A,typename B> struct result<This(A,B)> { typedef m_result<A,B> type;};
|
||||
|
||||
template< class A, class B > m_result<A,B> operator()(A const & a, B const & b) {
|
||||
static_assert( (ImmutableArray<A>::value), "map1 : A does not model ImmutableArray");
|
||||
static_assert( (ImmutableArray<B>::value), "map1 : B does not model ImmutableArray");
|
||||
static_assert( (ImmutableCuboidArray<A>::value), "map1 : A does not model ImmutableCuboidArray");
|
||||
static_assert( (ImmutableCuboidArray<B>::value), "map1 : B does not model ImmutableCuboidArray");
|
||||
return m_result<A,B>(f,a,b);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace triqs { namespace arrays {
|
||||
|
||||
/// The array proxy
|
||||
template<typename ValueType, int Rank, int Rank_f = Rank >
|
||||
class array_proxy : TRIQS_CONCEPT_TAG_NAME(ImmutableCuboidArray), // WRONG ! IT does not yet implement [ ]
|
||||
class array_proxy : TRIQS_CONCEPT_TAG_NAME(ImmutableArray), // WRONG ! IT does not yet implement [ ]
|
||||
public sliceable_object < ValueType,
|
||||
h5::index_system<Rank,Rank_f>,
|
||||
array_proxy_option<Rank_f>,
|
||||
|
@ -114,7 +114,7 @@ namespace triqs { namespace arrays {
|
||||
|
||||
// ----------------- assignment for expressions RHS --------------------------------------------------
|
||||
template<typename LHS, typename RHS, char OP>
|
||||
struct impl<LHS,RHS,OP, ENABLE_IFC( ImmutableArray<RHS>::value && (!is_scalar_for<RHS,LHS>::value) && (!is_isp<RHS,LHS>::value)) > {
|
||||
struct impl<LHS,RHS,OP, ENABLE_IFC( ImmutableCuboidArray<RHS>::value && (!is_scalar_for<RHS,LHS>::value) && (!is_isp<RHS,LHS>::value)) > {
|
||||
TRIQS_REJECT_ASSIGN_TO_CONST;
|
||||
TRIQS_REJECT_MATRIX_COMPOUND_MUL_DIV_NON_SCALAR;
|
||||
typedef typename LHS::value_type value_type;
|
||||
|
@ -53,7 +53,7 @@ namespace triqs { namespace arrays {
|
||||
template <class V, int R, ull_t OptionFlags, ull_t TraversalOrder, class ViewTag, bool Borrowed > struct ISPViewType;
|
||||
|
||||
template <typename IndexMapType, typename StorageType, ull_t OptionFlags, ull_t TraversalOrder, typename ViewTag >
|
||||
class indexmap_storage_pair : Tag::indexmap_storage_pair, TRIQS_CONCEPT_TAG_NAME(MutableArray) {
|
||||
class indexmap_storage_pair : Tag::indexmap_storage_pair, TRIQS_CONCEPT_TAG_NAME(MutableCuboidArray) {
|
||||
|
||||
public :
|
||||
typedef typename StorageType::value_type value_type;
|
||||
|
@ -29,32 +29,21 @@
|
||||
namespace triqs { namespace arrays {
|
||||
namespace mpl=boost::mpl;
|
||||
|
||||
// The ImmutableArray concept
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT(ImmutableArray);
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MutableArray,(ImmutableArray));
|
||||
// The ImmutableCuboidArray concept
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT(ImmutableCuboidArray);
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MutableCuboidArray,(ImmutableCuboidArray));
|
||||
|
||||
/*template <class X> struct BCC_ImmutableArray {
|
||||
BOOST_CONCEPT_USAGE(BCC_ImmutableArray)
|
||||
{
|
||||
typename X::mc_weight_type r = i.Try(); // this is e.g. for a QMC move
|
||||
r = i.Accept();
|
||||
i.Reject();
|
||||
}
|
||||
private: X i;
|
||||
};
|
||||
*/
|
||||
|
||||
// The ImmutableCuboidArray concept
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(ImmutableCuboidArray,(ImmutableArray));
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MutableCuboidArray,(ImmutableCuboidArray)(MutableArray));
|
||||
// The ImmutableArray concept
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(ImmutableArray,(ImmutableCuboidArray));
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MutableArray,(ImmutableArray)(MutableCuboidArray));
|
||||
|
||||
// The ImmutableMatrix concept
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(ImmutableMatrix,(ImmutableArray));
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MutableMatrix,(ImmutableMatrix)(MutableArray));
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(ImmutableMatrix,(ImmutableCuboidArray));
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MutableMatrix,(ImmutableMatrix)(MutableCuboidArray));
|
||||
|
||||
// The ImmutableVector concept
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(ImmutableVector,(ImmutableArray));
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MutableVector,(ImmutableVector)(MutableArray));
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(ImmutableVector,(ImmutableCuboidArray));
|
||||
TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MutableVector,(ImmutableVector)(MutableCuboidArray));
|
||||
|
||||
namespace Tag { struct array{}; struct array_view {}; }
|
||||
template <typename T> struct is_array : std::is_base_of<Tag::array,T> {};
|
||||
|
@ -184,5 +184,11 @@ namespace PrettyPrint_details {
|
||||
template<typename A>
|
||||
void pretty_print (std::ostream & out, A const & a ) { PrettyPrint_details::print_impl<A::domain_type::rank,A>(out,a).print();}
|
||||
|
||||
}}}
|
||||
}
|
||||
|
||||
template<typename ... U>
|
||||
indexmaps::cuboid::domain_t<sizeof...(U)> make_cuboid_domain(U ... u) { return {u...};}
|
||||
//cuboid_array_domain<sizeof...(U)> make_cuboid_domain(U ... u) { return {u...};}
|
||||
|
||||
}}
|
||||
#endif
|
||||
|
@ -29,7 +29,7 @@ namespace triqs { namespace arrays {
|
||||
template<typename A> struct get_traversal_order<A,typename A::indexmap_type::has_traversal_order_tag> : std::integral_constant<ull_t, A::indexmap_type::traversal_order>{};
|
||||
|
||||
template <typename T, typename Function>
|
||||
typename std::enable_if<ImmutableArray<T>::value >::type
|
||||
typename std::enable_if<ImmutableCuboidArray<T>::value >::type
|
||||
foreach (T const & x, Function const & F) { indexmaps::cuboid::foreach<get_traversal_order<T>::value> (x.domain(), F); }
|
||||
|
||||
template <typename T, typename Function>
|
||||
@ -40,7 +40,7 @@ namespace triqs { namespace arrays {
|
||||
};
|
||||
|
||||
template <typename T, typename Function>
|
||||
typename std::enable_if<MutableArray<T>::value >::type
|
||||
typename std::enable_if<MutableCuboidArray<T>::value >::type
|
||||
assign_foreach (T & x, Function const & F) { indexmaps::cuboid::foreach<get_traversal_order<T>::value> (x.domain(),assign_foreach_adapter<T,Function>(x,F)); }
|
||||
|
||||
}}//namespace
|
||||
|
@ -26,7 +26,7 @@
|
||||
namespace triqs { namespace arrays {
|
||||
|
||||
template<typename Expr, int ... ph>
|
||||
class immutable_array_expr_impl : TRIQS_CONCEPT_TAG_NAME(ImmutableCuboidArray) {
|
||||
class immutable_array_expr_impl : TRIQS_CONCEPT_TAG_NAME(ImmutableArray) {
|
||||
template<int I> struct _si { typedef size_t type;};
|
||||
public :
|
||||
immutable_array_expr_impl(Expr e_, clef::pair<ph,range> ... p):
|
||||
@ -46,7 +46,7 @@ namespace triqs { namespace arrays {
|
||||
* \brief Makes a lazy immutable (cuboid) array from a simple expression and a set of range...
|
||||
* \param expr The lazy expression
|
||||
* \param i_=R i_ is a placeholder, R a range. The i_=R produce a pair of i_ and R , which is the parameter.
|
||||
* \return A lazy object implementing the ImmutableCuboidArray concept with the domain built from the ranges.
|
||||
* \return A lazy object implementing the ImmutableArray concept with the domain built from the ranges.
|
||||
*/
|
||||
template<typename Expr, int ... ph>
|
||||
immutable_array_expr_impl<Expr,ph...> make_immutable_array( Expr const & expr, clef::pair<ph,range> ... p) {
|
||||
@ -56,7 +56,7 @@ namespace triqs { namespace arrays {
|
||||
// if ones prefers to use a function...
|
||||
|
||||
template<typename Function, typename ... Ranges>
|
||||
class immutable_array_fun_impl : TRIQS_CONCEPT_TAG_NAME(ImmutableCuboidArray) {
|
||||
class immutable_array_fun_impl : TRIQS_CONCEPT_TAG_NAME(ImmutableArray) {
|
||||
template<int I> struct _si { typedef size_t type;};
|
||||
public :
|
||||
immutable_array_fun_impl(Function f, Ranges ... r) : f_(std::move(f)), dom_(make_shape(r.size()...)) {};
|
||||
|
@ -133,7 +133,7 @@ namespace triqs { namespace arrays {
|
||||
|
||||
/// Build a new matrix from X.domain() and fill it with by evaluating X. X can be :
|
||||
template <typename T>
|
||||
matrix(const T & X, TYPE_ENABLE_IF(memory_layout<2>, ImmutableArray<T>) ml = memory_layout<2>(IMPL_TYPE::indexmap_type::traversal_order)):
|
||||
matrix(const T & X, TYPE_ENABLE_IF(memory_layout<2>, ImmutableCuboidArray<T>) ml = memory_layout<2>(IMPL_TYPE::indexmap_type::traversal_order)):
|
||||
IMPL_TYPE(indexmap_type(X.domain(),ml)) { triqs_arrays_assign_delegation(*this,X); }
|
||||
|
||||
#ifdef TRIQS_WITH_PYTHON_SUPPORT
|
||||
@ -181,7 +181,7 @@ namespace triqs { namespace arrays {
|
||||
*/
|
||||
template<typename RHS>
|
||||
matrix & operator=(const RHS & X) {
|
||||
static_assert( ImmutableArray<RHS>::value, "Assignment : RHS not supported");
|
||||
static_assert( ImmutableCuboidArray<RHS>::value, "Assignment : RHS not supported");
|
||||
IMPL_TYPE::resize(X.domain());
|
||||
triqs_arrays_assign_delegation(*this,X);
|
||||
return *this;
|
||||
|
@ -133,8 +133,8 @@ namespace triqs { namespace arrays {
|
||||
* - ml : useless directly, since there only one ml, but used in generic code it maintains the same constructor as array, matrix
|
||||
*/
|
||||
template <typename T>
|
||||
//vector(const T & X, typename boost::enable_if< ImmutableArray<T> >::type *dummy =0):
|
||||
vector(const T & X, TYPE_ENABLE_IF(memory_layout<1>, ImmutableArray<T>) ml = memory_layout<1>(IMPL_TYPE::indexmap_type::traversal_order)):
|
||||
//vector(const T & X, typename boost::enable_if< ImmutableCuboidArray<T> >::type *dummy =0):
|
||||
vector(const T & X, TYPE_ENABLE_IF(memory_layout<1>, ImmutableCuboidArray<T>) ml = memory_layout<1>(IMPL_TYPE::indexmap_type::traversal_order)):
|
||||
IMPL_TYPE(indexmap_type(X.domain(),ml)) { triqs_arrays_assign_delegation(*this,X); }
|
||||
|
||||
#ifdef TRIQS_WITH_PYTHON_SUPPORT
|
||||
@ -171,7 +171,7 @@ namespace triqs { namespace arrays {
|
||||
*/
|
||||
template<typename RHS>
|
||||
vector & operator=(const RHS & X) {
|
||||
static_assert( ImmutableArray<RHS>::value, "Assignment : RHS not supported");
|
||||
static_assert( ImmutableCuboidArray<RHS>::value, "Assignment : RHS not supported");
|
||||
IMPL_TYPE::resize(X.domain());
|
||||
triqs_arrays_assign_delegation(*this,X);
|
||||
return *this;
|
||||
|
Loading…
Reference in New Issue
Block a user