diff --git a/src/include/dynamic_operation.cc.h b/src/include/dynamic_operation.cc.h index 630986f..ffdf697 100644 --- a/src/include/dynamic_operation.cc.h +++ b/src/include/dynamic_operation.cc.h @@ -134,6 +134,7 @@ namespace MultiArrayTools template OpH> DynamicOuterOp::get(const DExtT& pos) const { + if(mPrev) mPrev.get(pos.expl()); mL(0,pos.expl()); return mProto; // empty } @@ -163,6 +164,15 @@ namespace MultiArrayTools { return &mProto; } + + template + template + inline T TwoOp::get(const ET& pos) const + { + return mOp2.get(pos); + + } + template std::shared_ptr>>> diff --git a/src/include/dynamic_operation.h b/src/include/dynamic_operation.h index 1dff713..b8f8a75 100644 --- a/src/include/dynamic_operation.h +++ b/src/include/dynamic_operation.h @@ -64,6 +64,7 @@ namespace MultiArrayTools std::shared_ptr mOp; OpH(const Op& op) : mOp(std::make_shared(op)) {} + // overload all operations here ... }; template @@ -76,7 +77,7 @@ namespace MultiArrayTools std::tuple...> mIndices; std::shared_ptr> mMa; OpH> mProto; - + std::shared_ptr>>> mPrev; typedef ILoop,Operation>, @@ -143,6 +144,25 @@ namespace MultiArrayTools inline const T* data() const { return mOp->data(); } }; + template + class TwoOp : public OperationTemplate> + { + private: + + Op1 mOp1; + typename Op1::value_type mOp2; // mOp1.data()->mOp + + public: + + typedef typename Op2::value_type value_type; + typedef value_type T; + + TwoOp(const Op1& op1); + + template + inline T get(const ET& pos) const; + }; + template auto mkDynOutOp(const Operation& op, const std::shared_ptr&... inds) { diff --git a/src/tests/op4_unit_test.cc b/src/tests/op4_unit_test.cc index 93a1194..c674f0e 100644 --- a/src/tests/op4_unit_test.cc +++ b/src/tests/op4_unit_test.cc @@ -194,26 +194,31 @@ namespace auto di3 = getIndex(dr3); auto di5 = getIndex(dr5); auto di6 = getIndex(dr6); - //auto di6a = getIndex(dr6a); + auto di6a = getIndex(dr6a); (*di1)({imap["i2_1"],imap["i2_1"],imap["i3_1"],imap["i4_1"]}); (*di3)({imap["i2_1"],imap["i5_1"]}); (*di5)({imap["i5_1"]}); (*di6)({imap["i3_1"],imap["i4_1"]}); - //(*di6a)({imap["i3_1"]}); + (*di6a)({imap["i3_1"]}); auto resx1 = res2; auto resx2 = res2; auto resx3 = res2; - //auto resx4 = res2; + auto resx4 = res2; res2(i1,di6) += (ma1(i1,di1) * ma5(di5)).c(di3); resx1(i1,di6) += (mkDynOp(ma1(i1,di1)) * mkDynOp(ma5(di5))).c(di3); resx2(i1,di6) += mkDynOp((ma1(i1,di1) * ma5(di5)).c(di3)); resx3(i1,di6) += mkDynOp((mkDynOp(ma1(i1,di1)) * mkDynOp(ma5(di5))).c(di3)); - //auto op1 = mkDynOutOp(ma1(i1,di1) * ma5(di5), ci4_1); - + auto op1 = ma1(i1,di1); + auto op2 = ma5(di5); + auto dop1 = mkDynOutOp(op1 * op2, ci4_1); + auto op3 = *dop1.data()->mOp; + auto dop2 = mkDynOutOp( dop1.c(di3), op3.c(di3), ci4_1 ); + auto opr = resx4(i1,di6); + //resx2(i1,di6) += mkDynOp((ma1(i1,di1) * ma5(di5)).c(di3)); auto i2_1 = imap.at("i2_1");