diff --git a/src/include/high_level_operation.cc.h b/src/include/high_level_operation.cc.h index 7e5ff6c..857a445 100644 --- a/src/include/high_level_operation.cc.h +++ b/src/include/high_level_operation.cc.h @@ -247,21 +247,25 @@ namespace MultiArrayTools { const size_t dim = di->dim(); if(dim >= 2){ - auto ci1 = std::dynamic_pointer_cast>(di->getP(dim-2)); - auto ci2 = std::dynamic_pointer_cast>(di->getP(dim-1)); + auto ci1 = di->getP(dim-2)->reduced(); + auto ci2 = di->getP(dim-1)->reduced(); + //auto ci1 = std::dynamic_pointer_cast>(di->getP(dim-2)); + //auto ci2 = std::dynamic_pointer_cast>(di->getP(dim-1)); assert(ci1 != nullptr); assert(ci2 != nullptr); auto odi = mkSubSpaceX(di, dim-2); auto mi = mkMIndex(is..., odi); - this->assign(in, mi, ci1->getIndex(), ci2->getIndex()); + //this->assign(in, mi, ci1->getIndex(), ci2->getIndex()); + this->assign(in, mi, ci1, ci2); } else { assert(dim == 1); - auto ci1 = std::dynamic_pointer_cast>(di->getP(dim-2)); + //auto ci1 = std::dynamic_pointer_cast>(di->getP(dim-2)); + auto ci1 = di->getP(dim-2)->reduced(); assert(ci1 != nullptr); auto odi = mkSubSpaceX(di, dim-1); auto mi = mkMIndex(is..., odi); - this->assign(in, mi, ci1->getIndex()); + this->assign(in, mi, ci1); } //INDS::template CallHLOp<> call; //call.assign(*this, in, is..., di); diff --git a/src/include/ranges/index_wrapper.cc.h b/src/include/ranges/index_wrapper.cc.h index b482cfb..234fc3b 100644 --- a/src/include/ranges/index_wrapper.cc.h +++ b/src/include/ranges/index_wrapper.cc.h @@ -6,7 +6,13 @@ namespace MultiArrayTools { template - IndexWrapper::IndexWrapper(const std::shared_ptr& i) : mI(i) {} + IndexWrapper::IndexWrapper(const std::shared_ptr& i) : mI(i) + { + ClassicRF crf(mI->max()); + mCI = std::make_shared + ( std::dynamic_pointer_cast( crf.create() ) ); + (*mCI) = mI->pos(); + } template IndexType IndexWrapper::type() const @@ -111,7 +117,11 @@ namespace MultiArrayTools template size_t IndexWrapper::getStepSizeComp(std::intptr_t j) const { - return MultiArrayHelper::getStepSize(*mI, j); + size_t out = MultiArrayHelper::getStepSize(*mI, j); + if(out == 0){ + out = MultiArrayHelper::getStepSize(*mCI, j); + } + return out; } template @@ -143,17 +153,31 @@ namespace MultiArrayTools { return std::make_shared( std::make_shared( *mI ) ); } - + /* template RegIndInfo IndexWrapper::regN() const { RegIndInfo out; return out.set(mI); } + */ + template + std::shared_ptr IndexWrapper::getIndex() const + { + return mI; + } + + template + std::shared_ptr IndexWrapper::reduced() const + { + (*mCI) = mI->pos(); + return mCI; + } template inline std::shared_ptr mkIndexWrapper(const Index& i) { return std::make_shared>(std::make_shared(i)); } + } diff --git a/src/include/ranges/index_wrapper.h b/src/include/ranges/index_wrapper.h index 17b77c4..a2ee44e 100644 --- a/src/include/ranges/index_wrapper.h +++ b/src/include/ranges/index_wrapper.h @@ -50,7 +50,7 @@ namespace MultiArrayTools virtual std::shared_ptr duplicate() const = 0; - virtual RegIndInfo regN() const = 0; + //virtual RegIndInfo regN() const = 0; //virtual DynamicMetaT meta() const = 0; //virtual const DynamicMetaT* metaPtr() const = 0; //virtual AbstractIW& at(const U& metaPos) = 0; @@ -73,6 +73,8 @@ namespace MultiArrayTools std::shared_ptr duplicateI() const { return std::dynamic_pointer_cast( this->duplicate() ); } */ + + virtual std::shared_ptr reduced() const = 0; }; typedef IndexWrapperBase IndexW; @@ -91,6 +93,7 @@ namespace MultiArrayTools private: std::shared_ptr mI; + std::shared_ptr mCI; // reduced; public: IndexWrapper(const IndexWrapper& in) = default; @@ -136,9 +139,10 @@ namespace MultiArrayTools virtual DynamicExpression iforh(size_t step, DynamicExpression ex) const override final; virtual std::shared_ptr duplicate() const override final; - virtual RegIndInfo regN() const override final; + //virtual RegIndInfo regN() const override final; - std::shared_ptr getIndex() const { return mI; } + std::shared_ptr getIndex() const; + virtual std::shared_ptr reduced() const override final; }; /*