WIP: index reformat: mindex: do not copy single-indices
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Christian Zimmermann 2023-12-22 01:52:49 +01:00
parent 4b9c8e94dc
commit df2a8e5a0b
5 changed files with 26 additions and 6 deletions

View file

@ -156,6 +156,18 @@ namespace CNORXZ
static_assert(index_expression_exists<I>::value, "expression for given index type does not exist");
return i->xpr(i);
}
template <class I>
decltype(auto) reformat(const Sptr<I>& i, const Vector<SizeT>& f, const Vector<SizeT>& s)
{
if constexpr(has_sub<I>::value){
return moveToPtr( i->reformat(f,s) );
}
else {
i->reformat(f,s); // checks
return i;
}
}
}
#endif

View file

@ -233,6 +233,10 @@ namespace CNORXZ
template <class I>
decltype(auto) xpr(const Sptr<I>& i);
// do not copy single-indices:
template <class I>
decltype(auto) reformat(const Sptr<I>& i, const Vector<SizeT>& f, const Vector<SizeT>& s);
}
#endif

View file

@ -69,7 +69,7 @@ namespace CNORXZ
{ static constexpr bool value = false; };
/** *****
check if given type is a statically multi-index-type
check if given type is a multi-index-type
@tparam I type to be checked
**/

View file

@ -550,11 +550,11 @@ namespace CNORXZ
Arr<UPos,NI> nformat;
auto npack = iter<0,NI>( [&](auto i) {
SizeT si = 1;
//if(mIPack[i]->lmax().val() == 1){
if(mIPack[i]->lmax().val() == 1){
//std::get<i>(npack) = mIPack[i];
//}
return mIPack[i];
}
// CHECK!!!
// TODO: DO NOT COPY SINGLE INDEX INSTANCES!!!
for(; si < mIPack[i]->lmax().val(); ++j){
si *= s[i];
CXZ_ASSERT(j < f.size(), "incompatible index formats");
@ -569,7 +569,7 @@ namespace CNORXZ
std::for_each(nf.begin(), nf.end(), [&](SizeT& x)
{ CXZ_ASSERT(x % nformat[i].val() == 0, "incompatible"); x /= nformat[i].val(); } );
std::copy(s.begin()+j0,s.begin()+j,ns.begin());
return moveToPtr( mIPack[i]->reformat(nf,ns) );
return CNORXZ::reformat(mIPack[i],nf,ns);
}, [](const auto&... e) { return std::make_tuple( e... ); } );
GMIndex<MFormat<NI>,Indices...> oi { MFormat<NI>(nformat),SPack<Indices...>(npack) };
oi = lex();

View file

@ -111,6 +111,10 @@ namespace CNORXZ
struct index_is_multi<YIndex>
{ static constexpr bool value = true; };
template <>
struct has_sub<YIndex>
{ static constexpr bool value = true; };
YIndex yindex(const DPack& pack);
YIndex yindex(const Vector<XIndexPtr>& is);
Sptr<YIndex> yindexPtr(const DPack& is);