diff --git a/src/include/array/array.h b/src/include/array/array.h index ec4e97d..183812d 100644 --- a/src/include/array/array.h +++ b/src/include/array/array.h @@ -4,3 +4,5 @@ #include "darray.h" #include "dcontainer_index.h" //#include "functional_array.h" + +#include "array.cc.h" diff --git a/src/include/base/base.h b/src/include/base/base.h index f0bfbe0..24fe0fe 100644 --- a/src/include/base/base.h +++ b/src/include/base/base.h @@ -11,4 +11,6 @@ #include "obj_handle.h" #include "dtype.h" +#include "base.cc.h" + #endif diff --git a/src/include/base/dtype.cc.h b/src/include/base/dtype.cc.h index 0b9255b..c0d356f 100644 --- a/src/include/base/dtype.cc.h +++ b/src/include/base/dtype.cc.h @@ -14,14 +14,14 @@ namespace CNORXZ template DType::DType(const T& d) : mD(d) { - _mkToStr(); + _mkToStr(); } template DType& DType::operator=(const T& d) { mD = d; - _mkToStr(); + _mkToStr(); return *this; } diff --git a/src/include/base/obj_handle.cc.h b/src/include/base/obj_handle.cc.h index cd2dbb7..f9fe826 100644 --- a/src/include/base/obj_handle.cc.h +++ b/src/include/base/obj_handle.cc.h @@ -8,29 +8,29 @@ namespace CNORXZ { template - ObjHandle::ObjHandle() : mC(std::make_unique()) {} + ObjHandle::ObjHandle() {} template ObjHandle::ObjHandle(const T& a) : mC(std::make_unique(a)) {} template - ObjHandle::ObjHandle(const Uptr& a) : mC(a) {} + ObjHandle::ObjHandle(Uptr&& a) : mC(std::forward>(a)) {} template - ObjHandle::ObjHandle(const ObjHandle& a) : mC(std::make_unique(*a.mC)) {} + ObjHandle::ObjHandle(const ObjHandle& a) : mC(a.mC->copy()) {} template ObjHandle::ObjHandle(ObjHandle&& a) : mC(a.mC) {} template - ObjHandle& ObjHandle::operator=(const ObjHandle& a) + ObjHandle& ObjHandle::operator=(const ObjHandle& a) { mC = std::make_unique(*a.mC); return *this; } template - ObjHandle& ObjHandle::operator=(ObjHandle&& a) + ObjHandle& ObjHandle::operator=(ObjHandle&& a) { mC = a.mC; return *this; diff --git a/src/include/base/obj_handle.h b/src/include/base/obj_handle.h index 0e5817f..cf140f2 100644 --- a/src/include/base/obj_handle.h +++ b/src/include/base/obj_handle.h @@ -19,12 +19,12 @@ namespace CNORXZ ObjHandle(); ObjHandle(const T& a); - ObjHandle(const Uptr& a); + ObjHandle(Uptr&& a); ObjHandle(const ObjHandle& a); ObjHandle(ObjHandle&& a); ObjHandle& operator=(const ObjHandle& a); ObjHandle& operator=(ObjHandle&& a); - + T& operator*(); T* operator->(); const T& operator*() const; diff --git a/src/include/base/to_string.cc.h b/src/include/base/to_string.cc.h index a9988ec..4185857 100644 --- a/src/include/base/to_string.cc.h +++ b/src/include/base/to_string.cc.h @@ -8,7 +8,7 @@ namespace CNORXZ { template - String toString(const T& a) + String ToString::func(const T& a) { std::stringstream ss; ss << a; @@ -16,7 +16,7 @@ namespace CNORXZ } template - String toString>(const vector& a) + String ToString>::func(const vector& a) { std::stringstream ss; ss << "["; @@ -29,7 +29,7 @@ namespace CNORXZ } template - String toString>(const std::array& a) + String ToString>::func(const std::array& a) { std::stringstream ss; ss << "("; @@ -42,11 +42,16 @@ namespace CNORXZ } template <> - String toString(const DType& a) + String ToString::func(const DType& a) { return a.str(); } + template + String toString(const T& a) + { + return ToString::func(a); + } } #endif diff --git a/src/include/base/to_string.h b/src/include/base/to_string.h index 77ab86e..ef883fd 100644 --- a/src/include/base/to_string.h +++ b/src/include/base/to_string.h @@ -3,21 +3,36 @@ #define __cxz_to_string_h__ #include "types.h" -#include namespace CNORXZ { template - String toString(const T& a); + struct ToString + { + static String func(const T& a); + }; template - String toString>(const vector& a); + struct ToString> + { + static String func(const Vector& a); + }; - template - String toString>(const std::array& a); + template + struct ToString> + { + static String func(const Arr& a); + }; template <> - String toString(const DType& a); + struct ToString + { + static String func(const DType& a); + }; + + template + String toString(const T& a); + } #endif diff --git a/src/include/base/types.h b/src/include/base/types.h index 3ae7fed..b4c76c5 100644 --- a/src/include/base/types.h +++ b/src/include/base/types.h @@ -40,18 +40,32 @@ namespace CNORXZ template using Tuple = std::tuple; - template - using TupleElem = std::tuple_element; + template + using TupleElem = std::tuple_element>; template using Map = std::map; - typedef std::typeinfo TypeInfo; + typedef std::type_info TypeInfo; /********************* * library types * *********************/ + /*** + Naming Prefixes: + D = Y = Dynamic + V = X = Virtual + S = Static + P = Partial = Sub + C = Classic + M = Multi or !const + U = One(=Uni) dimensional + N = None = Null + T = Thread + R = Rank + ***/ + // definition: base/dtype.h class DType; @@ -74,6 +88,7 @@ namespace CNORXZ class DPos; // definition: ranges/xfor/exttype.h + template class VPos; // definition: ranges/xfor/exttype.h @@ -134,12 +149,16 @@ namespace CNORXZ // definition: ranges/xindex.h class XIndexBase; // dynamic index wrapper + typedef Sptr XIndexPtr; + // definition: ranges/yrange.h class YRange; // dynamic multi range // definition: ranges/yrange.h class YIndex; + typedef Sptr YIndexPtr; + // definition: ranges/pindex.h template class PIndex; // partial index (index over sub-ranges and permutations) diff --git a/src/include/memory/allocator.h b/src/include/memory/allocator.h index ca3379c..6c7cf6d 100644 --- a/src/include/memory/allocator.h +++ b/src/include/memory/allocator.h @@ -19,11 +19,9 @@ namespace CNORXZ template class Allocator { - private: - static SizeT sMemUsage; - public: - static SizeT memUsage() { return sMemUsage; } + + typedef T value_type; static constexpr SizeT type_size = sizeof(T); static constexpr SizeT N = 32; // get from environment!!! @@ -48,15 +46,6 @@ namespace CNORXZ template bool operator!=(const Allocator& a, const Allocator& b); - template - SizeT Allocator::sMemUsage = 0; - - - template - inline SizeT memUsage() - { - return Allocator::memUsage(); - } } // namespace CNORXZ diff --git a/src/include/memory/memcount.h b/src/include/memory/memcount.h index 58edade..b767e31 100644 --- a/src/include/memory/memcount.h +++ b/src/include/memory/memcount.h @@ -2,7 +2,6 @@ #ifndef __cxz_memcount_h__ #define __cxz_memcount_h__ -#include "allocator_d.h" #include "base/types.h" namespace CNORXZ @@ -15,10 +14,11 @@ namespace CNORXZ static void sub(SizeT x) { sMemUsage -= x; } public: - MemCount() = delete(); // static only + MemCount() = delete; // static only static SizeT usage() { return sMemUsage; } - friend Allocator; + template + friend class Allocator; }; } // namespace CNORXZ diff --git a/src/include/memory/memory.h b/src/include/memory/memory.h index 9bcba4a..5550f77 100644 --- a/src/include/memory/memory.h +++ b/src/include/memory/memory.h @@ -1,3 +1,5 @@ #include "allocator.h" #include "memcount.h" + +#include "memory.cc.h" diff --git a/src/include/ranges/index_base.h b/src/include/ranges/index_base.h index 79d8d30..6cb3852 100644 --- a/src/include/ranges/index_base.h +++ b/src/include/ranges/index_base.h @@ -72,7 +72,7 @@ namespace CNORXZ IndexInterface& operator=(IndexInterface&& in); IndexInterface(SizeT pos); - IndexPtr mRel = nullptr; + IndexPtr mRel = nullptr; SizeT mPos = 0; PtrId mPtrId = 0; }; diff --git a/src/include/ranges/range_base.h b/src/include/ranges/range_base.h index 4afa25f..bfaa7b4 100644 --- a/src/include/ranges/range_base.h +++ b/src/include/ranges/range_base.h @@ -4,6 +4,9 @@ #define __cxz_range_base_h__ #include "base/base.h" +#include "base/base.cc.h" +#include "memory/memory.h" +#include "memory/memory.cc.h" namespace CNORXZ { @@ -29,7 +32,7 @@ namespace CNORXZ private: // also add single ranges here (PtrId -> own) // rangeCast: PtrId -> original Range - static Map,RangePtr>> sCreated; + static Map,RangePtr>> sCreated; }; diff --git a/src/include/ranges/ranges.h b/src/include/ranges/ranges.h index 0159ac6..4483373 100644 --- a/src/include/ranges/ranges.h +++ b/src/include/ranges/ranges.h @@ -8,3 +8,5 @@ //#include "value_range.h" #include "xindex.h" #include "yindex.h" + +#include "ranges.cc.h" diff --git a/src/include/ranges/xfor/exttype.h b/src/include/ranges/xfor/exttype.h index a38efd1..ff98c95 100644 --- a/src/include/ranges/xfor/exttype.h +++ b/src/include/ranges/xfor/exttype.h @@ -2,9 +2,9 @@ #ifndef __cxz_exttype_h__ #define __cxz_exttype_h__ -#include +#include "base/base.h" -namespace CNORXZInternal +namespace CNORXZ { // Dynamic Ext: ObjHandl @@ -14,7 +14,8 @@ namespace CNORXZInternal { public: DEFAULT_MEMBERS(VPosBase); - + + virtual Uptr copy() const = 0; virtual SizeT vsize() const = 0; virtual const SizeT& vval() const = 0; virtual VPosBase& vzero() = 0; @@ -31,9 +32,9 @@ namespace CNORXZInternal PosT& THIS() { return static_cast(*this); } const PosT& THIS() const { return static_cast(*this); } - inline SizeT size() const { THIS().size(); } - inline const SizeT& val() const { THIS().val(); } - inline auto next() const { THIS().next(); } + inline SizeT size() const { return THIS().size(); } + inline const SizeT& val() const { return THIS().val(); } + inline auto next() const { return THIS().next(); } inline bool operator==(const PosInterface& a) const { return val() == a.val() and next() == a.next(); } inline bool operator!=(const PosInterface& a) const { return val() != a.val() or next() != a.next(); } inline bool operator==(SizeT a) const { return val() == a and next() == a; } @@ -51,18 +52,18 @@ namespace CNORXZInternal { public: DEFAULT_MEMBERS(DPos); - DPos(Uptr a) : ObjHandle(a) {} + DPos(Uptr&& a) : ObjHandle(std::forward>(a)) {} template DPos(const PosT& a) : ObjHandle( std::make_unique(a) ) {} - + inline SizeT size() const { return mC->vsize(); } inline const SizeT& val() const { return mC->vval(); } inline DPos& zero() { mC->vzero(); return *this; } template inline DPos extend(const PosInterface

