WIP: index reformat: mindex: do not copy single-indices
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
4b9c8e94dc
commit
df2a8e5a0b
5 changed files with 26 additions and 6 deletions
|
@ -156,6 +156,18 @@ namespace CNORXZ
|
||||||
static_assert(index_expression_exists<I>::value, "expression for given index type does not exist");
|
static_assert(index_expression_exists<I>::value, "expression for given index type does not exist");
|
||||||
return i->xpr(i);
|
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
|
#endif
|
||||||
|
|
|
@ -233,6 +233,10 @@ namespace CNORXZ
|
||||||
|
|
||||||
template <class I>
|
template <class I>
|
||||||
decltype(auto) xpr(const Sptr<I>& 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
|
#endif
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace CNORXZ
|
||||||
{ static constexpr bool value = false; };
|
{ 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
|
@tparam I type to be checked
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -550,11 +550,11 @@ namespace CNORXZ
|
||||||
Arr<UPos,NI> nformat;
|
Arr<UPos,NI> nformat;
|
||||||
auto npack = iter<0,NI>( [&](auto i) {
|
auto npack = iter<0,NI>( [&](auto i) {
|
||||||
SizeT si = 1;
|
SizeT si = 1;
|
||||||
//if(mIPack[i]->lmax().val() == 1){
|
if(mIPack[i]->lmax().val() == 1){
|
||||||
//std::get<i>(npack) = mIPack[i];
|
//std::get<i>(npack) = mIPack[i];
|
||||||
//}
|
return mIPack[i];
|
||||||
|
}
|
||||||
// CHECK!!!
|
// CHECK!!!
|
||||||
// TODO: DO NOT COPY SINGLE INDEX INSTANCES!!!
|
|
||||||
for(; si < mIPack[i]->lmax().val(); ++j){
|
for(; si < mIPack[i]->lmax().val(); ++j){
|
||||||
si *= s[i];
|
si *= s[i];
|
||||||
CXZ_ASSERT(j < f.size(), "incompatible index formats");
|
CXZ_ASSERT(j < f.size(), "incompatible index formats");
|
||||||
|
@ -569,7 +569,7 @@ namespace CNORXZ
|
||||||
std::for_each(nf.begin(), nf.end(), [&](SizeT& x)
|
std::for_each(nf.begin(), nf.end(), [&](SizeT& x)
|
||||||
{ CXZ_ASSERT(x % nformat[i].val() == 0, "incompatible"); x /= nformat[i].val(); } );
|
{ CXZ_ASSERT(x % nformat[i].val() == 0, "incompatible"); x /= nformat[i].val(); } );
|
||||||
std::copy(s.begin()+j0,s.begin()+j,ns.begin());
|
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... ); } );
|
}, [](const auto&... e) { return std::make_tuple( e... ); } );
|
||||||
GMIndex<MFormat<NI>,Indices...> oi { MFormat<NI>(nformat),SPack<Indices...>(npack) };
|
GMIndex<MFormat<NI>,Indices...> oi { MFormat<NI>(nformat),SPack<Indices...>(npack) };
|
||||||
oi = lex();
|
oi = lex();
|
||||||
|
|
|
@ -111,6 +111,10 @@ namespace CNORXZ
|
||||||
struct index_is_multi<YIndex>
|
struct index_is_multi<YIndex>
|
||||||
{ static constexpr bool value = true; };
|
{ static constexpr bool value = true; };
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct has_sub<YIndex>
|
||||||
|
{ static constexpr bool value = true; };
|
||||||
|
|
||||||
YIndex yindex(const DPack& pack);
|
YIndex yindex(const DPack& pack);
|
||||||
YIndex yindex(const Vector<XIndexPtr>& is);
|
YIndex yindex(const Vector<XIndexPtr>& is);
|
||||||
Sptr<YIndex> yindexPtr(const DPack& is);
|
Sptr<YIndex> yindexPtr(const DPack& is);
|
||||||
|
|
Loading…
Reference in a new issue