still not better...
This commit is contained in:
parent
59ffd5adcc
commit
6f320fe9e9
7 changed files with 212 additions and 105 deletions
|
@ -29,7 +29,7 @@ namespace MultiArrayTools
|
|||
|
||||
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
||||
inline void OpExpr<MapF,IndexPack,Expr,STYPE>::operator()(size_t mlast,
|
||||
ExtType last) const
|
||||
ExtType last)
|
||||
{
|
||||
constexpr size_t NEXT = Op::SIZE;
|
||||
const ExtType nxpos = last;
|
||||
|
@ -42,7 +42,7 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
||||
inline void OpExpr<MapF,IndexPack,Expr,STYPE>::operator()(size_t mlast) const
|
||||
inline void OpExpr<MapF,IndexPack,Expr,STYPE>::operator()(size_t mlast)
|
||||
{
|
||||
const ExtType last;
|
||||
constexpr size_t NEXT = Op::SIZE;
|
||||
|
|
|
@ -66,8 +66,8 @@ namespace MultiArrayTools
|
|||
|
||||
OpExpr(const MapF& mapf, const IndexPack& ipack, const std::shared_ptr<OIType>& oind, size_t step, Expr ex);
|
||||
|
||||
inline void operator()(size_t mlast, ExtType last) const;
|
||||
inline void operator()(size_t mlast = 0) const;
|
||||
inline void operator()(size_t mlast, ExtType last);
|
||||
inline void operator()(size_t mlast = 0);
|
||||
|
||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||
|
||||
|
|
|
@ -109,18 +109,25 @@ namespace MultiArrayTools
|
|||
/*****************************************
|
||||
* OperationMaster::AssignmentExpr *
|
||||
*****************************************/
|
||||
|
||||
/*
|
||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||
OperationMaster<T,AOp,OpClass,Ranges...>::AssignmentExpr::
|
||||
AssignmentExpr(OperationMaster& m, const OpClass& sec) :
|
||||
mM(m), mSec(sec) {}
|
||||
|
||||
*/
|
||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||
OperationMaster<T,AOp,OpClass,Ranges...>::AssignmentExpr::
|
||||
AssignmentExpr(T* dataPtr, const OpClass& sec) :
|
||||
mSec(sec), mDataPtr(dataPtr) {}
|
||||
|
||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||
inline void OperationMaster<T,AOp,OpClass,Ranges...>::AssignmentExpr::
|
||||
operator()(size_t start, ExtType last) const
|
||||
operator()(size_t start, ExtType last)
|
||||
{
|
||||
//VCHECK(mSec.template get<ExtType>(last));
|
||||
mM.set(start, mSec.template get<ExtType>(last) );
|
||||
//mM.set(start, mSec.template get<ExtType>(last) );
|
||||
mDataPtr[start] = mSec.template get<ExtType>(last);
|
||||
//AOp::sapply(mDataPtr[start], mSec.template get<ExtType>(last));
|
||||
}
|
||||
|
||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||
|
@ -130,7 +137,30 @@ namespace MultiArrayTools
|
|||
{
|
||||
return mSec.rootSteps(iPtrNum);
|
||||
}
|
||||
|
||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||
OperationMaster<T,AOp,OpClass,Ranges...>::AddExpr::
|
||||
AddExpr(T* dataPtr, const OpClass& sec) :
|
||||
mSec(sec), mDataPtr(dataPtr) {}
|
||||
|
||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||
inline void OperationMaster<T,AOp,OpClass,Ranges...>::AddExpr::
|
||||
operator()(size_t start, ExtType last)
|
||||
{
|
||||
//VCHECK(mSec.template get<ExtType>(last));
|
||||
//mM.set(start, mSec.template get<ExtType>(last) );
|
||||
mDataPtr[start] += mSec.template get<ExtType>(last);
|
||||
//AOp::sapply(mDataPtr[start], mSec.template get<ExtType>(last));
|
||||
}
|
||||
|
||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||
typename OperationMaster<T,AOp,OpClass,Ranges...>::AddExpr::ExtType
|
||||
OperationMaster<T,AOp,OpClass,Ranges...>::AddExpr::
|
||||
rootSteps(std::intptr_t iPtrNum) const
|
||||
{
|
||||
return mSec.rootSteps(iPtrNum);
|
||||
}
|
||||
|
||||
|
||||
/*************************
|
||||
* OperationMaster *
|
||||
|
@ -159,15 +189,17 @@ namespace MultiArrayTools
|
|||
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||
void OperationMaster<T,AOp,OpClass,Ranges...>::performAssignment(std::intptr_t blockIndexNum)
|
||||
{
|
||||
/*
|
||||
AssignmentExpr ae(*this, mSecond); // Expression to be executed within loop
|
||||
if(mDoParallel){
|
||||
const auto ploop = mIndex.pifor( 1, mSecond.loop(ae) );
|
||||
auto ploop = mIndex.pifor( 1, mSecond.loop(ae) );
|
||||
ploop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||
}
|
||||
else {
|
||||
const auto loop = mIndex.ifor( 1, mSecond.loop(ae) );
|
||||
auto loop = mIndex.ifor( 1, mSecond.loop(ae) );
|
||||
loop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||
|
@ -186,11 +218,12 @@ namespace MultiArrayTools
|
|||
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
|
||||
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
||||
mDataPtr(ma.data()),
|
||||
mOrigDataPtr(ma.data()),
|
||||
mIndex( ma.begin() )
|
||||
{
|
||||
//VCHECK(ma.data());
|
||||
mIndex(indices...);
|
||||
mOff = mIndex.pos();
|
||||
//mOff = mIndex.pos();
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
|
@ -198,35 +231,37 @@ namespace MultiArrayTools
|
|||
ConstOperationRoot(std::shared_ptr<MultiArrayBase<T,Ranges...> > maptr,
|
||||
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
||||
mDataPtr(maptr->data()),
|
||||
mOrigDataPtr(maptr->data()),
|
||||
mIndex(maptr->begin()),
|
||||
mMaPtr(maptr)
|
||||
{
|
||||
mIndex(indices...);
|
||||
mOff = mIndex.pos();
|
||||
//mOff = mIndex.pos();
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
ConstOperationRoot<T,Ranges...>::
|
||||
ConstOperationRoot(const T* data, const IndexType& ind) :
|
||||
mDataPtr(data),
|
||||
mOrigDataPtr(data),
|
||||
mIndex( ind )
|
||||
{
|
||||
mOff = mIndex.pos();
|
||||
//mOff = mIndex.pos();
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
template <class ET>
|
||||
inline T ConstOperationRoot<T,Ranges...>::get(ET pos) const
|
||||
{
|
||||
return mDataPtr[pos.val()+mOff];
|
||||
return mDataPtr[pos.val()/*+mOff*/];
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
template <class ET>
|
||||
inline const ConstOperationRoot<T,Ranges...>& ConstOperationRoot<T,Ranges...>::set(ET pos) const
|
||||
inline ConstOperationRoot<T,Ranges...>& ConstOperationRoot<T,Ranges...>::set(ET pos)
|
||||
{
|
||||
mIndex = pos.val();
|
||||
mOff = mIndex.pos();
|
||||
mDataPtr = mOrigDataPtr + mIndex.pos();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -267,7 +302,7 @@ namespace MultiArrayTools
|
|||
|
||||
template <typename T, class Op>
|
||||
template <class ET>
|
||||
inline const StaticCast<T,Op>& StaticCast<T,Op>::set(ET pos) const
|
||||
inline StaticCast<T,Op>& StaticCast<T,Op>::set(ET pos)
|
||||
{
|
||||
mOp.set(pos);
|
||||
return *this;
|
||||
|
@ -311,7 +346,7 @@ namespace MultiArrayTools
|
|||
|
||||
template <class Range>
|
||||
template <class ET>
|
||||
inline const MetaOperationRoot<Range>& MetaOperationRoot<Range>::set(ET pos) const
|
||||
inline MetaOperationRoot<Range>& MetaOperationRoot<Range>::set(ET pos)
|
||||
{
|
||||
assert(0);
|
||||
//(*mIndex) = pos.val();
|
||||
|
@ -342,38 +377,65 @@ namespace MultiArrayTools
|
|||
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
|
||||
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
||||
mDataPtr(ma.data()),
|
||||
mOrigDataPtr(ma.data()),
|
||||
mIndex( ma.begin() )
|
||||
{
|
||||
mIndex(indices...);
|
||||
mOff = mIndex.pos();
|
||||
//mOff = mIndex.pos();
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
OperationRoot<T,Ranges...>::
|
||||
OperationRoot(T* data, const IndexType& ind) :
|
||||
mDataPtr(data),
|
||||
mOrigDataPtr(data),
|
||||
mIndex( ind )
|
||||
{
|
||||
mOff = mIndex.pos();
|
||||
//mOff = mIndex.pos();
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
template <class OpClass>
|
||||
OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
||||
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
||||
//OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
||||
{
|
||||
return OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...>(mDataPtr, in, mIndex, mDoParallel);
|
||||
typename OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...>::AssignmentExpr ae(mDataPtr, in);
|
||||
// Expression to be executed within loop
|
||||
if(mDoParallel){
|
||||
auto ploop = mIndex.pifor( 1, in.loop(ae) );
|
||||
ploop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||
}
|
||||
else {
|
||||
auto loop = mIndex.ifor( 1, in.loop(ae) );
|
||||
loop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||
}
|
||||
return *this;
|
||||
//return OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...>(mDataPtr, in, mIndex, mDoParallel);
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
template <class OpClass>
|
||||
OperationMaster<T,plus<T>,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator+=(const OpClass& in)
|
||||
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator+=(const OpClass& in)
|
||||
//OperationMaster<T,plus<T>,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator+=(const OpClass& in)
|
||||
{
|
||||
return OperationMaster<T,plus<T>,OpClass,Ranges...>(mDataPtr, in, mIndex, mDoParallel);
|
||||
typename OperationMaster<T,plus<T>,OpClass,Ranges...>::AddExpr ae(mDataPtr, in);
|
||||
// Expression to be executed within loop
|
||||
if(mDoParallel){
|
||||
auto ploop = mIndex.pifor( 1, in.loop(ae) );
|
||||
ploop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||
}
|
||||
else {
|
||||
auto loop = mIndex.ifor( 1, in.loop(ae) );
|
||||
loop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||
}
|
||||
return *this;
|
||||
//return OperationMaster<T,plus<T>,OpClass,Ranges...>(mDataPtr, in, mIndex, mDoParallel);
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
OperationMaster<T,SelfIdentity<T>,OperationRoot<T,Ranges...>,Ranges...>
|
||||
OperationRoot<T,Ranges...>::operator=(const OperationRoot<T,Ranges...>& in)
|
||||
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OperationRoot<T,Ranges...>& in)
|
||||
//OperationMaster<T,SelfIdentity<T>,OperationRoot<T,Ranges...>,Ranges...>
|
||||
//OperationRoot<T,Ranges...>::operator=(const OperationRoot<T,Ranges...>& in)
|
||||
{
|
||||
return operator=<OperationRoot<T,Ranges...> >(in);
|
||||
}
|
||||
|
@ -389,15 +451,15 @@ namespace MultiArrayTools
|
|||
template <class ET>
|
||||
inline T OperationRoot<T,Ranges...>::get(ET pos) const
|
||||
{
|
||||
return mDataPtr[pos.val()+mOff];
|
||||
return mDataPtr[pos.val()/*+mOff*/];
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
template <class ET>
|
||||
inline const OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::set(ET pos) const
|
||||
inline OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::set(ET pos)
|
||||
{
|
||||
mIndex = pos.val();
|
||||
mOff = mIndex.pos();
|
||||
mDataPtr = mOrigDataPtr + mIndex.pos();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -418,7 +480,8 @@ namespace MultiArrayTools
|
|||
template <typename T, class... Ranges>
|
||||
T* OperationRoot<T,Ranges...>::data() const
|
||||
{
|
||||
return mDataPtr + mIndex().pos();
|
||||
auto i = mIndex;
|
||||
return mDataPtr + i().pos();
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
|
@ -448,7 +511,7 @@ namespace MultiArrayTools
|
|||
|
||||
template <typename T>
|
||||
template <class ET>
|
||||
inline const OperationValue<T>& OperationValue<T>::set(ET pos) const
|
||||
inline OperationValue<T>& OperationValue<T>::set(ET pos)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
@ -498,7 +561,7 @@ namespace MultiArrayTools
|
|||
|
||||
template <typename T, class OpFunction, class... Ops>
|
||||
template <class ET>
|
||||
inline const Operation<T,OpFunction,Ops...>& Operation<T,OpFunction,Ops...>::set(ET pos) const
|
||||
inline Operation<T,OpFunction,Ops...>& Operation<T,OpFunction,Ops...>::set(ET pos)
|
||||
{
|
||||
PackNum<sizeof...(Ops)-1>::setOpPos(mOps,pos);
|
||||
return *this;
|
||||
|
@ -539,7 +602,7 @@ namespace MultiArrayTools
|
|||
|
||||
template <typename T, class Op, class IndexType>
|
||||
template <class ET>
|
||||
inline const Contraction<T,Op,IndexType>& Contraction<T,Op,IndexType>::set(ET pos) const
|
||||
inline Contraction<T,Op,IndexType>& Contraction<T,Op,IndexType>::set(ET pos)
|
||||
{
|
||||
mOp.set(pos);
|
||||
return *this;
|
||||
|
@ -586,7 +649,7 @@ namespace MultiArrayTools
|
|||
|
||||
template <typename T, class Op, class... Indices>
|
||||
template <class ET>
|
||||
inline const SliceContraction<T,Op,Indices...>& SliceContraction<T,Op,Indices...>::set(ET pos) const
|
||||
inline SliceContraction<T,Op,Indices...>& SliceContraction<T,Op,Indices...>::set(ET pos)
|
||||
{
|
||||
mOp.set(pos);
|
||||
return *this;
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace MultiArrayTools
|
|||
template <typename T>
|
||||
struct SelfIdentity
|
||||
{
|
||||
static inline T& sapply(T& a, const T& b)
|
||||
static inline T& sapply(T& a, T b)
|
||||
{
|
||||
return a = b;
|
||||
}
|
||||
|
@ -107,27 +107,57 @@ namespace MultiArrayTools
|
|||
private:
|
||||
AssignmentExpr() = default;
|
||||
|
||||
OperationMaster& mM;
|
||||
const OpClass& mSec;
|
||||
|
||||
//OperationMaster mM;
|
||||
OpClass mSec;
|
||||
T* mDataPtr;
|
||||
|
||||
public:
|
||||
|
||||
static constexpr size_t LAYER = 0;
|
||||
static constexpr size_t SIZE = OpClass::SIZE;
|
||||
typedef decltype(mSec.rootSteps()) ExtType;
|
||||
|
||||
AssignmentExpr(OperationMaster& m, const OpClass& sec);
|
||||
//AssignmentExpr(OperationMaster& m, const OpClass& sec);
|
||||
AssignmentExpr(T* dataPtr, const OpClass& sec);
|
||||
|
||||
AssignmentExpr(const AssignmentExpr& in) = default;
|
||||
AssignmentExpr(AssignmentExpr&& in) = default;
|
||||
|
||||
inline void operator()(size_t start = 0) const;
|
||||
inline void operator()(size_t start, ExtType last) const;
|
||||
inline void operator()(size_t start = 0);
|
||||
inline void operator()(size_t start, ExtType last);
|
||||
|
||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class AddExpr
|
||||
{
|
||||
private:
|
||||
AddExpr() = default;
|
||||
|
||||
//OperationMaster mM;
|
||||
OpClass mSec;
|
||||
T* mDataPtr;
|
||||
|
||||
public:
|
||||
|
||||
static constexpr size_t LAYER = 0;
|
||||
static constexpr size_t SIZE = OpClass::SIZE;
|
||||
typedef decltype(mSec.rootSteps()) ExtType;
|
||||
|
||||
//AssignmentExpr(OperationMaster& m, const OpClass& sec);
|
||||
AddExpr(T* dataPtr, const OpClass& sec);
|
||||
|
||||
AddExpr(const AddExpr& in) = default;
|
||||
AddExpr(AddExpr&& in) = default;
|
||||
|
||||
inline void operator()(size_t start = 0);
|
||||
inline void operator()(size_t start, ExtType last);
|
||||
|
||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||
|
||||
};
|
||||
|
||||
typedef T value_type;
|
||||
//typedef OperationBase<T> OB;
|
||||
typedef ContainerRange<T,Ranges...> CRange;
|
||||
|
@ -180,7 +210,7 @@ namespace MultiArrayTools
|
|||
inline T get(ET pos) const;
|
||||
|
||||
template <class ET>
|
||||
inline const ConstOperationRoot& set(ET pos) const;
|
||||
inline ConstOperationRoot& set(ET pos);
|
||||
|
||||
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
||||
|
||||
|
@ -193,8 +223,9 @@ namespace MultiArrayTools
|
|||
|
||||
//MultiArrayBase<T,Ranges...> const& mArrayRef;
|
||||
const T* mDataPtr;
|
||||
mutable IndexType mIndex;
|
||||
mutable size_t mOff = 0;
|
||||
const T* mOrigDataPtr;
|
||||
IndexType mIndex;
|
||||
//size_t mOff = 0;
|
||||
std::shared_ptr<MultiArrayBase<T,Ranges...> > mMaPtr; // never remove this ptr, otherwise we lose temporary container instances!
|
||||
};
|
||||
|
||||
|
@ -202,7 +233,7 @@ namespace MultiArrayTools
|
|||
class StaticCast : public OperationTemplate<T,StaticCast<T,Op> >
|
||||
{
|
||||
private:
|
||||
const Op& mOp;
|
||||
Op mOp;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -219,7 +250,7 @@ namespace MultiArrayTools
|
|||
inline T get(ET pos) const;
|
||||
|
||||
template <class ET>
|
||||
inline const StaticCast& set(ET pos) const;
|
||||
inline StaticCast& set(ET pos);
|
||||
|
||||
auto rootSteps(std::intptr_t iPtrNum = 0) const
|
||||
-> decltype(mOp.rootSteps(iPtrNum));
|
||||
|
@ -253,7 +284,7 @@ namespace MultiArrayTools
|
|||
inline value_type get(ET pos) const;
|
||||
|
||||
template <class ET>
|
||||
inline const MetaOperationRoot& set(ET pos) const;
|
||||
inline MetaOperationRoot& set(ET pos);
|
||||
|
||||
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
||||
|
||||
|
@ -284,7 +315,7 @@ namespace MultiArrayTools
|
|||
const std::shared_ptr<typename Ranges::IndexType>&... indices);
|
||||
|
||||
OperationRoot(T* data, const IndexType& ind);
|
||||
|
||||
/*
|
||||
template <class OpClass>
|
||||
OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...> operator=(const OpClass& in);
|
||||
|
||||
|
@ -292,14 +323,23 @@ namespace MultiArrayTools
|
|||
OperationMaster<T,plus<T>,OpClass,Ranges...> operator+=(const OpClass& in);
|
||||
|
||||
OperationMaster<T,SelfIdentity<T>,OperationRoot,Ranges...> operator=(const OperationRoot& in);
|
||||
*/
|
||||
|
||||
template <class OpClass>
|
||||
OperationRoot& operator=(const OpClass& in);
|
||||
|
||||
template <class OpClass>
|
||||
OperationRoot& operator+=(const OpClass& in);
|
||||
|
||||
OperationRoot& operator=(const OperationRoot& in);
|
||||
|
||||
OperationRoot& par();
|
||||
|
||||
template <class ET>
|
||||
inline T get(ET pos) const;
|
||||
|
||||
template <class ET>
|
||||
inline const OperationRoot& set(ET pos) const;
|
||||
inline OperationRoot& set(ET pos);
|
||||
|
||||
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
||||
|
||||
|
@ -316,8 +356,9 @@ namespace MultiArrayTools
|
|||
|
||||
//MutableMultiArrayBase<T,Ranges...>& mArrayRef;
|
||||
T* mDataPtr;
|
||||
mutable IndexType mIndex;
|
||||
mutable size_t mOff = 0;
|
||||
T* mOrigDataPtr;
|
||||
IndexType mIndex;
|
||||
//size_t mOff = 0;
|
||||
bool mDoParallel = false;
|
||||
};
|
||||
|
||||
|
@ -338,7 +379,7 @@ namespace MultiArrayTools
|
|||
inline T get(ET pos) const;
|
||||
|
||||
template <class ET>
|
||||
inline const OperationValue& set(ET pos) const;
|
||||
inline OperationValue& set(ET pos);
|
||||
|
||||
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
||||
|
||||
|
@ -415,7 +456,7 @@ namespace MultiArrayTools
|
|||
inline T get(ET pos) const;
|
||||
|
||||
template <class ET>
|
||||
inline const Operation& set(ET pos) const;
|
||||
inline Operation& set(ET pos);
|
||||
|
||||
auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype
|
||||
-> decltype(PackNum<sizeof...(Ops)-1>::mkSteps(iPtrNum, mOps));
|
||||
|
@ -473,7 +514,7 @@ namespace MultiArrayTools
|
|||
|
||||
private:
|
||||
|
||||
const Op& mOp;
|
||||
Op mOp;
|
||||
std::shared_ptr<IndexType> mInd;
|
||||
|
||||
public:
|
||||
|
@ -485,7 +526,7 @@ namespace MultiArrayTools
|
|||
inline T get(ET pos) const;
|
||||
|
||||
template <class ET>
|
||||
inline const Contraction& set(ET pos) const;
|
||||
inline Contraction& set(ET pos);
|
||||
|
||||
auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype
|
||||
-> decltype(mOp.rootSteps(iPtrNum));
|
||||
|
@ -509,7 +550,7 @@ namespace MultiArrayTools
|
|||
|
||||
private:
|
||||
|
||||
const Op& mOp;
|
||||
mutable Op mOp;
|
||||
mutable std::shared_ptr<MultiArray<T,typename Indices::RangeType...> > mCont;
|
||||
mutable OperationRoot<T,typename Indices::RangeType...> mTarOp;
|
||||
|
||||
|
@ -522,7 +563,7 @@ namespace MultiArrayTools
|
|||
inline const value_type& get(ET pos) const;
|
||||
|
||||
template <class ET>
|
||||
inline const SliceContraction& set(ET pos) const;
|
||||
inline SliceContraction& set(ET pos);
|
||||
|
||||
auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype
|
||||
-> decltype(mOp.rootSteps(iPtrNum));
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <size_t LAST, typename T, class ETuple, class OpTuple, class OpFunction, typename... Args>
|
||||
static inline T mkOpExpr(std::shared_ptr<OpFunction> f, const ETuple& pos, const OpTuple& ops, const Args&... args)
|
||||
static inline T mkOpExpr(std::shared_ptr<OpFunction> f, const ETuple& pos, const OpTuple& ops, Args... args)
|
||||
{
|
||||
typedef typename std::remove_reference<decltype(std::get<N>(ops))>::type NextOpType;
|
||||
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
||||
|
@ -116,7 +116,7 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <size_t LAST,class OpTuple, class ETuple>
|
||||
static inline void setOpPos(const OpTuple& ot, const ETuple& et)
|
||||
static inline void setOpPos(OpTuple& ot, const ETuple& et)
|
||||
{
|
||||
typedef typename std::remove_reference<decltype(std::get<N>(ot))>::type NextOpType;
|
||||
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
||||
|
@ -203,7 +203,7 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <size_t LAST,class OpTuple, class ETuple>
|
||||
static inline void setOpPos(const OpTuple& ot, const ETuple& et)
|
||||
static inline void setOpPos(OpTuple& ot, const ETuple& et)
|
||||
{
|
||||
typedef typename std::remove_reference<decltype(std::get<0>(et))>::type NextOpType;
|
||||
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
||||
|
|
|
@ -154,7 +154,10 @@ namespace MultiArrayTools
|
|||
friend OperationClass;
|
||||
};
|
||||
|
||||
typedef struct v256 { alignas(32) double _x[4]; } v256;
|
||||
struct v256
|
||||
{
|
||||
alignas(32) double _x[4];
|
||||
};
|
||||
|
||||
template <int N>
|
||||
inline void xadd(double* o, const double* a, const double* b)
|
||||
|
@ -173,16 +176,16 @@ namespace MultiArrayTools
|
|||
o[i] += a[i];
|
||||
}
|
||||
}
|
||||
|
||||
inline v256 operator+(const v256& a, const v256& b)
|
||||
|
||||
inline v256 operator+(v256 a, v256 b)
|
||||
{
|
||||
alignas(32) v256 o;
|
||||
v256 o;
|
||||
xadd<4>( reinterpret_cast<double*>(&o), reinterpret_cast<const double*>(&a),
|
||||
reinterpret_cast<const double*>(&b) );
|
||||
return o;
|
||||
}
|
||||
|
||||
inline v256& operator+=(v256& o, const v256& a)
|
||||
inline v256& operator+=(v256& o, v256 a)
|
||||
{
|
||||
xsadd<4>( reinterpret_cast<double*>(&o), reinterpret_cast<const double*>(&a) );
|
||||
return o;
|
||||
|
@ -190,7 +193,7 @@ namespace MultiArrayTools
|
|||
/*
|
||||
inline v256 operator-(const v256& a, const v256& b)
|
||||
{
|
||||
alignas(32) v256 out;
|
||||
v256 out;
|
||||
#pragma omp simd aligned(outp, ap, bp: 32)
|
||||
for(int i = 0; i < IN; ++i){
|
||||
outp[i] = ap[i] - bp[i];
|
||||
|
@ -200,7 +203,7 @@ namespace MultiArrayTools
|
|||
|
||||
inline v256 operator*(const v256& a, const v256& b)
|
||||
{
|
||||
alignas(32) v256 out;
|
||||
v256 out;
|
||||
#pragma omp simd aligned(outp, ap, bp: 32)
|
||||
for(int i = 0; i < IN; ++i){
|
||||
outp[i] = ap[i] * bp[i];
|
||||
|
@ -210,7 +213,7 @@ namespace MultiArrayTools
|
|||
|
||||
inline v256 operator/(const v256& a, const v256& b)
|
||||
{
|
||||
alignas(32) v256 out;
|
||||
v256 out;
|
||||
#pragma omp simd aligned(outp, ap, bp: 32)
|
||||
for(int i = 0; i < IN; ++i){
|
||||
outp[i] = ap[i] / bp[i];
|
||||
|
|
|
@ -35,8 +35,8 @@ namespace MultiArrayHelper
|
|||
ExpressionBase& operator=(const ExpressionBase& in) = default;
|
||||
ExpressionBase& operator=(ExpressionBase&& in) = default;
|
||||
|
||||
virtual void operator()(size_t mlast, DExt last) const = 0;
|
||||
virtual void operator()(size_t mlast = 0) const = 0;
|
||||
virtual void operator()(size_t mlast, DExt last) = 0;
|
||||
virtual void operator()(size_t mlast = 0) = 0;
|
||||
|
||||
virtual DExt dRootSteps(std::intptr_t iPtrNum = 0) const = 0;
|
||||
virtual DExt dExtension() const = 0;
|
||||
|
@ -127,9 +127,9 @@ namespace MultiArrayHelper
|
|||
Expr expr);
|
||||
|
||||
|
||||
inline void operator()(size_t mlast, DExt last) const override final;
|
||||
inline void operator()(size_t mlast, ExtType last) const;
|
||||
inline void operator()(size_t mlast = 0) const override final;
|
||||
inline void operator()(size_t mlast, DExt last) override final;
|
||||
inline void operator()(size_t mlast, ExtType last);
|
||||
inline void operator()(size_t mlast = 0) override final;
|
||||
|
||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||
DExt dExtension() const override final;
|
||||
|
@ -176,9 +176,9 @@ namespace MultiArrayHelper
|
|||
const vector<size_t>* subset, Expr expr);
|
||||
|
||||
|
||||
inline void operator()(size_t mlast, DExt last) const override final;
|
||||
inline void operator()(size_t mlast, ExtType last) const;
|
||||
inline void operator()(size_t mlast = 0) const override final;
|
||||
inline void operator()(size_t mlast, DExt last) override final;
|
||||
inline void operator()(size_t mlast, ExtType last) ;
|
||||
inline void operator()(size_t mlast = 0) override final;
|
||||
|
||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||
DExt dExtension() const override final;
|
||||
|
@ -224,9 +224,9 @@ namespace MultiArrayHelper
|
|||
For(const IndexClass* indPtr,
|
||||
size_t step, Expr expr);
|
||||
|
||||
inline void operator()(size_t mlast, DExt last) const override final;
|
||||
inline void operator()(size_t mlast, ExtType last) const;
|
||||
inline void operator()(size_t mlast = 0) const override final;
|
||||
inline void operator()(size_t mlast, DExt last) override final;
|
||||
inline void operator()(size_t mlast, ExtType last) ;
|
||||
inline void operator()(size_t mlast = 0) override final;
|
||||
|
||||
PFor<IndexClass,Expr> parallel() const;
|
||||
|
||||
|
@ -272,9 +272,9 @@ namespace MultiArrayHelper
|
|||
PFor(const IndexClass* indPtr,
|
||||
size_t step, Expr expr);
|
||||
|
||||
inline void operator()(size_t mlast, DExt last) const override final;
|
||||
inline void operator()(size_t mlast, ExtType last) const;
|
||||
inline void operator()(size_t mlast = 0) const override final;
|
||||
inline void operator()(size_t mlast, DExt last) override final;
|
||||
inline void operator()(size_t mlast, ExtType last) ;
|
||||
inline void operator()(size_t mlast = 0) override final;
|
||||
|
||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||
DExt dExtension() const override final;
|
||||
|
@ -311,8 +311,8 @@ namespace MultiArrayHelper
|
|||
template <class Expr>
|
||||
DynamicExpression(Expr ex) : mNext( std::make_shared<Expr>(ex) ) {}
|
||||
|
||||
inline void operator()(size_t mlast, DExt last) const override final;
|
||||
inline void operator()(size_t mlast = 0) const override final;
|
||||
inline void operator()(size_t mlast, DExt last) override final;
|
||||
inline void operator()(size_t mlast = 0) override final;
|
||||
|
||||
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||
inline DExt dExtension() const override final;
|
||||
|
@ -345,9 +345,9 @@ namespace MultiArrayHelper
|
|||
|
||||
ExpressionHolder(DynamicExpression expr);
|
||||
|
||||
inline void operator()(size_t mlast, DExt last) const override final;
|
||||
inline void operator()(size_t mlast, ExtType last) const;
|
||||
inline void operator()(size_t mlast = 0) const override final;
|
||||
inline void operator()(size_t mlast, DExt last) override final;
|
||||
inline void operator()(size_t mlast, ExtType last) ;
|
||||
inline void operator()(size_t mlast = 0) override final;
|
||||
|
||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||
DExt dExtension() const override final;
|
||||
|
@ -391,14 +391,14 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT>
|
||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast, DExt last) const
|
||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT>
|
||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast,
|
||||
ExtType last) const
|
||||
ExtType last)
|
||||
{
|
||||
typedef typename IndexClass::RangeType RangeType;
|
||||
for(size_t pos = 0u; pos != ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE>(mMax); ++pos){
|
||||
|
@ -411,7 +411,7 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <class IndexClass, class Expr, ForType FT>
|
||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast) const
|
||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast)
|
||||
{
|
||||
typedef typename IndexClass::RangeType RangeType;
|
||||
const ExtType last;
|
||||
|
@ -484,14 +484,14 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void PFor<IndexClass,Expr>::operator()(size_t mlast, DExt last) const
|
||||
inline void PFor<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void PFor<IndexClass,Expr>::operator()(size_t mlast,
|
||||
ExtType last) const
|
||||
ExtType last)
|
||||
{
|
||||
CHECK;
|
||||
typedef typename IndexClass::RangeType RangeType;
|
||||
|
@ -511,7 +511,7 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void PFor<IndexClass,Expr>::operator()(size_t mlast) const
|
||||
inline void PFor<IndexClass,Expr>::operator()(size_t mlast)
|
||||
{
|
||||
CHECK;
|
||||
typedef typename IndexClass::RangeType RangeType;
|
||||
|
@ -588,14 +588,14 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast, DExt last) const
|
||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast,
|
||||
ExtType last) const
|
||||
ExtType last)
|
||||
{
|
||||
//typedef typename IndexClass::RangeType RangeType;
|
||||
const size_t pos = mIndPtr->pos();
|
||||
|
@ -605,7 +605,7 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast) const
|
||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast)
|
||||
{
|
||||
//typedef typename IndexClass::RangeType RangeType;
|
||||
const ExtType last;
|
||||
|
@ -672,14 +672,14 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast, DExt last) const
|
||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast,
|
||||
ExtType last) const
|
||||
ExtType last)
|
||||
{
|
||||
const size_t pos = (*mSubSet)[last.val()];
|
||||
const size_t mnpos = mlast;
|
||||
|
@ -688,7 +688,7 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast) const
|
||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast)
|
||||
{
|
||||
const ExtType last;
|
||||
const size_t pos = (*mSubSet)[last.val()];
|
||||
|
@ -731,12 +731,12 @@ namespace MultiArrayHelper
|
|||
* DynamicExpression *
|
||||
***************************/
|
||||
|
||||
inline void DynamicExpression::operator()(size_t mlast, DExt last) const
|
||||
inline void DynamicExpression::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
(*mNext)(mlast,last);
|
||||
}
|
||||
|
||||
inline void DynamicExpression::operator()(size_t mlast) const
|
||||
inline void DynamicExpression::operator()(size_t mlast)
|
||||
{
|
||||
(*mNext)(mlast);
|
||||
}
|
||||
|
@ -759,13 +759,13 @@ namespace MultiArrayHelper
|
|||
ExpressionHolder<Expr>::ExpressionHolder(DynamicExpression expr) : mExpr(expr) {}
|
||||
|
||||
template <class Expr>
|
||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast, DExt last) const
|
||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast, DExt last)
|
||||
{
|
||||
mExpr(mlast,last);
|
||||
}
|
||||
|
||||
template <class Expr>
|
||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast, ExtType last) const
|
||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast, ExtType last)
|
||||
{
|
||||
mExpr(mlast,
|
||||
std::make_pair<size_t const*,size_t>
|
||||
|
@ -774,7 +774,7 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <class Expr>
|
||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast) const
|
||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast)
|
||||
{
|
||||
mExpr(mlast);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue