plus operation with foreign index
This commit is contained in:
parent
388440764e
commit
4a5a413a47
2 changed files with 48 additions and 20 deletions
|
@ -155,20 +155,22 @@ namespace MultiArrayTools
|
||||||
return mTar.rootSteps(iPtrNum).extend( mSec.rootSteps(iPtrNum) );
|
return mTar.rootSteps(iPtrNum).extend( mSec.rootSteps(iPtrNum) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class OpClass>
|
template <typename T, class Target, class OpClass>
|
||||||
AddExpr<T,OpClass>::AddExpr(T* dataPtr, const OpClass& sec) :
|
AddExpr<T,Target,OpClass>::AddExpr(T* dataPtr, const Target& tar, const OpClass& sec) :
|
||||||
mSec(sec), mDataPtr(dataPtr) {}
|
mTar(tar), mSec(sec), mDataPtr(dataPtr) {}
|
||||||
|
|
||||||
template <typename T, class OpClass>
|
template <typename T, class Target, class OpClass>
|
||||||
inline void AddExpr<T,OpClass>::operator()(size_t start, ExtType last)
|
inline void AddExpr<T,Target,OpClass>::operator()(size_t start, ExtType last)
|
||||||
{
|
{
|
||||||
mDataPtr[start] += mSec.template get<ExtType>(last);
|
mDataPtr[last.val()] += mSec.get(last.next());
|
||||||
|
//mDataPtr[start] += mSec.template get<ExtType>(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class OpClass>
|
template <typename T, class Target, class OpClass>
|
||||||
typename AddExpr<T,OpClass>::ExtType AddExpr<T,OpClass>::rootSteps(std::intptr_t iPtrNum) const
|
typename AddExpr<T,Target,OpClass>::ExtType AddExpr<T,Target,OpClass>::rootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
return mSec.rootSteps(iPtrNum);
|
return mTar.rootSteps(iPtrNum).extend( mSec.rootSteps(iPtrNum) );
|
||||||
|
//return mSec.rootSteps(iPtrNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -396,12 +398,23 @@ namespace MultiArrayTools
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
auto OperationRoot<T,Ranges...>::plus(const OpClass& in) const
|
auto OperationRoot<T,Ranges...>::plus(const OpClass& in) const
|
||||||
-> decltype(mIndex.ifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in))))
|
-> decltype(mIndex.ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass>(mOrigDataPtr,*this,in))))
|
||||||
{
|
{
|
||||||
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
||||||
return mIndex.ifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in)));
|
return mIndex.ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass>(mOrigDataPtr,*this,in)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
template <class OpClass, class Index>
|
||||||
|
auto OperationRoot<T,Ranges...>::plus(const OpClass& in, const std::shared_ptr<Index>& i) const
|
||||||
|
-> decltype(i->ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass>
|
||||||
|
(mOrigDataPtr,*this,in))))
|
||||||
|
{
|
||||||
|
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
|
||||||
|
return i->ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass>
|
||||||
|
(mOrigDataPtr,*this,in)));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
||||||
|
@ -518,9 +531,11 @@ namespace MultiArrayTools
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
auto ParallelOperationRoot<T,Ranges...>::plus(const OpClass& in)
|
auto ParallelOperationRoot<T,Ranges...>::plus(const OpClass& in)
|
||||||
-> decltype(mIndex.pifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in))))
|
-> decltype(mIndex.pifor(1,in.loop(AddExpr<T,ParallelOperationRoot<T,Ranges...>,OpClass>
|
||||||
|
(mOrigDataPtr,*this,in))))
|
||||||
{
|
{
|
||||||
return mIndex.pifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in)));
|
return mIndex.pifor(1,in.loop(AddExpr<T,ParallelOperationRoot<T,Ranges...>,OpClass>
|
||||||
|
(mOrigDataPtr,*this,in)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
|
|
|
@ -130,22 +130,28 @@ namespace MultiArrayTools
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, class OpClass>
|
//template <typename T, class OpClass>
|
||||||
|
template <typename T, class Target, class OpClass>
|
||||||
class AddExpr
|
class AddExpr
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
AddExpr() = default;
|
AddExpr() = default;
|
||||||
|
|
||||||
|
Target mTar;
|
||||||
OpClass mSec;
|
OpClass mSec;
|
||||||
T* mDataPtr;
|
T* mDataPtr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static constexpr size_t LAYER = 0;
|
static constexpr size_t LAYER = 0;
|
||||||
static constexpr size_t SIZE = OpClass::SIZE;
|
static constexpr size_t SIZE = Target::SIZE + OpClass::SIZE;
|
||||||
typedef decltype(mSec.rootSteps()) ExtType;
|
typedef decltype(mTar.rootSteps(0).extend( mSec.rootSteps(0) )) ExtType;
|
||||||
|
// static constexpr size_t LAYER = 0;
|
||||||
|
//static constexpr size_t SIZE = OpClass::SIZE;
|
||||||
|
//typedef decltype(mSec.rootSteps()) ExtType;
|
||||||
|
|
||||||
AddExpr(T* dataPtr, const OpClass& sec);
|
//AddExpr(T* dataPtr, const OpClass& sec);
|
||||||
|
AddExpr(T* dataPtr, const Target& tar, const OpClass& sec);
|
||||||
AddExpr(const AddExpr& in) = default;
|
AddExpr(const AddExpr& in) = default;
|
||||||
AddExpr(AddExpr&& in) = default;
|
AddExpr(AddExpr&& in) = default;
|
||||||
|
|
||||||
|
@ -307,8 +313,14 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
auto plus(const OpClass& in) const
|
auto plus(const OpClass& in) const
|
||||||
-> decltype(mIndex.ifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in))));
|
-> decltype(mIndex.ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass>
|
||||||
|
(mOrigDataPtr,*this,in))));
|
||||||
|
|
||||||
|
template <class OpClass, class Index>
|
||||||
|
auto plus(const OpClass& in, const std::shared_ptr<Index>& i) const
|
||||||
|
-> decltype(i->ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass>
|
||||||
|
(mOrigDataPtr,*this,in))));
|
||||||
|
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
OperationRoot& operator=(const OpClass& in);
|
OperationRoot& operator=(const OpClass& in);
|
||||||
|
|
||||||
|
@ -370,7 +382,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
auto plus(const OpClass& in)
|
auto plus(const OpClass& in)
|
||||||
-> decltype(mIndex.pifor(1,in.loop(AddExpr<T,OpClass>(mOrigDataPtr,in))));
|
-> decltype(mIndex.pifor(1,in.loop(AddExpr<T,ParallelOperationRoot<T,Ranges...>,OpClass>
|
||||||
|
(mOrigDataPtr,*this,in))));
|
||||||
|
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
ParallelOperationRoot& operator=(const OpClass& in);
|
ParallelOperationRoot& operator=(const OpClass& in);
|
||||||
|
|
Loading…
Reference in a new issue