diff --git a/src/include/xfor/iloop.h b/src/include/xfor/iloop.h index 65a492c..f6a4b30 100644 --- a/src/include/xfor/iloop.h +++ b/src/include/xfor/iloop.h @@ -13,6 +13,13 @@ namespace MultiArrayHelper template struct NN { + template + static inline constexpr size_t LSIZE() + { + typedef typename std::tuple_element::type LType; + return LType::SIZE + NN::template LSIZE(); + } + template static inline constexpr size_t lsize(const LTp& ltp) { @@ -44,12 +51,19 @@ namespace MultiArrayHelper std::get(ltp)(std::get(umpos)*mpos, pos.template nn::lsize(ltp)>()); return 0; } - + }; template <> struct NN<0> { + template + static inline constexpr size_t LSIZE() + { + typedef typename std::tuple_element<0,LTp>::type LType; + return LType::SIZE; + } + template static inline constexpr size_t lsize(const LTp& ltp) { @@ -88,7 +102,7 @@ namespace MultiArrayHelper private: static constexpr size_t LTpSize = std::tuple_size::value; static constexpr size_t VarTpSize = std::tuple_size::value; - + OpTp mOpTp; IndTp mIndTp; @@ -99,7 +113,8 @@ namespace MultiArrayHelper std::array mSetzero; // set variable to zero after each cycle public: - static constexpr size_t SIZE = NN::lsize(std::declval()); + //static constexpr size_t SIZE = NN::lsize(std::declval()); + static constexpr size_t SIZE = NN::template LSIZE(); static constexpr bool CONT = false; typedef decltype(NN::rootSteps(mLTp)) ExtType; @@ -108,7 +123,7 @@ namespace MultiArrayHelper ILoop(const OpTp& opTp, const IndTp& indTp, const VarTp& varTp, const LTp& lTp, const std::array& umpos, const std::array& setzero) : mOpTp(opTp), mIndTp(indTp), mVarTp(varTp), mLTp(lTp), mUmpos(umpos), mSetzero(setzero) {} - + inline size_t operator()(size_t mpos, ExtType pos) { NN::zero(mVarTp, mSetzero); @@ -122,7 +137,11 @@ namespace MultiArrayHelper { return NN::rootSteps(mLTp,i); } - + + VarTp& var() const + { + return mVarTp; + } }; template @@ -236,7 +255,11 @@ namespace MultiArrayHelper { return mL.rootSteps(i); } - + + auto var() const + { + return mL.var(); + } }; } diff --git a/src/include/xfor/xfor.h b/src/include/xfor/xfor.h index 43da4c5..e70bae3 100644 --- a/src/include/xfor/xfor.h +++ b/src/include/xfor/xfor.h @@ -161,7 +161,7 @@ namespace MultiArrayHelper typedef ExpressionBase EB; static constexpr size_t LAYER = Expr::LAYER + 1; - static constexpr size_t SIZE = Expr::SIZE; + static constexpr size_t SIZE = Expr::SIZE + 1; SubExpr(const SubExpr& in) = default; SubExpr& operator=(const SubExpr& in) = default;