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-23 18:29:07 +02:00
|
|
|
class ZeroF
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
template <typename... T>
|
|
|
|
constexpr decltype(auto) operator()(const T&... as) const;
|
|
|
|
};
|
2022-10-16 00:55:14 +02:00
|
|
|
|
2022-10-23 18:29:07 +02:00
|
|
|
class NoF
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
template <typename... T>
|
|
|
|
constexpr decltype(auto) operator()(const T&... as) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <SizeT L, class Xpr, class F = NoF>
|
|
|
|
class For : public XprInterface<For<L,Xpr,F>>
|
2022-10-16 00:55:14 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DEFAULT_MEMBERS(For);
|
|
|
|
|
2022-10-23 18:29:07 +02:00
|
|
|
constexpr For(SizeT size, const IndexId<L>& id, const Xpr& xpr, F&& f);
|
2022-10-16 00:55:14 +02:00
|
|
|
|
2022-10-21 00:21:47 +02:00
|
|
|
template <class PosT>
|
2022-10-23 18:29:07 +02:00
|
|
|
inline decltype(auto) operator()(const PosT& last) const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
2022-10-23 18:29:07 +02:00
|
|
|
inline decltype(auto) operator()() const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
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;
|
2022-10-16 23:05:48 +02:00
|
|
|
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
|
|
|
XPosT mExt;
|
2022-10-23 18:29:07 +02:00
|
|
|
F mF;
|
2022-10-16 00:55:14 +02:00
|
|
|
};
|
|
|
|
|
2022-10-23 18:29:07 +02:00
|
|
|
|
2022-10-16 00:55:14 +02:00
|
|
|
// unrolled loop:
|
2022-10-23 18:29:07 +02:00
|
|
|
template <SizeT N, SizeT L, class Xpr, class F = NoF>
|
|
|
|
class SFor : public XprInterface<SFor<N,L,Xpr,F>>
|
2022-10-16 00:55:14 +02:00
|
|
|
{
|
|
|
|
public:
|
2022-10-16 23:05:48 +02:00
|
|
|
DEFAULT_MEMBERS(SFor);
|
2022-10-16 00:55:14 +02:00
|
|
|
|
2022-10-23 18:29:07 +02:00
|
|
|
constexpr SFor(const IndexId<L>& id, const Xpr& xpr, F&& f);
|
2022-10-16 00:55:14 +02:00
|
|
|
|
2022-10-21 00:21:47 +02:00
|
|
|
template <class PosT>
|
2022-10-23 18:29:07 +02:00
|
|
|
constexpr decltype(auto) operator()(const PosT& last) const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
2022-10-23 18:29:07 +02:00
|
|
|
constexpr decltype(auto) operator()() const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
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:
|
|
|
|
|
2022-10-21 00:21:47 +02:00
|
|
|
template <SizeT I, class PosT>
|
2022-10-23 18:29:07 +02:00
|
|
|
constexpr decltype(auto) exec(const PosT& last) const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
template <SizeT I>
|
2022-10-23 18:29:07 +02:00
|
|
|
constexpr decltype(auto) 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 23:05:48 +02:00
|
|
|
typedef decltype(mXpr.RootSteps(mId)) XPosT;
|
|
|
|
XPosT mExt;
|
2022-10-23 18:29:07 +02:00
|
|
|
F mF;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// multi-threading
|
2022-10-23 18:29:07 +02:00
|
|
|
template <SizeT L, class Xpr, class F = NoF>
|
|
|
|
class TFor : public XprInterface<TFor<L,Xpr,F>>
|
2022-10-16 00:55:14 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DEFAULT_MEMBERS(TFor);
|
|
|
|
|
2022-10-23 18:29:07 +02:00
|
|
|
constexpr TFor(SizeT size, const IndexId<L>& id, const Xpr& xpr, F&& f);
|
2022-10-16 00:55:14 +02:00
|
|
|
|
2022-10-21 00:21:47 +02:00
|
|
|
template <class PosT>
|
2022-10-23 18:29:07 +02:00
|
|
|
inline decltype(auto) operator()(const PosT& last) const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
2022-10-23 18:29:07 +02:00
|
|
|
inline decltype(auto) operator()() const;
|
2022-10-16 00:55:14 +02:00
|
|
|
|
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-18 00:30:05 +02:00
|
|
|
IndexId<L> mId;
|
2022-10-16 00:55:14 +02:00
|
|
|
Xpr mXpr;
|
2022-10-16 23:05:48 +02:00
|
|
|
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
|
|
|
XPosT mExt;
|
2022-10-23 18:29:07 +02:00
|
|
|
F mF;
|
2022-10-16 00:55:14 +02:00
|
|
|
};
|
|
|
|
|
2022-10-18 00:30:05 +02:00
|
|
|
// Extension For (Vectorization)
|
2022-10-21 00:21:47 +02:00
|
|
|
template <SizeT N, SizeT L, class Xpr>
|
|
|
|
class EFor : public XprInterface<EFor<N,L,Xpr>>
|
2022-10-18 00:30:05 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DEFAULT_MEMBERS(EFor);
|
|
|
|
|
2022-10-21 00:21:47 +02:00
|
|
|
constexpr EFor(const IndexId<L>& id, const Xpr& xpr);
|
2022-10-18 00:30:05 +02:00
|
|
|
|
2022-10-21 00:21:47 +02:00
|
|
|
template <class PosT>
|
2022-10-23 18:29:07 +02:00
|
|
|
constexpr decltype(auto) operator()(const PosT& last) const;
|
2022-10-18 00:30:05 +02:00
|
|
|
|
2022-10-23 18:29:07 +02:00
|
|
|
constexpr decltype(auto) operator()() const;
|
2022-10-18 00:30:05 +02:00
|
|
|
|
|
|
|
template <SizeT I>
|
|
|
|
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
IndexId<L> mId;
|
|
|
|
Xpr mXpr;
|
|
|
|
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
|
|
|
XPosT mExt;
|
|
|
|
};
|
2022-10-16 00:55:14 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|