WIP: deepFormat + check format compatibility
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Christian Zimmermann 2023-09-09 11:14:03 +02:00
parent b0a5b1d13f
commit 944db31e02
8 changed files with 28 additions and 14 deletions

View file

@ -100,7 +100,7 @@ namespace CNORXZ
template <class Index>
COpRoot<T,Index> CArrayBase<T>::operator()(const Sptr<Index>& i) const
{
this->checkFormatCompatibility(i->deepFormat());
this->checkFormatCompatibility(toVec(i->deepFormat()));
return coproot(*this, i);
}
@ -109,7 +109,7 @@ namespace CNORXZ
inline decltype(auto) CArrayBase<T>::operator()(const SPack<Indices...>& pack) const
{
auto i = mindexPtr(pack);
this->checkFormatCompatibility(i->deepFormat());
this->checkFormatCompatibility(toVec(i->deepFormat()));
return coproot(*this, i);
}
@ -117,7 +117,7 @@ namespace CNORXZ
inline decltype(auto) CArrayBase<T>::operator()(const DPack& pack) const
{
auto i = yindexPtr(pack);
this->checkFormatCompatibility(i->deepFormat());
this->checkFormatCompatibility(toVec(i->deepFormat()));
return coproot(*this, i);
}
@ -223,7 +223,7 @@ namespace CNORXZ
template <class Index>
OpRoot<T,Index> ArrayBase<T>::operator()(const Sptr<Index>& i)
{
//CXZ_WARNING("FORMAT / BLOCKSIZES!!!");
this->checkFormatCompatibility(toVec(i->deepFormat()));
return oproot(*this, i);
}
@ -231,15 +231,17 @@ namespace CNORXZ
template <class... Indices>
inline decltype(auto) ArrayBase<T>::operator()(const SPack<Indices...>& pack)
{
//CXZ_WARNING("FORMAT / BLOCKSIZES!!!");
return oproot(*this, mindexPtr(pack));
auto i = mindexPtr(pack);
this->checkFormatCompatibility(toVec(i->deepFormat()));
return oproot(*this, i);
}
template <typename T>
inline decltype(auto) ArrayBase<T>::operator()(const DPack& pack)
{
//CXZ_WARNING("FORMAT / BLOCKSIZES!!!");
return oproot(*this, yindexPtr(pack));
auto i = yindexPtr(pack);
this->checkFormatCompatibility(toVec(i->deepFormat()));
return oproot(*this, i);
}
/*****************************

View file

@ -39,7 +39,7 @@ namespace CNORXZ
{
return iter<0,N1>
( [&](auto i) { return std::get<i>(a1); },
[](const auto&... e) { return Arr<T,N1+1> { e..., a2 }; } );
[&](const auto&... e) { return Arr<T,N1+1> { e..., a2 }; } );
}
template <typename T, SizeT N1>
@ -47,7 +47,7 @@ namespace CNORXZ
{
return iter<0,N1>
( [&](auto i) { return std::get<i>(a2); },
[](const auto&... e) { return Arr<T,N1+1> { a1, e... }; } );
[&](const auto&... e) { return Arr<T,N1+1> { a1, e... }; } );
}
template <typename T>
@ -113,7 +113,7 @@ namespace CNORXZ
template <typename T, SizeT N>
constexpr Arr<T,N> mul(const Arr<T,N>& a, const T& b)
{
return iter<0,N>( [&](auto i) { return std::get<i>(a) * b },
return iter<0,N>( [&](auto i) { return std::get<i>(a) * b; },
[](const auto&... e) { return Arr<T,N> { e... }; } );
}

View file

@ -55,6 +55,8 @@ namespace CNORXZ
DIndex& at(const DType& meta);
DXpr<SizeT> xpr(const Sptr<DIndex>& _this) const;
Vector<SizeT> deepFormat() const { return mI->deepFormat(); }
DXpr<SizeT> ifor(const DXpr<SizeT>& xpr, std::function<SizeT(SizeT,SizeT)>&& f) const;
const XIndexPtr& xptr() const;

View file

@ -63,6 +63,8 @@ namespace CNORXZ
// changes only MIndex/YIndex format, in this case we can just copy the pointers to the sub-index instances
{ return THIS().formatFrom(ind); }
decltype(auto) deepFormat() const { return THIS().deepFormat(); }
//template <class Index>
//decltype(auto) slice(const Sptr<Index>& ind) const { return THIS().slice(ind); }

View file

@ -482,8 +482,8 @@ namespace CNORXZ
template <class FormatT, class... Indices>
auto GMIndex<FormatT,Indices...>::deepFormat() const
{
return iter<0,NI>( [&](auto i) { return mul(std::get<i>(mIPack)->deepFormat(), mFormat[i]); },
[&](const auto&... e) { return concat(e, ...); } );
return iter<0,NI>( [&](auto i) { return mul(mIPack[i]->deepFormat(), format()[i].val()); },
[&](const auto&... e) { return concat(e...); } );
}
template <class FormatT, class... Indices>

View file

@ -141,6 +141,12 @@ namespace CNORXZ
return coproot(mMetaPtr,_this);
}
template <typename MetaT, SizeT S>
SizeT SIndex<MetaT,S>::deepFormat() const
{
return 1;
}
template <typename MetaT, SizeT S>
template <class Index>
decltype(auto) SIndex<MetaT,S>::formatFrom(const Index& ind) const

View file

@ -48,6 +48,8 @@ namespace CNORXZ
SIndex& at(const MetaT& metaPos);
decltype(auto) xpr(const Sptr<SIndex<MetaType,S>>& _this) const;
SizeT deepFormat() const;
template <class Index>
decltype(auto) formatFrom(const Index& ind) const;

View file

@ -65,7 +65,7 @@ namespace CNORXZ
YIndex& operator()();
const DPack& pack() const;
Vector<SizeT> deepFormat() const;
Vector<SizeT> deepFormat() const { CXZ_ERROR("implement!!!"); return Vector<SizeT> {1}; }
const YFormat& format() const;
const YFormat& lexFormat() const;
YIndex& setFormat(const YFormat& bs);