mrange: solve lower-dim-reformat issue
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Christian Zimmermann 2024-01-03 11:54:06 +01:00
parent ab13d97b03
commit d66164e874
2 changed files with 20 additions and 4 deletions

View file

@ -551,6 +551,12 @@ namespace CNORXZ
GMIndex<FormatT,Indices...>&
GMIndex<FormatT,Indices...>::reformat(const Vector<SizeT>& f, const Vector<SizeT>& s)
{
if(f.size() == 1){
CXZ_ASSERT(s.size() == 1, "f.size() != s.size()");
CXZ_ASSERT(s[0] == lmax().val(), "got inconsistent size; expeected "
<< lmax().val() << ", got " << s[0]);
return *this;
}
if constexpr(std::is_same<FormatT,None>::value){
CXZ_ASSERT(CNORXZ::formatIsTrivial(f,s),
"cannot reformat MIndex with format type = None");
@ -590,9 +596,7 @@ namespace CNORXZ
mIPack[i]->reformat(nf,ns);
}
else {
// TODO: IMPLEMENT!!!
// check trivial format in this partition
CXZ_ERROR("reformating with lower-dimensional formats has not yet been implemented");
CXZ_ERROR("reformating with lower-dimensional formats is not possible; use sub-indices instead");
}
}, NoF {});
mFormat = FormatT(nformat);

View file

@ -66,6 +66,7 @@ namespace
{
GMIndex<MFormat<4>,CIndex,CIndex,CIndex,CIndex> mi(mRange);
MIndex<CIndex,CIndex,CIndex,CIndex,CIndex> mi2(mRange2);
GMIndex<MFormat<4>,CIndex,GMIndex<MFormat<3>,CIndex,CIndex,CIndex>,CIndex,CIndex> mi32(mRange);
EXPECT_EQ(mi.lmax().val(), mRange->size());
EXPECT_EQ(mi2.lmax().val(), mRange2->size());
auto yi = indexAs<YIndex>( mRange->begin() );
@ -79,9 +80,20 @@ namespace
yi.setFormat( YFormat( Vector<SizeT>{ mi2.format()[CSizeT<0>{}].val(), mi2.format()[CSizeT<1>{}].val(), mi2.format()[CSizeT<2>{}].val(), mi2.format()[CSizeT<4>{}].val() } ) );
VCHECK(toString(yi.deepFormat()));
mi.reformat( yi.deepFormat(), yi.deepMax() );
VCHECK(toString(mi.deepFormat()));
VCHECK(toString(mi.deepMax()));
yi.setFormat( YFormat( Vector<SizeT>{ 13, 143, 1, 15015 } ) );
VCHECK(toString(yi.deepFormat()));
mi.reformat( yi.deepFormat(), yi.deepMax() );
VCHECK(toString(mi.deepFormat()));
VCHECK(toString(mi.deepMax()));
mi32.reformat( Vector<SizeT> { 105,1,2310,1155 }, Vector<SizeT> { 11,105,13,2 } );
VCHECK(toString(yi.deepFormat()));
mi32.reformat( yi.deepFormat(), yi.deepMax() );
VCHECK(toString(mi32.deepFormat()));
VCHECK(toString(mi32.deepMax()));
}
}