Templatize RankMap

This commit is contained in:
Alejandro Gallo 2022-01-27 20:41:08 +01:00
parent 61662e2717
commit 4543e712b3

View File

@ -549,6 +549,8 @@ namespace atrip {
#include <atrip/Slice.hpp>
namespace atrip {
template <typename F=double>
struct RankMap {
std::vector<size_t> const lengths;
@ -561,7 +563,7 @@ namespace atrip {
1UL, std::multiplies<size_t>()))
{ assert(lengths.size() <= 2); }
size_t find(Slice::Location const& p) const noexcept {
size_t find(typename Slice<F>::Location const& p) const noexcept {
return p.source * np + p.rank;
}
@ -581,10 +583,10 @@ namespace atrip {
return source == nSources() && isPaddingRank(rank);
}
Slice::Location
find(ABCTuple const& abc, Slice::Type sliceType) const noexcept {
typename Slice<F>::Location
find(ABCTuple const& abc, typename Slice<F>::Type sliceType) const noexcept {
// tuple = {11, 8} when abc = {11, 8, 9} and sliceType = AB
const auto tuple = Slice::subtupleBySlice(abc, sliceType);
const auto tuple = Slice<F>::subtupleBySlice(abc, sliceType);
const size_t index
= tuple[0]