yrange: replace index pack type

This commit is contained in:
Christian Zimmermann 2023-01-04 11:27:18 +01:00
parent 346f92f267
commit 8469fa9fb2
3 changed files with 17 additions and 16 deletions

View file

@ -90,20 +90,21 @@ namespace CNORXZ
} }
else if constexpr(std::is_same<I2,YIndex>::value){ else if constexpr(std::is_same<I2,YIndex>::value){
auto p = b.THIS().pack(); auto p = b.THIS().pack();
p.insert(0, a.THIS().xptr()); auto n = p.lmul( a.THIS().xptr() );
return YIndex(p); return YIndex(n.all());
} }
} }
else if constexpr(std::is_same<I1,YIndex>::value){ else if constexpr(std::is_same<I1,YIndex>::value){
if constexpr(std::is_same<I2,DIndex>::value){ if constexpr(std::is_same<I2,DIndex>::value){
auto p = a.THIS().pack(); auto p = a.THIS().pack();
p.push_back(b.THIS().xptr()); auto n = p.rmul( b.THIS().xptr() );
return YIndex(p); return YIndex(n.all());
} }
else if constexpr(std::is_same<I2,YIndex>::value){ else if constexpr(std::is_same<I2,YIndex>::value){
auto p = a.THIS().pack(); auto ap = a.THIS().pack().all();
p.insert(p.end(), b.THIS().pack().begin(), b.THIS().pack().end()); const auto& bp = b.THIS().pack();
return YIndex(p); ap.insert(ap.end(), bp.all().begin(), bp.all().end());
return YIndex(ap);
} }
} }
else { else {

View file

@ -59,7 +59,7 @@ namespace CNORXZ
YIndex& operator()(const Sptr<YIndex>& i); YIndex& operator()(const Sptr<YIndex>& i);
YIndex& operator()(); YIndex& operator()();
const Vector<XIndexPtr>& pack() const; const DPack& pack() const;
const YFormat& format() const; const YFormat& format() const;
const YFormat& lexFormat() const; const YFormat& lexFormat() const;
YIndex& setFormat(const YFormat& bs); YIndex& setFormat(const YFormat& bs);
@ -69,7 +69,7 @@ namespace CNORXZ
inline Vector<SizeT> mkLexFormat() const; inline Vector<SizeT> mkLexFormat() const;
inline Vector<RangePtr> mkRangeVec(const Vector<XIndexPtr>& is) const; inline Vector<RangePtr> mkRangeVec(const Vector<XIndexPtr>& is) const;
inline void mkPos(); inline void mkPos();
inline Vector<XIndexPtr> mkIndices() const; inline DPack mkIndices() const;
inline void up(SizeT i); inline void up(SizeT i);
inline void down(SizeT i); inline void down(SizeT i);
inline decltype(auto) mkIFor(SizeT i, const DXpr<SizeT>& xpr, inline decltype(auto) mkIFor(SizeT i, const DXpr<SizeT>& xpr,
@ -79,7 +79,7 @@ namespace CNORXZ
inline SizeT mkLMax() const; inline SizeT mkLMax() const;
Sptr<YRange> mRange; Sptr<YRange> mRange;
Vector<XIndexPtr> mIs; DPack mIs;
YFormat mFormat; // dim() elements only!!! YFormat mFormat; // dim() elements only!!!
YFormat mLexFormat; // dim() elements only!!! YFormat mLexFormat; // dim() elements only!!!
SizeT mLex = 0; SizeT mLex = 0;

View file

@ -7,7 +7,7 @@ namespace CNORXZ
* YIndex (private) * * YIndex (private) *
*************************/ *************************/
inline Vector<XIndexPtr> YIndex::mkIndices() const inline DPack YIndex::mkIndices() const
{ {
Vector<XIndexPtr> o(mRange->dim(), nullptr); Vector<XIndexPtr> o(mRange->dim(), nullptr);
for(SizeT i = 0; i != mRange->dim(); ++i){ for(SizeT i = 0; i != mRange->dim(); ++i){
@ -15,7 +15,7 @@ namespace CNORXZ
CXZ_ASSERT(rp != nullptr, "subranges not available"); CXZ_ASSERT(rp != nullptr, "subranges not available");
o[i] = rp->begin().xptr(); o[i] = rp->begin().xptr();
} }
return o; return DPack(std::move(o));
} }
inline Vector<SizeT> YIndex::mkFormat() const inline Vector<SizeT> YIndex::mkFormat() const
@ -115,7 +115,7 @@ namespace CNORXZ
inline SizeT YIndex::mkLMax() const 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(); } ); [](const auto& res, const auto& el) { return res * el->lmax().val(); } );
} }
@ -313,7 +313,7 @@ namespace CNORXZ
const String elim = "]"; const String elim = "]";
const String dlim = ","; const String dlim = ",";
return blim + 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) [&](const auto& s, const auto& e)
{ return s + dlim + e->stringMeta(); } ) + { return s + dlim + e->stringMeta(); } ) +
elim; elim;
@ -322,7 +322,7 @@ namespace CNORXZ
DType YIndex::meta() const DType YIndex::meta() const
{ {
Vector<DType> v(mIs.size()); Vector<DType> 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(); }); [](const auto& x) { return x->meta(); });
return DType(v); return DType(v);
} }
@ -357,7 +357,7 @@ namespace CNORXZ
return *this; return *this;
} }
const Vector<XIndexPtr>& YIndex::pack() const const DPack& YIndex::pack() const
{ {
return mIs; return mIs;
} }