multi_range: getMeta

This commit is contained in:
Christian Zimmermann 2021-01-11 11:16:29 +01:00
parent cfb3d4919b
commit 49812b18e2
3 changed files with 31 additions and 0 deletions

View file

@ -190,6 +190,8 @@ namespace MultiArrayTools
template <size_t N> template <size_t N>
auto get() const -> decltype( *std::get<N>( mSpace ) )&; auto get() const -> decltype( *std::get<N>( mSpace ) )&;
size_t getMeta(const MetaType& metaPos) const;
template <size_t N> template <size_t N>
auto getPtr() const -> decltype( std::get<N>( mSpace ) )&; auto getPtr() const -> decltype( std::get<N>( mSpace ) )&;
@ -556,6 +558,12 @@ namespace MultiArrayTools
return *std::get<N>(mSpace); return *std::get<N>(mSpace);
} }
template <class... Ranges>
size_t MultiRange<Ranges...>::getMeta(const MetaType& metaPos) const
{
return RPackNum<sizeof...(Ranges)-1>::getMeta(mSpace,metaPos);
}
template <class... Ranges> template <class... Ranges>
template <size_t N> template <size_t N>
auto MultiRange<Ranges...>::getPtr() const -> decltype( std::get<N>( mSpace ) )& auto MultiRange<Ranges...>::getPtr() const -> decltype( std::get<N>( mSpace ) )&

View file

@ -405,6 +405,15 @@ namespace MultiArrayHelper
RPackNum<N-1>::getTypeNum(res, stp); RPackNum<N-1>::getTypeNum(res, stp);
} }
template <size_t N>
template <class... Ranges>
inline size_t RPackNum<N>::getMeta(const std::tuple<std::shared_ptr<Ranges>...>& space,
const std::tuple<typename Ranges::IndexType::MetaType...>& meta)
{
return RPackNum<N-1>::getMeta(space,meta) * std::get<N>(space)->size() +
std::get<N>(space)->getMeta(std::get<N>(meta));
}
template <class... Indices> template <class... Indices>
@ -699,6 +708,13 @@ namespace MultiArrayHelper
res.insert(res.begin(), tn.begin(), tn.end()); res.insert(res.begin(), tn.begin(), tn.end());
} }
template <class... Ranges>
inline size_t RPackNum<0>::getMeta(const std::tuple<std::shared_ptr<Ranges>...>& space,
const std::tuple<typename Ranges::IndexType::MetaType...>& meta)
{
return std::get<0>(space)->getMeta(std::get<0>(meta));
}
template <IndexType IT> template <IndexType IT>
template <class Index> template <class Index>

View file

@ -180,6 +180,10 @@ namespace MultiArrayHelper
template <class... Ranges> template <class... Ranges>
static inline void getTypeNum(vector<size_t>& res, const std::tuple<std::shared_ptr<Ranges>...>& stp); static inline void getTypeNum(vector<size_t>& res, const std::tuple<std::shared_ptr<Ranges>...>& stp);
template <class... Ranges>
static inline size_t getMeta(const std::tuple<std::shared_ptr<Ranges>...>& space,
const std::tuple<typename Ranges::IndexType::MetaType...>& meta);
}; };
@ -315,6 +319,9 @@ namespace MultiArrayHelper
template <class... Ranges> template <class... Ranges>
static inline void getTypeNum(vector<size_t>& res, const std::tuple<std::shared_ptr<Ranges>...>& stp); static inline void getTypeNum(vector<size_t>& res, const std::tuple<std::shared_ptr<Ranges>...>& stp);
template <class... Ranges>
static inline size_t getMeta(const std::tuple<std::shared_ptr<Ranges>...>& space,
const std::tuple<typename Ranges::IndexType::MetaType...>& meta);
}; };
template <IndexType IT> template <IndexType IT>