diff --git a/src/include/multi_array_operation.cc.h b/src/include/multi_array_operation.cc.h index 6096506..d1684de 100644 --- a/src/include/multi_array_operation.cc.h +++ b/src/include/multi_array_operation.cc.h @@ -222,7 +222,7 @@ namespace MultiArrayTools { return RootSumN::get(last,mOps); } - + template inline MOp& MOp::set(ExtType last) { @@ -390,6 +390,13 @@ namespace MultiArrayTools return mDataPtr[pos.val()/*+mOff*/]; } + template + template + inline const V& ConstOperationRoot::vget(ET pos) const + { + return *reinterpret_cast(mDataPtr+pos.val()); + } + template template inline ConstOperationRoot& ConstOperationRoot::set(ET pos) @@ -437,6 +444,14 @@ namespace MultiArrayTools return static_cast( mOp.get(pos) ); } + template + template + inline V StaticCast::vget(ET pos) const + { + assert(0); // !!! + return V(); + } + template template inline StaticCast& StaticCast::set(ET pos) @@ -481,6 +496,15 @@ namespace MultiArrayTools return (mWorkIndex = pos.val()).meta(); } + template + template + inline V + MetaOperationRoot::vget(ET pos) const + { + assert(0); // !!! + return V(); + } + template template inline MetaOperationRoot& MetaOperationRoot::set(ET pos) @@ -633,6 +657,13 @@ namespace MultiArrayTools return mDataPtr[pos.val()]; } + template + template + inline V& OperationRoot::vget(ET pos) const + { + return *reinterpret_cast(mDataPtr + pos.val()); + } + template template inline OperationRoot& OperationRoot::set(ET pos) @@ -773,6 +804,13 @@ namespace MultiArrayTools return mDataPtr[pos.val()/*+mOff*/]; } + template + template + inline V& ParallelOperationRoot::vget(ET pos) const + { + return *reinterpret_cast(mDataPtr+pos.val()); + } + template template inline ParallelOperationRoot& ParallelOperationRoot::set(ET pos) @@ -818,6 +856,13 @@ namespace MultiArrayTools return mVal; } + template + template + inline V OperationValue::vget(ET pos) const + { + return static_cast(mVal); // implement???!!! + } + template template inline OperationValue& OperationValue::set(ET pos) @@ -868,6 +913,15 @@ namespace MultiArrayTools template mkOpExpr(mF, pos, mOps); } + template + template + inline auto Operation::vget(ET pos) const + { + typedef std::tuple OpTuple; + return PackNum:: + template mkVOpExpr(mF, pos, mOps); // implement!!! + } + template template inline Operation& Operation::set(ET pos) @@ -911,6 +965,14 @@ namespace MultiArrayTools return mOp.template get(pos); } + template + template + inline auto Contraction::vget(ET pos) const + -> decltype(mOp.template vget(pos)) + { + return mOp.template vget(pos); + } + template template inline Contraction& Contraction::set(ET pos) diff --git a/src/include/multi_array_operation.h b/src/include/multi_array_operation.h index 871db03..280c1cc 100644 --- a/src/include/multi_array_operation.h +++ b/src/include/multi_array_operation.h @@ -203,6 +203,7 @@ namespace MultiArrayTools EXTERN = 0, TARGET = 1 }; + template class AssignmentExpr2 : public ExpressionBase @@ -261,6 +262,10 @@ namespace MultiArrayTools MOp& operator=(MOp&& in) = default; inline size_t get(ExtType last) const; + + template + inline size_t vget(ExtType last) const { return get(last); } + inline MOp& set(ExtType last); auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType; @@ -301,6 +306,10 @@ namespace MultiArrayTools inline void operator()(size_t start = 0); inline void get(ExtType last); + + template + inline void vget(ExtType last) { get(last); } + inline void operator()(size_t start, ExtType last); auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType; @@ -388,6 +397,9 @@ namespace MultiArrayTools template inline const T& get(ET pos) const; + template + inline const V& vget(ET pos) const; + template inline ConstOperationRoot& set(ET pos); @@ -427,6 +439,9 @@ namespace MultiArrayTools template inline T get(ET pos) const; + template + inline V vget(ET pos) const; + template inline StaticCast& set(ET pos); @@ -462,6 +477,9 @@ namespace MultiArrayTools template inline value_type get(ET pos) const; + template + inline V vget(ET pos) const; + template inline MetaOperationRoot& set(ET pos); @@ -541,6 +559,9 @@ namespace MultiArrayTools template inline T& get(ET pos) const; + template + inline V& vget(ET pos) const; + template inline OperationRoot& set(ET pos); @@ -612,6 +633,9 @@ namespace MultiArrayTools template inline T& get(ET pos) const; + + template + inline V& vget(ET pos) const; template inline ParallelOperationRoot& set(ET pos); @@ -642,6 +666,9 @@ namespace MultiArrayTools template inline const T& get(ET pos) const; + template + inline V vget(ET pos) const; + template inline OperationValue& set(ET pos); @@ -682,6 +709,9 @@ namespace MultiArrayTools template inline auto get(ET pos) const; + template + inline auto vget(ET pos) const; + template inline Operation& set(ET pos); @@ -754,6 +784,10 @@ namespace MultiArrayTools inline auto get(ET pos) const -> decltype(mOp.template get(pos)); + template + inline auto vget(ET pos) const + -> decltype(mOp.template vget(pos)); + template inline Contraction& set(ET pos); diff --git a/src/include/pack_num.h b/src/include/pack_num.h index 5a185c5..7b6af61 100644 --- a/src/include/pack_num.h +++ b/src/include/pack_num.h @@ -81,6 +81,17 @@ namespace MultiArrayHelper ( f, pos, ops, std::get(ops).get(Getter::template getX( pos )), args...); } + template + static inline auto mkVOpExpr(std::shared_ptr f, const ETuple& pos, const OpTuple& ops, Args... args) + { + typedef typename std::remove_reference(ops))>::type NextOpType; + static_assert(LAST >= NextOpType::SIZE, "inconsistent array positions"); + static constexpr size_t NEXT = LAST - NextOpType::SIZE; + typedef decltype(std::get(ops).template vget(Getter::template getX( pos ))) ArgT; + return PackNum::template mkVOpExpr + ( f, pos, ops, std::get(ops).template vget(Getter::template getX( pos )), args...); + } + template static auto mkLoop( const OpTuple& ot, Expr exp ) -> decltype(std::get(ot).loop( PackNum::mkLoop(ot,exp) )) @@ -168,6 +179,16 @@ namespace MultiArrayHelper //return OpFunction::apply(std::get<0>(ops).get(Getter<0>::template getX( pos )), args...); } + template + static inline auto mkVOpExpr(std::shared_ptr f, const ETuple& pos, const OpTuple& ops, const Args&... args) + { + typedef typename std::remove_reference(ops))>::type NextOpType; + static constexpr size_t NEXT = LAST - NextOpType::SIZE; + static_assert(NEXT == 0, "inconsistent array positions"); + typedef decltype(std::get<0>(ops).template vget(Getter<0>::template getX( pos ))) ArgT; + return Application::template apply(f, std::get<0>(ops).template vget(Getter<0>::template getX( pos )), args...); + } + template static auto mkLoop( const OpTuple& ot, Expr exp ) -> decltype(std::get<0>(ot).loop( exp ))