2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
#ifndef __cxz_for_h__
|
|
|
|
#define __cxz_for_h__
|
|
|
|
|
|
|
|
#include "base/base.h"
|
|
|
|
#include "xpr_base.h"
|
|
|
|
|
|
|
|
namespace CNORXZ
|
|
|
|
{
|
|
|
|
|
2022-10-16 18:37:14 +02:00
|
|
|
template <SizeT L, class Xpr>
|
|
|
|
class For : public XprInterface<For<L,Xpr>>
|
2022-10-16 00:55:14 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DEFAULT_MEMBERS(For);
|
|
|
|
|
2022-10-16 18:37:14 +02:00
|
|
|
constexpr For(SizeT size, const IndexId<L>& id, SizeT step, const Xpr& xpr);
|
2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
template <class PosT1, class PosT2>
|
|
|
|
inline SizeT operator()(const PosT1& mlast, const PosT2& last) const;
|
|
|
|
|
|
|
|
inline SizeT operator()() const;
|
|
|
|
|
2022-10-16 18:37:14 +02:00
|
|
|
template <SizeT I>
|
|
|
|
inline decltype(auto) rootSteps(const IndexId<I>& id) const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
SizeT mSize = 0;
|
2022-10-16 18:37:14 +02:00
|
|
|
IndexId<L> mId;
|
2022-10-16 00:55:14 +02:00
|
|
|
Xpr mXpr;
|
|
|
|
UPos mStep;
|
2022-10-16 18:37:14 +02:00
|
|
|
typedef decltype(mXpr.rootSteps(mId)) PosT;
|
2022-10-16 00:55:14 +02:00
|
|
|
PosT mExt;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// unrolled loop:
|
|
|
|
template <SizeT N, SizeT L, SizeT S, class Xpr>
|
|
|
|
class SLFor : public XprInterface<SLFor<N,L,S,Xpr>>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DEFAULT_MEMBERS(SLFor);
|
|
|
|
|
2022-10-16 18:37:14 +02:00
|
|
|
constexpr SLFor(const IndexId<L>& id, const Xpr& xpr);
|
2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
template <class PosT1, class PosT2>
|
|
|
|
constexpr SizeT operator()(const PosT1& mlast, const PosT2& last) const;
|
|
|
|
|
|
|
|
constexpr SizeT operator()() const;
|
|
|
|
|
2022-10-16 18:37:14 +02:00
|
|
|
template <SizeT I>
|
|
|
|
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
template <SizeT I, class PosT1, class PosT2>
|
|
|
|
constexpr SizeT exec(const PosT1& mlast, const PosT2& last) const;
|
|
|
|
|
|
|
|
template <SizeT I>
|
|
|
|
constexpr SizeT exec() const;
|
2022-10-16 18:37:14 +02:00
|
|
|
|
|
|
|
IndexId<L> mId;
|
2022-10-16 00:55:14 +02:00
|
|
|
Xpr mXpr;
|
2022-10-16 18:37:14 +02:00
|
|
|
typedef decltype(mXpr.RootSteps(mId)) PosT;
|
2022-10-16 00:55:14 +02:00
|
|
|
PosT mExt;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// multi-threading
|
2022-10-16 18:37:14 +02:00
|
|
|
template <SizeT L, class Xpr>
|
|
|
|
class TFor : public XprInterface<TFor<L,Xpr>>
|
2022-10-16 00:55:14 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DEFAULT_MEMBERS(TFor);
|
|
|
|
|
2022-10-16 18:37:14 +02:00
|
|
|
constexpr TFor(SizeT size, const IndexId<L>& id, SizeT step, const Xpr& xpr);
|
2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
template <class PosT1, class PosT2>
|
|
|
|
inline SizeT operator()(const PosT1& mlast, const PosT2& last) const;
|
|
|
|
|
|
|
|
inline SizeT operator()() const;
|
|
|
|
|
2022-10-16 18:37:14 +02:00
|
|
|
template <SizeT I>
|
|
|
|
inline decltype(auto) rootSteps(const IndexId<I>& id) const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
SizeT mSize = 0;
|
2022-10-16 18:37:14 +02:00
|
|
|
IndexId<L> mId = 0;
|
2022-10-16 00:55:14 +02:00
|
|
|
Xpr mXpr;
|
|
|
|
UPos mStep;
|
2022-10-16 18:37:14 +02:00
|
|
|
typedef decltype(mXpr.rootSteps(mId)) PosT;
|
2022-10-16 00:55:14 +02:00
|
|
|
PosT mExt;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|