remove rpacknum getMeta, getSize, getTypeNum

This commit is contained in:
Christian Zimmermann 2021-05-27 11:02:36 +02:00
parent 29f4ddc0cd
commit 893b2360bc
8 changed files with 46 additions and 75 deletions

View file

@ -591,7 +591,7 @@ namespace MultiArrayTools
vector<size_t> GenMapRange<ORType,Op,XSTYPE,Ranges...>::typeNum() const
{
vector<size_t> o;
RPackNum<sizeof...(Ranges)-1>::getTypeNum(o,mSpace);
RangeHelper::getTypeNum<sizeof...(Ranges)-1>(o,mSpace);
return o;
}

View file

@ -213,7 +213,9 @@ namespace MultiArrayTools
RangeInterface<AnonymousIndex>()
{
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( origs, mOrig );
mSize = RPackNum<sizeof...(RangeTypes)-1>::getSize( origs );
mSize = sfor_p<0,sizeof...(RangeTypes)>
( [&](auto i) { return std::get<i>(origs)->size(); },
[&](auto a, auto b) { return a * b; } );
if(sizeof...(RangeTypes)){
mEmpty = false;
}
@ -225,7 +227,9 @@ namespace MultiArrayTools
{
auto rst = std::make_tuple(origs...);
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( rst, mOrig );
mSize = RPackNum<sizeof...(RangeTypes)-1>::getSize( rst );
mSize = sfor_p<0,sizeof...(RangeTypes)>
( [&](auto i) { return std::get<i>(rst)->size(); },
[&](auto a, auto b) { return a * b; } );
if(sizeof...(RangeTypes)){
mEmpty = false;
}

View file

@ -144,7 +144,9 @@ namespace MultiArrayTools
RangeInterface<DynamicIndex>()
{
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( origs, mOrig );
mSize = RPackNum<sizeof...(RangeTypes)-1>::getSize( origs );
mSize = sfor_p<0,sizeof...(RangeTypes)>
( [&](auto i) { return std::get<i>(origs)->size(); },
[&](auto a, auto b) { return a * b; } );
if(sizeof...(RangeTypes)){
mEmpty = false;
}
@ -157,7 +159,9 @@ namespace MultiArrayTools
{
auto rst = std::make_tuple(origs...);
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( rst, mOrig );
mSize = RPackNum<sizeof...(RangeTypes)-1>::getSize( rst );
mSize = sfor_p<0,sizeof...(RangeTypes)>
( [&](auto i) { return std::get<i>(rst)->size(); },
[&](auto a, auto b) { return a * b; } );
if(sizeof...(RangeTypes)){
mEmpty = false;
}

View file

@ -564,7 +564,7 @@ namespace MultiArrayTools
template <class... Ranges>
size_t MultiRange<Ranges...>::getMeta(const MetaType& metaPos) const
{
return RPackNum<sizeof...(Ranges)-1>::getMeta(mSpace,metaPos);
return RangeHelper::getMeta<sizeof...(Ranges)-1>(mSpace,metaPos);
}
template <class... Ranges>
@ -593,7 +593,10 @@ namespace MultiArrayTools
template <class... Ranges>
size_t MultiRange<Ranges...>::size() const
{
return RPackNum<sizeof...(Ranges)-1>::getSize(mSpace);
return sfor_p<0,sizeof...(Ranges)>
( [&](auto i) { return std::get<i>(mSpace)->size(); },
[&](auto a, auto b) { return a * b; } );
//return RPackNum<sizeof...(Ranges)-1>::getSize(mSpace);
}
template <class... Ranges>
@ -612,7 +615,7 @@ namespace MultiArrayTools
vector<size_t> MultiRange<Ranges...>::typeNum() const
{
vector<size_t> o;
RPackNum<sizeof...(Ranges)-1>::getTypeNum(o,mSpace);
RangeHelper::getTypeNum<sizeof...(Ranges)-1>(o,mSpace);
return o;
}

View file

@ -17,6 +17,30 @@ namespace MultiArrayTools
}
}
template <size_t N, class... Ranges>
inline size_t getMeta(const std::tuple<std::shared_ptr<Ranges>...>& space,
const std::tuple<typename Ranges::IndexType::MetaType...>& meta)
{
if constexpr(N != 0){
return getMeta<N-1>(space,meta) * std::get<N>(space)->size() +
std::get<N>(space)->getMeta(std::get<N>(meta));
}
else {
return std::get<0>(space)->getMeta(std::get<0>(meta));
}
}
template <size_t N, class... Ranges>
inline void getTypeNum(vector<size_t>& res, const std::tuple<std::shared_ptr<Ranges>...>& stp)
{
auto& r = *std::get<N>(stp);
auto tn = r.typeNum();
res.insert(res.begin(), tn.begin(), tn.end());
if constexpr(N != 0){
getTypeNum<N-1>(res, stp);
}
}
} // namespace RangeHelper
} // namespace MultiArrayTools

