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

View file

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

View file

@ -54,6 +54,8 @@ namespace CNORXZ
DType meta() const; DType meta() const;
DIndex& at(const DType& meta); DIndex& at(const DType& meta);
DXpr<SizeT> xpr(const Sptr<DIndex>& _this) const; 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; DXpr<SizeT> ifor(const DXpr<SizeT>& xpr, std::function<SizeT(SizeT,SizeT)>&& f) const;

View file

@ -62,6 +62,8 @@ namespace CNORXZ
decltype(auto) formatFrom(const Index& ind) const // yes this is const, decltype(auto) formatFrom(const Index& ind) const // yes this is const,
// changes only MIndex/YIndex format, in this case we can just copy the pointers to the sub-index instances // changes only MIndex/YIndex format, in this case we can just copy the pointers to the sub-index instances
{ return THIS().formatFrom(ind); } { return THIS().formatFrom(ind); }
decltype(auto) deepFormat() const { return THIS().deepFormat(); }
//template <class Index> //template <class Index>
//decltype(auto) slice(const Sptr<Index>& ind) const { return THIS().slice(ind); } //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> template <class FormatT, class... Indices>
auto GMIndex<FormatT,Indices...>::deepFormat() const auto GMIndex<FormatT,Indices...>::deepFormat() const
{ {
return iter<0,NI>( [&](auto i) { return mul(std::get<i>(mIPack)->deepFormat(), mFormat[i]); }, return iter<0,NI>( [&](auto i) { return mul(mIPack[i]->deepFormat(), format()[i].val()); },
[&](const auto&... e) { return concat(e, ...); } ); [&](const auto&... e) { return concat(e...); } );
} }
template <class FormatT, class... Indices> template <class FormatT, class... Indices>

View file

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

View file

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

View file

@ -65,7 +65,7 @@ namespace CNORXZ
YIndex& operator()(); YIndex& operator()();
const DPack& pack() const; 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& format() const;
const YFormat& lexFormat() const; const YFormat& lexFormat() const;
YIndex& setFormat(const YFormat& bs); YIndex& setFormat(const YFormat& bs);