From ba02601b9782ccb0f0f5938d22d98af2cf444268 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Sun, 4 Jun 2023 22:14:26 +0200 Subject: [PATCH] EIndex: new inheritance structure: SIndex -> LIndex,L> -> EIndex --- src/include/ranges/eindex.cc.h | 44 ++++++++++++++++++++++++++-------- src/include/ranges/eindex.h | 30 +++++++++++++++++------ src/include/ranges/lindex.cc.h | 38 ++++++++++++++++++++++------- src/include/ranges/lindex.h | 15 ++++++++++-- src/include/xpr/for.cc.h | 2 +- 5 files changed, 100 insertions(+), 29 deletions(-) diff --git a/src/include/ranges/eindex.cc.h b/src/include/ranges/eindex.cc.h index f4d1dad..9af559c 100644 --- a/src/include/ranges/eindex.cc.h +++ b/src/include/ranges/eindex.cc.h @@ -3,23 +3,47 @@ #define __cxz_eindex_cc_h__ #include "eindex.h" +#include "lindex.h" +#include "srange.h" namespace CNORXZ { - template - EIndex::EIndex(const SIndex& i) : - SIndex(i) {} + template + EIndex::EIndex(const Sptr,L>>& i) : + LIndex,L>(*i), + mLI(i) + {} - template - EIndex::EIndex(SIndex&& i) : - SIndex(i) {} - - template + template template - decltype(auto) EIndex::ifor(const Xpr& xpr, F&& f) const + decltype(auto) EIndex::ifor(const Xpr& xpr, F&& f) const { - return EFor(this->id(), xpr, std::forward(f)); + return EFor(mLI->id(), xpr, std::forward(f)); + } + + template + decltype(auto) operator*(const Sptr>& a, const Sptr& b) + { + return iptrMul(a, b); + } + + template + decltype(auto) eindexPtr(const Sptr,L>>& i) + { + return std::make_shared>(i); + } + + template + decltype(auto) eindexPtr(const Sptr,L>& i) + { + return eindexPtr( lindexPtr( i ) ); + } + + template + decltype(auto) eindexPtr(const Sptr,L>& i, CSizeT l) + { + return eindexPtr( i ); } } diff --git a/src/include/ranges/eindex.h b/src/include/ranges/eindex.h index 75b498c..55bd8f5 100644 --- a/src/include/ranges/eindex.h +++ b/src/include/ranges/eindex.h @@ -9,21 +9,37 @@ namespace CNORXZ { - template - class EIndex : public SIndex + + template + class EIndex : public LIndex,L> { public: - typedef typename SIndex::IB IB; - typedef typename SIndex::RangeType RangeType; + typedef typename LIndex,L>::IB IB; + typedef typename LIndex,L>::RangeType RangeType; DEFAULT_MEMBERS(EIndex); - EIndex(const SIndex& i); - EIndex(SIndex&& i); + EIndex(const LIndex,L>& i); + EIndex(LIndex,L>&& i); template decltype(auto) ifor(const Xpr& xpr, F&& f) const; + + private: + Sptr,L>> mLI; }; - + + template + decltype(auto) operator*(const Sptr>& a, const Sptr& b); + + template + decltype(auto) eindexPtr(const Sptr,L>>& i); + + template + decltype(auto) eindexPtr(const Sptr,L>& i); + + template + decltype(auto) eindexPtr(const Sptr,L>& i, CSizeT l); + } #endif diff --git a/src/include/ranges/lindex.cc.h b/src/include/ranges/lindex.cc.h index c489b91..55c99ea 100644 --- a/src/include/ranges/lindex.cc.h +++ b/src/include/ranges/lindex.cc.h @@ -7,17 +7,15 @@ namespace CNORXZ { template - LIndex::LIndex(const Index& i) : - Index(i) {} - - template - LIndex::LIndex(Index&& i) : - Index(i) {} + LIndex::LIndex(const Sptr& i) : + Index(*i), + mI(i) + {} template IndexId LIndex::id() const { - return IndexId(this->ptrId()); + return IndexId(mI->ptrId()); } template @@ -25,13 +23,35 @@ namespace CNORXZ decltype(auto) LIndex::stepSize(const IndexId& id) const { if constexpr(L == 0 or I == 0){ - return UPos(this->id() == id ? 1 : 0); + return UPos(mI->id() == id ? 1 : 0); } else { - return this->id() == id ? SPos<1>() : SPos<0>(); + if constexpr(L == I) { + return SPos<1>(); + } + else { + return SPos<0>(); + } } } + template + decltype(auto) operator*(const Sptr>& a, const Sptr& b) + { + return iptrMul(a, b); + } + + template + decltype(auto) lindexPtr(const Sptr& i) + { + return LIndex( i ); + } + + template + decltype(auto) lindexPtr(const Sptr& i, CSizeT l) + { + return lindexPtr( i ); + } } #endif diff --git a/src/include/ranges/lindex.h b/src/include/ranges/lindex.h index 4688f9a..4fa9160 100644 --- a/src/include/ranges/lindex.h +++ b/src/include/ranges/lindex.h @@ -18,15 +18,26 @@ namespace CNORXZ typedef typename Index::RangeType RangeType; DEFAULT_MEMBERS(LIndex); - LIndex(const Index& i); - LIndex(Index&& i); + LIndex(const Sptr& i); IndexId id() const; template decltype(auto) stepSize(const IndexId& id) const; + private: + Sptr mI; }; + + + template + decltype(auto) operator*(const Sptr>& a, const Sptr& b); + + template + decltype(auto) lindexPtr(const Sptr& i); + + template + decltype(auto) lindexPtr(const Sptr& i, CSizeT l); } #endif diff --git a/src/include/xpr/for.cc.h b/src/include/xpr/for.cc.h index 3a3c672..381ded2 100644 --- a/src/include/xpr/for.cc.h +++ b/src/include/xpr/for.cc.h @@ -393,7 +393,7 @@ namespace CNORXZ constexpr EFor::EFor(const IndexId& id, const Xpr& xpr, F&& f) : mId(id), mXpr(xpr), - mExt(mXpr.RootSteps(mId)), + mExt(mXpr.rootSteps(mId)), mF(std::forward(f)) {}