View file

@ -33,13 +33,6 @@ namespace MultiArrayHelper
v.insert(v.begin(), r);
}
template <size_t N>
template <class RangeTuple>
size_t RPackNum<N>::getSize(const RangeTuple& rt)
{
return std::get<N>(rt)->size() * RPackNum<N-1>::getSize(rt);
}
template <size_t N>
template <class... Indices>
inline size_t RPackNum<N>::makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
@ -215,32 +208,6 @@ namespace MultiArrayHelper
return r.cmetaSize() + RPackNum<N-1>::getCMetaSize(stp);
}
template <size_t N>
template <class... Ranges>
inline void RPackNum<N>::getTypeNum(vector<size_t>& res, const std::tuple<std::shared_ptr<Ranges>...>& stp)
{
auto& r = *std::get<N>(stp);
auto tn = r.typeNum();
res.insert(res.begin(), tn.begin(), tn.end());
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 RangeTuple>
size_t RPackNum<0>::getSize(const RangeTuple& rt)
{
return std::get<0>(rt)->size();
}
template <class... Indices>
inline size_t RPackNum<0>::makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
@ -388,20 +355,6 @@ namespace MultiArrayHelper
return r.cmetaSize();
}
template <class... Ranges>
inline void RPackNum<0>::getTypeNum(vector<size_t>& res, const std::tuple<std::shared_ptr<Ranges>...>& stp)
{
auto& r = *std::get<0>(stp);
auto tn = r.typeNum();
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>

View file

@ -102,9 +102,6 @@ namespace MultiArrayHelper
struct RPackNum
{
template <class RangeTuple>
static size_t getSize(const RangeTuple& rt);
template <class... Indices>
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
const std::array<size_t,sizeof...(Indices)+1>& blockSize);
@ -175,12 +172,6 @@ namespace MultiArrayHelper
template <class... Ranges>
static inline size_t getCMetaSize(const std::tuple<std::shared_ptr<Ranges>...>& stp);
template <class... Ranges>
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);
};
@ -188,9 +179,6 @@ namespace MultiArrayHelper
struct RPackNum<0>
{
template <class RangeTuple>
static size_t getSize(const RangeTuple& rt);
template <class... Indices>
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
const std::array<size_t,sizeof...(Indices)+1>& blockSize);
@ -259,12 +247,6 @@ namespace MultiArrayHelper
template <class... Ranges>
static inline size_t getCMetaSize(const std::tuple<std::shared_ptr<Ranges>...>& stp);
template <class... Ranges>
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>

View file

@ -258,7 +258,7 @@ namespace MultiArrayHelper
class DExtTX
{
private:
mutable DExt mDExt = nullptr;
mutable DExt mDExt;
X mNext;
template <class Y>
@ -268,7 +268,8 @@ namespace MultiArrayHelper
static constexpr size_t SIZE = NUM + 1;
DExtTX() { mDExt = std::make_shared<ExtT<None>>(); }
DExtTX(const DExtTX& in) : mDExt(in.mDExt->deepCopy()), mNext(in.mNext) {}
DExtTX(const DExtTX& in) : mNext(in.mNext)
{ mDExt = in.mDExt->deepCopy(); }
DExtTX(DExtTX&& in) : mDExt(in.mDExt->deepCopy()), mNext(in.mNext) {}
DExtTX& operator=(const DExtTX& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); return *this; }
DExtTX& operator=(DExtTX&& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); return *this; }