From 636c1d6407e97b694ee0aaa7fb8d3b9ae65bfbad Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 1 Nov 2023 01:23:32 +0100 Subject: [PATCH] corrections + remove old files + some todos --- src/include/ranges/index_base.h | 11 - src/include/ranges/mrange.cc.h | 16 +- src/include/ranges/nrange.h | 96 ------ src/include/ranges/prange.cc.h | 2 + src/include/ranges/srange.h | 6 - src/include/ranges/xindex.cc.h | 64 ---- src/include/ranges/xindex.h | 6 - src/include/xpr/pos_type.h | 2 +- src/include/xpr/xfor.h | 567 ------------------------------- src/lib/ranges/nrange.cc | 148 -------- src/tests/operation_unit_test.cc | 1 + src/tests/range_unit_test.cc | 1 + 12 files changed, 19 insertions(+), 901 deletions(-) delete mode 100644 src/include/ranges/nrange.h delete mode 100644 src/include/xpr/xfor.h delete mode 100644 src/lib/ranges/nrange.cc diff --git a/src/include/ranges/index_base.h b/src/include/ranges/index_base.h index d1454df..72a4356 100644 --- a/src/include/ranges/index_base.h +++ b/src/include/ranges/index_base.h @@ -56,20 +56,9 @@ namespace CNORXZ decltype(auto) xpr(const Sptr& _this) const { return THIS().xpr(_this); } RangePtr prange(const IndexInterface& end) const { return THIS().prange(end.THIS()); } - /* - template - decltype(auto) formatTo(const Sptr& ind) const { return ind->formatFrom(THIS()); } - template - decltype(auto) formatFrom(const Index& ind) const // yes this is const, - // changes only MIndex/YIndex format, in this case we can just copy the pointers to the sub-index instances - { return THIS().formatFrom(ind); } - */ decltype(auto) deepFormat() const { return THIS().deepFormat(); } - //template - //decltype(auto) slice(const Sptr& ind) const { return THIS().slice(ind); } - template decltype(auto) ifor(const Xpr& xpr, F&& f) const { return THIS().ifor(xpr,std::forward(f)); } diff --git a/src/include/ranges/mrange.cc.h b/src/include/ranges/mrange.cc.h index 445782b..baa9f76 100644 --- a/src/include/ranges/mrange.cc.h +++ b/src/include/ranges/mrange.cc.h @@ -604,8 +604,20 @@ namespace CNORXZ template MArray MRange::sub() const { - CXZ_ERROR("not implemented (SRange missing!!)"); //!!! - return MArray(); + // TODO: ZRange (meta and index pos static!) + if constexpr(NR == 0) { + return MArray(); + } + else { + RangePtr sr = SRangeFactory + ( iter<0,NR> + ( [](auto i) { return i; }, + [](auto... x) { return Arr { x... }; } ) ).create(); + return MArray + ( sr, iter<0,NR> + ( [&](auto i) { return std::get(mRs); }, + [](auto... x) { return Vector ({ x... }); } ) ); + } } template diff --git a/src/include/ranges/nrange.h b/src/include/ranges/nrange.h deleted file mode 100644 index 810ce30..0000000 --- a/src/include/ranges/nrange.h +++ /dev/null @@ -1,96 +0,0 @@ - - -#ifdef include_range_type -include_range_type(NUL,-2) -#else - -#ifdef __cxz_ranges_header__ -// assert, that this is only used within range_types/header.h - -#ifndef __cxz_range_type_null_def__ -#define __cxz_range_type_null_def__ - -namespace CNORXZ -{ - typedef GenSingleIndex NullIndex; - - std::shared_ptr > nullr(); - std::shared_ptr nulli(); - - template <> - class GenSingleRangeFactory : public RangeFactoryBase - { - public: - - typedef GenSingleRange oType; - - GenSingleRangeFactory(); - std::shared_ptr create(); - - friend std::shared_ptr nullr(); - - private: - static std::shared_ptr mRInstance; - }; - - template <> - class GenSingleRange : public RangeInterface - { - public: - typedef RangeBase RB; - typedef typename RangeInterface >::IndexType IndexType; - typedef GenSingleRange RangeType; - typedef size_t MetaType; - typedef GenSingleRangeFactory FType; - - virtual size_t size() const final; - virtual size_t dim() const final; - - virtual vector typeNum() const final; - virtual size_t cmeta(char* target, size_t pos) const final; - virtual size_t cmetaSize() const final; - virtual std::string stringMeta(size_t pos) const final; - virtual vector data() const final; - - virtual SpaceType spaceType() const final; - virtual DataHeader dataHeader() const final; - - size_t get(size_t pos) const; - size_t getMeta(size_t metapos) const; - - virtual IndexType begin() const final; - virtual IndexType end() const final; - //virtual std::shared_ptr index() const final; - - friend GenSingleRangeFactory; - - static constexpr bool defaultable = true; - - static constexpr size_t ISSTATIC = 1; - static constexpr size_t SIZE = 1; - static constexpr bool HASMETACONT = false; - - static GenSingleRangeFactory factory() - { return GenSingleRangeFactory(); } - - protected: - - GenSingleRange() = default; - GenSingleRange(const GenSingleRange& in) = delete; - - //GenSingleRange(size_t spinNum); - }; - - typedef GenSingleRange NullRange; - typedef GenSingleRangeFactory NullRF; - - std::shared_ptr mkNUL(const char* dp, size_t size); - -} - - -#endif // #ifndef __cxz_range_type_null_def__ - -#endif // #ifdef __cxz_ranges_header__ - -#endif // #ifdef include_range_type diff --git a/src/include/ranges/prange.cc.h b/src/include/ranges/prange.cc.h index efa1ed7..8288914 100644 --- a/src/include/ranges/prange.cc.h +++ b/src/include/ranges/prange.cc.h @@ -325,6 +325,8 @@ namespace CNORXZ RangePtr PRange::extend(const RangePtr& r) const { CXZ_ERROR("implement!!!"); + // if r is PRange of same Range, then just add parts + // else derive and add meta of r return nullptr; } diff --git a/src/include/ranges/srange.h b/src/include/ranges/srange.h index ea04686..41c788c 100644 --- a/src/include/ranges/srange.h +++ b/src/include/ranges/srange.h @@ -51,13 +51,7 @@ namespace CNORXZ RangePtr prange(const SIndex& last) const; SizeT deepFormat() const; - /* - template - decltype(auto) formatFrom(const Index& ind) const; - template - decltype(auto) slice(const Sptr& ind) const; - */ template decltype(auto) ifor(const Xpr& xpr, F&& f) const; diff --git a/src/include/ranges/xindex.cc.h b/src/include/ranges/xindex.cc.h index 8fc4e0a..6cc325e 100644 --- a/src/include/ranges/xindex.cc.h +++ b/src/include/ranges/xindex.cc.h @@ -147,69 +147,6 @@ namespace CNORXZ return toVec( mI->deepFormat() ); } - /* - template - Vector XIndex::pack() const - { - if constexpr(has_static_sub::value){ - constexpr SizeT D = index_dim::value; - return iter<0,D> - ( [&](auto i) { return xindexPtr(std::get(mI->THIS().pack())); }, - [](const auto&... e) { return Vector({ e ... }); } ); - } - else if constexpr(has_sub::value){ - return mI->THIS().pack(); - } - else { - return Vector(); - } - } - - template - Vector XIndex::blockSizes() const - { - if constexpr(has_static_sub::value){ - constexpr SizeT D = index_dim::value; - const auto& bs = mI->THIS().blockSizes(); - return iter<0,D> - ( [&](auto i) { return std::get(bs); }, - [](const auto&... e) { return Vector( { static_cast(e)... } ); } ); - } - else if constexpr(has_sub::value) { - return mI->THIS().blockSizes(); - } - else { - return Vector(); - } - } - - template - XIndexPtr XIndex::setBlockSizes(const Vector& bs) - { - if constexpr(has_static_sub::value){ - constexpr SizeT D = index_dim::value; - CXZ_ASSERT(bs.size() == D, - "got block sizes of wrong dimension: " << bs.size() << " vs " << D); - typedef decltype(mI->THIS().blockSizes()) BT; - Arr arr; - std::copy_n(bs.begin(), D, arr.begin()); - if constexpr(std::is_same>::value){ - mI->THIS().setBlockSizes(arr); - return nullptr; - } - else { - return xindexPtr(replaceBlockSizes(arr, std::static_pointer_cast(mI))); - } - } - else if constexpr(has_sub::value) { - mI->THIS().setBlockSizes(bs); - return nullptr; - } - else { - return nullptr; - } - } - */ template String XIndex::stringMeta() const { @@ -225,7 +162,6 @@ namespace CNORXZ template XIndexBase& XIndex::at(const DType& meta) { - // check!!! mI->at(std::any_cast(meta.get())); return *this; } diff --git a/src/include/ranges/xindex.h b/src/include/ranges/xindex.h index 81c303f..71fc4c3 100644 --- a/src/include/ranges/xindex.h +++ b/src/include/ranges/xindex.h @@ -41,9 +41,6 @@ namespace CNORXZ virtual UPos stepSize(const IndexId<0>& id) const = 0; virtual RangePtr prange(const XIndexPtr& last) const = 0; virtual Vector deepFormat() const = 0; - //virtual Vector pack() const = 0; - //virtual Vector format() const = 0; - //virtual XIndexPtr setBlockSizes(const Vector& bs) = 0; virtual String stringMeta() const = 0; virtual DType meta() const = 0; @@ -97,9 +94,6 @@ namespace CNORXZ virtual UPos stepSize(const IndexId<0>& id) const override final; virtual RangePtr prange(const XIndexPtr& last) const override final; virtual Vector deepFormat() const override final; - //virtual Vector pack() const override final; - //virtual Vector format() const override final; - //virtual XIndexPtr setBlockSizes(const Vector& bs) override final; virtual String stringMeta() const override final; virtual DType meta() const override final; diff --git a/src/include/xpr/pos_type.h b/src/include/xpr/pos_type.h index f82f27b..c23b57c 100644 --- a/src/include/xpr/pos_type.h +++ b/src/include/xpr/pos_type.h @@ -179,7 +179,7 @@ namespace CNORXZ constexpr decltype(auto) operator<<(const PosT& a) const; }; - // treat as scalar pos!!! + // treat as scalar pos! class DPos : public ObjHandle { public: diff --git a/src/include/xpr/xfor.h b/src/include/xpr/xfor.h deleted file mode 100644 index 1507e74..0000000 --- a/src/include/xpr/xfor.h +++ /dev/null @@ -1,567 +0,0 @@ - -#ifndef __cxz_xfor_h__ -#define __cxz_xfor_h__ - -#include - -#include "base/base.h" -#include "for_type.h" -#include "for_utils.h" -#include "exttype.h" - -namespace CNORXZ -{ - // 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o. - // (NO COUNTING OF MASTER POSITION !!!!!) - - - /* - template - struct PosForward - { - static inline size_t valuex(size_t last, size_t step, size_t pos) - { - return last + pos * step; - } - - static inline size_t value(size_t last, size_t max, size_t pos) - { - return last * max + pos; - } - }; - - template <> - struct PosForward - { - static inline size_t valuex(size_t last, size_t step, size_t pos) - { - return last; - } - - static inline size_t value(size_t last, size_t max, size_t pos) - { - return last; - } - }; - - template - class SubExpr : public ExpressionBase - { - private: - SubExpr() = default; - - const IndexClass* mIndPtr; - PtrId mSIPtr; - size_t mSPos; - size_t mMax; - - Expr mExpr; - typedef decltype(mkExt(0).extend(mExpr.rootSteps())) ExtType; - ExtType mExt; - - const Vector* mSubSet; - - mutable ExtType mRootSteps; - - public: - typedef ExpressionBase EB; - - static constexpr size_t LAYER = Expr::LAYER + 1; - static constexpr size_t SIZE = Expr::SIZE + 1; - //static constexpr size_t NHLAYER = Expr::NHLAYER + 1; - - DEFAULT_MEMBERS_X(SubExpr); - - SubExpr(const Sptr& indPtr, - std::intptr_t siptr, - const vector* subset, Expr expr); - - SubExpr(const IndexClass* indPtr, std::intptr_t siptr, - const vector* subset, Expr expr); - - inline void operator()(size_t mlast, DExt last) override final; - inline void operator()(size_t mlast, ExtType last) ; - inline void operator()(size_t mlast = 0) override final; - - DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final; - DExt dExtension() const override final; - - auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType; - auto extension() const -> ExtType; - }; - - template - struct NHLayer - { - template - static constexpr size_t get() - { - return Expr::NHLAYER + 1; - } - }; - - template - struct NHLayer - { - template - static constexpr size_t get() - { - return 0; - } - }; - - template <> - struct NHLayer - { - template - static constexpr size_t get() - { - return Expr::LAYER; - } - }; - - template - class For : public ExpressionBase - { - private: - For() = default; - - typedef typename IndexClass::RangeType RangeType; - const IndexClass* mIndPtr; - size_t mSPos; - size_t mMax; - size_t mStep; - - Expr mExpr; - typedef decltype(mExpr.rootSteps()) ExtType; - ExtType mExt; - - mutable ExtType mRootSteps; - - public: - typedef ExpressionBase EB; - - 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; - - DEFAULT_MEMBERS(For); - - For(const Sptr& indPtr, - size_t step, Expr expr); - - For(const IndexClass* indPtr, - size_t step, Expr expr); - - inline void operator()(size_t mlast, DExt last) override final; - inline void operator()(size_t mlast, ExtType last) ; - inline void operator()(size_t mlast = 0) override final; - - PFor parallel() const; - - DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final; - DExt dExtension() const override final; - - auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType; - auto extension() const -> ExtType; - - }; - - class DynamicExpression : public ExpressionBase - { - private: - - size_t mThreadId = 0; - Sptr mNext; - - DynamicExpression() : mThreadId(omp_get_thread_num()) {} - public: - - static constexpr size_t LAYER = 0; - static constexpr size_t SIZE = 0; - static constexpr size_t NHLAYER = 0; - - DynamicExpression(const DynamicExpression& in) : - mThreadId(omp_get_thread_num()), - mNext( (static_cast(in.mThreadId) == omp_get_thread_num()) ? - in.mNext : in.mNext->deepCopy()) {} - DynamicExpression(DynamicExpression&& in) : - mThreadId(omp_get_thread_num()), - mNext( (static_cast(in.mThreadId) == omp_get_thread_num()) ? - in.mNext : in.mNext->deepCopy()) {} - DynamicExpression& operator=(const DynamicExpression& in) - { - mThreadId = omp_get_thread_num(); - mNext = (static_cast(in.mThreadId) == omp_get_thread_num()) ? - in.mNext : in.mNext->deepCopy(); - return *this; - } - - DynamicExpression& operator=(DynamicExpression&& in) - { - mThreadId = omp_get_thread_num(); - mNext = (static_cast(in.mThreadId) == omp_get_thread_num()) ? - in.mNext : in.mNext->deepCopy(); - return *this; - } - - DynamicExpression(const Sptr& next) : - mNext(next) - {} - - template - DynamicExpression(const ExpressionBase& next) : - mNext(std::make_shared(next)) - {} - - template - DynamicExpression(Expr ex) : mNext( std::make_shared(ex) ) {} - - virtual Sptr deepCopy() const override final - { - return std::make_shared(*this); - } - - inline void operator()(size_t mlast, DExt last) override final; - inline void operator()(size_t mlast, DExtT last) { (*this)(mlast,last.get()); } - inline void operator()(size_t mlast = 0) override final; - - inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final; - inline DExt dExtension() const override final; - - inline DExtT rootSteps(std::intptr_t iPtrNum = 0) const { return DExtT(dRootSteps(iPtrNum)); } - inline DExtT extension() const { return DExtT(dExtension()); } - - }; - - */ -} - -/* ========================= * - * --- TEMPLATE CODE --- * - * ========================= */ - - -namespace CNORXZ -{ - - /***************** - * F o r * - *****************/ - /* - template - For::For(const Sptr& indPtr, - size_t step, Expr expr) : - mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step), - mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast( mIndPtr ))) - { - assert(mMax % DIV == 0); - assert(mIndPtr != nullptr); - } - - template - For::For(const IndexClass* indPtr, - size_t step, Expr expr) : - mIndPtr(indPtr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step), - mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast( mIndPtr ))) - { - //VCHECK(mMax); - //VCHECK(DIV); - //assert(mMax % DIV == 0); - assert(mIndPtr != nullptr); - } - - template - inline void For::operator()(size_t mlast, DExt last) - { - operator()(mlast, std::dynamic_pointer_cast>(last)->ext()); - //operator()(mlast, *reinterpret_cast(last.first)); - } - - template - inline void For::operator()(size_t mlast, - ExtType last) - { - typedef typename IndexClass::RangeType RangeType; - for(size_t pos = 0u; pos != ForBound::template bound(mMax); ++pos){ - const size_t mnpos = PosForward::valuex(mlast, mStep, pos); - const ExtType npos = last + mExt*pos; - mExpr(mnpos, npos); - } - } - - template - inline void For::operator()(size_t mlast) - { - typedef typename IndexClass::RangeType RangeType; - ExtType last = rootSteps(); - last.zero(); - for(size_t pos = 0u; pos != ForBound::template bound(mMax); ++pos){ - const size_t mnpos = PosForward::valuex(mlast, mStep, pos); - const ExtType npos = last + mExt*pos; - mExpr(mnpos, npos); - } - } - - - template - auto For::rootSteps(std::intptr_t iPtrNum) const - -> ExtType - { - return mExpr.rootSteps(iPtrNum); - } - - template - auto For::extension() const - -> ExtType - { - return mExt; - } - - template - DExt For::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 For::dExtension() const - { - return std::make_shared>(mExt); - //return std::make_pair(reinterpret_cast(&mExt), - // sizeof(ExtType)/sizeof(size_t)); - } - - template - PFor For::parallel() const - { - 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) : - mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step), - mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast( mIndPtr ))) - { - //assert(mMax % DIV == 0); - assert(mIndPtr != nullptr); - } - - template - PFor::PFor(const IndexClass* indPtr, - size_t step, Expr expr) : - mIndPtr(indPtr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step), - mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast( mIndPtr ))) - { - assert(mMax % DIV == 0); - assert(mIndPtr != nullptr); - } - - template - inline void PFor::operator()(size_t mlast, DExt last) - { - operator()(mlast, std::dynamic_pointer_cast>(last)->ext()); - //operator()(mlast, *reinterpret_cast(last.first)); - } - - template - inline void PFor::operator()(size_t mlast, - ExtType last) - { - CHECK; - typedef typename IndexClass::RangeType RangeType; - int pos = 0; - size_t mnpos = 0; - ExtType npos; -#pragma omp parallel shared(mExpr) private(pos,mnpos,npos) - { - auto expr = mExpr; -#pragma omp for nowait - for(pos = 0; pos < static_cast(ForBound::template bound(mMax)); pos++){ - mnpos = PosForward::valuex(mlast, mStep, pos); - npos = last + mExt*static_cast(pos); - expr(mnpos, npos); - } - } - } - - template - inline void PFor::operator()(size_t mlast) - { - CHECK; - ExtType last = rootSteps(); - last.zero(); - int pos = 0; - size_t mnpos = 0; - ExtType npos = rootSteps(); - npos.zero(); -#pragma omp parallel shared(mExpr) private(pos,mnpos,npos) - { - auto expr = mExpr; -#pragma omp for nowait - for(pos = 0; pos < static_cast(ForBound::template bound(mMax)); pos++){ - mnpos = PosForward::valuex(mlast, mStep, pos); - npos = last + mExt*static_cast(pos); - expr(mnpos, npos); - } - } - } - - - template - auto PFor::rootSteps(std::intptr_t iPtrNum) const - -> ExtType - { - return mExpr.rootSteps(iPtrNum); - } - - template - auto PFor::extension() const - -> ExtType - { - return mExt; - } - - template - DExt PFor::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 PFor::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, - const vector* subset, Expr expr) : - mIndPtr(indPtr.get()), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), - mExpr(expr), - mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast( mIndPtr )) ) ), - mSubSet(subset) - { - assert(mIndPtr != nullptr); - } - - template - SubExpr::SubExpr(const IndexClass* indPtr, std::intptr_t siptr, - const vector* subset, Expr expr) : - mIndPtr(indPtr), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), - mExpr(expr), - mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast( mIndPtr )) ) ), - mSubSet(subset) - { - assert(mIndPtr != nullptr); - } - - template - inline void SubExpr::operator()(size_t mlast, DExt last) - { - operator()(mlast, std::dynamic_pointer_cast>(last)->ext()); - //operator()(mlast, *reinterpret_cast(last.first)); - } - - template - inline void SubExpr::operator()(size_t mlast, - ExtType last) - { - const size_t pos = (*mSubSet)[last.val()]; - const size_t mnpos = mlast; - const ExtType npos = last + mExt*pos; - mExpr(mnpos, getX<1>( npos )); - } - - template - inline void SubExpr::operator()(size_t mlast) - { - ExtType last = rootSteps(); - last.zero(); - const size_t pos = (*mSubSet)[last.val()]; - const size_t mnpos = mlast; - const ExtType npos = last + mExt*pos; - mExpr(mnpos, getX<1>( npos )); - } - - - template - auto SubExpr::rootSteps(std::intptr_t iPtrNum) const - -> ExtType - { - return mkExt(iPtrNum == mSIPtr ? 1 : 0).extend(mExpr.rootSteps(iPtrNum)); - } - - template - auto SubExpr::extension() const - -> ExtType - { - return mExt; - } - - template - DExt SubExpr::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 SubExpr::dExtension() const - { - return std::make_shared>(mExt); - //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); - } - - inline void DynamicExpression::operator()(size_t mlast) - { - (*mNext)(mlast); - } - - inline DExt DynamicExpression::dRootSteps(std::intptr_t iPtrNum) const - { - return mNext->dRootSteps(iPtrNum); - } - - inline DExt DynamicExpression::dExtension() const - { - return mNext->dExtension(); - } - - */ -} // namespace CNORXZInternal - -#endif diff --git a/src/lib/ranges/nrange.cc b/src/lib/ranges/nrange.cc deleted file mode 100644 index 6dc79cc..0000000 --- a/src/lib/ranges/nrange.cc +++ /dev/null @@ -1,148 +0,0 @@ - -#include "ranges/rheader.h" -#include "ranges/x_to_string.h" -#include "ranges/ranges_header.cc.h" - -namespace CNORXZ -{ - std::shared_ptr mkNUL(const char* dp, size_t size) - { - return std::make_shared(); - } - - /******************** - * GenSingleRange * - ********************/ - - std::shared_ptr> - GenSingleRangeFactory::mRInstance = nullptr; - - std::shared_ptr nullr() - { - static NullRF nrf; // just that mRInstance is initialized - static auto nr = std::dynamic_pointer_cast( nrf.create() ); - return NullRF::mRInstance; - } - - std::shared_ptr nulli() - { - return std::make_shared(nullr()); - } - - GenSingleRangeFactory::GenSingleRangeFactory() - { - // Singleton - if(not mRInstance){ - if(not mProd){ - mProd = std::shared_ptr( new GenSingleRange() ); - setSelf(); - } - mRInstance = std::dynamic_pointer_cast( mProd ); - } else { - mProd = mRInstance; - } - } - - std::shared_ptr GenSingleRangeFactory::create() - { - return mProd; - } - - /******************** - * GenSingleRange * - ********************/ - - size_t GenSingleRange::get(size_t pos) const - { - return 0; - } - - size_t GenSingleRange::getMeta(size_t metapos) const - { - return 0; - } - - size_t GenSingleRange::size() const - { - return 1; - } - - size_t GenSingleRange::dim() const - { - return 1; - } - - SpaceType GenSingleRange::spaceType() const - { - return SpaceType::NUL; - } - - vector GenSingleRange::typeNum() const - { - return {NumTypeMap::num()}; - } - - size_t GenSingleRange::cmeta(char* target, size_t pos) const - { - *reinterpret_cast(target) = 0; - return sizeof(size_t); - } - - size_t GenSingleRange::cmetaSize() const - { - return sizeof(size_t); - } - - std::string GenSingleRange::stringMeta(size_t pos) const - { - return std::to_string(get(pos)); - } - - vector GenSingleRange::data() const - { - DataHeader h = dataHeader(); - vector out; - out.reserve(h.metaSize + sizeof(DataHeader)); - char* hcp = reinterpret_cast(&h); - out.insert(out.end(), hcp, hcp + sizeof(DataHeader)); - return out; - } - - DataHeader GenSingleRange::dataHeader() const - { - DataHeader h; - h.spaceType = static_cast( SpaceType::NUL ); - h.metaSize = 0; - h.multiple = 0; - return h; - } - - typename GenSingleRange::IndexType GenSingleRange::begin() const - { - GenSingleIndex i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ); - i = 0; - return i; - } - - typename GenSingleRange::IndexType GenSingleRange::end() const - { - GenSingleIndex i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ); - i = size(); - return i; - } - - // put this in the interface class !!! - /* - std::shared_ptr GenSingleRange::index() const - { - typedef IndexWrapper IW; - return std::make_shared - ( std::make_shared - ( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ) ); - } - */ -} - diff --git a/src/tests/operation_unit_test.cc b/src/tests/operation_unit_test.cc index 0252c15..8a4e532 100644 --- a/src/tests/operation_unit_test.cc +++ b/src/tests/operation_unit_test.cc @@ -6,6 +6,7 @@ #include "ranges/ranges.h" #include "operation/operation.h" +#include "array/array.h" #include "test_numbers.h" namespace diff --git a/src/tests/range_unit_test.cc b/src/tests/range_unit_test.cc index ee4bfeb..4ac711e 100644 --- a/src/tests/range_unit_test.cc +++ b/src/tests/range_unit_test.cc @@ -6,6 +6,7 @@ //#include "cnorxz.h" #include "ranges/ranges.h" +#include "array/array.h" namespace {