From 51dcbe7b92afeafdbf32504baeeffe168a18660d Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 1 Mar 2017 10:41:29 +0100 Subject: [PATCH] clean up some parts of the code --- src/index_base.cc | 38 ++++++++++++++++++-------------------- src/index_base.h | 4 ++-- src/multi_range.cc | 3 ++- src/multi_range.h | 5 ++--- src/single_range.cc | 2 ++ src/single_range.h | 5 ++--- src/unit_test.cc | 9 ++++----- 7 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/index_base.cc b/src/index_base.cc index 292d369..7ac0023 100644 --- a/src/index_base.cc +++ b/src/index_base.cc @@ -17,31 +17,31 @@ namespace MultiArrayTools size_t IndefinitIndexBase::pos() const { - assert(not virt()); + //assert(not virt()); return mPos; } const std::string& IndefinitIndexBase::name() const { - assert(not virt()); + //assert(not virt()); return mName; } void IndefinitIndexBase::name(const std::string& str) { - assert(not virt()); + //assert(not virt()); mName = str; } void IndefinitIndexBase::name(const Name& nm) { - assert(not virt()); + //assert(not virt()); mName = nm.own(); } bool IndefinitIndexBase::link(IndefinitIndexBase* toLink) { - assert(not virt()); + //assert(not virt()); if(toLink->rangeType() != rangeType() and toLink->name() == name()){ assert(0); // throw !! @@ -77,13 +77,13 @@ namespace MultiArrayTools bool IndefinitIndexBase::linked() const { - assert(not virt()); + //assert(not virt()); return mLinked != nullptr; } void IndefinitIndexBase::setPos(size_t pos) { - assert(not virt()); + //assert(not virt()); mPos = pos; if(linked()){ mLinked->setPos(mPos); @@ -93,26 +93,26 @@ namespace MultiArrayTools size_t IndefinitIndexBase::max() const { - assert(not virt()); + //assert(not virt()); return static_cast( -1 ); } size_t IndefinitIndexBase::outOfRange() const { - assert(not virt()); + //assert(not virt()); int res = pos() - max() + 1; return res > 0 ? static_cast(res) : 0; } bool IndefinitIndexBase::toNull() const { - assert(not virt()); + //assert(not virt()); return true; } void IndefinitIndexBase::evalMajor() { - assert(not virt()); + //assert(not virt()); if(not master()){ mMajor->eval(); } @@ -120,13 +120,13 @@ namespace MultiArrayTools bool IndefinitIndexBase::master() { - assert(not virt()); + //assert(not virt()); return mMajor == nullptr; } void IndefinitIndexBase::subOrd(IndefinitIndexBase* major) { - assert(not virt()); + //assert(not virt()); mMajor = major; } @@ -140,31 +140,29 @@ namespace MultiArrayTools template size_t IndexBase::max() const { - assert(not virt()); + //assert(not virt()); return mRange->size(); } template bool IndexBase::toNull() const { - assert(not virt()); + //assert(not virt()); return mRange == nullptr; } template void IndexBase::assignRange(RangeBase const* range) { - assert(not virt()); + //assert(not virt()); if(toNull()){ mRange = range; } } - - /* + template void IndexBase::eval() { - CHECK; setPos( evaluate(*dynamic_cast( this )) ); - }*/ + } } diff --git a/src/index_base.h b/src/index_base.h index 6c88b34..256f008 100644 --- a/src/index_base.h +++ b/src/index_base.h @@ -57,7 +57,7 @@ namespace MultiArrayTools virtual void subOrd(IndefinitIndexBase* major); - virtual bool virt() const { return true; } + //virtual bool virt() const { return true; } protected: @@ -85,7 +85,7 @@ namespace MultiArrayTools virtual void assignRange(RangeBase const* range); - //virtual void eval() override; + virtual void eval() override; virtual void copyPos(const Index& in) = 0; protected: diff --git a/src/multi_range.cc b/src/multi_range.cc index c38e7a7..628d2cd 100644 --- a/src/multi_range.cc +++ b/src/multi_range.cc @@ -486,12 +486,13 @@ namespace MultiArrayTools PositionCopy::copyPos(*this, in); } + /* template void MultiIndex::eval() { IIB::setPos( evaluate( *this ) ); } - + */ /* template struct RangeAssigner diff --git a/src/multi_range.h b/src/multi_range.h index 8b67083..815adc1 100644 --- a/src/multi_range.h +++ b/src/multi_range.h @@ -80,9 +80,8 @@ namespace MultiArrayTools virtual void copyPos(const MultiIndex& in) override; - virtual void eval() override; - - virtual bool virt() const override { return false; } + //virtual void eval() override; + //virtual bool virt() const override { return false; } //virtual void assignRange(RangeBase > const* range) override; }; diff --git a/src/single_range.cc b/src/single_range.cc index 97cb6dd..cd7478d 100644 --- a/src/single_range.cc +++ b/src/single_range.cc @@ -155,9 +155,11 @@ namespace MultiArrayTools IIB::setPos(in.pos()); } + /* template void SingleIndex::eval() { IIB::setPos( evaluate( *this ) ); } + */ } diff --git a/src/single_range.h b/src/single_range.h index abb7260..7ad231f 100644 --- a/src/single_range.h +++ b/src/single_range.h @@ -50,9 +50,8 @@ namespace MultiArrayTools virtual void copyPos(const SingleIndex& in) override; - virtual void eval() override; - - virtual bool virt() const override { return false; } + //virtual void eval() override; + //virtual bool virt() const override { return false; } protected: virtual size_t evaluate(const SingleIndex& in) const override; diff --git a/src/unit_test.cc b/src/unit_test.cc index ccab9e0..0440bea 100644 --- a/src/unit_test.cc +++ b/src/unit_test.cc @@ -359,11 +359,11 @@ namespace { auto i1 = i.template getIndex<0>(); auto i2 = i.template getIndex<1>(); auto i3 = i.template getIndex<2>(); - CHECK; + Slice2d3dAny sl(ra); - CHECK; sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)]; EXPECT_EQ(sl.size(), 6); + Slice2d3dAny sl2(rb); sl2("alpha","beta") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 0, i3 = 1)]; EXPECT_EQ(sl2.size(), 12); @@ -377,13 +377,12 @@ namespace { auto i3 = i.template getIndex<2>(); Slice2d3dAny sl(ra); sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)]; - CHECK; + auto j = sl.begin(); auto j1 = j.template getIndex<0>(); auto j2 = j.template getIndex<1>(); - CHECK; + EXPECT_EQ(sl[j(j1 = 0, j2 = 0)], 9); - CHECK; EXPECT_EQ(sl[j(j1 = 0, j2 = 1)], 54); EXPECT_EQ(sl[j(j1 = 1, j2 = 0)], -10);