diff --git a/src/multi_array_operation.cc b/src/multi_array_operation.cc index 60110b6..e8c6dc5 100644 --- a/src/multi_array_operation.cc +++ b/src/multi_array_operation.cc @@ -44,7 +44,7 @@ namespace MultiArrayTools std::cout << "assignment: " << endPos << " elements" << std::endl; // assignment loop for(iref = mArrayRef.beginIndex().pos(); iref != mArrayRef.endIndex(); ++iref){ - std::cout << iref.pos() << '\r' << std::flush; + //std::cout << iref.pos() << '\r' << std::flush; get() = in.get(); //assert(not std::isnan( get() )); } diff --git a/src/multi_range.cc b/src/multi_range.cc index b45c3b5..754b13a 100644 --- a/src/multi_range.cc +++ b/src/multi_range.cc @@ -80,7 +80,7 @@ namespace MultiArrayTools template static inline void plus(MultiIndex& index, int num) { - IndefinitIndexBase& si = index.get(DIGIT); + auto& si = index.template getIndex(); si.setPosRel(num); size_t oor = si.outOfRange(); if(oor > 0){ @@ -96,26 +96,28 @@ namespace MultiArrayTools template static inline void pp(MultiIndex& index) { - IndefinitIndexBase& si = index.get(DIGIT); - si.setPosRel(1); - size_t oor = si.outOfRange(); - if(oor > 0){ + auto& si = index.template getIndex(); + //IndefinitIndexBase& si = index.get(DIGIT); + if(si.pos() == si.max()-1){ + si.setPos(0); SubIteration::pp(index); - // set pos to zero ?? - SubIteration::plus(index, -si.max()); // This can be done faster because we know the pos + } + else { + si.setPosRel(1); } } template static inline void mm(MultiIndex& index) { - IndefinitIndexBase& si = index.get(DIGIT); - si.setPosRel(-1); - size_t oor = si.outOfRange(); - if(oor < 0){ + auto& si = index.template getIndex(); + //IndefinitIndexBase& si = index.get(DIGIT); + if(si.pos() == si.max()-1){ + si.setPos(si.max()-1); SubIteration::mm(index); - // or to max here ?? - SubIteration::plus(index, si.max()); // This can be done faster because we know the pos + } + else { + si.setPosRel(1); } } }; @@ -126,21 +128,24 @@ namespace MultiArrayTools template static inline void plus(MultiIndex& index, int num) { - IndefinitIndexBase& si = index.get(0); + auto& si = index.template getIndex<0>(); + //IndefinitIndexBase& si = index.get(0); si.setPosRel(num); } template static inline void pp(MultiIndex& index) { - IndefinitIndexBase& si = index.get(0); + auto& si = index.template getIndex<0>(); + //IndefinitIndexBase& si = index.get(0); si.setPosRel(1); } template static inline void mm(MultiIndex& index) { - IndefinitIndexBase& si = index.get(0); + auto& si = index.template getIndex<0>(); + //IndefinitIndexBase& si = index.get(0); si.setPosRel(-1); } };