From 43f5e560fa4d67ef63f2f7f5e111d8ab59028e47 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 8 Nov 2023 02:06:16 +0100 Subject: [PATCH] dynamic indices: DXpr -> DXpr --- src/include/ranges/dindex.cc.h | 19 +++++++++++++++++++ src/include/ranges/dindex.h | 8 ++++---- src/include/ranges/xindex.cc.h | 5 ++--- src/include/ranges/xindex.h | 6 ++---- src/include/ranges/yrange.h | 8 ++------ src/lib/ranges/dindex.cc | 8 ++++---- src/lib/ranges/yrange.cc | 9 ++++----- 7 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/include/ranges/dindex.cc.h b/src/include/ranges/dindex.cc.h index a192315..ca1f8db 100644 --- a/src/include/ranges/dindex.cc.h +++ b/src/include/ranges/dindex.cc.h @@ -22,6 +22,25 @@ namespace CNORXZ IndexInterface(i.pos()), mI(std::make_shared>(i)) {} + + template + decltype(auto) DIndex::ifor(const Xpr& xpr, F&& f) const + { + typedef typename std::remove_reference::type R; + if constexpr(std::is_same::value) { + if constexpr(std::is_same::value or std::is_same::value){ + return mI->ifor( DXpr(xpr), std::forward(f) ); + } + else { + CXZ_ERROR("IMPLEMENT!!!"); + return DXpr(); + } + } + else { + CXZ_ERROR("IMPLEMENT!!!"); + return DXpr(); + } + } } #endif diff --git a/src/include/ranges/dindex.h b/src/include/ranges/dindex.h index 80fe024..95906bc 100644 --- a/src/include/ranges/dindex.h +++ b/src/include/ranges/dindex.h @@ -58,9 +58,6 @@ namespace CNORXZ RangePtr range() const; UPos stepSize(const IndexId<0>& id) const; - //Vector pack() const; - //Vector format() const; - //DIndex& setBlockSizes(const Vector& bs); String stringMeta() const; DType meta() const; @@ -69,8 +66,11 @@ namespace CNORXZ RangePtr prange(const DIndex& end) const; Vector deepFormat() const; - DXpr ifor(const DXpr& xpr, std::function&& f) const; + //DXpr ifor(const DXpr& xpr, NoF&& f) const; + template + decltype(auto) ifor(const Xpr& xpr, F&& f) const; + const XIndexPtr& xptr() const; /** @copydoc IndexInterface::formatIsTrivial() */ diff --git a/src/include/ranges/xindex.cc.h b/src/include/ranges/xindex.cc.h index c73fc37..73ac1f1 100644 --- a/src/include/ranges/xindex.cc.h +++ b/src/include/ranges/xindex.cc.h @@ -185,10 +185,9 @@ namespace CNORXZ } template - DXpr XIndex::ifor(const DXpr& xpr, - std::function&& f) const + DXpr XIndex::ifor(const DXpr& xpr, NoF&& f) const { - return DXpr(mI->ifor(xpr, std::forward>(f))); + return DXpr(mI->ifor(xpr, std::forward(f))); } template diff --git a/src/include/ranges/xindex.h b/src/include/ranges/xindex.h index b60f672..f16d67f 100644 --- a/src/include/ranges/xindex.h +++ b/src/include/ranges/xindex.h @@ -58,8 +58,7 @@ namespace CNORXZ virtual XIndexBase& at(const DType& meta) = 0; virtual DXpr xpr(const XIndexPtr& _this) const = 0; - virtual DXpr ifor(const DXpr& xpr, - std::function&& f) const = 0; + virtual DXpr ifor(const DXpr& xpr, NoF&& f) const = 0; virtual bool formatIsTrivial() const = 0; }; @@ -112,8 +111,7 @@ namespace CNORXZ virtual XIndexBase& at(const DType& meta) override final; virtual DXpr xpr(const XIndexPtr& _this) const override final; - virtual DXpr ifor(const DXpr& xpr, - std::function&& f) const override final; + virtual DXpr ifor(const DXpr& xpr, NoF&& f) const override final; virtual bool formatIsTrivial() const override final; diff --git a/src/include/ranges/yrange.h b/src/include/ranges/yrange.h index 9a57027..e1c498f 100644 --- a/src/include/ranges/yrange.h +++ b/src/include/ranges/yrange.h @@ -64,15 +64,12 @@ namespace CNORXZ Sptr range() const; UPos stepSize(const IndexId<0> id) const; - //template - //YIndex formatFrom(const Index& ind) const; - String stringMeta() const; Vector meta() const; YIndex& at(const Vector& meta); DXpr xpr(const Sptr& _this) const; - DXpr ifor(const DXpr& xpr, std::function&& f) const; + DXpr ifor(const DXpr& xpr, NoF&& f) const; YIndex& operator()(const Sptr& i); YIndex& operator()(); @@ -95,8 +92,7 @@ namespace CNORXZ inline DPack mkIndices() const; inline void up(SizeT i); inline void down(SizeT i); - inline decltype(auto) mkIFor(SizeT i, const DXpr& xpr, - std::function&& f) const; + inline decltype(auto) mkIFor(SizeT i, const DXpr& xpr, NoF&& f) const; inline SizeT mkPMax() const; inline SizeT mkLMax() const; diff --git a/src/lib/ranges/dindex.cc b/src/lib/ranges/dindex.cc index 9947249..4a9c08f 100644 --- a/src/lib/ranges/dindex.cc +++ b/src/lib/ranges/dindex.cc @@ -186,12 +186,12 @@ namespace CNORXZ { return true; } - - DXpr DIndex::ifor(const DXpr& xpr, std::function&& f) const + /* + DXpr DIndex::ifor(const DXpr& xpr, NoF&& f) const { - return DXpr(mI->ifor(xpr, std::forward>(f)) ); + return mI->ifor(xpr, std::forward(f)); } - + */ const XIndexPtr& DIndex::xptr() const { return mI; diff --git a/src/lib/ranges/yrange.cc b/src/lib/ranges/yrange.cc index 7569eb4..147857f 100644 --- a/src/lib/ranges/yrange.cc +++ b/src/lib/ranges/yrange.cc @@ -92,11 +92,10 @@ namespace CNORXZ --(*idx); } - inline decltype(auto) YIndex::mkIFor(SizeT i, const DXpr& xpr, - std::function&& f) const + inline decltype(auto) YIndex::mkIFor(SizeT i, const DXpr& xpr, NoF&& f) const { if(i == mIs.size()-1){ - return mIs[i]->ifor( xpr, std::forward>(f) ); + return mIs[i]->ifor( xpr, std::forward(f) ); } else { auto f1 = f; @@ -350,9 +349,9 @@ namespace CNORXZ return DXpr(); } - DXpr YIndex::ifor(const DXpr& xpr, std::function&& f) const + DXpr YIndex::ifor(const DXpr& xpr, NoF&& f) const { - return mkIFor(0, xpr, std::forward>(f)); + return mkIFor(0, xpr, std::forward(f)); } YIndex& YIndex::operator()(const Sptr& i)