YRange: bug fix in deepFormat + add setFormat + array: bug fix in check format
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
fb8a44e88b
commit
642381ecc0
3 changed files with 42 additions and 1 deletions
|
@ -206,6 +206,10 @@ namespace CNORXZ
|
|||
CXZ_ASSERT(f1[i1] >= f2[i2], "obtained format " << toString(f1)
|
||||
<< ", which is incompatible to target format " << toString(f2));
|
||||
}
|
||||
else {
|
||||
++i1;
|
||||
++i2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ namespace CNORXZ
|
|||
const DPack& pack() const;
|
||||
RangePtr prange(const YIndex& last) const;
|
||||
Vector<SizeT> deepFormat() const;
|
||||
YIndex& setFormat(const Vector<SizeT>& f, const Vector<SizeT>& s);
|
||||
const YFormat& format() const;
|
||||
const YFormat& lexFormat() const;
|
||||
YIndex& setFormat(const YFormat& bs);
|
||||
|
|
|
@ -383,6 +383,8 @@ namespace CNORXZ
|
|||
SizeT osize = 0;
|
||||
for(SizeT j = 0; j != dfv.size(); ++j){
|
||||
dfv[j] = mIs[j]->deepFormat();
|
||||
std::for_each(dfv[j].begin(), dfv[j].end(),
|
||||
[&](SizeT& x) { x *= mFormat[j].val(); } );
|
||||
osize += dfv[j].size();
|
||||
}
|
||||
Vector<SizeT> o(osize);
|
||||
|
@ -394,6 +396,40 @@ namespace CNORXZ
|
|||
return o;
|
||||
}
|
||||
|
||||
YIndex& YIndex::setFormat(const Vector<SizeT>& f, const Vector<SizeT>& s)
|
||||
{
|
||||
CXZ_ASSERT(f.size() == s.size(), "input error: f.size() != s.size()");
|
||||
// f: input format
|
||||
// s: input sizes
|
||||
SizeT j = 0;
|
||||
SizeT j0 = 0;
|
||||
Vector<UPos> nformat(dim());
|
||||
for(SizeT i = 0; i != dim(); ++i){
|
||||
SizeT si = 1;
|
||||
if(mIs[i]->lmax().val() == 1){
|
||||
continue;
|
||||
}
|
||||
for(; si < mIs[i]->lmax().val(); ++j){
|
||||
si *= s[i];
|
||||
CXZ_ASSERT(j < f.size(), "incompatible index formats");
|
||||
}
|
||||
CXZ_ASSERT(si == mIs[i]->lmax().val(),
|
||||
"incompatible index formats: " << toString(s) << " vs " //!!!
|
||||
);
|
||||
Vector<SizeT> nf(j-j0);
|
||||
Vector<SizeT> ns(j-j0);
|
||||
std::copy(f.begin()+j0,f.begin()+j,nf.begin());
|
||||
nformat[i] = *std::min_element(nf.begin(), nf.end());
|
||||
std::for_each(nf.begin(), nf.end(), [&](SizeT& x)
|
||||
{ CXZ_ASSERT(x % mFormat[i].val() == 0, "incompatible"); x /= nformat[i].val(); } );
|
||||
std::copy(s.begin()+j0,s.begin()+j,ns.begin());
|
||||
CXZ_ERROR("implement for all indices!!!");
|
||||
//mIs[i]->setFormat(nf,ns);
|
||||
}
|
||||
mFormat = nformat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool YIndex::formatIsTrivial() const
|
||||
{
|
||||
for(SizeT i = 0; i != mIs.size(); ++i){
|
||||
|
|
Loading…
Reference in a new issue