ext -> pos, expressions...
This commit is contained in:
parent
10db0908e0
commit
796bb50118
5 changed files with 251 additions and 253 deletions
|
@ -13,6 +13,9 @@ namespace CNORXZ
|
|||
template <typename T>
|
||||
ObjHandle<T>::ObjHandle(const T& a) : mC(std::make_unique<T>(a)) {}
|
||||
|
||||
template <typename T>
|
||||
ObjHandle<T>::ObjHandle(const Uptr<T>& a) : mC(a) {}
|
||||
|
||||
template <typename T>
|
||||
ObjHandle<T>::ObjHandle(const ObjHandle& a) : mC(std::make_unique<T>(*a.mC)) {}
|
||||
|
||||
|
|
|
@ -12,13 +12,14 @@ namespace CNORXZ
|
|||
template <typename T>
|
||||
class ObjHandle
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<T> mC;
|
||||
protected:
|
||||
Uptr<T> mC;
|
||||
|
||||
public:
|
||||
|
||||
ObjHandle();
|
||||
ObjHandle(const T& a);
|
||||
ObjHandle(const Uptr<T>& a);
|
||||
ObjHandle(const ObjHandle& a);
|
||||
ObjHandle(ObjHandle&& a);
|
||||
ObjHandle& operator=(const ObjHandle& a);
|
||||
|
|
|
@ -63,6 +63,26 @@ namespace CNORXZ
|
|||
template <typename T>
|
||||
class Allocator;
|
||||
|
||||
// definition: ranges/xfor/exttype.h
|
||||
class VPosBase;
|
||||
|
||||
// definition: ranges/xfor/exttype.h
|
||||
template <class PosT>
|
||||
class PosInterface;
|
||||
|
||||
// definition: ranges/xfor/exttype.h
|
||||
class DPos;
|
||||
|
||||
// definition: ranges/xfor/exttype.h
|
||||
class VPos;
|
||||
|
||||
// definition: ranges/xfor/exttype.h
|
||||
template <class PosT>
|
||||
class MPos;
|
||||
|
||||
// definition: ranges/xfor/exttype.h
|
||||
class NPos;
|
||||
|
||||
// definition: ranges/range_base.h
|
||||
class RangeBase;
|
||||
|
||||
|
|
|
@ -10,126 +10,161 @@ namespace CNORXZInternal
|
|||
// Dynamic Ext: ObjHandl<ExtBase>
|
||||
// In For Expr: try to resolve until some upper limit
|
||||
|
||||
struct None;
|
||||
|
||||
class ExtBase
|
||||
class VPosBase
|
||||
{
|
||||
public:
|
||||
ExtBase() = default;
|
||||
ExtBase(const ExtBase& in) = default;
|
||||
ExtBase(ExtBase&& in) = default;
|
||||
ExtBase& operator=(const ExtBase& in) = default;
|
||||
ExtBase& operator=(ExtBase&& in) = default;
|
||||
DEFAULT_MEMBERS(VPosBase);
|
||||
|
||||
virtual size_t size() const = 0;
|
||||
virtual const size_t& val() const = 0;
|
||||
virtual bool operator==(const ExtBase& in) const = 0;
|
||||
virtual bool operator==(size_t 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 void zero() = 0;
|
||||
|
||||
virtual std::shared_ptr<ExtBase> deepCopy() const = 0;
|
||||
|
||||
template <class ExtType>
|
||||
const ExtType& expl() const;
|
||||
|
||||
virtual SizeT vsize() const = 0;
|
||||
virtual const SizeT& vval() const = 0;
|
||||
virtual VPosBase& vzero() = 0;
|
||||
virtual Uptr<VPosBase> vextend(const DPos& a) const = 0;
|
||||
virtual Uptr<VPosBase> vextend(const MPos<NPos>& a) const = 0;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<ExtBase> DExt;
|
||||
template <class PosT>
|
||||
class PosInterface
|
||||
{
|
||||
public:
|
||||
DEFAULT_MEMBERS(PosInterface);
|
||||
|
||||
template <class ExtType>
|
||||
class ExtT : public ExtBase
|
||||
PosT& THIS() { return static_cast<PosT&>(*this); }
|
||||
const PosT& THIS() const { return static_cast<const PosT&>(*this); }
|
||||
|
||||
inline SizeT size() const { THIS().size(); }
|
||||
inline const SizeT& val() const { THIS().val(); }
|
||||
inline auto next() const { THIS().next(); }
|
||||
inline bool operator==(const PosInterface<PosT>& a) const { return val() == a.val() and next() == a.next(); }
|
||||
inline bool operator!=(const PosInterface<PosT>& a) const { return val() != a.val() or next() != a.next(); }
|
||||
inline bool operator==(SizeT a) const { return val() == a and next() == a; }
|
||||
inline bool operator!=(SizeT a) const { return val() != a or next() != a; }
|
||||
inline PosInterface<PosT> operator+(const PosInterface<PosT>& a) const { return PosT(val()+a.val(), next()+a.next()); }
|
||||
inline PosInterface<PosT> operator*(SizeT a) const { return PosT(val()*a, next()*a); }
|
||||
inline PosInterface<PosT>& zero() { return THIS().zero(); }
|
||||
|
||||
template <class P>
|
||||
inline auto extend(const PosInterface<P>& a) const { return THIS().extend(a); }
|
||||
};
|
||||
|
||||
class DPos : public ObjHandle<VPosBase>,
|
||||
public PosInterface<DPos>
|
||||
{
|
||||
public:
|
||||
DEFAULT_MEMBERS(DPos);
|
||||
DPos(Uptr<VPosBase> a) : ObjHandle<VPosBase>(a) {}
|
||||
|
||||
template <class PosT>
|
||||
DPos(const PosT& a) : ObjHandle<VPosBase>( std::make_unique<PosT>(a) ) {}
|
||||
|
||||
inline SizeT size() const { return mC->vsize(); }
|
||||
inline const SizeT& val() const { return mC->vval(); }
|
||||
inline DPos& zero() { mC->vzero(); return *this; }
|
||||
|
||||
template <class P>
|
||||
inline DPos extend(const PosInterface<P>& a) const
|
||||
{ /* append MPos<NPos> in static for loop over entries */ }
|
||||
};
|
||||
|
||||
/*
|
||||
template <class PosT>
|
||||
class VPos : public VPosBase
|
||||
{
|
||||
private:
|
||||
ExtType mExt;
|
||||
PosT mExt;
|
||||
public:
|
||||
static constexpr size_t SIZE = ExtType::SIZE;
|
||||
static constexpr size_t NUM = ExtType::NUM;
|
||||
|
||||
ExtT() = default;
|
||||
ExtT(const ExtT& in) = default;
|
||||
ExtT(ExtT&& in) = default;
|
||||
ExtT& operator=(const ExtT& in) = default;
|
||||
ExtT& operator=(ExtT&& in) = default;
|
||||
|
||||
ExtT(const ExtType& in) : mExt(in) {}
|
||||
DEFAULT_MEMBERS(VPos);
|
||||
|
||||
virtual std::shared_ptr<ExtBase> deepCopy() const override final { return std::make_shared<ExtT<ExtType>>(mExt); }
|
||||
VPos(const PosT& in) : mExt(in) {}
|
||||
|
||||
virtual size_t size() const override final { return sizeof(ExtType)/sizeof(size_t); }
|
||||
const ExtType& ext() const { return mExt; }
|
||||
virtual const size_t& val() const override final { return mExt.val(); }
|
||||
virtual SizeT size() const override final { return sizeof(PosT)/sizeof(size_t); }
|
||||
//const PosT& ext() const { return mExt; }
|
||||
virtual const SizeT& val() const override final { return mExt.val(); }
|
||||
virtual void zero() override final { mExt.zero(); }
|
||||
|
||||
virtual bool operator==(const ExtBase& in) const override final
|
||||
{ return mExt == dynamic_cast<const ExtT<ExtType>&>(in).mExt; }
|
||||
virtual bool operator==(const VPosBase& in) const override final
|
||||
{ return mExt == dynamic_cast<const VPos<PosT>&>(in).mExt; }
|
||||
|
||||
virtual bool operator==(size_t in) const override final
|
||||
virtual bool operator==(SizeT in) const override final
|
||||
{ return mExt == in; }
|
||||
|
||||
virtual DExt operator+(const ExtBase& in) const override final
|
||||
{ return std::make_shared<ExtT<ExtType>>( mExt + dynamic_cast<const ExtT<ExtType>&>(in).mExt ); }
|
||||
virtual DExt operator+(const VPosBase& in) const override final
|
||||
{ return std::make_shared<VPos<PosT>>( mExt + dynamic_cast<const VPos<PosT>&>(in).mExt ); }
|
||||
virtual DExt operator*(size_t in) const override final
|
||||
{ return std::make_shared<ExtT<ExtType>>( mExt * in ); }
|
||||
{ return std::make_shared<VPos<PosT>>( mExt * in ); }
|
||||
|
||||
};
|
||||
*/
|
||||
template <class PosT>
|
||||
class VPos : public VPosBase, public PosT
|
||||
{
|
||||
public:
|
||||
|
||||
DEFAULT_MEMBERS(VPos);
|
||||
|
||||
VPos(const PosInterface<PosT>& a) : PosT(a.THIS()) {}
|
||||
|
||||
virtual SizeT vsize() const override final { return THIS().size(); }
|
||||
virtual const SizeT& vval() const override final { return THIS().val(); }
|
||||
virtual VPos& vzero() override final { THIS().zero(); return *this; }
|
||||
virtual Uptr<VPosBase> vextend(const DPos& a) const override final
|
||||
{ return std::make_unique<VPosBase>( THIS().extend(a) ); }
|
||||
virtual Uptr<VPosBase> vextend(const MPos<NPos>& a) const override final
|
||||
{ return std::make_unique<VPosBase>( THIS().extend(a) ); } // ??? if that works it would be a miracle ???
|
||||
// .... probably I need to define a static instanciation limit...
|
||||
|
||||
};
|
||||
|
||||
template <class ExtType>
|
||||
DExt mkDExt(const ExtT<ExtType>& in)
|
||||
template <class PosT>
|
||||
DPos mkDExt(const VPos<PosT>& in)
|
||||
{
|
||||
return std::make_shared<ExtT<ExtType>>(in);
|
||||
return std::make_shared<VPos<PosT>>(in);
|
||||
}
|
||||
|
||||
template <class ExtType>
|
||||
ExtT<ExtType> mkExtT(const ExtType& in)
|
||||
template <class PosT>
|
||||
VPos<PosT> mkVPos(const PosT& in)
|
||||
{
|
||||
return ExtT<ExtType>(in);
|
||||
return VPos<PosT>(in);
|
||||
}
|
||||
|
||||
template <class X>
|
||||
class MExt
|
||||
template <class PosT>
|
||||
class MPos
|
||||
{
|
||||
private:
|
||||
|
||||
size_t mExt = 0u;
|
||||
X mNext;
|
||||
SizeT mExt = 0u;
|
||||
PosT mNext;
|
||||
|
||||
public:
|
||||
|
||||
static constexpr size_t NUM = X::SIZE;
|
||||
static constexpr size_t SIZE = NUM + 1;
|
||||
//static constexpr SizeT NUM = PosT::SIZE;
|
||||
//static constexpr SizeT SIZE = NUM + 1;
|
||||
|
||||
MExt() = default;
|
||||
MExt(const MExt& in) = default;
|
||||
MExt& operator=(const MExt& in) = default;
|
||||
MExt(MExt&& in) = default;
|
||||
MExt& operator=(MExt&& in) = default;
|
||||
|
||||
inline MExt(size_t ext, X next);
|
||||
DEFAULT_MEMBERS(MPos);
|
||||
|
||||
inline MPos(SizeT ext, PosT next);
|
||||
|
||||
template <class Z>
|
||||
inline MExt(size_t y, const Z& z);
|
||||
inline MPos(SizeT y, const Z& z);
|
||||
|
||||
template <class Y, class Z>
|
||||
inline MExt(const Y& y, const Z& z);
|
||||
inline MPos(const Y& y, const Z& z);
|
||||
|
||||
template <size_t N>
|
||||
inline MExt(const std::array<size_t,N>& arr);
|
||||
inline MPos(const Arr<SizeT,N>& arr);
|
||||
|
||||
template <class Y>
|
||||
inline MExt(const MExt<Y>& y);
|
||||
inline MPos(const MPos<Y>& y);
|
||||
|
||||
inline void zero();
|
||||
|
||||
inline const size_t& val() const;
|
||||
inline const X& next() const;
|
||||
inline const SizeT& val() const;
|
||||
inline const PosT& next() const;
|
||||
|
||||
template <size_t N>
|
||||
inline auto nn() const;
|
||||
|
||||
inline bool operator==(const MExt& in) const
|
||||
inline bool operator==(const MPos& in) const
|
||||
{
|
||||
return mExt == in.mExt and mNext == in.mNext;
|
||||
}
|
||||
|
@ -139,89 +174,71 @@ namespace CNORXZInternal
|
|||
return mExt == in and mNext == in;
|
||||
}
|
||||
|
||||
inline MExt operator+(const MExt& in) const;
|
||||
inline MExt operator+(const None& in) const;
|
||||
inline MExt operator*(size_t in) const;
|
||||
inline MPos operator+(const MPos& in) const;
|
||||
inline MPos operator+(const NPos& in) const;
|
||||
inline MPos operator*(size_t in) const;
|
||||
|
||||
template <class Y>
|
||||
auto extend(const Y& y) const -> MExt<decltype(mNext.extend(y))>
|
||||
{ return MExt<decltype(mNext.extend(y))>(mExt, mNext.extend(y)); }
|
||||
auto extend(const Y& y) const -> MPos<decltype(mNext.extend(y))>
|
||||
{ return MPos<decltype(mNext.extend(y))>(mExt, mNext.extend(y)); }
|
||||
|
||||
std::string stype() const { return std::string("E[") + mNext.stype() + "]"; }
|
||||
};
|
||||
|
||||
struct None
|
||||
class NPos : public PosInterface<NPos>
|
||||
{
|
||||
size_t VAL = 0;
|
||||
None() = default;
|
||||
None(const None& in) = default;
|
||||
None(None&& in) = default;
|
||||
None& operator=(const None& in) = default;
|
||||
None& operator=(None&& in) = default;
|
||||
|
||||
private:
|
||||
SizeT VAL = 0;
|
||||
public:
|
||||
|
||||
DEFAULT_MEMBERS(NPos);
|
||||
|
||||
template <class Y>
|
||||
None(const Y& y) {}
|
||||
NPos(const Y& y) {}
|
||||
|
||||
static constexpr size_t SIZE = 0;
|
||||
//static constexpr SizeT SIZE = 0;
|
||||
|
||||
inline bool operator==(const None& in) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator==(size_t in) const
|
||||
{
|
||||
return true; // CHECK!!!
|
||||
}
|
||||
|
||||
inline None operator+(const None& in) const { return None(); }
|
||||
inline None operator*(size_t in) const { return None(); }
|
||||
|
||||
inline const size_t& val() const { assert(0); return VAL; }
|
||||
inline const SizeT& val() const { assert(0); return VAL; }
|
||||
inline bool operator==(const NPos& in) const { return true; }
|
||||
inline bool operator==(SizeT in) const { return true; }
|
||||
inline NPos operator+(const NPos& in) const { return NPos(); }
|
||||
inline NPos operator*(size_t in) const { return NPos(); }
|
||||
inline void zero() {}
|
||||
|
||||
template <class Y>
|
||||
Y extend(const Y& y) const
|
||||
{ return y; }
|
||||
|
||||
std::string stype() const { return std::string("N"); }
|
||||
};
|
||||
|
||||
template <>
|
||||
class MExt<None>
|
||||
class MPos<NPos> : public PosInterface<MPos<NPos>>
|
||||
{
|
||||
private:
|
||||
|
||||
size_t mExt = 0u;
|
||||
SizeT mExt = 0u;
|
||||
|
||||
public:
|
||||
|
||||
static constexpr size_t NUM = 0;
|
||||
static constexpr size_t SIZE = NUM + 1;
|
||||
//static constexpr size_t NUM = 0;
|
||||
//static constexpr size_t SIZE = NUM + 1;
|
||||
|
||||
MExt() = default;
|
||||
MExt(const MExt& in) = default;
|
||||
MExt& operator=(const MExt& in) = default;
|
||||
MExt(MExt&& in) = default;
|
||||
MExt& operator=(MExt&& in) = default;
|
||||
DEFAULT_MEMBERS(MPos);
|
||||
|
||||
inline MExt(size_t ext);
|
||||
inline MPos(size_t ext);
|
||||
|
||||
inline MExt(size_t y, const None& z) : mExt(y) {}
|
||||
inline MPos(size_t y, const NPos& z) : mExt(y) {}
|
||||
|
||||
template <class Z>
|
||||
inline MExt(size_t y, const Z& z);
|
||||
inline MPos(size_t y, const Z& z);
|
||||
|
||||
template <class Y, class Z>
|
||||
inline MExt(const Y& y, const Z& z);
|
||||
inline MPos(const Y& y, const Z& z);
|
||||
|
||||
template <size_t N>
|
||||
inline MExt(const std::array<size_t,N>& arr);
|
||||
inline MPos(const std::array<size_t,N>& arr);
|
||||
|
||||
template <class Y>
|
||||
inline MExt(const MExt<Y>& y);
|
||||
inline MPos(const MPos<Y>& y);
|
||||
|
||||
inline bool operator==(const MExt& in) const
|
||||
inline bool operator==(const MPos& in) const
|
||||
{
|
||||
return mExt == in.mExt;
|
||||
}
|
||||
|
@ -232,94 +249,28 @@ namespace CNORXZInternal
|
|||
}
|
||||
|
||||
inline const size_t& val() const;
|
||||
inline None next() const { return None(); }
|
||||
inline NPos next() const { return NPos(); }
|
||||
|
||||
inline void zero();
|
||||
|
||||
template <size_t N>
|
||||
inline auto nn() const;
|
||||
|
||||
inline MExt operator+(const MExt& in) const;
|
||||
inline MExt operator+(const None& in) const;
|
||||
inline MExt operator*(size_t in) const;
|
||||
inline MPos operator+(const MPos& in) const;
|
||||
inline MPos operator+(const NPos& in) const;
|
||||
inline MPos operator*(size_t in) const;
|
||||
|
||||
template <class Y>
|
||||
auto extend(const Y& y) const -> MExt<Y>
|
||||
{ return MExt<Y>(mExt,y); }
|
||||
|
||||
std::string stype() const { return std::string("E[N]"); }
|
||||
auto extend(const Y& y) const -> MPos<Y>
|
||||
{ return MPos<Y>(mExt,y); }
|
||||
|
||||
};
|
||||
|
||||
template <class X>
|
||||
class DExtTX
|
||||
{
|
||||
private:
|
||||
mutable DExt mDExt;
|
||||
X mNext;
|
||||
|
||||
template <class Y>
|
||||
friend class DExtTX;
|
||||
public:
|
||||
static constexpr size_t NUM = X::SIZE;
|
||||
static constexpr size_t SIZE = NUM + 1;
|
||||
|
||||
DExtTX() { mDExt = std::make_shared<ExtT<None>>(); }
|
||||
DExtTX(const DExtTX& in) : mNext(in.mNext)
|
||||
{ mDExt = in.mDExt->deepCopy(); }
|
||||
DExtTX(DExtTX&& in) : mNext(in.mNext)
|
||||
{ mDExt = in.mDExt->deepCopy(); }
|
||||
DExtTX& operator=(const DExtTX& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); return *this; }
|
||||
DExtTX& operator=(DExtTX&& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); return *this; }
|
||||
explicit DExtTX(const DExt& in) : mDExt(in) {}
|
||||
|
||||
bool operator==(const DExtTX& in) const
|
||||
{ return *mDExt == *in.mDExt and mNext == in.mNext; }
|
||||
|
||||
bool operator==(size_t in) const
|
||||
{ return *mDExt == in and mNext == in; }
|
||||
|
||||
template <class Y>
|
||||
DExtTX(const DExtTX<Y>& in) : mDExt(in.mDExt), mNext(in.mNext) {}
|
||||
|
||||
DExtTX(const DExt& y, const X& x) : mDExt(y->deepCopy()),
|
||||
mNext(x) {}
|
||||
|
||||
virtual size_t size() const { return mDExt->size(); }
|
||||
inline const DExt& get() const { return mDExt; }
|
||||
|
||||
inline DExtTX<None> reduce() const { return DExtTX<None>(mDExt,None(0)); }
|
||||
|
||||
inline DExtTX operator+(const DExtTX& in) const
|
||||
{ if (not mDExt) return in; else return DExtTX( (*mDExt) + (*in.mDExt), mNext + in.mNext ); }
|
||||
inline DExtTX operator*(size_t in) const
|
||||
{ if (not mDExt) return *this; else return DExtTX((*mDExt) * in, mNext * in); }
|
||||
|
||||
template <class 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>
|
||||
inline auto extend(const Y& y) const -> DExtTX<decltype(mNext.extend(y))>
|
||||
{ return DExtTX<decltype(mNext.extend(y))>(mDExt, mNext.extend(y)); }
|
||||
|
||||
inline const size_t& val() const { return mDExt->val(); }
|
||||
inline const X& next() const { return mNext; }
|
||||
|
||||
inline void zero() { mDExt->zero(); }
|
||||
|
||||
template <size_t N>
|
||||
inline auto nn() const;
|
||||
|
||||
};
|
||||
|
||||
typedef DExtTX<None> DExtT;
|
||||
|
||||
inline MExt<None> mkExt(size_t s) { return MExt<None>(s); }
|
||||
inline MPos<NPos> mkExt(SizeT s) { return MPos<NPos>(s); }
|
||||
|
||||
|
||||
template <size_t I, class X>
|
||||
auto getX(const MExt<X>& et)
|
||||
auto getX(const MPos<X>& et)
|
||||
{
|
||||
if constexpr(I == 0){
|
||||
return et;
|
||||
|
@ -330,7 +281,7 @@ namespace CNORXZInternal
|
|||
}
|
||||
|
||||
template <size_t I, class X>
|
||||
auto getX(const DExtTX<X>& et)
|
||||
auto getX(const DVPosX<X>& et)
|
||||
{
|
||||
if constexpr(I == 0){
|
||||
return et;
|
||||
|
@ -341,26 +292,26 @@ namespace CNORXZInternal
|
|||
}
|
||||
|
||||
template <size_t I>
|
||||
auto getX(const None& et)
|
||||
auto getX(const NPos& et)
|
||||
{
|
||||
static_assert(I == 0);
|
||||
return et;
|
||||
}
|
||||
|
||||
template <size_t I, class X>
|
||||
size_t get(const MExt<X>& et)
|
||||
size_t get(const MPos<X>& et)
|
||||
{
|
||||
return getX<I>(et).get();
|
||||
}
|
||||
|
||||
template <size_t I, class X>
|
||||
size_t get(const DExtTX<X>& et)
|
||||
size_t get(const DVPosX<X>& et)
|
||||
{
|
||||
return getX<I>(et).get();
|
||||
}
|
||||
|
||||
template <size_t I>
|
||||
size_t get(const None& et)
|
||||
size_t get(const NPos& et)
|
||||
{
|
||||
return getX<I>(et).get();
|
||||
}
|
||||
|
@ -375,42 +326,42 @@ namespace CNORXZInternal
|
|||
{
|
||||
|
||||
template <class X>
|
||||
inline MExt<X>::MExt(size_t ext, X next) : mExt(ext), mNext(next) {}
|
||||
inline MPos<X>::MPos(size_t ext, X next) : mExt(ext), mNext(next) {}
|
||||
|
||||
template <class X>
|
||||
template <size_t N>
|
||||
inline MExt<X>::MExt(const std::array<size_t,N>& arr) :
|
||||
inline MPos<X>::MPos(const std::array<size_t,N>& arr) :
|
||||
mExt(std::get<NUM>(arr)), mNext(arr) {}
|
||||
|
||||
template <class X>
|
||||
template <class Z>
|
||||
inline MExt<X>::MExt(size_t y, const Z& z) :
|
||||
inline MPos<X>::MPos(size_t y, const Z& z) :
|
||||
mExt(z.val()), mNext(z.val(), z.next()) {}
|
||||
|
||||
template <class X>
|
||||
template <class Y, class Z>
|
||||
inline MExt<X>::MExt(const Y& y, const Z& z) :
|
||||
inline MPos<X>::MPos(const Y& y, const Z& z) :
|
||||
mExt(y.val()), mNext(y.next(), z) {}
|
||||
|
||||
template <class X>
|
||||
template <class Y>
|
||||
inline MExt<X>::MExt(const MExt<Y>& y) :
|
||||
inline MPos<X>::MPos(const MPos<Y>& y) :
|
||||
mExt(y.val()), mNext(y.next()) {}
|
||||
|
||||
template <class X>
|
||||
inline const size_t& MExt<X>::val() const
|
||||
inline const size_t& MPos<X>::val() const
|
||||
{
|
||||
return mExt;
|
||||
}
|
||||
|
||||
template <class X>
|
||||
inline const X& MExt<X>::next() const
|
||||
inline const X& MPos<X>::next() const
|
||||
{
|
||||
return mNext;
|
||||
}
|
||||
|
||||
template <class X>
|
||||
inline void MExt<X>::zero()
|
||||
inline void MPos<X>::zero()
|
||||
{
|
||||
mExt = 0u;
|
||||
mNext.zero();
|
||||
|
@ -418,91 +369,91 @@ namespace CNORXZInternal
|
|||
|
||||
template <class X>
|
||||
template <size_t N>
|
||||
inline auto MExt<X>::nn() const
|
||||
inline auto MPos<X>::nn() const
|
||||
{
|
||||
return getX<N>(*this);
|
||||
}
|
||||
|
||||
template <class X>
|
||||
inline MExt<X> MExt<X>::operator+(const MExt<X>& in) const
|
||||
inline MPos<X> MPos<X>::operator+(const MPos<X>& in) const
|
||||
{
|
||||
return MExt<X>(mExt + in.val(), mNext + in.next());
|
||||
return MPos<X>(mExt + in.val(), mNext + in.next());
|
||||
}
|
||||
|
||||
template <class X>
|
||||
inline MExt<X> MExt<X>::operator+(const None& in) const
|
||||
inline MPos<X> MPos<X>::operator+(const NPos& in) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class X>
|
||||
inline MExt<X> MExt<X>::operator*(size_t in) const
|
||||
inline MPos<X> MPos<X>::operator*(size_t in) const
|
||||
{
|
||||
return MExt<X>(mExt * in, mNext * in);
|
||||
return MPos<X>(mExt * in, mNext * in);
|
||||
}
|
||||
|
||||
|
||||
//template <>
|
||||
inline MExt<None>::MExt(size_t ext) : mExt(ext) {}
|
||||
inline MPos<NPos>::MPos(size_t ext) : mExt(ext) {}
|
||||
|
||||
|
||||
//template <>
|
||||
template <class Z>
|
||||
inline MExt<None>::MExt(size_t y, const Z& z) :
|
||||
inline MPos<NPos>::MPos(size_t y, const Z& z) :
|
||||
mExt(z.val()) {}
|
||||
|
||||
//template <>
|
||||
template <class Y, class Z>
|
||||
inline MExt<None>::MExt(const Y& y, const Z& z) :
|
||||
inline MPos<NPos>::MPos(const Y& y, const Z& z) :
|
||||
mExt(y.val()) {}
|
||||
|
||||
|
||||
//template <>
|
||||
template <size_t N>
|
||||
inline MExt<None>::MExt(const std::array<size_t,N>& arr) :
|
||||
inline MPos<NPos>::MPos(const std::array<size_t,N>& arr) :
|
||||
mExt(std::get<NUM>(arr)) {}
|
||||
|
||||
template <class Y>
|
||||
inline MExt<None>::MExt(const MExt<Y>& y) :
|
||||
inline MPos<NPos>::MPos(const MPos<Y>& y) :
|
||||
mExt(y.val()) {}
|
||||
|
||||
//template <>
|
||||
inline void MExt<None>::zero()
|
||||
inline void MPos<NPos>::zero()
|
||||
{
|
||||
mExt = 0u;
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
inline auto MExt<None>::nn() const
|
||||
inline auto MPos<NPos>::nn() const
|
||||
{
|
||||
return getX<N>(*this);
|
||||
}
|
||||
|
||||
inline const size_t& MExt<None>::val() const
|
||||
inline const size_t& MPos<NPos>::val() const
|
||||
{
|
||||
return mExt;
|
||||
}
|
||||
|
||||
//template <>
|
||||
inline MExt<None> MExt<None>::operator+(const MExt<None>& in) const
|
||||
inline MPos<NPos> MPos<NPos>::operator+(const MPos<NPos>& in) const
|
||||
{
|
||||
return MExt<None>(mExt + in.val());
|
||||
return MPos<NPos>(mExt + in.val());
|
||||
}
|
||||
|
||||
inline MExt<None> MExt<None>::operator+(const None& in) const
|
||||
inline MPos<NPos> MPos<NPos>::operator+(const NPos& in) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//template <>
|
||||
inline MExt<None> MExt<None>::operator*(size_t in) const
|
||||
inline MPos<NPos> MPos<NPos>::operator*(size_t in) const
|
||||
{
|
||||
return MExt<None>(mExt * in);
|
||||
return MPos<NPos>(mExt * in);
|
||||
}
|
||||
|
||||
template <class X>
|
||||
template <size_t N>
|
||||
inline auto DExtTX<X>::nn() const
|
||||
inline auto DVPosX<X>::nn() const
|
||||
{
|
||||
return getX<N>(*this);
|
||||
}
|
||||
|
|
|
@ -14,39 +14,62 @@ namespace CNORXZ
|
|||
// 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o.
|
||||
// (NO COUNTING OF MASTER POSITION !!!!!)
|
||||
|
||||
template <class Expr, class Pos>
|
||||
class ExpressionInterface
|
||||
template <class Xpr, class PosT>
|
||||
class ExprInterface
|
||||
{
|
||||
public:
|
||||
DEFAULT_MEMBERS(ExpressionInterface);
|
||||
DEFAULT_MEMBERS(ExprInterface);
|
||||
|
||||
Expr& THIS() { return static_cast<Expr&>(*this); }
|
||||
const Expr& THIS() const { return static_cast<const Expr&>(*this); }
|
||||
Xpr& THIS() { return static_cast<Xpr&>(*this); }
|
||||
const Xpr& THIS() const { return static_cast<const Expr&>(*this); }
|
||||
|
||||
Sptr<Expr> copy() const { THIS().copy(); }
|
||||
//Sptr<Expr> copy() const { THIS().copy(); }
|
||||
|
||||
void operator(SizeT mlast, Pos last) { THIS()(mlast, last); }
|
||||
void operator(SizeT mlast = 0) { THIS()(mlast); }
|
||||
void operator()(SizeT mlast, PosT last) { THIS()(mlast, last); }
|
||||
void operator()(SizeT mlast = 0) { THIS()(mlast); }
|
||||
|
||||
Pos rootSteps(PtrId ptrId = 0) const { return THIS().rootSteps(ptrId); }
|
||||
Pos extension() const { return THIS().extenrion(); }
|
||||
PosT rootSteps(PtrId ptrId = 0) const { return THIS().rootSteps(ptrId); }
|
||||
PosT extension() const { return THIS().extenrion(); }
|
||||
};
|
||||
|
||||
class XprBase : public ExpressionInterface<XprBase,Dext>
|
||||
class VExprBase
|
||||
{
|
||||
public:
|
||||
DEFAULT_MEMBERS(VExprBase);
|
||||
|
||||
DEFAULT_MEMBERS(XprBase);
|
||||
virtual void vexec(SizeT mlast, PosT last) = 0;
|
||||
virtual void vexec(SizeT mlast) = 0;
|
||||
|
||||
virtual Sptr<XprBase> copy() const = 0;
|
||||
|
||||
virtual void operator()(SizeT mlast, DExt last) = 0;
|
||||
virtual void operator()(SizeT mlast) = 0;
|
||||
|
||||
virtual DExt rootSteps(PtrId iPtrNum = 0) const = 0;
|
||||
virtual DExt extension() const = 0;
|
||||
virtual DPos vrootSteps(PtrId ptrId) const = 0;
|
||||
virtual DPos vextension() const = 0;
|
||||
};
|
||||
|
||||
template <class Xpr>
|
||||
class VExpr : public VExprBase, public Xpr
|
||||
{
|
||||
public:
|
||||
DEFAULT_MEMBERS(VExpr);
|
||||
VExpr(const ExprInterface<Xpr>& a) : Xpr(a.THIS()) {}
|
||||
|
||||
virtual void vexec(SizeT mlast, PosT last) override final { THIS()(mlast,last); }
|
||||
virtual void vexec(SizeT mlast) override final { THIS()(mlast); }
|
||||
|
||||
virtual DPos vrootSteps(PtrId ptrId) const override final { return THIS().rootSteps(ptrId); }
|
||||
virtual DPos vextension() const override final { return THIS().extension(); }
|
||||
};
|
||||
|
||||
class DExpr : public ObjHandle<VExprBase>,
|
||||
public ExprInterface<DExpr>
|
||||
{
|
||||
public:
|
||||
DEFAULT_MEMBERS(DExpr);
|
||||
|
||||
inline void operator()(SizeT mlast, DPos last) { mC->vexec(mlast, last); }
|
||||
inline void operator()(SizeT mlast) { mC->vexec(mlast); }
|
||||
|
||||
inline DPos rootSteps(PtrId ptrId) const { return mC->vrootSteps(ptrId); }
|
||||
inline DPos extension() const { return mC->vextension(); }
|
||||
};
|
||||
|
||||
template <ForType FT = ForType::DEFAULT>
|
||||
struct PosForward
|
||||
|
@ -100,7 +123,7 @@ namespace CNORXZ
|
|||
|
||||
static constexpr size_t LAYER = Expr::LAYER + 1;
|
||||
static constexpr size_t SIZE = Expr::SIZE + 1;
|
||||
static constexpr size_t NHLAYER = Expr::NHLAYER + 1;
|
||||
//static constexpr size_t NHLAYER = Expr::NHLAYER + 1;
|
||||
|
||||
DEFAULT_MEMBERS_X(SubExpr);
|
||||
|
||||
|
@ -121,7 +144,7 @@ namespace CNORXZ
|
|||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||
auto extension() const -> ExtType;
|
||||
};
|
||||
|
||||
/*
|
||||
template <ForType FT, size_t LAYER>
|
||||
struct NHLayer
|
||||
{
|
||||
|
@ -151,7 +174,7 @@ namespace CNORXZ
|
|||
return Expr::LAYER;
|
||||
}
|
||||
};
|
||||
|
||||
*/
|
||||
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
||||
class For : public ExpressionBase
|
||||
{
|
||||
|
@ -175,8 +198,8 @@ namespace CNORXZ
|
|||
|
||||
static constexpr size_t LAYER = Expr::LAYER + 1;
|
||||
static constexpr size_t SIZE = Expr::SIZE;
|
||||
static constexpr size_t MAX = RangeType::SIZE / DIV;
|
||||
static constexpr size_t NHLAYER = (FT == ForType::HIDDEN) ? 0 : Expr::NHLAYER + 1;
|
||||
//static constexpr size_t MAX = RangeType::SIZE / DIV;
|
||||
//static constexpr size_t NHLAYER = (FT == ForType::HIDDEN) ? 0 : Expr::NHLAYER + 1;
|
||||
|
||||
DEFAULT_MEMBERS(For);
|
||||
|
||||
|
|
Loading…
Reference in a new issue