From 8469fa9fb2aed86738c31bd0556a4d1698b57084 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 4 Jan 2023 11:27:18 +0100 Subject: [PATCH] yrange: replace index pack type --- src/include/ranges/index_mul.cc.h | 15 ++++++++------- src/include/ranges/yrange.h | 6 +++--- src/lib/ranges/yrange.cc | 12 ++++++------ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/include/ranges/index_mul.cc.h b/src/include/ranges/index_mul.cc.h index bdf4563..7265e62 100644 --- a/src/include/ranges/index_mul.cc.h +++ b/src/include/ranges/index_mul.cc.h @@ -90,20 +90,21 @@ namespace CNORXZ } else if constexpr(std::is_same::value){ auto p = b.THIS().pack(); - p.insert(0, a.THIS().xptr()); - return YIndex(p); + auto n = p.lmul( a.THIS().xptr() ); + return YIndex(n.all()); } } else if constexpr(std::is_same::value){ if constexpr(std::is_same::value){ auto p = a.THIS().pack(); - p.push_back(b.THIS().xptr()); - return YIndex(p); + auto n = p.rmul( b.THIS().xptr() ); + return YIndex(n.all()); } else if constexpr(std::is_same::value){ - auto p = a.THIS().pack(); - p.insert(p.end(), b.THIS().pack().begin(), b.THIS().pack().end()); - return YIndex(p); + auto ap = a.THIS().pack().all(); + const auto& bp = b.THIS().pack(); + ap.insert(ap.end(), bp.all().begin(), bp.all().end()); + return YIndex(ap); } } else { diff --git a/src/include/ranges/yrange.h b/src/include/ranges/yrange.h index c8ca99f..5000418 100644 --- a/src/include/ranges/yrange.h +++ b/src/include/ranges/yrange.h @@ -59,7 +59,7 @@ namespace CNORXZ YIndex& operator()(const Sptr& i); YIndex& operator()(); - const Vector& pack() const; + const DPack& pack() const; const YFormat& format() const; const YFormat& lexFormat() const; YIndex& setFormat(const YFormat& bs); @@ -69,7 +69,7 @@ namespace CNORXZ inline Vector mkLexFormat() const; inline Vector mkRangeVec(const Vector& is) const; inline void mkPos(); - inline Vector mkIndices() const; + inline DPack mkIndices() const; inline void up(SizeT i); inline void down(SizeT i); inline decltype(auto) mkIFor(SizeT i, const DXpr& xpr, @@ -79,7 +79,7 @@ namespace CNORXZ inline SizeT mkLMax() const; Sptr mRange; - Vector mIs; + DPack mIs; YFormat mFormat; // dim() elements only!!! YFormat mLexFormat; // dim() elements only!!! SizeT mLex = 0; diff --git a/src/lib/ranges/yrange.cc b/src/lib/ranges/yrange.cc index 8954323..61c78a9 100644 --- a/src/lib/ranges/yrange.cc +++ b/src/lib/ranges/yrange.cc @@ -7,7 +7,7 @@ namespace CNORXZ * YIndex (private) * *************************/ - inline Vector YIndex::mkIndices() const + inline DPack YIndex::mkIndices() const { Vector o(mRange->dim(), nullptr); for(SizeT i = 0; i != mRange->dim(); ++i){ @@ -15,7 +15,7 @@ namespace CNORXZ CXZ_ASSERT(rp != nullptr, "subranges not available"); o[i] = rp->begin().xptr(); } - return o; + return DPack(std::move(o)); } inline Vector YIndex::mkFormat() const @@ -115,7 +115,7 @@ namespace CNORXZ inline SizeT YIndex::mkLMax() const { - return std::accumulate(mIs.begin(), mIs.end(),1, + return std::accumulate(mIs.all().begin(), mIs.all().end(),1, [](const auto& res, const auto& el) { return res * el->lmax().val(); } ); } @@ -313,7 +313,7 @@ namespace CNORXZ const String elim = "]"; const String dlim = ","; return blim + - std::accumulate(std::next(mIs.begin()), mIs.end(), mIs[0]->stringMeta(), + std::accumulate(std::next(mIs.all().begin()), mIs.all().end(), mIs[0]->stringMeta(), [&](const auto& s, const auto& e) { return s + dlim + e->stringMeta(); } ) + elim; @@ -322,7 +322,7 @@ namespace CNORXZ DType YIndex::meta() const { Vector v(mIs.size()); - std::transform(mIs.begin(), mIs.end(), v.begin(), + std::transform(mIs.all().begin(), mIs.all().end(), v.begin(), [](const auto& x) { return x->meta(); }); return DType(v); } @@ -357,7 +357,7 @@ namespace CNORXZ return *this; } - const Vector& YIndex::pack() const + const DPack& YIndex::pack() const { return mIs; }