From 13488b9839589e169f07db9033dfa361d84af242 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 5 May 2021 20:04:13 +0200 Subject: [PATCH] ranges: start replacement of rpack_num --- src/include/ranges/multi_range.h | 28 +++++++++++++++++++++++++--- src/include/ranges/range_base.h | 2 ++ src/include/ranges/rpack_num.cc.h | 1 + 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/include/ranges/multi_range.h b/src/include/ranges/multi_range.h index f6f923c..2c359fd 100644 --- a/src/include/ranges/multi_range.h +++ b/src/include/ranges/multi_range.h @@ -17,6 +17,8 @@ #include "ranges/x_to_string.h" #include "ranges/type_map.h" +#include "statics/static_for.h" + namespace MultiArrayTools { namespace @@ -279,10 +281,30 @@ namespace MultiArrayTools MultiIndex::MultiIndex(const std::shared_ptr& range) : IndexInterface,std::tuple >(range, 0) { - RPackNum::construct(mIPack, *range); - IB::mPos = RPackNum::makePos(mIPack); std::get(mBlockSizes) = 1; - RPackNum::initBlockSizes(mBlockSizes, mIPack); // has one more element! + sfor + ( [&](auto i) constexpr { return i-1; } , + [&](auto i) { + auto r = range->template getPtr(); + std::get(mIPack) = r->beginPtr(); + *std::get(mIPack) = 0; + + std::get(mBlockSizes) = sfor + ( [&](auto j) { return j+1; } , + [&](auto j) { return std::get(mIPack)->max(); } , + [&](auto a, auto b) { return a * b; } + ); + + return 0; + }, + [&](auto a, auto b) { return 0; } + ); + + IB::mPos = sfor<0,sizeof...(Indices),0> + ( [&](auto i) {return i+1;}, + [&](auto i) {return std::get(mIPack);}, + [&](auto a, auto b) {return a->pos() + b*a->max();}, + 0 ); } template diff --git a/src/include/ranges/range_base.h b/src/include/ranges/range_base.h index dd2b421..8217797 100644 --- a/src/include/ranges/range_base.h +++ b/src/include/ranges/range_base.h @@ -116,6 +116,8 @@ namespace MultiArrayTools virtual Index begin() const = 0; virtual Index end() const = 0; + std::shared_ptr beginPtr() const { return std::make_shared(this->begin()); } + std::shared_ptr endPtr() const { return std::make_shared(this->end()); } virtual std::shared_ptr aindex() const override final { return mkIndexWrapper(this->begin()); } //{ auto i = std::make_shared(this->begin()); return std::make_shared>(i); } //!!! diff --git a/src/include/ranges/rpack_num.cc.h b/src/include/ranges/rpack_num.cc.h index 9d74c2c..48c8def 100644 --- a/src/include/ranges/rpack_num.cc.h +++ b/src/include/ranges/rpack_num.cc.h @@ -174,6 +174,7 @@ namespace MultiArrayHelper std::get(ip) = std::shared_ptr( new SubIndexType( range.template getPtr() ) ); *std::get(ip) = 0; + //VCHECK(std::get(ip)->max()); RPackNum::construct(ip, range); }