From 0d045c006d661db8d396b308b3802b0edce73805 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Thu, 10 Sep 2020 18:29:06 +0200 Subject: [PATCH] im com --- src/include/hl_reg_ind.h | 130 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/src/include/hl_reg_ind.h b/src/include/hl_reg_ind.h index 68c723c..d8592c9 100644 --- a/src/include/hl_reg_ind.h +++ b/src/include/hl_reg_ind.h @@ -1,4 +1,134 @@ +#ifndef __hl_reg_ind_h__ +#define __hl_reg_ind_h__ + +namespace MultiArrayTools +{ + + template + struct RegIndNum + { + static constexpr size_t VALUE = -1; + static constexpr size_t DEPTH = 0; + }; + + template <> + struct RegIndNum + { + static constexpr size_t VALUE = 0; + static constexpr size_t DEPTH = 3; + }; + + // to be returned by IndexWrapper + struct RegIndInfo + { + size_t type; + size_t depth; + + template + RegIndInfo& set(const std::shared_ptr& i) + { + type = RegIndNum::VALUE; + depth = RegIndNum::DEPTH; + } + }; + + template + struct SetLInds + { + template + struct xx + { + template + static inline void assign(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr&... is) + { + SetLInds::template xx::assign(tar, args..., itp, std::get(itp), is...); + } + + template + static inline void plus(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr&... is) + { + SetLInds::template xx::plus(tar, args..., itp, std::get(itp), is...); + } + }; + }; + + template <> + struct SetLInds<0> + { + template + struct xx + { + template + static inline void assign(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr&... is) + { + tar.assign(args..., std::get<0>(itp), is...); + } + + template + static inline void plus(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr&... is) + { + tar.plus(args..., std::get<0>(itp), is...); + } + }; + }; + + template + struct INDS + { + class CallHLOpBase + { + private: + size_t mDepth; + public: + void assign(const HighLevelOpHolder& target, const HighLevelOpHolder& source, + const std::shared_ptr&... is, + const std::shared_ptr& di) const = 0; + + void plus(const HighLevelOpHolder& target, const HighLevelOpHolder& source, + const std::shared_ptr&... is, + const std::shared_ptr& di) const = 0; + }; + + template + class CallHLOp + { + private: + typedef std::tuple...> ITuple; + static vector> sNext; + public: + void assign(HighLevelOpHolder& target, const HighLevelOpHolder& source, + const std::shared_ptr&... is, + const std::shared_ptr& di) const override final + { + auto ip = di->get(di->dim()-mDepth); + auto iregn = ip->regN(); + if(iregn.type >= 0 and iregn.depth > sizeof...(LIndices)){ + sCall[iregn.type]->assign(target, source, is..., di); + } + else { + auto mi = mkIndex(is...,di->subSpaceI(0, di->dim()-mDepth)); + SetLInds:: + template xx:: + assign(target, source, mi, + SetLInds::template mkLIT(di)); + } + } + + void plus(HighLevelOpHolder& target, const HighLevelOpHolder& source, + const std::shared_ptr&... is, + const std::shared_ptr& di) const override final + { + auto mi = mkIndex(is...,di); + SetLInds::template xx::plus + (target, source, mi, mLInds); + } + }; + }; +} + +#endif + #ifdef reg_ind1 #ifdef reg_ind2 #ifdef reg_ind3