From fae345f455c72cf74d974123b990a8ba531b624b Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Sun, 14 Apr 2024 01:45:15 +0200 Subject: [PATCH] WIP: rank array member function implementations --- src/opt/mpi/include/rarray.cc.h | 37 ++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/opt/mpi/include/rarray.cc.h b/src/opt/mpi/include/rarray.cc.h index a952704..f4aed5d 100644 --- a/src/opt/mpi/include/rarray.cc.h +++ b/src/opt/mpi/include/rarray.cc.h @@ -72,30 +72,42 @@ namespace CNORXZ template T RCArray::operator[](const SPack& pack) const { - CXZ_ERROR("not implemented"); - return T(); + typedef typename std::remove_reference{}])>::type I0; + if constexpr(is_rank_index::value){ + return *(begin() + pack.lex()); + } + else { + return (*mA)[pack]; + } } template template T RCArray::at(const SPack& pack) const { - CXZ_ERROR("not implemented"); - return T(); + typedef typename std::remove_reference{}])>::type I0; + if constexpr(is_rank_index::value){ + CXZ_ASSERT(pack[CSizeT<0>{}]->rank() == getNumRanks(), + "rank number out of scope"); + return *(begin() + pack.lex()); + } + else { + return mA->at(pack); + } } template T RCArray::operator[](const DPack& pack) const { - CXZ_ERROR("not implemented"); - return T(); + // TODO: assert that none of the indices is rank index + return (*mA)[pack]; } template T RCArray::at(const DPack& pack) const { - CXZ_ERROR("not implemented"); - return T(); + // TODO: assert that none of the indices is rank index + return mA->at(pack); } template @@ -103,8 +115,13 @@ namespace CNORXZ Sptr> RCArray::sl(const IndexInterface& begin, const IndexInterface& end) const { - CXZ_ERROR("not implemented"); - return nullptr; + if constexpr(is_rank_index::value){ + CXZ_ERROR("not implemented"); + return nullptr; + } + else { + return mA->sl(begin, end); + } } template