& a) const - { /* append MPos in static for loop over entries */ } + { return DPos();/* append MPos in static for loop over entries */ } }; /* @@ -104,13 +105,14 @@ namespace CNORXZInternal VPos(const PosInterface& 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 copy() const override final { return std::make_unique(*this); } + virtual SizeT vsize() const override final { return PosT::THIS().size(); } + virtual const SizeT& vval() const override final { return PosT::THIS().val(); } + virtual VPos& vzero() override final { PosT::THIS().zero(); return *this; } virtual Uptr vextend(const DPos& a) const override final - { return std::make_unique( THIS().extend(a) ); } + { return std::make_unique( PosT::THIS().extend(a) ); } virtual Uptr vextend(const MPos& a) const override final - { return std::make_unique( THIS().extend(a) ); } // ??? if that works it would be a miracle ??? + { return std::make_unique( PosT::THIS().extend(a) ); } // ??? if that works it would be a miracle ??? // .... probably I need to define a static instanciation limit... }; @@ -268,7 +270,7 @@ namespace CNORXZInternal inline MPos mkExt(SizeT s) { return MPos(s); } - + /* template auto getX(const MPos& et) { @@ -315,6 +317,7 @@ namespace CNORXZInternal { return getX(et).get(); } + */ } // end namespace CNORXZInternal @@ -322,17 +325,17 @@ namespace CNORXZInternal * --- TEMPLATE CODE --- * * ========================= */ -namespace CNORXZInternal +namespace CNORXZ { template inline MPos::MPos(size_t ext, X next) : mExt(ext), mNext(next) {} - + /* template template inline MPos::MPos(const std::array& arr) : mExt(std::get(arr)), mNext(arr) {} - + */ template template inline MPos::MPos(size_t y, const Z& z) : @@ -366,14 +369,14 @@ namespace CNORXZInternal mExt = 0u; mNext.zero(); } - + /* template template inline auto MPos::nn() const { return getX(*this); } - + */ template inline MPos MPos::operator+(const MPos& in) const { @@ -407,12 +410,12 @@ namespace CNORXZInternal inline MPos::MPos(const Y& y, const Z& z) : mExt(y.val()) {} - + /* //template <> template inline MPos::MPos(const std::array& arr) : mExt(std::get(arr)) {} - + */ template inline MPos::MPos(const MPos& y) : mExt(y.val()) {} @@ -422,13 +425,13 @@ namespace CNORXZInternal { mExt = 0u; } - + /* template inline auto MPos::nn() const { return getX(*this); } - + */ inline const size_t& MPos::val() const { return mExt; @@ -450,14 +453,14 @@ namespace CNORXZInternal { return MPos(mExt * in); } - + /* template template inline auto DVPosX::nn() const { return getX(*this); } - + */ } // end namespace CNORXZInternal diff --git a/src/include/ranges/xfor/xfor.h b/src/include/ranges/xfor/xfor.h index 4f91140..dadd253 100644 --- a/src/include/ranges/xfor/xfor.h +++ b/src/include/ranges/xfor/xfor.h @@ -21,7 +21,7 @@ namespace CNORXZ DEFAULT_MEMBERS(ExprInterface); Xpr& THIS() { return static_cast(*this); } - const Xpr& THIS() const { return static_cast(*this); } + const Xpr& THIS() const { return static_cast(*this); } //Sptr copy() const { THIS().copy(); } @@ -37,29 +37,34 @@ namespace CNORXZ public: DEFAULT_MEMBERS(VExprBase); - virtual void vexec(SizeT mlast, PosT last) = 0; + virtual Uptr copy() const = 0; + + virtual void vexec(SizeT mlast, DPos last) = 0; virtual void vexec(SizeT mlast) = 0; virtual DPos vrootSteps(PtrId ptrId) const = 0; virtual DPos vextension() const = 0; }; - template + template class VExpr : public VExprBase, public Xpr { public: + typedef ExprInterface EI; DEFAULT_MEMBERS(VExpr); - VExpr(const ExprInterface& a) : Xpr(a.THIS()) {} + VExpr(const ExprInterface& 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 Uptr copy() const override final { return std::make_unique(*this); } - virtual DPos vrootSteps(PtrId ptrId) const override final { return THIS().rootSteps(ptrId); } - virtual DPos vextension() const override final { return THIS().extension(); } + virtual void vexec(SizeT mlast, DPos last) override final { EI::THIS()(mlast,last); } + virtual void vexec(SizeT mlast) override final { EI::THIS()(mlast); } + + virtual DPos vrootSteps(PtrId ptrId) const override final { return EI::THIS().rootSteps(ptrId); } + virtual DPos vextension() const override final { return EI::THIS().extension(); } }; class DExpr : public ObjHandle, - public ExprInterface + public ExprInterface { public: DEFAULT_MEMBERS(DExpr); @@ -70,7 +75,7 @@ namespace CNORXZ inline DPos rootSteps(PtrId ptrId) const { return mC->vrootSteps(ptrId); } inline DPos extension() const { return mC->vextension(); } }; - + /* template struct PosForward { @@ -106,7 +111,7 @@ namespace CNORXZ SubExpr() = default; const IndexClass* mIndPtr; - std::intptr_t mSIPtr; + PtrId mSIPtr; size_t mSPos; size_t mMax; @@ -114,7 +119,7 @@ namespace CNORXZ typedef decltype(mkExt(0).extend(mExpr.rootSteps())) ExtType; ExtType mExt; - const vector* mSubSet; + const Vector* mSubSet; mutable ExtType mRootSteps; @@ -144,7 +149,7 @@ namespace CNORXZ auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType; auto extension() const -> ExtType; }; - /* + template struct NHLayer { @@ -174,7 +179,7 @@ namespace CNORXZ return Expr::LAYER; } }; - */ + template class For : public ExpressionBase { @@ -290,26 +295,21 @@ namespace CNORXZ }; + */ } /* ========================= * * --- TEMPLATE CODE --- * * ========================= */ -#include -namespace CNORXZInternal +namespace CNORXZ { - template - const ExtType& ExtBase::expl() const - { - return dynamic_cast*>(this)->ext(); - } /***************** * F o r * *****************/ - + /* template For::For(const Sptr& indPtr, size_t step, Expr expr) : @@ -402,11 +402,11 @@ namespace CNORXZInternal static_assert(FT == ForType::DEFAULT, "hidden for not parallelizable"); return PFor(mIndPtr, mStep, mExpr); } - + */ /****************** * P F o r * ******************/ - + /* template PFor::PFor(const Sptr& indPtr, size_t step, Expr expr) : @@ -508,98 +508,12 @@ namespace CNORXZInternal //return std::make_pair(reinterpret_cast(&mExt), // sizeof(ExtType)/sizeof(size_t)); } - - /************************ - * SingleExpression * - ************************/ - - template - SingleExpression::SingleExpression(const Sptr& indPtr, - Expr expr) : - mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), - mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast( mIndPtr ))) - { - assert(mIndPtr != nullptr); - //VCHECK(mIndPtr->id()); - //VCHECK(mIndPtr->max()); - } - - template - SingleExpression::SingleExpression(const IndexClass* indPtr, - Expr expr) : - mIndPtr(indPtr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), - mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast( mIndPtr ))) - { - assert(mIndPtr != nullptr); - //VCHECK(mIndPtr->id()); - //VCHECK(mIndPtr->max()); - } - - template - inline void SingleExpression::operator()(size_t mlast, DExt last) - { - operator()(mlast, std::dynamic_pointer_cast>(last)->ext()); - //operator()(mlast, *reinterpret_cast(last.first)); - } - - template - inline void SingleExpression::operator()(size_t mlast, - ExtType last) - { - //typedef typename IndexClass::RangeType RangeType; - const size_t pos = mIndPtr->pos(); - const size_t mnpos = PosForward::value(mlast, mMax, pos); - const ExtType npos = last + mExt*pos; - mExpr(mnpos, npos); - } - - template - inline void SingleExpression::operator()(size_t mlast) - { - //typedef typename IndexClass::RangeType RangeType; - ExtType last = rootSteps(); - last.zero(); - const size_t pos = mIndPtr->pos(); - const size_t mnpos = PosForward::value(mlast, mMax, pos); - const ExtType npos = last + mExt*pos; - mExpr(mlast, last); - } - - template - auto SingleExpression::rootSteps(std::intptr_t iPtrNum) const - -> ExtType - { - return mExpr.rootSteps(iPtrNum); - } - - template - auto SingleExpression::extension() const - -> ExtType - { - return mExt; - } - - template - DExt SingleExpression::dRootSteps(std::intptr_t iPtrNum) const - { - return std::make_shared>(rootSteps(iPtrNum)); - //mRootSteps = rootSteps(iPtrNum); - //return std::make_pair(reinterpret_cast(&mRootSteps), - // sizeof(ExtType)/sizeof(size_t)); - } - - template - DExt SingleExpression::dExtension() const - { - return std::make_shared>(mExt); - //return std::make_pair(reinterpret_cast(&mExt), - // sizeof(ExtType)/sizeof(size_t)); - } + */ /**************** * SubExpr * ****************/ - + /* template SubExpr::SubExpr(const Sptr& indPtr, std::intptr_t siptr, @@ -682,11 +596,11 @@ namespace CNORXZInternal //return std::make_pair(reinterpret_cast(&mExt), // sizeof(ExtType)/sizeof(size_t)); } - + */ /*************************** * DynamicExpression * ***************************/ - + /* inline void DynamicExpression::operator()(size_t mlast, DExt last) { (*mNext)(mlast,last); @@ -707,62 +621,7 @@ namespace CNORXZInternal return mNext->dExtension(); } - /************************ - * ExpressionHolder * - ************************/ - - template - ExpressionHolder::ExpressionHolder(DynamicExpression expr) : mExpr(expr) {} - - template - inline void ExpressionHolder::operator()(size_t mlast, DExt last) - { - mExpr(mlast,last); - } - - template - inline void ExpressionHolder::operator()(size_t mlast, ExtType last) - { - mExpr(mlast, - std::make_shared>(last)); - } - - template - inline void ExpressionHolder::operator()(size_t mlast) - { - mExpr(mlast); - } - - template - DExt ExpressionHolder::dRootSteps(std::intptr_t iPtrNum) const - { - return mExpr.dRootSteps(iPtrNum); - } - - template - DExt ExpressionHolder::dExtension() const - { - return mExpr.dExtension(); - } - - template - auto ExpressionHolder::rootSteps(std::intptr_t iPtrNum) const - -> ExtType - { - return std::dynamic_pointer_cast>(mExpr.dRootSteps(iPtrNum))->ext(); - //return *reinterpret_cast( mExpr.dRootSteps(iPtrNum).first ); - } - - template - auto ExpressionHolder::extension() const - -> ExtType - { - return std::dynamic_pointer_cast>(mExpr.dExtension())->ext(); - //return *reinterpret_cast( mExpr.dExtension().first ); - } - - - + */ } // namespace CNORXZInternal #endif diff --git a/src/include/ranges/xindex.cc.h b/src/include/ranges/xindex.cc.h index ec5d29e..226e192 100644 --- a/src/include/ranges/xindex.cc.h +++ b/src/include/ranges/xindex.cc.h @@ -14,7 +14,7 @@ namespace CNORXZ XIndex::XIndex(const IndexPtr& i) : mI(i) {} template - XIndex& XIndex::operator=(size_t pos) + XIndex& XIndex::operator=(SizeT pos) { *mI = pos; return *this; @@ -35,31 +35,31 @@ namespace CNORXZ } template - int XIndex::pp(std::intptr_t idxPtrNum) + Int XIndex::pp(PtrId idxPtrNum) { return mI->pp(idxPtrNum); } template - int XIndex::mm(std::intptr_t idxPtrNum) + Int XIndex::mm(PtrId idxPtrNum) { return mI->mm(idxPtrNum); } template - size_t XIndex::dim() const + SizeT XIndex::dim() const { return mI->dim(); } template - size_t XIndex::getStepSize(size_t n) const + SizeT XIndex::getStepSize(SizeT n) const { return mI->getStepSize(n); } template - std::string XIndex::stringMeta() const + String XIndex::stringMeta() const { return mI->stringMeta(); } @@ -79,13 +79,13 @@ namespace CNORXZ } template - DynamicExpression XIndex::ifor(size_t step, DynamicExpression ex) const + DExpr XIndex::ifor(SizeT step, DExpr ex) const { return mI->ifor(step, ex); } template - DynamicExpression XIndex::iforh(size_t step, DynamicExpression ex) const + DExpr XIndex::iforh(SizeT step, DExpr ex) const { return mI->iforh(step, ex); } diff --git a/src/include/ranges/xindex.h b/src/include/ranges/xindex.h index b16d5d2..76d8b88 100644 --- a/src/include/ranges/xindex.h +++ b/src/include/ranges/xindex.h @@ -14,25 +14,21 @@ namespace CNORXZ public: DEFAULT_MEMBERS(XIndexBase); - constexpr IndexType type() const; - - virtual XIndexBase& operator=(size_t pos) = 0; + virtual XIndexBase& operator=(SizeT pos) = 0; virtual XIndexBase& operator++() = 0; virtual XIndexBase& operator--() = 0; - virtual int pp(std::intptr_t idxPtrNum) = 0; - virtual int mm(std::intptr_t idxPtrNum) = 0; + virtual Int pp(PtrId idxPtrNum) = 0; + virtual Int mm(PtrId idxPtrNum) = 0; virtual size_t dim() const = 0; - virtual size_t getStepSize(size_t n) const = 0; - virtual std::string stringMeta() const = 0; + virtual size_t getStepSize(SizeT n) const = 0; + virtual String stringMeta() const = 0; virtual DType meta() const = 0; virtual XIndexBase& at(const DType& meta) = 0; - virtual DynamicExpression ifor(size_t step, DynamicExpression ex) const = 0; - virtual DynamicExpression iforh(size_t step, DynamicExpression ex) const = 0; + virtual DExpr ifor(SizeT step, DExpr ex) const = 0; + virtual DExpr iforh(SizeT step, DExpr ex) const = 0; // ...!!! }; - typedef std::shared_ptr XIndexPtr; - // MultiIndex Wrapper: template class XIndex : public XIndexBase @@ -44,18 +40,18 @@ namespace CNORXZ DEFAULT_MEMBERS(XIndex); XIndex(const IndexPtr& i); - virtual XIndex& operator=(size_t pos) override; + virtual XIndex& operator=(SizeT pos) override; virtual XIndex& operator++() override; virtual XIndex& operator--() override; - virtual int pp(std::intptr_t idxPtrNum) override; - virtual int mm(std::intptr_t idxPtrNum) override; - virtual size_t dim() const override; - virtual size_t getStepSize(size_t n) const override; - virtual std::string stringMeta() const override; + virtual Int pp(PtrId idxPtrNum) override; + virtual Int mm(PtrId idxPtrNum) override; + virtual SizeT dim() const override; + virtual SizeT getStepSize(SizeT n) const override; + virtual String stringMeta() const override; virtual DType meta() const override; virtual XIndexBase& at(const DType& meta) override; - virtual DynamicExpression ifor(size_t step, DynamicExpression ex) const override; - virtual DynamicExpression iforh(size_t step, DynamicExpression ex) const override; + virtual DExpr ifor(SizeT step, DExpr ex) const override; + virtual DExpr iforh(SizeT step, DExpr ex) const override; // ....!!!! }; diff --git a/src/include/ranges/yindex.h b/src/include/ranges/yindex.h index 3543926..ba8f6e8 100644 --- a/src/include/ranges/yindex.h +++ b/src/include/ranges/yindex.h @@ -3,46 +3,47 @@ #define __cxz_yindex_h__ #include "base/base.h" -#include "ranges/range_base.h" -#include "ranges/index_base.h" +#include "range_base.h" +#include "index_base.h" +#include "xindex.h" #include "xfor/xfor.h" namespace CNORXZ { // Future DynamicIndex - //class YIndex : public IndexInterface - class YIndex : public XIndexBase + //class YIndex : public XIndexBase + class YIndex : public IndexInterface { public: typedef IndexInterface IB; private: RangePtr mRange; - vector mIs; - std::vector mBlockSizes; // dim() elements only!!! + Vector mIs; + Vector mBlockSizes; // dim() elements only!!! bool mExternalControl = false; public: DEFAULT_MEMBERS(YIndex); YIndex(const RangePtr& range); - YIndex(const RangePtr& range, const std::vector& is); + YIndex(const RangePtr& range, const Vector& is); - YIndex& operator=(size_t pos); + YIndex& sync(); + YIndex& operator=(SizeT pos); YIndex& operator++(); YIndex& operator--(); - int pp(std::intptr_t idxPtrNum); - int mm(std::intptr_t idxPtrNum); + int pp(PtrId idxPtrNum); + int mm(PtrId idxPtrNum); size_t dim() const; - size_t getStepSize(size_t n) const; - std::string stringMeta() const; + size_t getStepSize(SizeT n) const; + String stringMeta() const; DType meta() const; YIndex& at(const DType& meta); - DynamicExpression ifor(size_t step, DynamicExpression ex) const; - DynamicExpression iforh(size_t step, DynamicExpression ex) const; + DExpr ifor(SizeT step, DExpr ex) const; + DExpr iforh(SizeT step, DExpr ex) const; }; - typedef std::shared_ptr YIndexPtr; } #endif diff --git a/src/lib/ranges/range_base.cc b/src/lib/ranges/range_base.cc index 3def0e2..a346769 100644 --- a/src/lib/ranges/range_base.cc +++ b/src/lib/ranges/range_base.cc @@ -8,11 +8,11 @@ namespace CNORXZ * RangeFactoryBase * *************************/ - static Map,RangePtr>> RangeFactoryBase::sCreated; + Map,RangePtr>> RangeFactoryBase::sCreated; RangePtr RangeFactoryBase::create() { - mProd = this->make(); + this->make(); mProd->mThis = mProd; return mProd; } @@ -20,9 +20,9 @@ namespace CNORXZ RangePtr RangeFactoryBase::fromCreated(const TypeInfo& info, const Vector& rids) const { RangePtr out = nullptr; - if(sCreated.count(info) != 0){ - if(sCreated[info].count(rids) != 0){ - out = sCreated[info][rids]; + if(sCreated.count(info.hash_code()) != 0){ + if(sCreated[info.hash_code()].count(rids) != 0){ + out = sCreated[info.hash_code()][rids]; } } return out; @@ -30,7 +30,7 @@ namespace CNORXZ void RangeFactoryBase::addToCreated(const TypeInfo& info, const Vector& rids, const RangePtr& r) { - sCreated[info][rids] = r; + sCreated[info.hash_code()][rids] = r; } /****************** diff --git a/src/lib/ranges/yindex.cc b/src/lib/ranges/yindex.cc index 105f31d..4b808f4 100644 --- a/src/lib/ranges/yindex.cc +++ b/src/lib/ranges/yindex.cc @@ -4,19 +4,23 @@ namespace CNORXZ { YIndex::YIndex(const RangePtr& range) : - mIs(mRange.dim()), mBlockSizes(mRange.dim()), mExternalControl(false) + mRange(range), mIs(mRange->dim()), + mBlockSizes(mRange->dim()), mExternalControl(false) { + assert(0); // init ...!!! } YIndex::YIndex(const RangePtr& range, const Vector& is) : - mIs(is), mBlockSizes(mRange.dim()), mExternalControl(false) + mRange(range), mIs(is), + mBlockSizes(mRange->dim()), mExternalControl(false) { - CXZ_ASSERT(mIs.size() == mRange.dim(), "obtained wrong number of indices"); + CXZ_ASSERT(mIs.size() == mRange->dim(), "obtained wrong number of indices"); + assert(0); // init ...!!! } - YIndex& YIndex::operator=(size_t pos) + YIndex& YIndex::operator=(SizeT pos) { IB::mPos = pos; // sub inds... (LAZY!!!) !!! @@ -39,24 +43,27 @@ namespace CNORXZ return *this; } - int YIndex::pp(std::intptr_t idxPtrNum) + Int YIndex::pp(PtrId idxPtrNum) { - + assert(0); + return 0; } - int YIndex::mm(std::intptr_t idxPtrNum) + Int YIndex::mm(PtrId idxPtrNum) { - + assert(0); + return 0; } - size_t YIndex::dim() const + SizeT YIndex::dim() const { return mRange->dim(); } - size_t YIndex::getStepSize(size_t n) const + SizeT YIndex::getStepSize(SizeT n) const { - + assert(0); + return 0; } String YIndex::stringMeta() const @@ -64,9 +71,9 @@ namespace CNORXZ String out = "["; auto it = mIs.begin(); for(; it != mIs.end()-1; ++it){ - out += it->stringMeta() + "," + out += (*it)->stringMeta() + ","; } - out += it->stringMeta() + "]" + out += (*it)->stringMeta() + "]"; return out; } @@ -74,7 +81,7 @@ namespace CNORXZ { //this->sync(); Vector v(mIs.size()); - std::transform(mIs.begin(), mIs.end(), v.begin(), [](auto& x) { return x->meta() }); + std::transform(mIs.begin(), mIs.end(), v.begin(), [](auto& x) { return x->meta(); }); return DType(v); } @@ -82,20 +89,22 @@ namespace CNORXZ { auto& v = std::any_cast&>(meta.get()); assert(v.size() == mIs.size()); - for(size_t i = 0; i != mIs.size()){ + for(SizeT i = 0; i != mIs.size(); ++i){ mIs[i]->at(v[i]); } return *this; } - DynamicExpression YIndex::ifor(size_t step, DynamicExpression ex) const + DExpr YIndex::ifor(SizeT step, DExpr ex) const { - + assert(0); + return DExpr(); } - DynamicExpression YIndex::iforh(size_t step, DynamicExpression ex) const + DExpr YIndex::iforh(SizeT step, DExpr ex) const { - + assert(0); + return DExpr(); } }