diff --git a/src/include/array/array_base.cc.h b/src/include/array/array_base.cc.h index ca1f4f9..de82ef6 100644 --- a/src/include/array/array_base.cc.h +++ b/src/include/array/array_base.cc.h @@ -7,120 +7,6 @@ namespace CNORXZ { - /****************************** - * CArrayBase (protected) * - ******************************/ - - template - template - YIndex CArrayBase::mkSliceIndex(const YIndex& yi, const Index& ind) const - { - // TODO: if ind.dim() < iy.dim: assume Null-Indices on missing positions; - static_assert(has_sub::value, "got non-mutliple index"); - CXZ_ASSERT(yi.dim() == ind.dim(), "got index of incompatible dimension = " - << ind.dim() << ", expected: " << yi.dim()); - Vector npack; - Vector nbs; - auto ypack = yi.pack(); - auto ipack = ind.pack(); - const auto& bs = yi.blockSizes(); - if constexpr(has_static_sub::value){ - constexpr SizeT ID = index_dim::value; - npack.reserve(ID); - nbs.reserve(ID); - iter<0,ID>( [&](auto i) { - const auto& ii1 = ypack[i]; - const auto& ii2 = std::get(ipack); - if(ii2->dim() != 0){ - npack.push_back( mkSliceIndex(ii1, ii2) ); - nbs.push_back(bs[i]); - } - }, NoF {} ); - } - else { - const SizeT idim = ind.dim(); - npack.reserve(idim); - nbs.reserve(idim); - for(SizeT i = 0; i != idim; ++i){ - const auto& ii1 = ypack[i]; - const auto& ii2 = ipack[i]; - if(ii2->dim() != 0){ - npack.push_back( mkSliceIndex(ii1, ii2) ); - nbs.push_back(bs[i]); - } - } - } - return yindex(npack); - } - - template - template - XIndexPtr CArrayBase::mkSliceIndex(const XIndexPtr& xi, const Sptr& ind) const - { - // TODO: if ind.dim() < iy.dim: assume Null-Indices on missing positions; - CXZ_ASSERT(xi->dim() == ind->dim(), "got index of incompatible dimension = " - << ind->dim() << ", expected: " << xi->dim()); - Vector npack; - Vector nbs; - auto xpack = xi->pack(); - const auto& bs = xi->blockSizes(); - if constexpr(has_static_sub::value){ - auto ipack = ind->pack(); - constexpr SizeT ID = index_dim::value; - npack.reserve(ID); - nbs.reserve(ID); - iter<0,ID>( [&](auto i) { - const auto& ii1 = xpack[i]; - const auto& ii2 = std::get(ipack); - const XIndexPtr si = mkSliceIndex(ii1, ii2); - if(si != nullptr){ - npack.push_back( si ); - nbs.push_back(bs[i]); - } - }, NoF {} ); - } - else if constexpr(has_static_sub::value){ - auto ipack = ind->pack(); - const SizeT idim = ind->dim(); - const SizeT xdim = xi->dim(); - const SizeT isize = ipack.size(); - const SizeT xsize = xpack.size(); - if(isize == 0 or xsize == 0){ - if(idim == 0){ - return xi->copy(); - } - else { - return nullptr; - } - } - CXZ_ASSERT(isize == idim and xsize == xdim, "index error"); - npack.reserve(idim); - nbs.reserve(idim); - for(SizeT i = 0; i != idim; ++i){ - const auto& ii1 = xpack[i]; - const auto& ii2 = ipack[i]; - const XIndexPtr si = mkSliceIndex(ii1, ii2); - if(si != nullptr){ - npack.push_back( si ); - nbs.push_back(bs[i]); - } - } - } - else { - const SizeT idim = ind->dim(); - if(idim == 0){ - return xi->copy(); - } - else { - return nullptr; - } - } - if(npack.size() == 0){ - return nullptr; - } - return xindexPtr(yindexPtr(npack)); - } - /****************** * CArrayBase * ******************/ @@ -154,11 +40,10 @@ namespace CNORXZ template Sptr> CArrayBase::sl(const IndexInterface& i) const { - auto beg = this->begin(); - auto si = mkSliceIndex(beg, i); - auto it = beg + i.lex(); - return std::make_shared(this, si, it.pos()); - //return std::make_shared(); + auto beg = std::make_shared(this->begin()); + auto si = i.slice(beg); + auto it = *beg + i.lex(); + return std::make_shared(this, *si, it.pos()); } template @@ -189,32 +74,16 @@ namespace CNORXZ template COpRoot CArrayBase::operator()(const IndexPtr& i) const { - CXZ_ASSERT(false, "BLOCKSIZES!!"); - return COpRoot(*this, std::static_pointer_cast(i)); + auto fi = this->cbegin().format( std::static_pointer_cast(i) ); + return COpRoot(*this, fi); } template template - COpRoot CArrayBase::operator()(const LIndex& i) const + COpRoot CArrayBase::operator()(const Sptr>& i) const { - CXZ_ASSERT(false, "BLOCKSIZES!!"); - return COpRoot>(*this, i); - } - - template - template - COpRoot CArrayBase::op(const IndexPtr& i) const - { - CXZ_ASSERT(false, "IMPLEMENT CHECKS!!"); - return COpRoot(*this, std::static_pointer_cast(i)); - } - - template - template - COpRoot CArrayBase::op(const LIndex& i) const - { - CXZ_ASSERT(false, "IMPLEMENT CHECKS!!"); - return COpRoot>(*this, i); + auto fi = this->cbegin().format( i ); + return COpRoot>(*this, fi); } /***************** @@ -248,11 +117,10 @@ namespace CNORXZ template Sptr> ArrayBase::sl(const IndexInterface& i) { - auto r = mkSliceRange(i); - auto beg = this->begin(); - auto bs = mkSliceBlockSizes(i, beg); - auto it = beg + i.lex(); - return std::make_shared(r, this, bs, it.pos()); + auto beg = std::make_shared(this->cbegin()); + auto si = i.slice(beg); + auto it = *beg + i.lex(); + return std::make_shared(this, *si, it.pos()); } template @@ -269,35 +137,20 @@ namespace CNORXZ template template - OpRoot ArrayBase::operator()(const IndexPtr& i) const + OpRoot ArrayBase::operator()(const IndexPtr& i) { - CXZ_ASSERT(false, "BLOCKSIZES!!"); - return OpRoot(*this, std::static_pointer_cast(i)); + auto fi = this->cbegin().format( std::static_pointer_cast(i) ); + return OpRoot(*this, fi); } template template - OpRoot ArrayBase::operator()(const LIndex& i) const + OpRoot ArrayBase::operator()(const Sptr>& i) { - CXZ_ASSERT(false, "BLOCKSIZES!!"); - return OpRoot>(*this, i); + auto fi = this->cbegin().format( i ); + return OpRoot>(*this, fi); } - template - template - OpRoot ArrayBase::op(const IndexPtr& i) const - { - CXZ_ASSERT(false, "IMPLEMENT CHECKS!!"); - return OpRoot(*this, std::static_pointer_cast(i)); - } - - template - template - OpRoot ArrayBase::op(const LIndex& i) const - { - CXZ_ASSERT(false, "IMPLEMENT CHECKS!!"); - return OpRoot>(*this, i); - } } #endif diff --git a/src/include/array/array_base.h b/src/include/array/array_base.h index ae552cc..741a744 100644 --- a/src/include/array/array_base.h +++ b/src/include/array/array_base.h @@ -21,12 +21,6 @@ namespace CNORXZ protected: RangePtr mRange; - - template - YIndex mkSliceIndex(const YIndex& yi, const Index& i) const; - - template - XIndexPtr mkSliceIndex(const XIndexPtr& xi, const Sptr& i) const; public: @@ -59,13 +53,8 @@ namespace CNORXZ COpRoot operator()(const IndexPtr& i) const; template - COpRoot operator()(const LIndex& i) const; + COpRoot operator()(const Sptr>& i) const; - template - COpRoot op(const IndexPtr& i) const; - - template - COpRoot op(const LIndex& i) const; }; template @@ -103,16 +92,11 @@ namespace CNORXZ virtual iterator end(); template - OpRoot operator()(const IndexPtr& i) const; + OpRoot operator()(const IndexPtr& i); template - OpRoot operator()(const LIndex& i) const; + OpRoot operator()(const Sptr>& i); - template - OpRoot op(const IndexPtr& i) const; - - template - OpRoot op(const LIndex& i) const; }; }