diff --git a/src/include/operation/op_types.cc.h b/src/include/operation/op_types.cc.h index 62419e7..4df3517 100644 --- a/src/include/operation/op_types.cc.h +++ b/src/include/operation/op_types.cc.h @@ -164,12 +164,6 @@ namespace CNORXZ return xpr; } - template - T* OpRoot::data() const - { - return mData; - } - /******************* * Operation * @@ -210,26 +204,6 @@ namespace CNORXZ } } - template - inline auto - mkVOpExpr(std::shared_ptr f, const ETuple& pos, const OpTuple& ops, Args... args) - { - if constexpr(I == std::tuple_size{}){ - if constexpr(OpFunction::FISSTATIC){ - return VFunc::apply(args...); - } - else { - auto vf = mkVFuncPtr(f); - (*vf)(args...); - } - } - else { - typedef typename std::remove_reference(ops))>::type NextOpType; - return mkVOpExpr( f, getX(pos), ops, args..., - std::get(ops).template vget(pos)); - } - } - template template inline auto Operation::get(ET pos) const @@ -284,51 +258,38 @@ namespace CNORXZ * Contraction * *********************/ - template - Contraction::Contraction(const Op& op, std::shared_ptr ind) : - mOp(op), - mInd(ind) {} + template + Contraction::Contraction(CXpr&& cxpr) : + mCXpr(cxpr) + {} - // forward loop !!!! - template - template - inline auto Contraction::get(ET pos) const - -> decltype(mOp.template get(pos)) + template + template + constexpr decltype(auto) Contraction::get(const PosT& pos) const { - return mOp.template get(pos); + return mCXpr(pos); } - template - template - inline auto Contraction::vget(ET pos) const - -> decltype(mOp.template vget(pos)) + template + template + constexpr decltype(auto) Contraction::rootSteps(const IndexId& id) const; { - return mOp.template vget(pos); + return mCXpr.stepSize(id); } - template - template - inline Contraction& Contraction::set(ET pos) - { - mOp.set(pos); - return *this; - } - - template - auto Contraction::rootSteps(std::intptr_t iPtrNum) const - -> decltype(mOp.rootSteps(iPtrNum)) - { - return mOp.rootSteps(iPtrNum); - } - - template + template template - auto Contraction::loop(Expr exp) const - -> decltype(mInd->iforh(1,mOp.loop(exp))) + constexpr decltype(auto) Contraction::loop(Xpr&& xpr) const { - return mInd->iforh(0,mOp.loop(exp)); + return xpr; } + template + constexpr decltype(auto) mkContracion(F&& f, Op&& op, const Sptr& i) + { + typedef decltype(i->ifor( mkOpXpr( f, op ) )) CXprT; + return Contraction( i->ifor( mkOpXpr( f, op ) ) ); + } } #endif diff --git a/src/include/operation/op_types.h b/src/include/operation/op_types.h index 6128170..9b25aab 100644 --- a/src/include/operation/op_types.h +++ b/src/include/operation/op_types.h @@ -154,48 +154,30 @@ namespace CNORXZ }; - template - class Contraction : public OperationTemplate > + template + class Contraction : public OpInterface> { public: + typedef OpInterface> OI; - typedef T value_type; - typedef OperationBase > OT; + constexpr Contraction(CXpr&& cxpr); + + template + constexpr decltype(auto) get(const PosT& pos) const; + + template + constexpr decltype(auto) rootSteps(const IndexId& id) const; + + template + constexpr decltype(auto) loop(Xpr&& xpr) const; - static constexpr size_t SIZE = Op::SIZE; - static constexpr bool CONT = Op::CONT; - static constexpr bool VABLE = Op::VABLE; - private: - - Op mOp; - std::shared_ptr mInd; - - public: - typedef decltype(mOp.rootSteps(0)) ETuple; - - Contraction(const Op& op, std::shared_ptr ind); - - template - 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); - - T* data() const { assert(0); return nullptr; } - - auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype - -> decltype(mOp.rootSteps(iPtrNum)); - - template - auto loop(Expr exp) const - -> decltype(mInd->iforh(1,mOp.loop(exp))); + CXpr mCXpr; + Sptr mInd; }; + + template + constexpr decltype(auto) mkContracion(F&& f, Op&& op, const Sptr& i); } #endif