From 312074c486f6bb42302a63df16a13bdbac30a9c1 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Thu, 1 Jul 2021 00:42:31 +0200 Subject: [PATCH] multi_array_operation: remove RootSumN --- src/include/multi_array_operation.cc.h | 33 +++++++++++-- src/include/multi_array_operation.h | 64 +------------------------- 2 files changed, 32 insertions(+), 65 deletions(-) diff --git a/src/include/multi_array_operation.cc.h b/src/include/multi_array_operation.cc.h index 956e702..e3b8161 100644 --- a/src/include/multi_array_operation.cc.h +++ b/src/include/multi_array_operation.cc.h @@ -134,7 +134,8 @@ namespace MultiArrayTools { return OperationPointer(THIS()); } - + + /* template template auto OperationBase::ho(const std::shared_ptr& inds...) const @@ -142,6 +143,7 @@ namespace MultiArrayTools typedef XX SubOp; return HyperOperation() } + */ /************************ * AssignmentExpr * @@ -208,16 +210,41 @@ namespace MultiArrayTools static_assert(SIZE == sizeof...(Ops), "size missmatch"); } + template + inline size_t MOpGetX( ExtType last, const std::tuple& etp) + { + if constexpr(N > 0){ + std::get(etp).get(last); + return MOpGetX(last.next(),etp); + } + else { + std::get(etp).get(last); + return 0; + } + } + + template + inline void MOpSetX( ExtType last, std::tuple& etp) + { + if constexpr(N > 0){ + std::get(etp).set(last); + MOpSetX(last.next(),etp); + } + else { + std::get(etp).set(last); + } + } + template inline size_t MOp::get(ExtType last) const { - return RootSumN::get(last,mOps.mOps); + return MOpGetX(last,mOps.mOps); } template inline MOp& MOp::set(ExtType last) { - RootSumN::set(last,mOps.mOps); + MOpSetX(last,mOps.mOps); return *this; } diff --git a/src/include/multi_array_operation.h b/src/include/multi_array_operation.h index 7ed20ef..01126f6 100644 --- a/src/include/multi_array_operation.h +++ b/src/include/multi_array_operation.h @@ -99,68 +99,6 @@ namespace MultiArrayTools friend OperationClass; }; - template - struct RootSumN - { - - template - static inline auto rootSteps(const std::tuple& etp, std::intptr_t i) - { - return RootSumN::rootSteps(etp,i).extend( std::get(etp).rootSteps(i) ); - } - - template - static inline void exec( size_t start, ExtType last, std::tuple& etp) - { - std::get(etp)(start,last); - RootSumN::exec(start,last.next(),etp); - } - - template - static inline size_t get( ExtType last, const std::tuple& etp) - { - std::get(etp).get(last); - return RootSumN::get(last.next(),etp); - } - - template - static inline void set( ExtType last, std::tuple& etp) - { - std::get(etp).set(last); - RootSumN::set(last.next(),etp); - } - }; - - template <> - struct RootSumN<0> - { - - template - static inline auto rootSteps(const std::tuple& etp, std::intptr_t i) - { - return std::get<0>(etp).rootSteps(i); - } - - template - static inline void exec( size_t start, ExtType last, std::tuple& etp) - { - std::get(etp)(start,last); - } - - template - static inline size_t get( ExtType last, const std::tuple& etp) - { - std::get(etp).get(last); - return 0; - } - - template - static inline void set( ExtType last, std::tuple& etp) - { - std::get(etp).set(last); - } - }; - template struct SelfIdentity @@ -875,6 +813,7 @@ namespace MultiArrayTools }; // for SliceArray + /* template class HyperOperation : public OperationTemplate > { @@ -915,6 +854,7 @@ namespace MultiArrayTools auto loop(Expr exp) const -> decltype(mInd->iforh(1,mOp.loop(exp))); }; + */ }