xpr -> only one pos argument
This commit is contained in:
parent
477ea8d43d
commit
aafc6f0e2a
15 changed files with 109 additions and 129 deletions
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
namespace CNORXZ
|
namespace CNORXZ
|
||||||
{
|
{
|
||||||
template <class PosT, class Xpr>
|
template <class Xpr>
|
||||||
decltype(auto) CIndex::ifor(const PosT& step, const Xpr& xpr) const
|
decltype(auto) CIndex::ifor(const Xpr& xpr) const
|
||||||
{
|
{
|
||||||
return For<0,PosT,Xpr>(this->max(), this->id(), step, xpr);
|
return For<0,Xpr>(this->max(), this->id(), xpr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ namespace CNORXZ
|
||||||
SizeT meta() const;
|
SizeT meta() const;
|
||||||
CIndex& at(const SizeT& metaPos);
|
CIndex& at(const SizeT& metaPos);
|
||||||
|
|
||||||
template <class PosT, class Xpr>
|
template <class Xpr>
|
||||||
decltype(auto) ifor(const PosT& step, const Xpr& xpr) const;
|
decltype(auto) ifor(const Xpr& xpr) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Sptr<RangeType> mRangePtr;
|
Sptr<RangeType> mRangePtr;
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace CNORXZ
|
||||||
DType meta() const;
|
DType meta() const;
|
||||||
DIndex& at(const DType& meta);
|
DIndex& at(const DType& meta);
|
||||||
|
|
||||||
DXpr ifor(const UPos& step, const DXpr& xpr) const;
|
DXpr ifor(const DXpr& xpr) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XIndexPtr mI;
|
XIndexPtr mI;
|
||||||
|
|
|
@ -55,8 +55,8 @@ namespace CNORXZ
|
||||||
decltype(auto) meta() const { return THIS().meta(); }
|
decltype(auto) meta() const { return THIS().meta(); }
|
||||||
I& at(const MetaType& meta) { return THIS().at(meta); }
|
I& at(const MetaType& meta) { return THIS().at(meta); }
|
||||||
|
|
||||||
template <class PosT, class Xpr>
|
template <class Xpr>
|
||||||
decltype(auto) ifor(const PosT& step, const Xpr& xpr) const { return THIS().ifor(step,xpr); }
|
decltype(auto) ifor(const Xpr& xpr) const { return THIS().ifor(xpr); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SizeT mPos = 0;
|
SizeT mPos = 0;
|
||||||
|
|
|
@ -145,10 +145,10 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MetaType>
|
template <typename MetaType>
|
||||||
template <class PosT, class Xpr>
|
template <class Xpr>
|
||||||
decltype(auto) UIndex<MetaType>::ifor(const PosT step, Xpr xpr) const
|
decltype(auto) UIndex<MetaType>::ifor(const Xpr& xpr) const
|
||||||
{
|
{
|
||||||
return For<0,PosT,Xpr>(this->max(), this->id(), step, xpr);
|
return For<0,Xpr>(this->max(), this->id(), xpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
|
|
|
@ -48,8 +48,8 @@ namespace CNORXZ
|
||||||
const MetaType& meta() const;
|
const MetaType& meta() const;
|
||||||
UIndex& at(const MetaType& metaPos);
|
UIndex& at(const MetaType& metaPos);
|
||||||
|
|
||||||
template <class PosT, class Xpr>
|
template <class Xpr>
|
||||||
decltype(auto) ifor(const PosT step, Xpr xpr) const;
|
decltype(auto) ifor(const Xpr& xpr) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Sptr<RangeType> mRangePtr;
|
Sptr<RangeType> mRangePtr;
|
||||||
|
|
|
@ -155,9 +155,9 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Index, typename Meta>
|
template <class Index, typename Meta>
|
||||||
DXpr XIndex<Index,Meta>::ifor(const UPos& step, const DXpr& xpr) const
|
DXpr XIndex<Index,Meta>::ifor(const DXpr& xpr) const
|
||||||
{
|
{
|
||||||
return DXpr(mI->ifor(step, xpr));
|
return DXpr(mI->ifor(xpr));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace CNORXZ
|
||||||
virtual DType meta() const = 0;
|
virtual DType meta() const = 0;
|
||||||
virtual XIndexBase& at(const DType& meta) = 0;
|
virtual XIndexBase& at(const DType& meta) = 0;
|
||||||
|
|
||||||
virtual DXpr ifor(const UPos& step, const DXpr& xpr) const = 0;
|
virtual DXpr ifor(const DXpr& xpr) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Sptr<XIndexBase>& operator++(Sptr<XIndexBase>& i);
|
//Sptr<XIndexBase>& operator++(Sptr<XIndexBase>& i);
|
||||||
|
@ -91,7 +91,7 @@ namespace CNORXZ
|
||||||
virtual DType meta() const override final;
|
virtual DType meta() const override final;
|
||||||
virtual XIndexBase& at(const DType& meta) override final;
|
virtual XIndexBase& at(const DType& meta) override final;
|
||||||
|
|
||||||
virtual DXpr ifor(const UPos& step, const DXpr& xpr) const override final;
|
virtual DXpr ifor(const DXpr& xpr) const override final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IndexPtr<Index,Meta> mI;
|
IndexPtr<Index,Meta> mI;
|
||||||
|
|
|
@ -12,43 +12,38 @@ namespace CNORXZ
|
||||||
* For *
|
* For *
|
||||||
***********/
|
***********/
|
||||||
|
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
constexpr For<L,PosT,Xpr>::For(SizeT size, const IndexId<L>& id, const PosT& step, const Xpr& xpr) :
|
constexpr For<L,Xpr>::For(SizeT size, const IndexId<L>& id, const Xpr& xpr) :
|
||||||
mSize(size),
|
mSize(size),
|
||||||
mId(id),
|
mId(id),
|
||||||
mXpr(xpr),
|
mXpr(xpr),
|
||||||
mStep(step),
|
|
||||||
mExt(mXpr.rootSteps(mId))
|
mExt(mXpr.rootSteps(mId))
|
||||||
{
|
{}
|
||||||
static_assert(is_pos_type<PosT>::value, "got non-pos type");
|
|
||||||
}
|
|
||||||
|
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
template <class PosT1, class PosT2>
|
template <class PosT>
|
||||||
inline SizeT For<L,PosT,Xpr>::operator()(const PosT1& mlast, const PosT2& last) const
|
inline SizeT For<L,Xpr>::operator()(const PosT& last) const
|
||||||
{
|
{
|
||||||
for(SizeT i = 0; i != mSize; ++i){
|
for(SizeT i = 0; i != mSize; ++i){
|
||||||
const auto mpos = mlast + mStep * UPos(i);
|
|
||||||
const auto pos = last + mExt * UPos(i);
|
const auto pos = last + mExt * UPos(i);
|
||||||
mXpr(mpos, pos);
|
mXpr(pos);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
inline SizeT For<L,PosT,Xpr>::operator()() const
|
inline SizeT For<L,Xpr>::operator()() const
|
||||||
{
|
{
|
||||||
for(SizeT i = 0; i != mSize; ++i){
|
for(SizeT i = 0; i != mSize; ++i){
|
||||||
const auto mpos = mStep * UPos(i);
|
|
||||||
const auto pos = mExt * UPos(i);
|
const auto pos = mExt * UPos(i);
|
||||||
mXpr(mpos, pos);
|
mXpr(pos);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
inline decltype(auto) For<L,PosT,Xpr>::rootSteps(const IndexId<I>& id) const
|
inline decltype(auto) For<L,Xpr>::rootSteps(const IndexId<I>& id) const
|
||||||
{
|
{
|
||||||
return mXpr.rootSteps(id);
|
return mXpr.rootSteps(id);
|
||||||
}
|
}
|
||||||
|
@ -58,60 +53,55 @@ namespace CNORXZ
|
||||||
* SFor *
|
* SFor *
|
||||||
************/
|
************/
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
constexpr SFor<N,L,PosT,Xpr>::SFor(const IndexId<L>& id, const PosT& step, const Xpr& xpr) :
|
constexpr SFor<N,L,Xpr>::SFor(const IndexId<L>& id, const Xpr& xpr) :
|
||||||
mId(id),
|
mId(id),
|
||||||
mStep(step),
|
|
||||||
mXpr(xpr),
|
mXpr(xpr),
|
||||||
mExt(mXpr.RootSteps(mId))
|
mExt(mXpr.RootSteps(mId))
|
||||||
|
{}
|
||||||
|
|
||||||
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
|
template <class PosT>
|
||||||
|
constexpr SizeT SFor<N,L,Xpr>::operator()(const PosT& last) const
|
||||||
{
|
{
|
||||||
static_assert(is_pos_type<PosT>::value, "got non-pos type");
|
return exec<0>(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
template <class PosT1, class PosT2>
|
constexpr SizeT SFor<N,L,Xpr>::operator()() const
|
||||||
constexpr SizeT SFor<N,L,PosT,Xpr>::operator()(const PosT1& mlast, const PosT2& last) const
|
|
||||||
{
|
|
||||||
return exec<0>(mlast, last);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
|
||||||
constexpr SizeT SFor<N,L,PosT,Xpr>::operator()() const
|
|
||||||
{
|
{
|
||||||
return exec<0>();
|
return exec<0>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
constexpr decltype(auto) SFor<N,L,PosT,Xpr>::rootSteps(const IndexId<I>& id) const
|
constexpr decltype(auto) SFor<N,L,Xpr>::rootSteps(const IndexId<I>& id) const
|
||||||
{
|
{
|
||||||
return mXpr.rootSteps(id);
|
return mXpr.rootSteps(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
template <SizeT I, class PosT1, class PosT2>
|
template <SizeT I, class PosT>
|
||||||
constexpr SizeT SFor<N,L,PosT,Xpr>::exec(const PosT1& mlast, const PosT2& last) const
|
constexpr SizeT SFor<N,L,Xpr>::exec(const PosT& last) const
|
||||||
{
|
{
|
||||||
constexpr SPos<I> i;
|
constexpr SPos<I> i;
|
||||||
const auto mpos = mlast + mStep * i;
|
|
||||||
const auto pos = last + mExt * i;
|
const auto pos = last + mExt * i;
|
||||||
mXpr(mpos, pos);
|
mXpr(pos);
|
||||||
if constexpr(I < N-1){
|
if constexpr(I < N-1){
|
||||||
return exec<I+1>(mlast, last);
|
return exec<I+1>(last);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
constexpr SizeT SFor<N,L,PosT,Xpr>::exec() const
|
constexpr SizeT SFor<N,L,Xpr>::exec() const
|
||||||
{
|
{
|
||||||
constexpr SPos<I> i;
|
constexpr SPos<I> i;
|
||||||
const auto mpos = mStep * i;
|
|
||||||
const auto pos = mExt * i;
|
const auto pos = mExt * i;
|
||||||
mXpr(mpos, pos);
|
mXpr(pos);
|
||||||
if constexpr(I < N-1){
|
if constexpr(I < N-1){
|
||||||
return exec<I+1>();
|
return exec<I+1>();
|
||||||
}
|
}
|
||||||
|
@ -124,24 +114,25 @@ namespace CNORXZ
|
||||||
* TFor *
|
* TFor *
|
||||||
************/
|
************/
|
||||||
|
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
constexpr TFor<L,PosT,Xpr>::TFor(SizeT size, const IndexId<L>& id, const PosT& step, const Xpr& xpr) :
|
constexpr TFor<L,Xpr>::TFor(SizeT size, const IndexId<L>& id, const Xpr& xpr) :
|
||||||
mSize(size),
|
mSize(size),
|
||||||
mId(id),
|
mId(id),
|
||||||
mStep(step),
|
|
||||||
mXpr(xpr),
|
mXpr(xpr),
|
||||||
mExt(mXpr.rootSteps(mId))
|
mExt(mXpr.rootSteps(mId))
|
||||||
{
|
{
|
||||||
static_assert(is_pos_type<PosT>::value, "got non-pos type");
|
// check for write access!!!
|
||||||
|
/*
|
||||||
if constexpr(is_static_pos_type<PosT>::value){
|
if constexpr(is_static_pos_type<PosT>::value){
|
||||||
static_assert(step.val() != 0, "step has to be non-zero for TPos");
|
static_assert(step.val() != 0, "step has to be non-zero for TPos");
|
||||||
}
|
}
|
||||||
CXZ_ASSERT(step.val() != 0, "step has to be non-zero for TPos");
|
CXZ_ASSERT(step.val() != 0, "step has to be non-zero for TPos");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
template <class PosT1, class PosT2>
|
template <class PosT>
|
||||||
inline SizeT TFor<L,PosT,Xpr>::operator()(const PosT1& mlast, const PosT2& last) const
|
inline SizeT TFor<L,Xpr>::operator()(const PosT& last) const
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const int size = static_cast<int>(mSize);
|
const int size = static_cast<int>(mSize);
|
||||||
|
@ -150,16 +141,15 @@ namespace CNORXZ
|
||||||
auto xpr = mXpr;
|
auto xpr = mXpr;
|
||||||
#pragma omp for
|
#pragma omp for
|
||||||
for(i = 0; i < size; i++){
|
for(i = 0; i < size; i++){
|
||||||
const auto mpos = mlast + mStep * UPos(i);
|
|
||||||
const auto pos = last + mExt * UPos(i);
|
const auto pos = last + mExt * UPos(i);
|
||||||
xpr(mpos, pos);
|
xpr(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
inline SizeT TFor<L,PosT,Xpr>::operator()() const
|
inline SizeT TFor<L,Xpr>::operator()() const
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const int size = static_cast<int>(mSize);
|
const int size = static_cast<int>(mSize);
|
||||||
|
@ -168,17 +158,16 @@ namespace CNORXZ
|
||||||
auto xpr = mXpr;
|
auto xpr = mXpr;
|
||||||
#pragma omp for
|
#pragma omp for
|
||||||
for(i = 0; i < size; i++){
|
for(i = 0; i < size; i++){
|
||||||
const auto mpos = mStep * UPos(i);
|
|
||||||
const auto pos = mExt * UPos(i);
|
const auto pos = mExt * UPos(i);
|
||||||
xpr(mpos, pos);
|
xpr(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
inline decltype(auto) TFor<L,PosT,Xpr>::rootSteps(const IndexId<I>& id) const
|
inline decltype(auto) TFor<L,Xpr>::rootSteps(const IndexId<I>& id) const
|
||||||
{
|
{
|
||||||
return mXpr.rootSteps(id);
|
return mXpr.rootSteps(id);
|
||||||
}
|
}
|
||||||
|
@ -188,36 +177,31 @@ namespace CNORXZ
|
||||||
* EFor *
|
* EFor *
|
||||||
************/
|
************/
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
constexpr EFor<N,L,PosT,Xpr>::EFor(const IndexId<L>& id, const PosT& step, const Xpr& xpr) :
|
constexpr EFor<N,L,Xpr>::EFor(const IndexId<L>& id, const Xpr& xpr) :
|
||||||
mId(id),
|
mId(id),
|
||||||
mStep(step),
|
|
||||||
mXpr(xpr),
|
mXpr(xpr),
|
||||||
mExt(mXpr.RootSteps(mId))
|
mExt(mXpr.RootSteps(mId))
|
||||||
{
|
{}
|
||||||
static_assert(is_pos_type<PosT>::value, "got non-pos type");
|
|
||||||
}
|
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
template <class PosT1, class PosT2>
|
template <class PosT>
|
||||||
constexpr SizeT EFor<N,L,PosT,Xpr>::operator()(const PosT1& mlast, const PosT2& last) const
|
constexpr SizeT EFor<N,L,Xpr>::operator()(const PosT& last) const
|
||||||
{
|
{
|
||||||
auto mpos = mkEPos<N>(mlast, mStep);
|
|
||||||
auto pos = mkEPos<N>(last, mExt);
|
auto pos = mkEPos<N>(last, mExt);
|
||||||
return mXpr(mpos, pos);
|
return mXpr(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
constexpr SizeT EFor<N,L,PosT,Xpr>::operator()() const
|
constexpr SizeT EFor<N,L,Xpr>::operator()() const
|
||||||
{
|
{
|
||||||
auto mpos = mkEPos<N>(SPos<0>(), mStep);
|
|
||||||
auto pos = mkEPos<N>(SPos<0>(), mExt);
|
auto pos = mkEPos<N>(SPos<0>(), mExt);
|
||||||
return mXpr(mpos, pos);
|
return mXpr(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
constexpr decltype(auto) EFor<N,L,PosT,Xpr>::rootSteps(const IndexId<I>& id) const
|
constexpr decltype(auto) EFor<N,L,Xpr>::rootSteps(const IndexId<I>& id) const
|
||||||
{
|
{
|
||||||
return mXpr.rootSteps(id);
|
return mXpr.rootSteps(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,16 @@
|
||||||
namespace CNORXZ
|
namespace CNORXZ
|
||||||
{
|
{
|
||||||
|
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
class For : public XprInterface<For<L,PosT,Xpr>>
|
class For : public XprInterface<For<L,Xpr>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DEFAULT_MEMBERS(For);
|
DEFAULT_MEMBERS(For);
|
||||||
|
|
||||||
constexpr For(SizeT size, const IndexId<L>& id, const PosT& step, const Xpr& xpr);
|
constexpr For(SizeT size, const IndexId<L>& id, const Xpr& xpr);
|
||||||
|
|
||||||
template <class PosT1, class PosT2>
|
template <class PosT>
|
||||||
inline SizeT operator()(const PosT1& mlast, const PosT2& last) const;
|
inline SizeT operator()(const PosT& last) const;
|
||||||
|
|
||||||
inline SizeT operator()() const;
|
inline SizeT operator()() const;
|
||||||
|
|
||||||
|
@ -28,23 +28,22 @@ namespace CNORXZ
|
||||||
SizeT mSize = 0;
|
SizeT mSize = 0;
|
||||||
IndexId<L> mId;
|
IndexId<L> mId;
|
||||||
Xpr mXpr;
|
Xpr mXpr;
|
||||||
PosT mStep; // one-dim
|
|
||||||
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
||||||
XPosT mExt;
|
XPosT mExt;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// unrolled loop:
|
// unrolled loop:
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
class SFor : public XprInterface<SFor<N,L,PosT,Xpr>>
|
class SFor : public XprInterface<SFor<N,L,Xpr>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DEFAULT_MEMBERS(SFor);
|
DEFAULT_MEMBERS(SFor);
|
||||||
|
|
||||||
constexpr SFor(const IndexId<L>& id, const PosT& step, const Xpr& xpr);
|
constexpr SFor(const IndexId<L>& id, const Xpr& xpr);
|
||||||
|
|
||||||
template <class PosT1, class PosT2>
|
template <class PosT>
|
||||||
constexpr SizeT operator()(const PosT1& mlast, const PosT2& last) const;
|
constexpr SizeT operator()(const PosT& last) const;
|
||||||
|
|
||||||
constexpr SizeT operator()() const;
|
constexpr SizeT operator()() const;
|
||||||
|
|
||||||
|
@ -53,15 +52,14 @@ namespace CNORXZ
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
template <SizeT I, class PosT1, class PosT2>
|
template <SizeT I, class PosT>
|
||||||
constexpr SizeT exec(const PosT1& mlast, const PosT2& last) const;
|
constexpr SizeT exec(const PosT& last) const;
|
||||||
|
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
constexpr SizeT exec() const;
|
constexpr SizeT exec() const;
|
||||||
|
|
||||||
IndexId<L> mId;
|
IndexId<L> mId;
|
||||||
Xpr mXpr;
|
Xpr mXpr;
|
||||||
PosT mStep;
|
|
||||||
typedef decltype(mXpr.RootSteps(mId)) XPosT;
|
typedef decltype(mXpr.RootSteps(mId)) XPosT;
|
||||||
XPosT mExt;
|
XPosT mExt;
|
||||||
|
|
||||||
|
@ -69,16 +67,16 @@ namespace CNORXZ
|
||||||
|
|
||||||
|
|
||||||
// multi-threading
|
// multi-threading
|
||||||
template <SizeT L, class PosT, class Xpr>
|
template <SizeT L, class Xpr>
|
||||||
class TFor : public XprInterface<TFor<L,PosT,Xpr>>
|
class TFor : public XprInterface<TFor<L,Xpr>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DEFAULT_MEMBERS(TFor);
|
DEFAULT_MEMBERS(TFor);
|
||||||
|
|
||||||
constexpr TFor(SizeT size, const IndexId<L>& id, const PosT& step, const Xpr& xpr);
|
constexpr TFor(SizeT size, const IndexId<L>& id, const Xpr& xpr);
|
||||||
|
|
||||||
template <class PosT1, class PosT2>
|
template <class PosT>
|
||||||
inline SizeT operator()(const PosT1& mlast, const PosT2& last) const;
|
inline SizeT operator()(const PosT& last) const;
|
||||||
|
|
||||||
inline SizeT operator()() const;
|
inline SizeT operator()() const;
|
||||||
|
|
||||||
|
@ -89,23 +87,22 @@ namespace CNORXZ
|
||||||
SizeT mSize = 0;
|
SizeT mSize = 0;
|
||||||
IndexId<L> mId;
|
IndexId<L> mId;
|
||||||
Xpr mXpr;
|
Xpr mXpr;
|
||||||
PosT mStep;
|
|
||||||
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
||||||
XPosT mExt;
|
XPosT mExt;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extension For (Vectorization)
|
// Extension For (Vectorization)
|
||||||
template <SizeT N, SizeT L, class PosT, class Xpr>
|
template <SizeT N, SizeT L, class Xpr>
|
||||||
class EFor : public XprInterface<EFor<N,L,PosT,Xpr>>
|
class EFor : public XprInterface<EFor<N,L,Xpr>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DEFAULT_MEMBERS(EFor);
|
DEFAULT_MEMBERS(EFor);
|
||||||
|
|
||||||
constexpr EFor(const IndexId<L>& id, const PosT& step, const Xpr& xpr);
|
constexpr EFor(const IndexId<L>& id, const Xpr& xpr);
|
||||||
|
|
||||||
template <class PosT1, class PosT2>
|
template <class PosT>
|
||||||
constexpr SizeT operator()(const PosT1& mlast, const PosT2& last) const;
|
constexpr SizeT operator()(const PosT& last) const;
|
||||||
|
|
||||||
constexpr SizeT operator()() const;
|
constexpr SizeT operator()() const;
|
||||||
|
|
||||||
|
@ -115,7 +112,6 @@ namespace CNORXZ
|
||||||
private:
|
private:
|
||||||
IndexId<L> mId;
|
IndexId<L> mId;
|
||||||
Xpr mXpr;
|
Xpr mXpr;
|
||||||
PosT mStep;
|
|
||||||
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
typedef decltype(mXpr.rootSteps(mId)) XPosT;
|
||||||
XPosT mExt;
|
XPosT mExt;
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,9 +23,9 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Xpr>
|
template <class Xpr>
|
||||||
SizeT VXpr<Xpr>::vexec(const UPos& mlast, const DPos& last) const
|
SizeT VXpr<Xpr>::vexec(const DPos& last) const
|
||||||
{
|
{
|
||||||
return (*this)(mlast, last);
|
return (*this)(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Xpr>
|
template <class Xpr>
|
||||||
|
@ -49,9 +49,9 @@ namespace CNORXZ
|
||||||
ObjHandle<VXprBase>(std::make_unique<VXpr<Xpr>>(a))
|
ObjHandle<VXprBase>(std::make_unique<VXpr<Xpr>>(a))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline SizeT DXpr::operator()(const UPos& mlast, const DPos& last) const
|
inline SizeT DXpr::operator()(const DPos& last) const
|
||||||
{
|
{
|
||||||
return mC->vexec(mlast, last);
|
return mC->vexec(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline SizeT DXpr::operator()() const
|
inline SizeT DXpr::operator()() const
|
||||||
|
|
|
@ -18,8 +18,8 @@ namespace CNORXZ
|
||||||
inline Xpr& THIS() { return static_cast<Xpr&>(*this); }
|
inline Xpr& THIS() { return static_cast<Xpr&>(*this); }
|
||||||
inline const Xpr& THIS() const { return static_cast<const Xpr&>(*this); }
|
inline const Xpr& THIS() const { return static_cast<const Xpr&>(*this); }
|
||||||
|
|
||||||
template <class PosT1, class PosT2>
|
template <class PosT>
|
||||||
inline SizeT operator()(const PosT1& mlast, const PosT2& last) const { return THIS()(mlast,last); }
|
inline SizeT operator()(const PosT& last) const { return THIS()(last); }
|
||||||
|
|
||||||
inline SizeT operator()() const { return THIS()(); }
|
inline SizeT operator()() const { return THIS()(); }
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace CNORXZ
|
||||||
|
|
||||||
virtual Uptr<VXprBase> copy() const = 0;
|
virtual Uptr<VXprBase> copy() const = 0;
|
||||||
|
|
||||||
virtual SizeT vexec(const UPos& mlast, const DPos& last) const = 0;
|
virtual SizeT vexec(const DPos& last) const = 0;
|
||||||
virtual SizeT vexec() const = 0;
|
virtual SizeT vexec() const = 0;
|
||||||
|
|
||||||
virtual DPos vrootSteps(const IndexId<0>& id) const = 0;
|
virtual DPos vrootSteps(const IndexId<0>& id) const = 0;
|
||||||
|
@ -49,7 +49,7 @@ namespace CNORXZ
|
||||||
|
|
||||||
virtual Uptr<VXprBase> copy() const override final;
|
virtual Uptr<VXprBase> copy() const override final;
|
||||||
|
|
||||||
virtual SizeT vexec(const UPos& mlast, const DPos& last) const override final;
|
virtual SizeT vexec(const DPos& last) const override final;
|
||||||
virtual SizeT vexec() const override final;
|
virtual SizeT vexec() const override final;
|
||||||
|
|
||||||
virtual DPos vrootSteps(const IndexId<0>& id) const override final;
|
virtual DPos vrootSteps(const IndexId<0>& id) const override final;
|
||||||
|
@ -64,7 +64,7 @@ namespace CNORXZ
|
||||||
template <class Xpr>
|
template <class Xpr>
|
||||||
explicit DXpr(const Xpr& a);
|
explicit DXpr(const Xpr& a);
|
||||||
|
|
||||||
inline SizeT operator()(const UPos& mlast, const DPos& last) const;
|
inline SizeT operator()(const DPos& last) const;
|
||||||
inline SizeT operator()() const;
|
inline SizeT operator()() const;
|
||||||
|
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace CNORXZ
|
||||||
DType meta() const;
|
DType meta() const;
|
||||||
YIndex& at(const DType& meta);
|
YIndex& at(const DType& meta);
|
||||||
|
|
||||||
DXpr ifor(const UPos& step, const DXpr& xpr) const;
|
DXpr ifor(const DXpr& xpr) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -138,9 +138,9 @@ namespace CNORXZ
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
DXpr DIndex::ifor(const UPos& step, const DXpr& xpr) const
|
DXpr DIndex::ifor(const DXpr& xpr) const
|
||||||
{
|
{
|
||||||
return DXpr(mI->ifor(step, xpr));
|
return DXpr(mI->ifor(xpr));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ namespace CNORXZ
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
DXpr YIndex::ifor(const UPos& step, const DXpr& xpr) const
|
DXpr YIndex::ifor(const DXpr& xpr) const
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
return DXpr();
|
return DXpr();
|
||||||
|
|
Loading…
Reference in a new issue