#ifndef __cxz_for_h__ #define __cxz_for_h__ #include "base/base.h" #include "xpr_base.h" #include "func.h" namespace CNORXZ { template class For : public XprInterface> { public: DEFAULT_MEMBERS(For); constexpr For(SizeT size, const IndexId& id, const Xpr& xpr, F&& f); template inline decltype(auto) operator()(const PosT& last) const; inline decltype(auto) operator()() const; template inline decltype(auto) rootSteps(const IndexId& id) const; private: SizeT mSize = 0; IndexId mId; Xpr mXpr; typedef decltype(mXpr.rootSteps(mId)) XPosT; XPosT mExt; F mF; }; template constexpr decltype(auto) mkFor(SizeT size, const IndexId& id, const Xpr& xpr, F&& f); template constexpr decltype(auto) mkFor(SizeT size, const IndexId& id, const Xpr& xpr); // unrolled loop: template class SFor : public XprInterface> { public: DEFAULT_MEMBERS(SFor); constexpr SFor(const IndexId& id, const Xpr& xpr, F&& f); template constexpr decltype(auto) operator()(const PosT& last) const; constexpr decltype(auto) operator()() const; template constexpr decltype(auto) rootSteps(const IndexId& id) const; private: template constexpr decltype(auto) exec(const PosT& last) const; template constexpr decltype(auto) exec() const; template inline void exec2(const PosT& last) const; template inline void exec2() const; IndexId mId; Xpr mXpr; typedef decltype(mXpr.rootSteps(mId)) XPosT; XPosT mExt; F mF; }; template constexpr decltype(auto) mkSFor(const IndexId& id, const Xpr& xpr, F&& f); template constexpr decltype(auto) mkSFor(const IndexId& id, const Xpr& xpr); // multi-threading template class TFor : public XprInterface> { public: DEFAULT_MEMBERS(TFor); constexpr TFor(SizeT size, const IndexId& id, const Xpr& xpr, F&& f); template inline decltype(auto) operator()(const PosT& last) const; inline decltype(auto) operator()() const; template inline decltype(auto) rootSteps(const IndexId& id) const; private: SizeT mSize = 0; IndexId mId; Xpr mXpr; typedef decltype(mXpr.rootSteps(mId)) XPosT; XPosT mExt; F mF; }; // Extension For (Vectorization) template class EFor : public XprInterface> { public: DEFAULT_MEMBERS(EFor); constexpr EFor(const IndexId& id, const Xpr& xpr); template constexpr decltype(auto) operator()(const PosT& last) const; constexpr decltype(auto) operator()() const; template constexpr decltype(auto) rootSteps(const IndexId& id) const; private: IndexId mId; Xpr mXpr; typedef decltype(mXpr.rootSteps(mId)) XPosT; XPosT mExt; }; } #endif