diff --git a/src/include/array/array_base.cc.h b/src/include/array/array_base.cc.h index 90db3ce..f22864e 100644 --- a/src/include/array/array_base.cc.h +++ b/src/include/array/array_base.cc.h @@ -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); } /***************************** diff --git a/src/include/base/utils.h b/src/include/base/utils.h index 8646cfa..74df958 100644 --- a/src/include/base/utils.h +++ b/src/include/base/utils.h @@ -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... }; } ); } diff --git a/src/include/ranges/dindex.h b/src/include/ranges/dindex.h index f5cbfde..54ead2f 100644 --- a/src/include/ranges/dindex.h +++ b/src/include/ranges/dindex.h @@ -54,6 +54,8 @@ namespace CNORXZ DType meta() const; 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; diff --git a/src/include/ranges/index_base.h b/src/include/ranges/index_base.h index 8abc4d8..5a3753b 100644 --- a/src/include/ranges/index_base.h +++ b/src/include/ranges/index_base.h @@ -62,6 +62,8 @@ namespace CNORXZ 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 { 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); } diff --git a/src/include/ranges/mrange.cc.h b/src/include/ranges/mrange.cc.h index 2a5efbc..42ae67e 100644 --- a/src/include/ranges/mrange.cc.h +++ b/src/include/ranges/mrange.cc.h @@ -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> diff --git a/src/include/ranges/srange.cc.h b/src/include/ranges/srange.cc.h index 41ecba6..60dde3c 100644 --- a/src/include/ranges/srange.cc.h +++ b/src/include/ranges/srange.cc.h @@ -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 diff --git a/src/include/ranges/srange.h b/src/include/ranges/srange.h index 2a8ab0b..868537c 100644 --- a/src/include/ranges/srange.h +++ b/src/include/ranges/srange.h @@ -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; diff --git a/src/include/ranges/yrange.h b/src/include/ranges/yrange.h index 4104a5a..b5da566 100644 --- a/src/include/ranges/yrange.h +++ b/src/include/ranges/yrange.h @@ -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);