im com; TODO: rootSteps, mkOpExpr

This commit is contained in:
Christian Zimmermann 2018-02-12 18:26:56 +01:00
parent ec844f5b68
commit 87a699a445
3 changed files with 24 additions and 27 deletions

View file

@ -108,7 +108,7 @@ namespace MultiArrayTools
inline void operator()(size_t start = 0);
inline void operator()(size_t start, ExtType last);
auto rootSteps(std::intptr_t iPtrNum = 0) -> ExtType;
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
};
@ -170,7 +170,7 @@ namespace MultiArrayTools
const Block<T>& get() const;
template <class ET, size_t SITE>
template <class ET>
inline const T& get(const ET& pos) const;
std::vector<BTSS> block(const IndexInfo* blockIndex, bool init = false) const;
@ -218,10 +218,10 @@ namespace MultiArrayTools
const MBlock<T>& get() const;
MBlock<T>& get();
template <class ET, size_t SITE>
template <class ET>
inline const T& get(const ET& pos) const;
template <class ET, size_t SITE>
template <class ET>
inline T& get(const ET& pos);
OperationRoot& set(const IndexInfo* blockIndex);
@ -363,7 +363,7 @@ namespace MultiArrayTools
-> decltype(mOp.rootSteps(iPtrNum));
template <class Expr>
auto loop(Expr&& exp) const -> decltype(mInd->iforh(exp))&&;
auto loop(Expr exp) const -> decltype(mInd->iforh(exp));
};
}
@ -497,7 +497,7 @@ namespace MultiArrayTools
template <typename T, class OpClass, class... Ranges>
typename OperationMaster<T,OpClass,Ranges...>::AssignmentExpr::ExtType
OperationMaster<T,OpClass,Ranges...>::AssignmentExpr::
rootSteps(std::intptr_t iPtrNum)
rootSteps(std::intptr_t iPtrNum) const
{
return mSec.rootSteps(iPtrNum);
}
@ -650,10 +650,10 @@ namespace MultiArrayTools
}
template <typename T, class... Ranges>
template <class ET, size_t SITE>
template <class ET>
inline const T& ConstOperationRoot<T,Ranges...>::get(const ET& pos) const
{
return mData[std::get<SITE>(pos)];
return mData[pos.val()];
}
template <typename T, class... Ranges>
@ -739,17 +739,17 @@ namespace MultiArrayTools
}
template <typename T, class... Ranges>
template <class ET, size_t SITE>
template <class ET>
inline const T& OperationRoot<T,Ranges...>::get(const ET& pos) const
{
return mData[std::get<SITE>( pos )];
return mData[pos.val()];
}
template <typename T, class... Ranges>
template <class ET, size_t SITE>
template <class ET>
inline T& OperationRoot<T,Ranges...>::get(const ET& pos)
{
return mData[std::get<SITE>( pos )];
return mData[pos.val()];
}
template <typename T, class... Ranges>

View file

@ -9,6 +9,7 @@
#include <ostream>
#include "base_def.h"
#include "xfor/exttype.h"
namespace MultiArrayHelper
{
@ -67,14 +68,12 @@ namespace MultiArrayHelper
}
// call with -2 (instead of -1)
template <typename T, class ETuple, class OpTuple, class OpFunction, size_t START>
static T mkOpExpr(const ETuple& pos, const OpTuple& ops)
template <typename T, class ETuple, class OpTuple, class OpFunction, typename... Args>
static inline T mkOpExpr(const ETuple& pos, const OpTuple& ops, const Args&... args)
{
typedef typename std::tuple_element<N,OpTuple>::type SubOpTypeRef;
typedef typename std::remove_reference<SubOpTypeRef>::type SubOpType;
static const size_t NEXT = START - SubOpType::SIZE;
return OpFunction::apply( std::get<N+1>(ops).template get<ETuple,START>(pos),
PackNum<N-1>::template mkOpExpr<ETuple,OpTuple,OpFunction,NEXT>(pos, ops) );
return PackNum<N-1>::template mkOpExpr<ETuple,OpTuple,OpFunction,decltype(std::get<N>(ops)),Args...>
( pos, ops, std::get<N>(ops).get(Getter<>::template get<ETuple>( pos )), args...);
}
template <class OpTuple, class Expr>
@ -138,11 +137,9 @@ namespace MultiArrayHelper
}
template <typename T, class ETuple, class OpTuple, class OpFunction, size_t START>
static T mkOpExpr(const ETuple& pos, const OpTuple& ops)
static inline T mkOpExpr(const ETuple& pos, const OpTuple& ops)
{
typedef typename std::tuple_element<1,OpTuple>::type SubOpTypeRef;
typedef typename std::remove_reference<SubOpTypeRef>::type SubOpType;
static const size_t NEXT = START - SubOpType::SIZE;
static constexpr size_t NEXT = START - SubOpType::SIZE;
return OpFunction::apply( std::get<1>(ops).template get<ETuple,START>(pos),
std::get<0>(ops).template get<ETuple,NEXT>(pos) );
}

View file

@ -4,7 +4,7 @@
#include <array>
namespace XFOR
namespace MultiArrayHelper
{
template <class X>
@ -102,13 +102,13 @@ namespace XFOR
}
};
} // end namespace XFOR
} // end namespace MultiArrayHelper
/* ========================= *
* --- TEMPLATE CODE --- *
* ========================= */
namespace XFOR
namespace MultiArrayHelper
{
template <class X>
@ -172,7 +172,7 @@ namespace XFOR
}
} // end namespace XFOR
} // end namespace MultiArrayHelper
#endif