WIP: see last commit (there is still a non-initialized dynamic ext object)
This commit is contained in:
parent
f04ee322bb
commit
233a0a7452
4 changed files with 53 additions and 22 deletions
|
@ -6,9 +6,6 @@ namespace MultiArrayTools
|
||||||
template <typename T, class Operation>
|
template <typename T, class Operation>
|
||||||
const T& DynamicOperation<T,Operation>::get(const DExtT& pos) const
|
const T& DynamicOperation<T,Operation>::get(const DExtT& pos) const
|
||||||
{
|
{
|
||||||
VCHECK(pos.size());
|
|
||||||
VCHECK(sizeof(ET)/sizeof(size_t));
|
|
||||||
assert(0);
|
|
||||||
return mOp.get(pos.expl<ET>());
|
return mOp.get(pos.expl<ET>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,8 @@ namespace MultiArrayTools
|
||||||
template <typename T, class Target, class OpClass, OpIndexAff OIA>
|
template <typename T, class Target, class OpClass, OpIndexAff OIA>
|
||||||
inline void AssignmentExpr2<T,Target,OpClass,OIA>::operator()(size_t start)
|
inline void AssignmentExpr2<T,Target,OpClass,OIA>::operator()(size_t start)
|
||||||
{
|
{
|
||||||
ExtType last;
|
ExtType last = rootSteps();
|
||||||
|
last.zero();
|
||||||
mDataPtr[OpIndexResolve<OIA>::get(start,last)] = mSec.get(last.next());
|
mDataPtr[OpIndexResolve<OIA>::get(start,last)] = mSec.get(last.next());
|
||||||
//mDataPtr[last.val()] = mSec.get(last.next());
|
//mDataPtr[last.val()] = mSec.get(last.next());
|
||||||
}
|
}
|
||||||
|
@ -224,7 +225,8 @@ namespace MultiArrayTools
|
||||||
template <typename T, class Target, class OpClass, OpIndexAff OIA>
|
template <typename T, class Target, class OpClass, OpIndexAff OIA>
|
||||||
inline void AddExpr<T,Target,OpClass,OIA>::operator()(size_t start)
|
inline void AddExpr<T,Target,OpClass,OIA>::operator()(size_t start)
|
||||||
{
|
{
|
||||||
ExtType last;
|
ExtType last = rootSteps();
|
||||||
|
last.zero();
|
||||||
mDataPtr[OpIndexResolve<OIA>::get(start,last)] += mSec.get(last.next());
|
mDataPtr[OpIndexResolve<OIA>::get(start,last)] += mSec.get(last.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace MultiArrayHelper
|
||||||
MExt& operator=(const MExt& in) = default;
|
MExt& operator=(const MExt& in) = default;
|
||||||
MExt(MExt&& in) = default;
|
MExt(MExt&& in) = default;
|
||||||
MExt& operator=(MExt&& in) = default;
|
MExt& operator=(MExt&& in) = default;
|
||||||
|
|
||||||
inline MExt(size_t ext, X next);
|
inline MExt(size_t ext, X next);
|
||||||
|
|
||||||
template <class Z>
|
template <class Z>
|
||||||
|
@ -74,7 +74,9 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <class Y>
|
template <class Y>
|
||||||
inline MExt(const MExt<Y>& y);
|
inline MExt(const MExt<Y>& y);
|
||||||
|
|
||||||
|
inline void zero();
|
||||||
|
|
||||||
inline const size_t& val() const;
|
inline const size_t& val() const;
|
||||||
inline const X& next() const;
|
inline const X& next() const;
|
||||||
|
|
||||||
|
@ -107,7 +109,9 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
inline None operator+(const None& in) const { return None(); }
|
inline None operator+(const None& in) const { return None(); }
|
||||||
inline None operator*(size_t in) const { return None(); }
|
inline None operator*(size_t in) const { return None(); }
|
||||||
|
|
||||||
|
inline void zero() {}
|
||||||
|
|
||||||
template <class Y>
|
template <class Y>
|
||||||
Y extend(const Y& y) const
|
Y extend(const Y& y) const
|
||||||
{ return y; }
|
{ return y; }
|
||||||
|
@ -150,6 +154,8 @@ namespace MultiArrayHelper
|
||||||
inline const size_t& val() const;
|
inline const size_t& val() const;
|
||||||
inline None next() const { return None(); }
|
inline None next() const { return None(); }
|
||||||
|
|
||||||
|
inline void zero();
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
inline auto nn() const
|
inline auto nn() const
|
||||||
-> decltype(Getter<N>::getX(*this))
|
-> decltype(Getter<N>::getX(*this))
|
||||||
|
@ -209,7 +215,14 @@ namespace MultiArrayHelper
|
||||||
{
|
{
|
||||||
return mNext;
|
return mNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class X>
|
||||||
|
inline void MExt<X>::zero()
|
||||||
|
{
|
||||||
|
mExt = 0u;
|
||||||
|
mNext.zero();
|
||||||
|
}
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
inline MExt<X> MExt<X>::operator+(const MExt<X>& in) const
|
inline MExt<X> MExt<X>::operator+(const MExt<X>& in) const
|
||||||
{
|
{
|
||||||
|
@ -248,11 +261,16 @@ namespace MultiArrayHelper
|
||||||
mExt(y.val()) {}
|
mExt(y.val()) {}
|
||||||
|
|
||||||
//template <>
|
//template <>
|
||||||
|
inline void MExt<None>::zero()
|
||||||
|
{
|
||||||
|
mExt = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
inline const size_t& MExt<None>::val() const
|
inline const size_t& MExt<None>::val() const
|
||||||
{
|
{
|
||||||
return mExt;
|
return mExt;
|
||||||
}
|
}
|
||||||
|
|
||||||
//template <>
|
//template <>
|
||||||
inline MExt<None> MExt<None>::operator+(const MExt<None>& in) const
|
inline MExt<None> MExt<None>::operator+(const MExt<None>& in) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,6 +37,9 @@ namespace MultiArrayHelper
|
||||||
//virtual size_t rootSteps() const = 0;
|
//virtual size_t rootSteps() const = 0;
|
||||||
virtual std::shared_ptr<ExtBase> operator+(const ExtBase& in) const = 0;
|
virtual std::shared_ptr<ExtBase> operator+(const ExtBase& in) const = 0;
|
||||||
virtual std::shared_ptr<ExtBase> operator*(size_t in) const = 0;
|
virtual std::shared_ptr<ExtBase> operator*(size_t in) const = 0;
|
||||||
|
virtual void zero() = 0;
|
||||||
|
|
||||||
|
virtual std::shared_ptr<ExtBase> deepCopy() const = 0;
|
||||||
|
|
||||||
template <class ExtType>
|
template <class ExtType>
|
||||||
const ExtType& expl() const;
|
const ExtType& expl() const;
|
||||||
|
@ -61,12 +64,15 @@ namespace MultiArrayHelper
|
||||||
ExtT& operator=(ExtT&& in) = default;
|
ExtT& operator=(ExtT&& in) = default;
|
||||||
|
|
||||||
ExtT(const ExtType& in) : mExt(in) {}
|
ExtT(const ExtType& in) : mExt(in) {}
|
||||||
|
|
||||||
|
virtual std::shared_ptr<ExtBase> deepCopy() const override final { return std::make_shared<ExtT<ExtType>>(mExt); }
|
||||||
|
|
||||||
virtual size_t size() const override final { return sizeof(ExtType)/sizeof(size_t); }
|
virtual size_t size() const override final { return sizeof(ExtType)/sizeof(size_t); }
|
||||||
//virtual size_t size() const override final { return ExtType::MExtSize(); }
|
//virtual size_t size() const override final { return ExtType::MExtSize(); }
|
||||||
//virtual size_t rootSteps() const override final;
|
//virtual size_t rootSteps() const override final;
|
||||||
const ExtType& ext() const { return mExt; }
|
const ExtType& ext() const { return mExt; }
|
||||||
virtual const size_t& val() const override final { return mExt.val(); }
|
virtual const size_t& val() const override final { return mExt.val(); }
|
||||||
|
virtual void zero() override final { mExt.zero(); }
|
||||||
|
|
||||||
virtual DExt operator+(const ExtBase& in) const override final
|
virtual DExt operator+(const ExtBase& in) const override final
|
||||||
{ return std::make_shared<ExtT>( mExt + dynamic_cast<const ExtT&>(in).mExt ); }
|
{ return std::make_shared<ExtT>( mExt + dynamic_cast<const ExtT&>(in).mExt ); }
|
||||||
|
@ -79,17 +85,17 @@ namespace MultiArrayHelper
|
||||||
class DExtTX
|
class DExtTX
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
DExt mDExt = nullptr;
|
mutable DExt mDExt = nullptr;
|
||||||
X mNext;
|
X mNext;
|
||||||
public:
|
public:
|
||||||
static constexpr size_t NUM = X::SIZE;
|
static constexpr size_t NUM = X::SIZE;
|
||||||
static constexpr size_t SIZE = NUM + 1;
|
static constexpr size_t SIZE = NUM + 1;
|
||||||
|
|
||||||
DExtTX() = default;
|
DExtTX() = default;
|
||||||
DExtTX(const DExtTX& in) = default;
|
DExtTX(const DExtTX& in) : mDExt(in.mDExt->deepCopy()), mNext(in.mNext) {}
|
||||||
DExtTX(DExtTX&& in) = default;
|
DExtTX(DExtTX&& in) : mDExt(in.mDExt->deepCopy()), mNext(in.mNext) {}
|
||||||
DExtTX& operator=(const DExtTX& in) = default;
|
DExtTX& operator=(const DExtTX& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); }
|
||||||
DExtTX& operator=(DExtTX&& in) = default;
|
DExtTX& operator=(DExtTX&& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); }
|
||||||
DExtTX(const DExt& in) : mDExt(in) {}
|
DExtTX(const DExt& in) : mDExt(in) {}
|
||||||
|
|
||||||
template <class Y>
|
template <class Y>
|
||||||
|
@ -110,7 +116,8 @@ namespace MultiArrayHelper
|
||||||
{ if (not mDExt) return *this; else return DExtTX( (*mDExt) * in ) ; }
|
{ if (not mDExt) return *this; else return DExtTX( (*mDExt) * in ) ; }
|
||||||
|
|
||||||
template <class ExtType>
|
template <class ExtType>
|
||||||
inline const ExtType& expl() const { return mDExt->expl<ExtType>(); }
|
inline const ExtType& expl() const
|
||||||
|
{ if(mDExt == nullptr) mDExt = std::make_shared<ExtT<ExtType>>(); assert(mDExt != nullptr); return mDExt->expl<ExtType>(); }
|
||||||
|
|
||||||
template <class Y>
|
template <class Y>
|
||||||
inline auto extend(const Y& y) const -> DExtTX<decltype(mNext.extend(y))>
|
inline auto extend(const Y& y) const -> DExtTX<decltype(mNext.extend(y))>
|
||||||
|
@ -119,6 +126,8 @@ namespace MultiArrayHelper
|
||||||
inline const size_t& val() const { return mDExt->val(); }
|
inline const size_t& val() const { return mDExt->val(); }
|
||||||
inline const X& next() const { return mNext; }
|
inline const X& next() const { return mNext; }
|
||||||
|
|
||||||
|
inline void zero() { mDExt->zero(); }
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
inline auto nn() const -> decltype(Getter<N>::getX(*this))
|
inline auto nn() const -> decltype(Getter<N>::getX(*this))
|
||||||
{ return Getter<N>::getX(*this); }
|
{ return Getter<N>::getX(*this); }
|
||||||
|
@ -533,7 +542,8 @@ namespace MultiArrayHelper
|
||||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast)
|
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
typedef typename IndexClass::RangeType RangeType;
|
typedef typename IndexClass::RangeType RangeType;
|
||||||
const ExtType last;
|
ExtType last = rootSteps();
|
||||||
|
last.zero();
|
||||||
for(size_t pos = 0u; pos != ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE>(mMax); ++pos){
|
for(size_t pos = 0u; pos != ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE>(mMax); ++pos){
|
||||||
const size_t mnpos = PosForward<FT>::valuex(mlast, mStep, pos);
|
const size_t mnpos = PosForward<FT>::valuex(mlast, mStep, pos);
|
||||||
const ExtType npos = last + mExt*pos;
|
const ExtType npos = last + mExt*pos;
|
||||||
|
@ -635,10 +645,12 @@ namespace MultiArrayHelper
|
||||||
{
|
{
|
||||||
CHECK;
|
CHECK;
|
||||||
typedef typename IndexClass::RangeType RangeType;
|
typedef typename IndexClass::RangeType RangeType;
|
||||||
const ExtType last;
|
ExtType last = rootSteps();
|
||||||
|
last.zero();
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
size_t mnpos = 0;
|
size_t mnpos = 0;
|
||||||
ExtType npos;
|
ExtType npos = rootSteps();
|
||||||
|
npos.zero();
|
||||||
#pragma omp parallel shared(mExpr) private(pos,mnpos,npos)
|
#pragma omp parallel shared(mExpr) private(pos,mnpos,npos)
|
||||||
{
|
{
|
||||||
auto expr = mExpr;
|
auto expr = mExpr;
|
||||||
|
@ -731,7 +743,8 @@ namespace MultiArrayHelper
|
||||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast)
|
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
//typedef typename IndexClass::RangeType RangeType;
|
//typedef typename IndexClass::RangeType RangeType;
|
||||||
const ExtType last;
|
ExtType last = rootSteps();
|
||||||
|
last.zero();
|
||||||
const size_t pos = mIndPtr->pos();
|
const size_t pos = mIndPtr->pos();
|
||||||
const size_t mnpos = PosForward<ForType::DEFAULT>::value(mlast, mMax, pos);
|
const size_t mnpos = PosForward<ForType::DEFAULT>::value(mlast, mMax, pos);
|
||||||
const ExtType npos = last + mExt*pos;
|
const ExtType npos = last + mExt*pos;
|
||||||
|
@ -816,7 +829,8 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast)
|
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
const ExtType last;
|
ExtType last = rootSteps();
|
||||||
|
last.zero();
|
||||||
const size_t pos = (*mSubSet)[last.val()];
|
const size_t pos = (*mSubSet)[last.val()];
|
||||||
const size_t mnpos = mlast;
|
const size_t mnpos = mlast;
|
||||||
const ExtType npos = last + mExt*pos;
|
const ExtType npos = last + mExt*pos;
|
||||||
|
|
Loading…
Reference in a new issue