From 8ff366d40f6841ee7849899f60a8b63f6de38b83 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Mon, 6 Aug 2018 19:20:57 +0200 Subject: [PATCH] some fixes --- src/include/ranges/anonymous_range.h | 17 ++++++++++++++--- src/include/ranges/rpack_num.h | 2 -- src/lib/ranges/anonymous_range.cc | 5 +++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/include/ranges/anonymous_range.h b/src/include/ranges/anonymous_range.h index 6adab6d..71dc06e 100644 --- a/src/include/ranges/anonymous_range.h +++ b/src/include/ranges/anonymous_range.h @@ -87,6 +87,8 @@ namespace MultiArrayTools template std::shared_ptr > scast(SIZET... sizes) const; // save cast + + bool isEmpty() const; friend AnonymousRangeFactory; @@ -105,6 +107,7 @@ namespace MultiArrayTools SingleRange(std::shared_ptr... origs); size_t mSize = 1; + bool mEmpty = true; std::vector > mOrig; }; @@ -143,6 +146,7 @@ namespace MultiArrayTools } std::dynamic_pointer_cast(mProd)->mOrig.push_back(r); std::dynamic_pointer_cast(mProd)->mSize *= r->size(); + std::dynamic_pointer_cast(mProd)->mEmpty = false; } /***************** @@ -162,7 +166,6 @@ namespace MultiArrayHelper size_t origpos, size_t size) { AnonymousRangeFactory arf; - //VCHECK(size); for(size_t op = origpos; op != origpos + size; ++op){ //VCHECK(op); arf.append(orig[op]); @@ -174,8 +177,10 @@ namespace MultiArrayHelper inline void setRangeToVec(std::vector >& v, std::shared_ptr r) { - for(size_t i = 0; i != r->dim(); ++i){ - v.insert(v.begin(), r->sub(i)); + if(not r->isEmpty()){ + for(size_t i = r->anonymousDim(); i != 0; --i){ + v.insert(v.begin(), r->sub(i-1)); + } } } @@ -193,6 +198,9 @@ namespace MultiArrayTools { RPackNum::RangesToVec( origs, mOrig ); mSize = RPackNum::getSize( origs ); + if(sizeof...(RangeTypes)){ + mEmpty = false; + } } template @@ -202,6 +210,9 @@ namespace MultiArrayTools auto rst = std::make_tuple(origs...); RPackNum::RangesToVec( rst, mOrig ); mSize = RPackNum::getSize( rst ); + if(sizeof...(RangeTypes)){ + mEmpty = false; + } } template diff --git a/src/include/ranges/rpack_num.h b/src/include/ranges/rpack_num.h index 3f21e4b..636a3ed 100644 --- a/src/include/ranges/rpack_num.h +++ b/src/include/ranges/rpack_num.h @@ -59,8 +59,6 @@ namespace MultiArrayHelper { v.insert(v.begin(), r); } - - template struct RPackNum diff --git a/src/lib/ranges/anonymous_range.cc b/src/lib/ranges/anonymous_range.cc index a0785d8..b094b4d 100644 --- a/src/lib/ranges/anonymous_range.cc +++ b/src/lib/ranges/anonymous_range.cc @@ -81,6 +81,11 @@ namespace MultiArrayTools { return SpaceType::ANON; } + + bool AnonymousRange::isEmpty() const + { + return mEmpty; + } std::string AnonymousRange::stringMeta(size_t pos) const {