adds to last commit

This commit is contained in:
Christian Zimmermann 2018-01-09 22:38:46 +01:00
parent 529ae3353e
commit 9d7ab24d8c
7 changed files with 44 additions and 11 deletions

View file

@ -439,11 +439,16 @@ namespace MultiArrayTools
{ {
#ifdef XX_USE_NEW_LOOP_ROUTINE_XX #ifdef XX_USE_NEW_LOOP_ROUTINE_XX
// === N E W === // === N E W ===
AssignmentExpr ae(this, &mSecond); static const size_t TDIM = IndexType::totalDim()
typedef std::array<std::intptr_t,TDIM> IAT;
typedef decltype(mSecond.rootSteps()) RootStepType; typedef decltype(mSecond.rootSteps()) RootStepType;
std::array<RootStepType,/*sizeof single indices!!*/>
ee(PackNum</*sizeof single indices!!*/-1>::mkExt(mIndex, mSecond)); AssignmentExpr ae(this, &mSecond);
static auto loop = mIndex->ifor(ee, ae);
IAT siar = mIndex->getSIndexTuple();
std::array<RootStepType,TDIM> ee;
PackNum<TDIM-1>::mkExt(ee, siar, mSecond);
auto loop = mIndex->ifor(ee, ae);
loop(); loop();
#else #else
// === O L D === // === O L D ===

View file

@ -56,12 +56,15 @@ namespace MultiArrayHelper
{ {
return std::tuple_cat( PackNum<N-1>::mkStepTuple(ii, otp), std::get<N>(otp).rootSteps(ii) ); return std::tuple_cat( PackNum<N-1>::mkStepTuple(ii, otp), std::get<N>(otp).rootSteps(ii) );
} }
/*
template <class IndexClass, class OpClass> template <class RootStepTuple, class IndexClass, class OpClass>
static auto mkExt(const std::shared_ptr<IndexClass>& idxPtr, const OpClass& second) static void mkExt(std::array<RootStepTuple,IndexClass::totalDim()>& out,
const std::array<std::intptr_t,IndexClass::totalDim()>& siar,
const OpClass& second)
{ {
// !!!!! std::get<N>(out) = second.rootSteps( std::get<N>(siar) );
}*/ PackNum<N-1>::mkExt(out, siar, second);
}
}; };
template<> template<>
@ -108,6 +111,14 @@ namespace MultiArrayHelper
return std::get<0>(otp).rootSteps(ii); return std::get<0>(otp).rootSteps(ii);
} }
template <class RootStepTuple, class IndexClass, class OpClass>
static void mkExt(std::array<RootStepTuple,IndexClass::totalDim()>& out,
const std::array<std::intptr_t,IndexClass::totalDim()>& siar,
const OpClass& second)
{
std::get<0>(out) = second.rootSteps( std::get<0>(siar) );
}
}; };

View file

@ -30,6 +30,7 @@ namespace MultiArrayTools
static IndexType sType() { return IndexType::CONT; } static IndexType sType() { return IndexType::CONT; }
static size_t sDim() { return sizeof...(Indices); } static size_t sDim() { return sizeof...(Indices); }
static size_t totalDim() { return mkTotalDim<Indices...>(); }
private: private:

View file

@ -34,6 +34,7 @@ namespace MultiArrayTools
static IndexType sType() { return IndexType::MULTI; } static IndexType sType() { return IndexType::MULTI; }
static size_t sDim() { return sizeof...(Indices); } static size_t sDim() { return sizeof...(Indices); }
static size_t totalDim() { return mkTotalDim<Indices...>(); }
private: private:

View file

@ -10,6 +10,20 @@ namespace MultiArrayHelper
{ {
using namespace MultiArrayTools; using namespace MultiArrayTools;
template <class Index1>
size_t mkTotalDim()
{
return typename Index1::totalDim();
}
template <class Index1, class Index2, class... Indices>
size_t mkTotalDim()
{
return typename Index1::totalDim() * mkTotalDim<Index2,Indices...>();
}
template <size_t N> template <size_t N>
struct RPackNum struct RPackNum
{ {

View file

@ -32,6 +32,7 @@ namespace MultiArrayTools
SingleIndex(const std::shared_ptr<SingleRange<U,TYPE> >& range); SingleIndex(const std::shared_ptr<SingleRange<U,TYPE> >& range);
static IndexType sType() { return IndexType::SINGLE; } static IndexType sType() { return IndexType::SINGLE; }
static size_t totalDim() { return 1; }
// ==== >>>>> STATIC POLYMORPHISM <<<<< ==== // ==== >>>>> STATIC POLYMORPHISM <<<<< ====