Revert "vertical structure..."

This reverts commit c6f140a18e.
This commit is contained in:
Christian Zimmermann 2020-08-12 16:48:07 +02:00
parent c6f140a18e
commit d7436ed577
3 changed files with 21 additions and 102 deletions

View file

@ -6,19 +6,9 @@ namespace MultiArrayTools
template <typename T, class Operation>
const T& DynamicOperation<T,Operation>::get(const DExtT& pos) const
{
if(pos.isInit()){
VCHECK(pos.stype());
ET xx;
VCHECK(xx.stype());
VCHECK(mOp.rootSteps(0).stype());
VCHECK(pos.expl<ET>().val());
return mOp.get(pos.expl<ET>());
}
else {
ET xx;
return mOp.get(xx);
}
}
template <typename T, class Operation>
DynamicOperationBase<T>& DynamicOperation<T,Operation>::set(const DExtT& pos)

View file

@ -92,10 +92,6 @@ namespace MultiArrayHelper
auto extend(const Y& y) const -> MExt<decltype(mNext.extend(y))>
{ return MExt<decltype(mNext.extend(y))>(mExt, mNext.extend(y)); }
std::string stype() const { return std::string("E[") + mNext.stype() + "]"; }
const MExt& lowest() const { return *this; }
MExt& lowest() { return *this; }
};
struct None
@ -121,11 +117,6 @@ namespace MultiArrayHelper
template <class Y>
Y extend(const Y& y) const
{ return y; }
std::string stype() const { return "N"; }
const None& lowest() const { return *this; }
None& lowest() { return *this; }
};
template <>
@ -179,10 +170,6 @@ namespace MultiArrayHelper
auto extend(const Y& y) const -> MExt<Y>
{ return MExt<Y>(mExt,y); }
std::string stype() const { return "E[N]"; }
const MExt& lowest() const { return *this; }
MExt& lowest() { return *this; }
};

View file

