multi_array_operation: remove RootSumN

This commit is contained in:
Christian Zimmermann 2021-07-01 00:42:31 +02:00
parent 24ea3c2c30
commit 312074c486
2 changed files with 32 additions and 65 deletions

View file

@ -135,6 +135,7 @@ namespace MultiArrayTools
return OperationPointer<T,OperationClass>(THIS()); return OperationPointer<T,OperationClass>(THIS());
} }
/*
template <typename T, class OperationClass> template <typename T, class OperationClass>
template <class... Indices> template <class... Indices>
auto OperationBase<T,OperationClass>::ho(const std::shared_ptr<Indices>& inds...) const auto OperationBase<T,OperationClass>::ho(const std::shared_ptr<Indices>& inds...) const
@ -142,6 +143,7 @@ namespace MultiArrayTools
typedef XX SubOp; typedef XX SubOp;
return HyperOperation<T,SubOp,Indices...>() return HyperOperation<T,SubOp,Indices...>()
} }
*/
/************************ /************************
* AssignmentExpr * * AssignmentExpr *
@ -208,16 +210,41 @@ namespace MultiArrayTools
static_assert(SIZE == sizeof...(Ops), "size missmatch"); static_assert(SIZE == sizeof...(Ops), "size missmatch");
} }
template <size_t N, class ExtType, class... Exprs>
inline size_t MOpGetX( ExtType last, const std::tuple<Exprs...>& etp)
{
if constexpr(N > 0){
std::get<sizeof...(Exprs)-N-1>(etp).get(last);
return MOpGetX<N-1>(last.next(),etp);
}
else {
std::get<sizeof...(Exprs)-1>(etp).get(last);
return 0;
}
}
template <size_t N, class ExtType, class... Exprs>
inline void MOpSetX( ExtType last, std::tuple<Exprs...>& etp)
{
if constexpr(N > 0){
std::get<sizeof...(Exprs)-N-1>(etp).set(last);
MOpSetX<N-1>(last.next(),etp);
}
else {
std::get<sizeof...(Exprs)-1>(etp).set(last);
}
}
template <typename T, class... Ops> template <typename T, class... Ops>
inline size_t MOp<T,Ops...>::get(ExtType last) const inline size_t MOp<T,Ops...>::get(ExtType last) const
{ {
return RootSumN<sizeof...(Ops)-1>::get(last,mOps.mOps); return MOpGetX<sizeof...(Ops)-1>(last,mOps.mOps);
} }
template <typename T, class... Ops> template <typename T, class... Ops>
inline MOp<T,Ops...>& MOp<T,Ops...>::set(ExtType last) inline MOp<T,Ops...>& MOp<T,Ops...>::set(ExtType last)
{ {
RootSumN<sizeof...(Ops)-1>::set(last,mOps.mOps); MOpSetX<sizeof...(Ops)-1>(last,mOps.mOps);
return *this; return *this;
} }

View file

@ -99,68 +99,6 @@ namespace MultiArrayTools
friend OperationClass; friend OperationClass;
}; };
template <size_t N>
struct RootSumN
{
template <class... Exprs>
static inline auto rootSteps(const std::tuple<Exprs...>& etp, std::intptr_t i)
{
return RootSumN<N-1>::rootSteps(etp,i).extend( std::get<N>(etp).rootSteps(i) );
}
template <class ExtType, class... Exprs>
static inline void exec( size_t start, ExtType last, std::tuple<Exprs...>& etp)
{
std::get<sizeof...(Exprs)-N-1>(etp)(start,last);
RootSumN<N-1>::exec(start,last.next(),etp);
}
template <class ExtType, class... Exprs>
static inline size_t get( ExtType last, const std::tuple<Exprs...>& etp)
{
std::get<sizeof...(Exprs)-N-1>(etp).get(last);
return RootSumN<N-1>::get(last.next(),etp);
}
template <class ExtType, class... Exprs>
static inline void set( ExtType last, std::tuple<Exprs...>& etp)
{
std::get<sizeof...(Exprs)-N-1>(etp).set(last);
RootSumN<N-1>::set(last.next(),etp);
}
};
template <>
struct RootSumN<0>
{
template <class... Exprs>
static inline auto rootSteps(const std::tuple<Exprs...>& etp, std::intptr_t i)
{
return std::get<0>(etp).rootSteps(i);
}
template <class ExtType, class... Exprs>
static inline void exec( size_t start, ExtType last, std::tuple<Exprs...>& etp)
{
std::get<sizeof...(Exprs)-1>(etp)(start,last);
}
template <class ExtType, class... Exprs>
static inline size_t get( ExtType last, const std::tuple<Exprs...>& etp)
{
std::get<sizeof...(Exprs)-1>(etp).get(last);
return 0;
}
template <class ExtType, class... Exprs>
static inline void set( ExtType last, std::tuple<Exprs...>& etp)
{
std::get<sizeof...(Exprs)-1>(etp).set(last);
}
};
template <typename T> template <typename T>
struct SelfIdentity struct SelfIdentity
@ -875,6 +813,7 @@ namespace MultiArrayTools
}; };
// for SliceArray // for SliceArray
/*
template <typename T, class Op> template <typename T, class Op>
class HyperOperation : public OperationTemplate<T,HyperOperation<T,Op> > class HyperOperation : public OperationTemplate<T,HyperOperation<T,Op> >
{ {
@ -915,6 +854,7 @@ namespace MultiArrayTools
auto loop(Expr exp) const auto loop(Expr exp) const
-> decltype(mInd->iforh(1,mOp.loop(exp))); -> decltype(mInd->iforh(1,mOp.loop(exp)));
}; };
*/
} }