This commit is contained in:
Christian Zimmermann 2020-08-30 03:52:44 +02:00
parent 7e963c1c95
commit 371107cb5d
3 changed files with 41 additions and 6 deletions

View file

@ -134,6 +134,7 @@ namespace MultiArrayTools
template <typename T, class Operation, class... Ranges> template <typename T, class Operation, class... Ranges>
OpH<OperationRoot<T,Ranges...>> DynamicOuterOp<T,Operation,Ranges...>::get(const DExtT& pos) const OpH<OperationRoot<T,Ranges...>> DynamicOuterOp<T,Operation,Ranges...>::get(const DExtT& pos) const
{ {
if(mPrev) mPrev.get(pos.expl<ET>());
mL(0,pos.expl<ET>()); mL(0,pos.expl<ET>());
return mProto; // empty return mProto; // empty
} }
@ -164,6 +165,15 @@ namespace MultiArrayTools
return &mProto; return &mProto;
} }
template <class Op1, class Op2>
template <class ET>
inline T TwoOp<Op1,Op2>::get(const ET& pos) const
{
return mOp2.get(pos);
}
template <typename T, class Operation, class... Ranges> template <typename T, class Operation, class... Ranges>
std::shared_ptr<DynamicOperationBase<OpH<OperationRoot<T,Ranges...>>>> std::shared_ptr<DynamicOperationBase<OpH<OperationRoot<T,Ranges...>>>>
DynamicOuterOp<T,Operation,Ranges...>::deepCopy() const DynamicOuterOp<T,Operation,Ranges...>::deepCopy() const

View file

@ -64,6 +64,7 @@ namespace MultiArrayTools
std::shared_ptr<Op> mOp; std::shared_ptr<Op> mOp;
OpH(const Op& op) : mOp(std::make_shared<Op>(op)) {} OpH(const Op& op) : mOp(std::make_shared<Op>(op)) {}
// overload all operations here ...
}; };
template <typename T, class Operation, class... Ranges> template <typename T, class Operation, class... Ranges>
@ -76,7 +77,7 @@ namespace MultiArrayTools
std::tuple<std::shared_ptr<typename Ranges::IndexType>...> mIndices; std::tuple<std::shared_ptr<typename Ranges::IndexType>...> mIndices;
std::shared_ptr<MultiArray<T,Ranges...>> mMa; std::shared_ptr<MultiArray<T,Ranges...>> mMa;
OpH<OperationRoot<T,Ranges...>> mProto; OpH<OperationRoot<T,Ranges...>> mProto;
std::shared_ptr<DynamicOperationBase<OpH<OperationRoot<T,Ranges...>>>> mPrev;
typedef ILoop<std::tuple<OperationRoot<T,Ranges...>,Operation>, typedef ILoop<std::tuple<OperationRoot<T,Ranges...>,Operation>,
@ -143,6 +144,25 @@ namespace MultiArrayTools
inline const T* data() const { return mOp->data(); } inline const T* data() const { return mOp->data(); }
}; };
template <class Op1>
class TwoOp : public OperationTemplate<typename Op2::value_type,TwoOp<Op1>>
{
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 <class ET>
inline T get(const ET& pos) const;
};
template <class Operation, class... Indices> template <class Operation, class... Indices>
auto mkDynOutOp(const Operation& op, const std::shared_ptr<Indices>&... inds) auto mkDynOutOp(const Operation& op, const std::shared_ptr<Indices>&... inds)
{ {

View file

@ -194,25 +194,30 @@ namespace
auto di3 = getIndex(dr3); auto di3 = getIndex(dr3);
auto di5 = getIndex(dr5); auto di5 = getIndex(dr5);
auto di6 = getIndex(dr6); 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"]}); (*di1)({imap["i2_1"],imap["i2_1"],imap["i3_1"],imap["i4_1"]});
(*di3)({imap["i2_1"],imap["i5_1"]}); (*di3)({imap["i2_1"],imap["i5_1"]});
(*di5)({imap["i5_1"]}); (*di5)({imap["i5_1"]});
(*di6)({imap["i3_1"],imap["i4_1"]}); (*di6)({imap["i3_1"],imap["i4_1"]});
//(*di6a)({imap["i3_1"]}); (*di6a)({imap["i3_1"]});
auto resx1 = res2; auto resx1 = res2;
auto resx2 = res2; auto resx2 = res2;
auto resx3 = res2; auto resx3 = res2;
//auto resx4 = res2; auto resx4 = res2;
res2(i1,di6) += (ma1(i1,di1) * ma5(di5)).c(di3); res2(i1,di6) += (ma1(i1,di1) * ma5(di5)).c(di3);
resx1(i1,di6) += (mkDynOp(ma1(i1,di1)) * mkDynOp(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)); resx2(i1,di6) += mkDynOp((ma1(i1,di1) * ma5(di5)).c(di3));
resx3(i1,di6) += mkDynOp((mkDynOp(ma1(i1,di1)) * mkDynOp(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)); //resx2(i1,di6) += mkDynOp((ma1(i1,di1) * ma5(di5)).c(di3));