@ -44,8 +44,6 @@ namespace MultiArrayHelper
template <class ExtType>
const ExtType& expl() const;
virtual std::string stype() const = 0;
};
typedef std::shared_ptr<ExtBase> DExt;
@ -65,7 +63,7 @@ namespace MultiArrayHelper
ExtT& operator=(const ExtT& in) = default;
ExtT& operator=(ExtT&& in) = default;
ExtT(const ExtType& in) : mExt(in) { assert(in.stype()[0] != 'T'); }
ExtT(const ExtType& in) : mExt(in) {}
virtual std::shared_ptr<ExtBase> deepCopy() const override final { return std::make_shared<ExtT<ExtType>>(mExt); }
@ -80,70 +78,31 @@ namespace MultiArrayHelper
{ return std::make_shared<ExtT>( mExt + dynamic_cast<const ExtT&>(in).mExt ); }
virtual DExt operator*(size_t in) const override final
{ return std::make_shared<ExtT>( mExt * in ); }
virtual std::string stype() const override final { return std::string("T[")+mExt.stype()+"]"; }
const ExtType& lowest() const { return mExt; }
ExtType& lowest() { return mExt; }
};
//class DExtT;
template <class X>
class DExtTX;
template <class Y>
struct SptrExtT
{
typedef typename std::remove_reference<decltype(std::declval<Y>().lowest())>::type YX;
static DExt mk(const Y& y)
{
return std::make_shared<ExtT<YX>>(y.lowest());
}
};
template <class X>
struct SptrExtT<DExtTX<X>>
{
static DExt mk(const DExtTX<X>& y)
{
return y.lowest();
}
};
/*
template <class Y>
struct SptrExtT<ExtT<Y>>
{
static DExt mk(const ExtT<Y>& y)
{
return std::make_shared<ExtT<Y>>(y);
}
};
*/
template <class X>
class DExtTX
{
private:
mutable DExt mDExt = nullptr;
X mNext;
static DExt getDeepCopy(const DExtTX& in) { if(in.mDExt) return in.mDExt->deepCopy(); else return DExt(); }
public:
static constexpr size_t NUM = X::SIZE;
static constexpr size_t SIZE = NUM + 1;
//DExtTX() { VCHECK(mDExt->val()) ;mDExt = std::make_shared<ExtT<None>>(); }
DExtTX() = default;
DExtTX(const DExtTX& in) : mDExt(getDeepCopy(in)), mNext(in.mNext) {}
DExtTX(DExtTX&& in) : mDExt(getDeepCopy(in)), mNext(in.mNext) {}
DExtTX& operator=(const DExtTX& in) { mNext = in.mNext; mDExt = getDeepCopy(in); }
DExtTX& operator=(DExtTX&& in) { mNext = in.mNext; mDExt = getDeepCopy(in); }
DExtTX() { mDExt = std::make_shared<ExtT<None>>(); }
DExtTX(const DExtTX& in) : mDExt(in.mDExt->deepCopy()), mNext(in.mNext) {}
DExtTX(DExtTX&& in) : mDExt(in.mDExt->deepCopy()), mNext(in.mNext) {}
DExtTX& operator=(const DExtTX& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); }
DExtTX& operator=(DExtTX&& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); }
DExtTX(const DExt& in) : mDExt(in) {}
template <class Y>
DExtTX& operator=(const Y& y) { mDExt = SptrExtT<Y>::mk(y); return *this; }
DExtTX& operator=(const Y& y) { mDExt = std::make_shared<ExtT<Y>>(y); return *this; }
template <class Y>
DExtTX(const Y& y) : mDExt(SptrExtT<Y>::mk(y)) {}
DExtTX(const Y& y) : mDExt(std::make_shared<ExtT<Y>>(y)) {}
DExtTX(const DExt& y, const X& x) : mDExt(y),
mNext(x) {}
@ -158,8 +117,7 @@ namespace MultiArrayHelper
template <class ExtType>
inline const ExtType& expl() const
//{ if(mDExt == nullptr) mDExt = std::make_shared<ExtT<ExtType>>(); assert(mDExt != nullptr); return mDExt->expl<ExtType>(); }
{ return mDExt->expl<ExtType>(); }
{ if(mDExt == nullptr) mDExt = std::make_shared<ExtT<ExtType>>(); assert(mDExt != nullptr); return mDExt->expl<ExtType>(); }
template <class Y>
inline auto extend(const Y& y) const -> DExtTX<decltype(mNext.extend(y))>
@ -173,13 +131,6 @@ namespace MultiArrayHelper
template <size_t N>
inline auto nn() const -> decltype(Getter<N>::getX(*this))
{ return Getter<N>::getX(*this); }
inline std::string stype() const { return std::string("S[")+mDExt->stype()+"]"; }
inline bool isInit() const { return mDExt != nullptr; }
const DExt& lowest() const { return mDExt; }
DExt& lowest() { return mDExt; }
};
typedef DExtTX<None> DExtT;
@ -543,13 +494,7 @@ namespace MultiArrayHelper
template <class ExtType>
const ExtType& ExtBase::expl() const
{
VCHECK(this);
VCHECK(this->stype());
auto xx = dynamic_cast<const ExtT<ExtType>*>(this);
VCHECK(xx);
ExtT<ExtType> xxx;
VCHECK(xxx.stype());
return xx->ext();
return dynamic_cast<const ExtT<ExtType>*>(this)->ext();
}
/*****************
@ -577,9 +522,6 @@ namespace MultiArrayHelper
template <class IndexClass, class Expr, ForType FT>
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast, DExt last)
{
VCHECK(last->stype());
ExtType xxx;
VCHECK(xxx.stype());
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
}
@ -627,7 +569,7 @@ namespace MultiArrayHelper
template <class IndexClass, class Expr, ForType FT>
DExt For<IndexClass,Expr,FT>::dRootSteps(std::intptr_t iPtrNum) const
{
return SptrExtT<ExtType>::mk(rootSteps(iPtrNum));
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
//mRootSteps = rootSteps(iPtrNum);
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
// sizeof(ExtType)/sizeof(size_t));
@ -636,7 +578,7 @@ namespace MultiArrayHelper
template <class IndexClass, class Expr, ForType FT>
DExt For<IndexClass,Expr,FT>::dExtension() const
{
return SptrExtT<ExtType>::mk(mExt);
return std::make_shared<ExtT<ExtType>>(mExt);
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
// sizeof(ExtType)/sizeof(size_t));
}
@ -739,7 +681,7 @@ namespace MultiArrayHelper
template <class IndexClass, class Expr>
DExt PFor<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
{
return SptrExtT<ExtType>::mk(rootSteps(iPtrNum));
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
//mRootSteps = rootSteps(iPtrNum);
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
// sizeof(ExtType)/sizeof(size_t));
@ -748,7 +690,7 @@ namespace MultiArrayHelper
template <class IndexClass, class Expr>
DExt PFor<IndexClass,Expr>::dExtension() const
{
return SptrExtT<ExtType>::mk(mExt);
return std::make_shared<ExtT<ExtType>>(mExt);
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
// sizeof(ExtType)/sizeof(size_t));
}
@ -826,7 +768,7 @@ namespace MultiArrayHelper
template <class IndexClass, class Expr>
DExt SingleExpression<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
{
return SptrExtT<ExtType>::mk(rootSteps(iPtrNum));
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
//mRootSteps = rootSteps(iPtrNum);
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
// sizeof(ExtType)/sizeof(size_t));
@ -835,7 +777,7 @@ namespace MultiArrayHelper
template <class IndexClass, class Expr>
DExt SingleExpression<IndexClass,Expr>::dExtension() const
{
return SptrExtT<ExtType>::mk(mExt);
return std::make_shared<ExtT<ExtType>>(mExt);
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
// sizeof(ExtType)/sizeof(size_t));
}
@ -913,7 +855,7 @@ namespace MultiArrayHelper
template <class IndexClass, class Expr>
DExt SubExpr<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
{
return SptrExtT<ExtType>::mk(rootSteps(iPtrNum));
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
//mRootSteps = rootSteps(iPtrNum);
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
//sizeof(ExtType)/sizeof(size_t));
@ -922,7 +864,7 @@ namespace MultiArrayHelper
template <class IndexClass, class Expr>
DExt SubExpr<IndexClass,Expr>::dExtension() const
{
return SptrExtT<ExtType>::mk(mExt);
return std::make_shared<ExtT<ExtType>>(mExt);
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
// sizeof(ExtType)/sizeof(size_t));
}
@ -968,7 +910,7 @@ namespace MultiArrayHelper
inline void ExpressionHolder<Expr>::operator()(size_t mlast, ExtType last)
{
mExpr(mlast,
SptrExtT<ExtType>::mk(last));
std::make_shared<ExtT<ExtType>>(last));
}
template <class Expr>