diff --git a/src/include/map_range.cc.h b/src/include/map_range.cc.h index 0df0cdd..8b69fd3 100644 --- a/src/include/map_range.cc.h +++ b/src/include/map_range.cc.h @@ -14,9 +14,9 @@ namespace MultiArrayTools * OpExpr * **************/ - template - OpExpr::OpExpr(const Op& mapf, const IndexPack& ipack, - const std::shared_ptr& oind, size_t step, Expr ex) : + template + OpExpr::OpExpr(const Op& mapf, const std::shared_ptr& oind, + size_t step, Expr ex) : mIndPtr(oind.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step), mExpr( ex ), mOp(mapf), @@ -27,9 +27,9 @@ namespace MultiArrayTools assert(mIndPtr != nullptr); } - template - inline void OpExpr::operator()(size_t mlast, - ExtType last) + template + inline void OpExpr::operator()(size_t mlast, + ExtType last) { constexpr size_t NEXT = Op::SIZE; const ExtType nxpos = last; @@ -41,8 +41,8 @@ namespace MultiArrayTools mExpr(mnpos, Getter::template getX( npos ) ); } - template - inline void OpExpr::operator()(size_t mlast) + template + inline void OpExpr::operator()(size_t mlast) { const ExtType last; constexpr size_t NEXT = Op::SIZE; @@ -53,8 +53,8 @@ namespace MultiArrayTools mExpr(mnpos, Getter::template getX( npos )); } - template - auto OpExpr::rootSteps(std::intptr_t iPtrNum) const + template + auto OpExpr::rootSteps(std::intptr_t iPtrNum) const -> ExtType { return mOp.rootSteps(iPtrNum).extend( mExpr.rootSteps(iPtrNum) ); @@ -91,7 +91,7 @@ namespace MultiArrayTools template template GenMapIndex::GenMapIndex(const std::shared_ptr& range) : - IndexInterface,std::tuple >(range, 0) + IndexInterface,typename Op::value_type>(range, 0) { RPackNum::construct(mIPack, *range); IB::mPos = RPackNum::makePos(mIPack); @@ -158,41 +158,48 @@ namespace MultiArrayTools template GenMapIndex& GenMapIndex::operator=(size_t pos) { - IB::mPos = pos; - RPackNum::setIndexPack(mIPack, pos); + (*mOutIndex) = pos; + IB::mPos = mOutIndex->pos(); + //RPackNum::setIndexPack(mIPack, pos); return *this; } template GenMapIndex& GenMapIndex::operator++() { - RPackNum::pp( mIPack ); - ++IB::mPos; + //RPackNum::pp( mIPack ); + ++(*mOutIndex); + IB::mPos = mOutIndex->pos(); return *this; } template GenMapIndex& GenMapIndex::operator--() { - RPackNum::mm( mIPack ); - --IB::mPos; + //RPackNum::mm( mIPack ); + --(*mOutIndex); + IB::mPos = mOutIndex->pos(); return *this; } template int GenMapIndex::pp(std::intptr_t idxPtrNum) { - int tmp = RPackNum::pp(mIPack, mBlockSizes, idxPtrNum); - IB::mPos += tmp; - return tmp; + //int tmp = RPackNum::pp(mIPack, mBlockSizes, idxPtrNum); + mOutIndex->pp(idxPtrNum); + IB::mPos = mOutIndex->pos(); + //IB::mPos += tmp; + return 1; } template int GenMapIndex::mm(std::intptr_t idxPtrNum) { - int tmp = RPackNum::mm(mIPack, mBlockSizes, idxPtrNum); - IB::mPos -= tmp; - return tmp; + //int tmp = RPackNum::mm(mIPack, mBlockSizes, idxPtrNum); + mOutIndex->mm(idxPtrNum); + IB::mPos = mOutIndex->pos(); + //IB::mPos -= tmp; + return 1; } template @@ -204,16 +211,19 @@ namespace MultiArrayTools template typename GenMapIndex::MetaType GenMapIndex::meta() const { - MetaType metaTuple; - RPackNum::getMetaPos(metaTuple, mIPack); - return metaTuple; + //MetaType metaTuple; + //RPackNum::getMetaPos(metaTuple, mIPack); + //assert(0); + return mOutIndex->meta(); } template GenMapIndex& GenMapIndex::at(const MetaType& metaPos) { - RPackNum::setMeta(mIPack, metaPos); - IB::mPos = RPackNum::makePos(mIPack); + //RPackNum::setMeta(mIPack, metaPos); + //IB::mPos = RPackNum::makePos(mIPack); + mOutIndex->at(metaPos); + IB::mPos = mOutIndex->pos(); return *this; } @@ -281,12 +291,12 @@ namespace MultiArrayTools template auto GenMapIndex::ifor(size_t step, Exprs exs) const -> decltype(RPackNum::mkForh - (step, mIPack, mBlockSizes, OpExpr - ( range()->map(), mIPack, mOutIndex, step, exs ) ) ) + (step, mIPack, mBlockSizes, OpExpr + ( range()->map(), mOutIndex, step, exs ) ) ) { return RPackNum::mkForh - (step, mIPack, mBlockSizes, OpExpr - ( range()->map(), mIPack, mOutIndex, step, exs ) ); + (step, mIPack, mBlockSizes, OpExpr + ( range()->map(), mOutIndex, step, exs ) ); } template @@ -297,15 +307,14 @@ namespace MultiArrayTools return ifor(step, exs); } - /* template template - auto GenMapIndex::iforh(Exprs exs) const - -> decltype(RPackNum::mkForh(mIPack, exs)) + auto GenMapIndex::iforh(size_t step, Exprs exs) const + -> decltype(ifor(step, exs)) { - return RPackNum::mkForh(mIPack, exs); + return ifor(step, exs); } - */ + /************************* * MapRangeFactory * *************************/ diff --git a/src/include/map_range.h b/src/include/map_range.h index d3993f8..237d07c 100644 --- a/src/include/map_range.h +++ b/src/include/map_range.h @@ -48,14 +48,12 @@ namespace MultiArrayTools - template + template //template class OpExpr { public: - //typedef decltype(mkMapOp(std::declval(), std::declval())) Op; typedef SingleIndex OIType; - //typedef typename MapF::IndexPack IndexPack; static constexpr size_t LAYER = Expr::LAYER + 1; static constexpr size_t SIZE = Expr::SIZE + Op::SIZE; @@ -78,8 +76,7 @@ namespace MultiArrayTools OpExpr& operator=(const OpExpr& in) = default; OpExpr& operator=(OpExpr&& in) = default; - OpExpr(const Op& mapf, const IndexPack& ipack, const std::shared_ptr& oind, size_t step, Expr ex); - //OpExpr(const MapF& mapf, const IndexPack& ipack, const std::shared_ptr& oind, size_t step, Expr ex); + OpExpr(const Op& mapf, const std::shared_ptr& oind, size_t step, Expr ex); inline void operator()(size_t mlast, ExtType last); inline void operator()(size_t mlast = 0); @@ -90,14 +87,17 @@ namespace MultiArrayTools template class GenMapIndex : public IndexInterface, - std::tuple > + typename Op::value_type> + //std::tuple > { public: typedef IndexInterface, - std::tuple > IB; + typename Op::value_type> IB; + //std::tuple > IB; typedef std::tuple...> IndexPack; - typedef std::tuple MetaType; + //typedef std::tuple MetaType; + typedef typename Op::value_type MetaType; typedef GenMapRange RangeType; typedef GenMapIndex IType; typedef SingleIndex OIType; @@ -184,18 +184,18 @@ namespace MultiArrayTools template auto ifor(size_t step, Exprs exs) const -> decltype(RPackNum::mkForh - (step, mIPack, mBlockSizes, OpExpr( range()->map(), mIPack, mOutIndex, step, exs ) ) ); + (step, mIPack, mBlockSizes, OpExpr( range()->map(), mOutIndex, step, exs ) ) ); // first step arg not used! template auto pifor(size_t step, Exprs exs) const -> decltype(ifor(step, exs)); // NO MULTITHREADING - /* + template - auto iforh(Exprs exs) const - -> decltype(RPackNum::mkForh(mIPack, exs)); - */ + auto iforh(size_t step, Exprs exs) const + -> decltype(ifor(step, exs)); + }; @@ -241,6 +241,7 @@ namespace MultiArrayTools typedef GenMapRange RangeType; typedef SingleRange ORType; typedef SingleRangeFactory ORFType; + typedef typename Op::value_type MetaType; //typedef typename RangeInterface >::IndexType IndexType; protected: diff --git a/src/include/ranges/index_base.h b/src/include/ranges/index_base.h index 6e7e08d..6d22f15 100644 --- a/src/include/ranges/index_base.h +++ b/src/include/ranges/index_base.h @@ -68,12 +68,14 @@ namespace MultiArrayTools // CHECK / IMPLEMENT !!!!!! template - auto ifor(const Expr ex) const -> decltype(THIS().template ifor(ex)) - { return THIS().template ifor(ex); } + auto ifor(size_t step, const Expr ex) const + -> decltype(THIS().template ifor(step,ex)) + { return THIS().template ifor(step,ex); } template - auto iforh(const Expr ex) const -> decltype(THIS().template iforh(ex)) - { return THIS().template iforh(ex); } + auto iforh(size_t step, const Expr ex) const + -> decltype(THIS().template iforh(step,ex)) + { return THIS().template iforh(step,ex); } std::intptr_t ptrNum() const; diff --git a/src/include/ranges/subrange.h b/src/include/ranges/subrange.h index 7e17cda..ed9eb8d 100644 --- a/src/include/ranges/subrange.h +++ b/src/include/ranges/subrange.h @@ -107,6 +107,16 @@ namespace MultiArrayTools template class SubRange : public RangeInterface> { + private: + + SubRange() = delete; + SubRange(const SubRange& in) = delete; + + SubRange(const std::shared_ptr& fullRange, const vector& subset); + + std::shared_ptr mFullRange; + vector mSubSet; + public: typedef RangeBase RB; typedef SubIndex IndexType; @@ -128,7 +138,8 @@ namespace MultiArrayTools bool isMeta(const MetaType& metaPos) const; - const MetaType& get(size_t pos) const; + auto get(size_t pos) const + -> decltype(mFullRange->get(mSubSet[pos])); size_t getMeta(const MetaType& metaPos) const; virtual IndexType begin() const final; @@ -145,15 +156,6 @@ namespace MultiArrayTools static constexpr size_t SIZE = -1; static constexpr bool HASMETACONT = false; - private: - - SubRange() = delete; - SubRange(const SubRange& in) = delete; - - SubRange(const std::shared_ptr& fullRange, const vector& subset); - - std::shared_ptr mFullRange; - vector mSubSet; }; } // namespace MultiArrayTools @@ -457,7 +459,8 @@ namespace MultiArrayTools } template - const typename SubRange::MetaType& SubRange::get(size_t pos) const + auto SubRange::get(size_t pos) const + -> decltype(mFullRange->get(mSubSet[pos])) { return mFullRange->get( mSubSet[pos] ); }