From 9d7ab24d8ce504959966dedd9c65a5eb6ab442f0 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Tue, 9 Jan 2018 22:38:46 +0100 Subject: [PATCH] adds to last commit --- src/multi_array_operation.h | 13 +++++++++---- src/pack_num.h | 21 ++++++++++++++++----- src/ranges/container_range.h | 1 + src/ranges/multi_range.h | 1 + src/ranges/rpack_num.h | 16 +++++++++++++++- src/ranges/single_range.h | 1 + src/xfor/xfor.h | 2 +- 7 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/multi_array_operation.h b/src/multi_array_operation.h index bc4af02..e293f7d 100644 --- a/src/multi_array_operation.h +++ b/src/multi_array_operation.h @@ -439,11 +439,16 @@ namespace MultiArrayTools { #ifdef XX_USE_NEW_LOOP_ROUTINE_XX // === N E W === - AssignmentExpr ae(this, &mSecond); + static const size_t TDIM = IndexType::totalDim() + typedef std::array IAT; typedef decltype(mSecond.rootSteps()) RootStepType; - std::array - ee(PackNum::mkExt(mIndex, mSecond)); - static auto loop = mIndex->ifor(ee, ae); + + AssignmentExpr ae(this, &mSecond); + + IAT siar = mIndex->getSIndexTuple(); + std::array ee; + PackNum::mkExt(ee, siar, mSecond); + auto loop = mIndex->ifor(ee, ae); loop(); #else // === O L D === diff --git a/src/pack_num.h b/src/pack_num.h index a7dc0db..95c903c 100644 --- a/src/pack_num.h +++ b/src/pack_num.h @@ -56,12 +56,15 @@ namespace MultiArrayHelper { return std::tuple_cat( PackNum::mkStepTuple(ii, otp), std::get(otp).rootSteps(ii) ); } - /* - template - static auto mkExt(const std::shared_ptr& idxPtr, const OpClass& second) + + template + static void mkExt(std::array& out, + const std::array& siar, + const OpClass& second) { - // !!!!! - }*/ + std::get(out) = second.rootSteps( std::get(siar) ); + PackNum::mkExt(out, siar, second); + } }; template<> @@ -108,6 +111,14 @@ namespace MultiArrayHelper return std::get<0>(otp).rootSteps(ii); } + template + static void mkExt(std::array& out, + const std::array& siar, + const OpClass& second) + { + std::get<0>(out) = second.rootSteps( std::get<0>(siar) ); + } + }; diff --git a/src/ranges/container_range.h b/src/ranges/container_range.h index e1d38cb..9d1498b 100644 --- a/src/ranges/container_range.h +++ b/src/ranges/container_range.h @@ -30,6 +30,7 @@ namespace MultiArrayTools static IndexType sType() { return IndexType::CONT; } static size_t sDim() { return sizeof...(Indices); } + static size_t totalDim() { return mkTotalDim(); } private: diff --git a/src/ranges/multi_range.h b/src/ranges/multi_range.h index 0b02516..9ca449d 100644 --- a/src/ranges/multi_range.h +++ b/src/ranges/multi_range.h @@ -34,6 +34,7 @@ namespace MultiArrayTools static IndexType sType() { return IndexType::MULTI; } static size_t sDim() { return sizeof...(Indices); } + static size_t totalDim() { return mkTotalDim(); } private: diff --git a/src/ranges/rpack_num.h b/src/ranges/rpack_num.h index d3af73f..86a9a27 100644 --- a/src/ranges/rpack_num.h +++ b/src/ranges/rpack_num.h @@ -10,6 +10,20 @@ namespace MultiArrayHelper { using namespace MultiArrayTools; + + template + size_t mkTotalDim() + { + return typename Index1::totalDim(); + } + + template + size_t mkTotalDim() + { + return typename Index1::totalDim() * mkTotalDim(); + } + + template struct RPackNum { @@ -227,7 +241,7 @@ namespace MultiArrayHelper return std::get::value-N>(ipack) ->ifor( ext, RPackNum::mkFor(ipack, ext, exs) ); } - + }; diff --git a/src/ranges/single_range.h b/src/ranges/single_range.h index b453c4c..186b9a3 100644 --- a/src/ranges/single_range.h +++ b/src/ranges/single_range.h @@ -32,6 +32,7 @@ namespace MultiArrayTools SingleIndex(const std::shared_ptr >& range); static IndexType sType() { return IndexType::SINGLE; } + static size_t totalDim() { return 1; } // ==== >>>>> STATIC POLYMORPHISM <<<<< ==== diff --git a/src/xfor/xfor.h b/src/xfor/xfor.h index 26ffda3..fb90c29 100644 --- a/src/xfor/xfor.h +++ b/src/xfor/xfor.h @@ -80,7 +80,7 @@ namespace MultiArrayHelper std::tuple...>&& ext, const Args&... args) : mIndPtr(indPtr), mExpr(args...), mExt(ext) {} - + template For::For(IndexClass* indPtr, Expr&& expr, std::tuple...>&& ext) :