remove slicecontraction + start hyperoperation (for slicearray)
This commit is contained in:
parent
c282cf683d
commit
d5e02ba9d2
3 changed files with 29 additions and 111 deletions
|
@ -66,15 +66,6 @@ namespace MultiArrayTools
|
|||
return out;
|
||||
}
|
||||
|
||||
template <typename T, class OperationClass>
|
||||
template <class... Indices>
|
||||
auto OperationBase<T,OperationClass>::slc(const std::shared_ptr<Indices>&... inds) const
|
||||
-> SliceContraction<T,OperationClass,Indices...>
|
||||
{
|
||||
return SliceContraction<T,OperationClass,Indices...>
|
||||
(THIS(), inds...);
|
||||
}
|
||||
|
||||
template <typename T, class OperationClass>
|
||||
template <class... Indices>
|
||||
auto OperationBase<T,OperationClass>::p(const std::shared_ptr<Indices>&... inds) const
|
||||
|
@ -144,6 +135,11 @@ namespace MultiArrayTools
|
|||
return OperationPointer<T,OperationClass>(THIS());
|
||||
}
|
||||
|
||||
template <class... Indices>
|
||||
HyperOperation ho(const std::shared_ptr<Indices>& inds...) const
|
||||
{
|
||||
return HyperOperation<T,SubOp,Indices...>()
|
||||
}
|
||||
|
||||
/************************
|
||||
* AssignmentExpr *
|
||||
|
@ -1104,50 +1100,4 @@ namespace MultiArrayTools
|
|||
return mInd->iforh(0,mOp.loop(exp));
|
||||
}
|
||||
|
||||
/**************************
|
||||
* SliceContraction *
|
||||
**************************/
|
||||
|
||||
template <typename T, class Op, class... Indices>
|
||||
SliceContraction<T,Op,Indices...>::SliceContraction(const Op& op,
|
||||
std::shared_ptr<Indices>... ind) :
|
||||
mOp(op),
|
||||
mCont(std::make_shared<MultiArray<T,typename Indices::RangeType...> >(ind->range()...)),
|
||||
mTarOp(*mCont,ind...)
|
||||
{ }
|
||||
|
||||
// forward loop !!!!
|
||||
template <typename T, class Op, class... Indices>
|
||||
template <class ET>
|
||||
inline const MultiArray<T,typename Indices::RangeType...>&
|
||||
SliceContraction<T,Op,Indices...>::get(ET pos) const
|
||||
{
|
||||
*mCont = 0;
|
||||
mOp.set(pos);
|
||||
mTarOp = mOp;
|
||||
return *mCont;
|
||||
}
|
||||
|
||||
template <typename T, class Op, class... Indices>
|
||||
template <class ET>
|
||||
inline SliceContraction<T,Op,Indices...>& SliceContraction<T,Op,Indices...>::set(ET pos)
|
||||
{
|
||||
mOp.set(pos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, class Op, class... Indices>
|
||||
auto SliceContraction<T,Op,Indices...>::rootSteps(std::intptr_t iPtrNum) const
|
||||
-> decltype(mOp.rootSteps(iPtrNum))
|
||||
{
|
||||
return mOp.rootSteps(iPtrNum);
|
||||
}
|
||||
|
||||
template <typename T, class Op, class... Indices>
|
||||
template <class Expr>
|
||||
auto SliceContraction<T,Op,Indices...>::loop(Expr exp) const -> decltype(mOp.loop(exp))
|
||||
{
|
||||
return mOp.loop(exp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,10 +57,6 @@ namespace MultiArrayTools
|
|||
auto sl(const std::shared_ptr<Indices>&... inds) const
|
||||
-> ConstSlice<T,typename Indices::RangeType...>;
|
||||
|
||||
template <class... Indices>
|
||||
auto slc(const std::shared_ptr<Indices>&... inds) const
|
||||
-> SliceContraction<T,OperationClass,Indices...>;
|
||||
|
||||
template <class... Indices>
|
||||
auto p(const std::shared_ptr<Indices>&... inds) const
|
||||
-> ConstOperationRoot<T,typename Indices::RangeType...>;
|
||||
|
@ -878,15 +874,14 @@ namespace MultiArrayTools
|
|||
-> decltype(mInd->iforh(1,mOp.loop(exp)));
|
||||
};
|
||||
|
||||
template <typename T, class Op, class... Indices>
|
||||
// class SliceContraction : public OperationTemplate
|
||||
//<MultiArray<T,typename Indices::RangeType...>,
|
||||
//SliceContraction<MultiArray<T,typename Indices::RangeType...>,Op,Indices...> >
|
||||
class SliceContraction : public OperationTemplate<T,SliceContraction<T,Op,Indices...> >
|
||||
// for SliceArray
|
||||
template <typename T, class Op>
|
||||
class HyperOperation : public OperationTemplate<T,HyperOperation<T,Op> >
|
||||
{
|
||||
public:
|
||||
typedef MultiArray<T,typename Indices::RangeType...> value_type;
|
||||
typedef OperationTemplate<T,SliceContraction<T,Op,Indices...> > OT;
|
||||
|
||||
typedef Op value_type;
|
||||
typedef OperationTemplate<T,HyperOperation<T,Op> > OT;
|
||||
|
||||
static constexpr size_t SIZE = Op::SIZE;
|
||||
static constexpr bool CONT = false;
|
||||
|
@ -894,27 +889,31 @@ namespace MultiArrayTools
|
|||
|
||||
private:
|
||||
|
||||
mutable Op mOp;
|
||||
mutable std::shared_ptr<MultiArray<T,typename Indices::RangeType...> > mCont;
|
||||
mutable OperationRoot<T,typename Indices::RangeType...> mTarOp;
|
||||
Op mOp; // proto
|
||||
|
||||
public:
|
||||
typedef decltype(mOp.rootSteps(0)) ETuple;
|
||||
|
||||
SliceContraction(const Op& op, std::shared_ptr<Indices>... ind);
|
||||
//typedef decltype(mOp.rootSteps(0)) ETuple;
|
||||
|
||||
template <class ET>
|
||||
inline const value_type& get(ET pos) const;
|
||||
// include ALL indices (external/internal!!!)
|
||||
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 SliceContraction& set(ET pos);
|
||||
inline HyperOperation& 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(mOp.loop(exp)); // no loop
|
||||
|
||||
auto loop(Expr exp) const
|
||||
-> decltype(mInd->iforh(1,mOp.loop(exp)));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -318,9 +318,6 @@ namespace
|
|||
EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'A')) ), xround(2.911 + 0.373 + 1.470) );
|
||||
EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'B')) ), xround(2.911 + 0.373 + 2.210) );
|
||||
|
||||
MultiArray<MultiArray<double,SRange,SRange>,SRange,SRange> ma7(sr2ptr,sr4ptr);
|
||||
ma7(si1,si3) = ma4(si0,si1,si2,si3).slc(si0,si2);
|
||||
|
||||
si1->at('1');
|
||||
si0->at('x');
|
||||
(*si2) = 0;
|
||||
|
@ -335,34 +332,6 @@ namespace
|
|||
|
||||
EXPECT_EQ( xround( ma8.at(mkt('a','A')) ), xround( sl.at(mkt('A','a')) ) );
|
||||
EXPECT_EQ( xround( ma8.at(mkt('b','A')) ), xround( sl.at(mkt('A','b')) ) );
|
||||
|
||||
EXPECT_EQ( xround( ma7.at(mkt('1','A')).at(mkt('x','a')) ),
|
||||
xround( ma4.at(mkt('x','1','a','A')) ) );
|
||||
EXPECT_EQ( xround( ma7.at(mkt('2','A')).at(mkt('x','a')) ),
|
||||
xround( ma4.at(mkt('x','2','a','A')) ) );
|
||||
EXPECT_EQ( xround( ma7.at(mkt('3','A')).at(mkt('x','a')) ),
|
||||
xround( ma4.at(mkt('x','3','a','A')) ) );
|
||||
|
||||
EXPECT_EQ( xround( ma7.at(mkt('1','A')).at(mkt('x','b')) ),
|
||||
xround( ma4.at(mkt('x','1','b','A')) ) );
|
||||
EXPECT_EQ( xround( ma7.at(mkt('2','A')).at(mkt('x','b')) ),
|
||||
xround( ma4.at(mkt('x','2','b','A')) ) );
|
||||
EXPECT_EQ( xround( ma7.at(mkt('3','A')).at(mkt('x','b')) ),
|
||||
xround( ma4.at(mkt('x','3','b','A')) ) );
|
||||
|
||||
EXPECT_EQ( xround( ma7.at(mkt('1','A')).at(mkt('l','b')) ),
|
||||
xround( ma4.at(mkt('l','1','b','A')) ) );
|
||||
EXPECT_EQ( xround( ma7.at(mkt('2','A')).at(mkt('l','b')) ),
|
||||
xround( ma4.at(mkt('l','2','b','A')) ) );
|
||||
EXPECT_EQ( xround( ma7.at(mkt('3','A')).at(mkt('l','b')) ),
|
||||
xround( ma4.at(mkt('l','3','b','A')) ) );
|
||||
|
||||
EXPECT_EQ( xround( ma7.at(mkt('1','B')).at(mkt('l','b')) ),
|
||||
xround( ma4.at(mkt('l','1','b','B')) ) );
|
||||
EXPECT_EQ( xround( ma7.at(mkt('2','B')).at(mkt('l','b')) ),
|
||||
xround( ma4.at(mkt('l','2','b','B')) ) );
|
||||
EXPECT_EQ( xround( ma7.at(mkt('3','B')).at(mkt('l','b')) ),
|
||||
xround( ma4.at(mkt('l','3','b','B')) ) );
|
||||
}
|
||||
|
||||
} // anonymous namspace
|
||||
|
|
Loading…
Reference in a new issue