diff --git a/src/include/array/array_base.cc.h b/src/include/array/array_base.cc.h index 1b6f80b..8854a2b 100644 --- a/src/include/array/array_base.cc.h +++ b/src/include/array/array_base.cc.h @@ -222,7 +222,7 @@ namespace CNORXZ OpRoot ArrayBase::operator()(const Sptr& i) { //CXZ_WARNING("FORMAT / BLOCKSIZES!!!"); - auto j = moveToPtr( begin()->reformat(i) ); // moveToPtr: keep original instance of sub indices + auto j = moveToPtr( begin()->formatTo(i) ); // moveToPtr: keep original instance of sub indices return oproot(*this, j); } @@ -231,7 +231,7 @@ namespace CNORXZ inline decltype(auto) ArrayBase::operator()(const SPack& pack) { //CXZ_WARNING("FORMAT / BLOCKSIZES!!!"); - auto j = moveToPtr( begin()->reformat(mindexPtr(pack)) ); + auto j = moveToPtr( begin()->formatTo(mindexPtr(pack)) ); return oproot(*this, j); } @@ -239,7 +239,7 @@ namespace CNORXZ inline decltype(auto) ArrayBase::operator()(const DPack& pack) { //CXZ_WARNING("FORMAT / BLOCKSIZES!!!"); - auto j = moveToPtr( begin()->reformat(yindexPtr(pack)) ); + auto j = moveToPtr( begin()->formatTo(yindexPtr(pack)) ); return oproot(*this, j); } diff --git a/src/include/ranges/mrange.cc.h b/src/include/ranges/mrange.cc.h index 8d8e468..0419742 100644 --- a/src/include/ranges/mrange.cc.h +++ b/src/include/ranges/mrange.cc.h @@ -387,16 +387,45 @@ namespace CNORXZ template decltype(auto) GMIndex::formatFrom(const Index& ind) const { + static_assert(is_index::value, "got non-index"); + CXZ_ASSERT(ind.dim() >= dim(), "for formatting index of dimension " << dim() + << " need index of at least the same dimension, got " << ind.dim()); + if constexpr(index_is_multi::value){ - // controll compatibility, coherent blocks etc... - // two possibilities: single index (CIndex, UIndex, DIndex) - // or multi index (MIndex,YIndex) - + if constexpr(has_static_sub::value){ // static dim (GMIndex) + // assert either same dim, dim == 1, or static sizes + CXZ_WARNING("not implemented!"); + } + else { // YIndex + SizeT j = 0; + iter<0,NI> + ( [&](auto i){ + CXZ_ASSERT(j < ind.dim(), "no sub indices left"); + const auto isize = pack()[i]->size(); + SizeT ssize = 1; + for(; j < ind.dim() and ssize < isize; ++j){ + ssize *= ind.pack()[j]; + } + CXZ_ASSERT(ssize == isize, "incompatible sizes: " << ssize + << " vs " << isize); + }, + + ); + } } else { - // no input format, keep the original format - return *this + if(ind.dim() > 1) { // DIndex to YIndex + + } + else { // this->dim() == 1 and ind.dim() == 1 + static_assert + (std::is_same>::type, + "got incompatible static index format types"); + mFormat = ind.format(); + // assert that all lower indices in ind have dim == 1!!! + } } + return *this; } template