op_types: contraction (not finished)
This commit is contained in:
parent
e3fe04d5da
commit
fa1ea56d51
2 changed files with 39 additions and 96 deletions
|
@ -164,12 +164,6 @@ namespace CNORXZ
|
|||
return xpr;
|
||||
}
|
||||
|
||||
template <typename T, class IndexT>
|
||||
T* OpRoot<T,IndexT>::data() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
|
||||
/*******************
|
||||
* Operation *
|
||||
|
@ -210,26 +204,6 @@ namespace CNORXZ
|
|||
}
|
||||
}
|
||||
|
||||
template <size_t I, typename V, class OpFunction, class ETuple, class OpTuple, typename... Args>
|
||||
inline auto
|
||||
mkVOpExpr(std::shared_ptr<OpFunction> f, const ETuple& pos, const OpTuple& ops, Args... args)
|
||||
{
|
||||
if constexpr(I == std::tuple_size<OpTuple>{}){
|
||||
if constexpr(OpFunction::FISSTATIC){
|
||||
return VFunc<OpFunction>::apply(args...);
|
||||
}
|
||||
else {
|
||||
auto vf = mkVFuncPtr(f);
|
||||
(*vf)(args...);
|
||||
}
|
||||
}
|
||||
else {
|
||||
typedef typename std::remove_reference<decltype(std::get<I>(ops))>::type NextOpType;
|
||||
return mkVOpExpr<I+1,V>( f, getX<NextOpType::SIZE>(pos), ops, args...,
|
||||
std::get<I>(ops).template vget<V>(pos));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, class OpFunction, class... Ops>
|
||||
template <class ET>
|
||||
inline auto Operation<T,OpFunction,Ops...>::get(ET pos) const
|
||||
|
@ -284,51 +258,38 @@ namespace CNORXZ
|
|||
* Contraction *
|
||||
*********************/
|
||||
|
||||
template <typename T, class Op, class IndexType>
|
||||
Contraction<T,Op,IndexType>::Contraction(const Op& op, std::shared_ptr<IndexType> ind) :
|
||||
mOp(op),
|
||||
mInd(ind) {}
|
||||
template <class CXpr>
|
||||
Contraction<CXpr>::Contraction(CXpr&& cxpr) :
|
||||
mCXpr(cxpr)
|
||||
{}
|
||||
|
||||
// forward loop !!!!
|
||||
template <typename T, class Op, class IndexType>
|
||||
template <class ET>
|
||||
inline auto Contraction<T,Op,IndexType>::get(ET pos) const
|
||||
-> decltype(mOp.template get<ET>(pos))
|
||||
template <class CXpr>
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) Contraction<CXpr>::get(const PosT& pos) const
|
||||
{
|
||||
return mOp.template get<ET>(pos);
|
||||
return mCXpr(pos);
|
||||
}
|
||||
|
||||
template <typename T, class Op, class IndexType>
|
||||
template <typename V, class ET>
|
||||
inline auto Contraction<T,Op,IndexType>::vget(ET pos) const
|
||||
-> decltype(mOp.template vget<V,ET>(pos))
|
||||
template <class CXpr>
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) Contraction<CXpr>::rootSteps(const IndexId<I>& id) const;
|
||||
{
|
||||
return mOp.template vget<V,ET>(pos);
|
||||
return mCXpr.stepSize(id);
|
||||
}
|
||||
|
||||
template <typename T, class Op, class IndexType>
|
||||
template <class ET>
|
||||
inline Contraction<T,Op,IndexType>& Contraction<T,Op,IndexType>::set(ET pos)
|
||||
{
|
||||
mOp.set(pos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, class Op, class IndexType>
|
||||
auto Contraction<T,Op,IndexType>::rootSteps(std::intptr_t iPtrNum) const
|
||||
-> decltype(mOp.rootSteps(iPtrNum))
|
||||
{
|
||||
return mOp.rootSteps(iPtrNum);
|
||||
}
|
||||
|
||||
template <typename T, class Op, class IndexType>
|
||||
template <class CXpr>
|
||||
template <class Expr>
|
||||
auto Contraction<T,Op,IndexType>::loop(Expr exp) const
|
||||
-> decltype(mInd->iforh(1,mOp.loop(exp)))
|
||||
constexpr decltype(auto) Contraction<CXpr>::loop(Xpr&& xpr) const
|
||||
{
|
||||
return mInd->iforh(0,mOp.loop(exp));
|
||||
return xpr;
|
||||
}
|
||||
|
||||
template <class F, class Op, class IndexT>
|
||||
constexpr decltype(auto) mkContracion(F&& f, Op&& op, const Sptr<IndexT>& i)
|
||||
{
|
||||
typedef decltype(i->ifor( mkOpXpr( f, op ) )) CXprT;
|
||||
return Contraction<CXprT>( i->ifor( mkOpXpr( f, op ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -154,48 +154,30 @@ namespace CNORXZ
|
|||
|
||||
};
|
||||
|
||||
template <typename T, class Op, class IndexType>
|
||||
class Contraction : public OperationTemplate<T,Contraction<T,Op,IndexType> >
|
||||
template <class CXpr>
|
||||
class Contraction : public OpInterface<Contraction<CXpr>>
|
||||
{
|
||||
public:
|
||||
typedef OpInterface<Contraction<CXpr>> OI;
|
||||
|
||||
typedef T value_type;
|
||||
typedef OperationBase<T,Contraction<T,Op,IndexType> > OT;
|
||||
constexpr Contraction(CXpr&& cxpr);
|
||||
|
||||
static constexpr size_t SIZE = Op::SIZE;
|
||||
static constexpr bool CONT = Op::CONT;
|
||||
static constexpr bool VABLE = Op::VABLE;
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) get(const PosT& pos) const;
|
||||
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
||||
|
||||
template <class Xpr>
|
||||
constexpr decltype(auto) loop(Xpr&& xpr) const;
|
||||
|
||||
private:
|
||||
|
||||
Op mOp;
|
||||
std::shared_ptr<IndexType> mInd;
|
||||
|
||||
public:
|
||||
typedef decltype(mOp.rootSteps(0)) ETuple;
|
||||
|
||||
Contraction(const Op& op, std::shared_ptr<IndexType> ind);
|
||||
|
||||
template <class ET>
|
||||
inline auto get(ET pos) const
|
||||
-> decltype(mOp.template get<ET>(pos));
|
||||
|
||||
template <typename V, class ET>
|
||||
inline auto vget(ET pos) const
|
||||
-> decltype(mOp.template vget<V,ET>(pos));
|
||||
|
||||
template <class ET>
|
||||
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 <class Expr>
|
||||
auto loop(Expr exp) const
|
||||
-> decltype(mInd->iforh(1,mOp.loop(exp)));
|
||||
CXpr mCXpr;
|
||||
Sptr<IndexType> mInd;
|
||||
};
|
||||
|
||||
template <class F, class Op, class IndexT>
|
||||
constexpr decltype(auto) mkContracion(F&& f, Op&& op, const Sptr<IndexT>& i);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue