further packnum replacements
This commit is contained in:
parent
12c79b595f
commit
6dc926f234
8 changed files with 110 additions and 232 deletions
|
@ -175,10 +175,7 @@ namespace MultiArrayTools
|
||||||
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
|
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
|
||||||
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator()(const std::shared_ptr<Indices>&... indices)
|
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator()(const std::shared_ptr<Indices>&... indices)
|
||||||
{
|
{
|
||||||
//RPackNum<sizeof...(Indices)-1>::swapIndices(mIPack, indices...);
|
|
||||||
//RPackNum<sizeof...(Indices)-1>::setIndexPack(mIPack, IB::mPos);
|
|
||||||
return (*this)(std::make_tuple(indices...));
|
return (*this)(std::make_tuple(indices...));
|
||||||
//return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
|
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
|
||||||
|
@ -186,7 +183,6 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
sfor_pn<0,sizeof...(Indices)>
|
sfor_pn<0,sizeof...(Indices)>
|
||||||
( [&](auto i) { std::get<i>(mIPack) = std::get<i>(indices); return 0; } );
|
( [&](auto i) { std::get<i>(mIPack) = std::get<i>(indices); return 0; } );
|
||||||
//RPackNum<sizeof...(Indices)-1>::swapIndices(mIPack, indices...);
|
|
||||||
RangeHelper::setIndexPack<sizeof...(Indices)-1>(mIPack, IB::mPos);
|
RangeHelper::setIndexPack<sizeof...(Indices)-1>(mIPack, IB::mPos);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +382,9 @@ namespace MultiArrayTools
|
||||||
bool check = false;
|
bool check = false;
|
||||||
for(auto& x: MapRangeFactoryProductMap::mAleadyCreated){
|
for(auto& x: MapRangeFactoryProductMap::mAleadyCreated){
|
||||||
if(x.second.size() == sizeof...(Ranges)){
|
if(x.second.size() == sizeof...(Ranges)){
|
||||||
check = RPackNum<sizeof...(Ranges)-1>::checkIfCreated(ptp, x.second);
|
check = sfor_p<0,sizeof...(Ranges)>
|
||||||
|
( [&](auto i) { return reinterpret_cast<std::intptr_t>( std::get<i>(ptp).get() ) == x.second[i]; },
|
||||||
|
[&](auto a, auto b) { return a and b; } );
|
||||||
if(check){
|
if(check){
|
||||||
out = x.first;
|
out = x.first;
|
||||||
break;
|
break;
|
||||||
|
@ -395,7 +393,8 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
if(not check){
|
if(not check){
|
||||||
vector<std::intptr_t> pv(sizeof...(Ranges));
|
vector<std::intptr_t> pv(sizeof...(Ranges));
|
||||||
RPackNum<sizeof...(Ranges)-1>::RangesToVec(ptp, pv);
|
sfor_pn<0,sizeof...(Ranges)>
|
||||||
|
( [&](auto i) { pv[i] = reinterpret_cast<std::intptr_t>( std::get<i>(ptp).get() ); return 0; } );
|
||||||
pv.push_back( reinterpret_cast<std::intptr_t>
|
pv.push_back( reinterpret_cast<std::intptr_t>
|
||||||
( &std::dynamic_pointer_cast<oType>( mProd )->mMapf ) );
|
( &std::dynamic_pointer_cast<oType>( mProd )->mMapf ) );
|
||||||
MapRangeFactoryProductMap::mAleadyCreated[mProd] = pv;
|
MapRangeFactoryProductMap::mAleadyCreated[mProd] = pv;
|
||||||
|
@ -626,7 +625,13 @@ namespace MultiArrayTools
|
||||||
//out.reserve(h.metaSize + sizeof(DataHeader));
|
//out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
RPackNum<sizeof...(Ranges)-1>::fillRangeDataVec(out, mSpace);
|
sfor_pn<0,sizeof...(Ranges)>
|
||||||
|
( [&](auto i) {
|
||||||
|
vector<char> part = std::get<i>(mSpace)->data();
|
||||||
|
out.insert(out.end(), part.begin(), part.end());
|
||||||
|
return 0;
|
||||||
|
} );
|
||||||
|
//RPackNum<sizeof...(Ranges)-1>::fillRangeDataVec(out, mSpace);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,11 +171,10 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
std::shared_ptr<AnonymousRange> defaultRange(size_t size = 0);
|
std::shared_ptr<AnonymousRange> defaultRange(size_t size = 0);
|
||||||
}
|
}
|
||||||
|
namespace MultiArrayTools
|
||||||
namespace MultiArrayHelper
|
{
|
||||||
|
namespace RangeHelper
|
||||||
{
|
{
|
||||||
using namespace MultiArrayTools;
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void resolveSetRange<AnonymousRange>(std::shared_ptr<AnonymousRange>& rp,
|
inline void resolveSetRange<AnonymousRange>(std::shared_ptr<AnonymousRange>& rp,
|
||||||
const vector<std::shared_ptr<RangeBase> >& orig,
|
const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
|
@ -188,6 +187,12 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
rp = std::dynamic_pointer_cast<AnonymousRange>( arf.create() );
|
rp = std::dynamic_pointer_cast<AnonymousRange>( arf.create() );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
namespace MultiArrayHelper
|
||||||
|
{
|
||||||
|
using namespace MultiArrayTools;
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void setRangeToVec<AnonymousRange>(vector<std::shared_ptr<RangeBase> >& v,
|
inline void setRangeToVec<AnonymousRange>(vector<std::shared_ptr<RangeBase> >& v,
|
||||||
|
@ -212,7 +217,9 @@ namespace MultiArrayTools
|
||||||
GenSingleRange<size_t,SpaceType::ANON,MUI>::GenSingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
|
GenSingleRange<size_t,SpaceType::ANON,MUI>::GenSingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
|
||||||
RangeInterface<AnonymousIndex>()
|
RangeInterface<AnonymousIndex>()
|
||||||
{
|
{
|
||||||
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( origs, mOrig );
|
mOrig.resize(sizeof...(RangeTypes));
|
||||||
|
sfor_pn<0,sizeof...(RangeTypes)>
|
||||||
|
( [&](auto i) { mOrig[i] = std::get<i>(origs); return 0; } );
|
||||||
mSize = sfor_p<0,sizeof...(RangeTypes)>
|
mSize = sfor_p<0,sizeof...(RangeTypes)>
|
||||||
( [&](auto i) { return std::get<i>(origs)->size(); },
|
( [&](auto i) { return std::get<i>(origs)->size(); },
|
||||||
[&](auto a, auto b) { return a * b; } );
|
[&](auto a, auto b) { return a * b; } );
|
||||||
|
@ -226,7 +233,9 @@ namespace MultiArrayTools
|
||||||
RangeInterface<AnonymousIndex>()
|
RangeInterface<AnonymousIndex>()
|
||||||
{
|
{
|
||||||
auto rst = std::make_tuple(origs...);
|
auto rst = std::make_tuple(origs...);
|
||||||
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( rst, mOrig );
|
mOrig.resize(sizeof...(RangeTypes));
|
||||||
|
sfor_pn<0,sizeof...(RangeTypes)>
|
||||||
|
( [&](auto i) { mOrig[i] = std::get<i>(rst); return 0; } );
|
||||||
mSize = sfor_p<0,sizeof...(RangeTypes)>
|
mSize = sfor_p<0,sizeof...(RangeTypes)>
|
||||||
( [&](auto i) { return std::get<i>(rst)->size(); },
|
( [&](auto i) { return std::get<i>(rst)->size(); },
|
||||||
[&](auto a, auto b) { return a * b; } );
|
[&](auto a, auto b) { return a * b; } );
|
||||||
|
@ -245,7 +254,8 @@ namespace MultiArrayTools
|
||||||
std::shared_ptr<MultiRange<Ranges...> > GenSingleRange<size_t,SpaceType::ANON,MUI>::scast(SIZET<Ranges>... sizes) const
|
std::shared_ptr<MultiRange<Ranges...> > GenSingleRange<size_t,SpaceType::ANON,MUI>::scast(SIZET<Ranges>... sizes) const
|
||||||
{
|
{
|
||||||
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
||||||
RPackNum<sizeof...(Ranges)-1>::resolveRangeType(mOrig, rtp, 0, sizes...);
|
RangeHelper::resolveRangeType<0>(mOrig, rtp, 0, sizes...);
|
||||||
|
//RPackNum<sizeof...(Ranges)-1>::resolveRangeType(mOrig, rtp, 0, sizes...);
|
||||||
MultiRangeFactory<Ranges...> mrf(rtp);
|
MultiRangeFactory<Ranges...> mrf(rtp);
|
||||||
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
|
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,9 +154,6 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
size_t getStepSize(size_t n);
|
size_t getStepSize(size_t n);
|
||||||
|
|
||||||
std::string id() const;
|
|
||||||
void print(size_t offset);
|
|
||||||
|
|
||||||
template <class Exprs>
|
template <class Exprs>
|
||||||
auto ifor(size_t step, Exprs exs) const;
|
auto ifor(size_t step, Exprs exs) const;
|
||||||
|
|
||||||
|
@ -458,24 +455,6 @@ namespace MultiArrayTools
|
||||||
return mBlockSizes[n+1];
|
return mBlockSizes[n+1];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Indices>
|
|
||||||
std::string ContainerIndex<T,Indices...>::id() const
|
|
||||||
{
|
|
||||||
return std::string("con") + std::to_string(IB::mId);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, class... Indices>
|
|
||||||
void ContainerIndex<T,Indices...>::print(size_t offset)
|
|
||||||
{
|
|
||||||
if(offset == 0){
|
|
||||||
std::cout << " === " << std::endl;
|
|
||||||
}
|
|
||||||
for(size_t j = 0; j != offset; ++j) { std::cout << "\t"; }
|
|
||||||
std::cout << id() << "[" << reinterpret_cast<std::intptr_t>(this) << "]"
|
|
||||||
<< "(" << IB::mRangePtr << "): " << meta() << std::endl;
|
|
||||||
RPackNum<sizeof...(Indices)-1>::printIndex(mIPack, offset+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, class... Indices>
|
template <typename T, class... Indices>
|
||||||
template <class Exprs>
|
template <class Exprs>
|
||||||
auto ContainerIndex<T,Indices...>::ifor(size_t step, Exprs exs) const
|
auto ContainerIndex<T,Indices...>::ifor(size_t step, Exprs exs) const
|
||||||
|
|
|
@ -143,7 +143,9 @@ namespace MultiArrayTools
|
||||||
DynamicRange::DynamicRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
|
DynamicRange::DynamicRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
|
||||||
RangeInterface<DynamicIndex>()
|
RangeInterface<DynamicIndex>()
|
||||||
{
|
{
|
||||||
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( origs, mOrig );
|
mOrig.resize(sizeof...(RangeTypes));
|
||||||
|
sfor_pn<0,sizeof...(RangeTypes)>
|
||||||
|
( [&](auto i) { mOrig[i] = std::get<i>(origs); return 0; } );
|
||||||
mSize = sfor_p<0,sizeof...(RangeTypes)>
|
mSize = sfor_p<0,sizeof...(RangeTypes)>
|
||||||
( [&](auto i) { return std::get<i>(origs)->size(); },
|
( [&](auto i) { return std::get<i>(origs)->size(); },
|
||||||
[&](auto a, auto b) { return a * b; } );
|
[&](auto a, auto b) { return a * b; } );
|
||||||
|
@ -158,7 +160,9 @@ namespace MultiArrayTools
|
||||||
RangeInterface<DynamicIndex>()
|
RangeInterface<DynamicIndex>()
|
||||||
{
|
{
|
||||||
auto rst = std::make_tuple(origs...);
|
auto rst = std::make_tuple(origs...);
|
||||||
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( rst, mOrig );
|
mOrig.resize(sizeof...(RangeTypes));
|
||||||
|
sfor_pn<0,sizeof...(RangeTypes)>
|
||||||
|
( [&](auto i) { mOrig[i] = std::get<i>(rst); return 0; } );
|
||||||
mSize = sfor_p<0,sizeof...(RangeTypes)>
|
mSize = sfor_p<0,sizeof...(RangeTypes)>
|
||||||
( [&](auto i) { return std::get<i>(rst)->size(); },
|
( [&](auto i) { return std::get<i>(rst)->size(); },
|
||||||
[&](auto a, auto b) { return a * b; } );
|
[&](auto a, auto b) { return a * b; } );
|
||||||
|
@ -179,7 +183,8 @@ namespace MultiArrayTools
|
||||||
std::shared_ptr<MultiRange<Ranges...> > DynamicRange::scast(SIZET<Ranges>... sizes) const
|
std::shared_ptr<MultiRange<Ranges...> > DynamicRange::scast(SIZET<Ranges>... sizes) const
|
||||||
{
|
{
|
||||||
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
||||||
RPackNum<sizeof...(Ranges)-1>::resolveRangeType(mOrig, rtp, 0, sizes...);
|
RangeHelper::resolveRangeType<0>(mOrig, rtp, 0, sizes...);
|
||||||
|
//RPackNum<sizeof...(Ranges)-1>::resolveRangeType(mOrig, rtp, 0, sizes...);
|
||||||
MultiRangeFactory<Ranges...> mrf(rtp);
|
MultiRangeFactory<Ranges...> mrf(rtp);
|
||||||
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
|
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
|
||||||
}
|
}
|
||||||
|
@ -187,13 +192,10 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
} // end namespace MultiArrayTools
|
} // end namespace MultiArrayTools
|
||||||
|
|
||||||
namespace MultiArrayHelper
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
namespace
|
namespace RangeHelper
|
||||||
{
|
{
|
||||||
using namespace MultiArrayTools;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void resolveSetRange<DynamicRange>(std::shared_ptr<DynamicRange>& rp,
|
inline void resolveSetRange<DynamicRange>(std::shared_ptr<DynamicRange>& rp,
|
||||||
const vector<std::shared_ptr<RangeBase> >& orig,
|
const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
|
@ -207,6 +209,17 @@ namespace MultiArrayHelper
|
||||||
rp = std::dynamic_pointer_cast<DynamicRange>( arf.create() );
|
rp = std::dynamic_pointer_cast<DynamicRange>( arf.create() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MultiArrayHelper
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace MultiArrayTools;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void setRangeToVec<DynamicRange>(vector<std::shared_ptr<RangeBase> >& v,
|
inline void setRangeToVec<DynamicRange>(vector<std::shared_ptr<RangeBase> >& v,
|
||||||
std::shared_ptr<DynamicRange> r)
|
std::shared_ptr<DynamicRange> r)
|
||||||
|
|
|
@ -528,7 +528,9 @@ namespace MultiArrayTools
|
||||||
bool check = false;
|
bool check = false;
|
||||||
for(auto& x: MultiRangeFactoryProductMap::mAleadyCreated){
|
for(auto& x: MultiRangeFactoryProductMap::mAleadyCreated){
|
||||||
if(x.second.size() == sizeof...(Ranges)){
|
if(x.second.size() == sizeof...(Ranges)){
|
||||||
check = RPackNum<sizeof...(Ranges)-1>::checkIfCreated(ptp, x.second);
|
check = sfor_p<0,sizeof...(Ranges)>
|
||||||
|
( [&](auto i) { return reinterpret_cast<std::intptr_t>( std::get<i>(ptp).get() ) == x.second[i]; },
|
||||||
|
[&](auto a, auto b) { return a and b; } );
|
||||||
if(check){
|
if(check){
|
||||||
out = x.first;
|
out = x.first;
|
||||||
break;
|
break;
|
||||||
|
@ -537,7 +539,8 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
if(not check){
|
if(not check){
|
||||||
vector<std::intptr_t> pv(sizeof...(Ranges));
|
vector<std::intptr_t> pv(sizeof...(Ranges));
|
||||||
RPackNum<sizeof...(Ranges)-1>::RangesToVec(ptp, pv);
|
sfor_pn<0,sizeof...(Ranges)>
|
||||||
|
( [&](auto i) { pv[i] = reinterpret_cast<std::intptr_t>( std::get<i>(ptp).get() ); return 0; } );
|
||||||
MultiRangeFactoryProductMap::mAleadyCreated[mProd] = pv;
|
MultiRangeFactoryProductMap::mAleadyCreated[mProd] = pv;
|
||||||
out = mProd;
|
out = mProd;
|
||||||
}
|
}
|
||||||
|
@ -647,7 +650,13 @@ namespace MultiArrayTools
|
||||||
//out.reserve(h.metaSize + sizeof(DataHeader));
|
//out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
RPackNum<sizeof...(Ranges)-1>::fillRangeDataVec(out, mSpace);
|
sfor_pn<0,sizeof...(Ranges)>
|
||||||
|
( [&](auto i) {
|
||||||
|
vector<char> part = std::get<i>(mSpace)->data();
|
||||||
|
out.insert(out.end(), part.begin(), part.end());
|
||||||
|
return 0;
|
||||||
|
} );
|
||||||
|
//RPackNum<sizeof...(Ranges)-1>::fillRangeDataVec(out, mSpace);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,14 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
namespace RangeHelper
|
namespace RangeHelper
|
||||||
{
|
{
|
||||||
|
template <class Range>
|
||||||
|
inline void resolveSetRange(std::shared_ptr<Range>& rp, const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
|
size_t origpos, size_t size)
|
||||||
|
{
|
||||||
|
assert(size == 1);
|
||||||
|
rp = std::dynamic_pointer_cast<Range>( orig[origpos] ); // catch bad cast here!!
|
||||||
|
}
|
||||||
|
|
||||||
template <size_t N, class IndexPack>
|
template <size_t N, class IndexPack>
|
||||||
void setIndexPack(IndexPack& iPack, size_t pos)
|
void setIndexPack(IndexPack& iPack, size_t pos)
|
||||||
{
|
{
|
||||||
|
@ -81,6 +89,26 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <size_t N, class RangeTuple, typename... SIZET>
|
||||||
|
inline void resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
|
RangeTuple& rtp, size_t off, size_t size, SIZET... sizes)
|
||||||
|
{
|
||||||
|
constexpr size_t tps = std::tuple_size<RangeTuple>::value;
|
||||||
|
::MultiArrayTools::RangeHelper::resolveSetRange(std::get<N>(rtp), orig, off, size);
|
||||||
|
if constexpr(N < tps-1){
|
||||||
|
resolveRangeType<N+1>(orig, rtp, off+size, sizes...);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t N, class RangeTuple>
|
||||||
|
inline void resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
|
RangeTuple& rtp, size_t off, size_t size)
|
||||||
|
{
|
||||||
|
constexpr size_t tps = std::tuple_size<RangeTuple>::value;
|
||||||
|
::MultiArrayTools::RangeHelper::resolveSetRange(std::get<N>(rtp), orig, off, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace RangeHelper
|
} // namespace RangeHelper
|
||||||
} // namespace MultiArrayTools
|
} // namespace MultiArrayTools
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
#include "rpack_num.h"
|
#include "rpack_num.h"
|
||||||
|
|
||||||
namespace MultiArrayHelper
|
namespace MultiArrayHelper
|
||||||
{
|
{
|
||||||
using namespace MultiArrayTools;
|
using namespace MultiArrayTools;
|
||||||
|
@ -17,7 +18,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
template <class Range>
|
template <class Range>
|
||||||
inline void resolveSetRange(std::shared_ptr<Range>& rp, const vector<std::shared_ptr<RangeBase> >& orig,
|
inline void resolveSetRange(std::shared_ptr<Range>& rp, const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
size_t origpos, size_t size)
|
size_t origpos, size_t size)
|
||||||
|
@ -25,6 +26,7 @@ namespace MultiArrayHelper
|
||||||
assert(size == 1);
|
assert(size == 1);
|
||||||
rp = std::dynamic_pointer_cast<Range>( orig[origpos] ); // catch bad cast here!!
|
rp = std::dynamic_pointer_cast<Range>( orig[origpos] ); // catch bad cast here!!
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
||||||
|
@ -41,23 +43,6 @@ namespace MultiArrayHelper
|
||||||
return RPackNum<N-1>::makePos(iPtrTup, blockSize) + std::get<N>(iPtrTup)->pos() * std::get<N+1>(blockSize);
|
return RPackNum<N-1>::makePos(iPtrTup, blockSize) + std::get<N>(iPtrTup)->pos() * std::get<N+1>(blockSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class Pack, class IndexType, class... Indices>
|
|
||||||
void RPackNum<N>::swapIndices(Pack& ipack, const std::shared_ptr<IndexType>& nind,
|
|
||||||
const std::shared_ptr<Indices>&... ninds)
|
|
||||||
{
|
|
||||||
std::get<std::tuple_size<Pack>::value-N-1>(ipack) = nind;
|
|
||||||
RPackNum<N-1>::swapIndices(ipack, ninds...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class Pack, class... Indices>
|
|
||||||
void RPackNum<N>::swapIndices(Pack& ipack, const std::tuple<std::shared_ptr<Indices>...>& ninds)
|
|
||||||
{
|
|
||||||
std::get<N>(ipack) = std::get<N>(ninds);
|
|
||||||
RPackNum<N-1>::swapIndices(ipack, ninds);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
size_t RPackNum<N>::blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack)
|
size_t RPackNum<N>::blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack)
|
||||||
|
@ -65,26 +50,6 @@ namespace MultiArrayHelper
|
||||||
return std::get<sizeof...(Indices)-N>(pack)->max() * RPackNum<N-1>::blockSize(pack);
|
return std::get<sizeof...(Indices)-N>(pack)->max() * RPackNum<N-1>::blockSize(pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class... Ranges>
|
|
||||||
inline void RPackNum<N>::RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
|
||||||
vector<std::shared_ptr<RangeBase> >& v)
|
|
||||||
{
|
|
||||||
setRangeToVec(v, std::get<N>(rst));
|
|
||||||
RPackNum<N-1>::RangesToVec(rst, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class... Ranges>
|
|
||||||
inline void RPackNum<N>::RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
|
||||||
vector<std::intptr_t>& v)
|
|
||||||
{
|
|
||||||
v[N] = reinterpret_cast<std::intptr_t>( std::get<N>(rst).get() );
|
|
||||||
RPackNum<N-1>::RangesToVec(rst, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
template <class Index>
|
template <class Index>
|
||||||
inline void RPackNum<N>::getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx)
|
inline void RPackNum<N>::getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx)
|
||||||
|
@ -99,25 +64,6 @@ namespace MultiArrayHelper
|
||||||
RPackNum<N-1>::getStepSizeX(ii, j, ss, sx);
|
RPackNum<N-1>::getStepSizeX(ii, j, ss, sx);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class RangeTuple, typename... SIZET>
|
|
||||||
inline void RPackNum<N>::resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
|
|
||||||
RangeTuple& rtp, size_t off, size_t size, SIZET... sizes)
|
|
||||||
{
|
|
||||||
constexpr size_t tps = std::tuple_size<RangeTuple>::value;
|
|
||||||
resolveSetRange(std::get<tps-N-1>(rtp), orig, off, size);
|
|
||||||
RPackNum<N-1>::resolveRangeType(orig, rtp, off+size, sizes...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class... Ranges>
|
|
||||||
inline bool RPackNum<N>::checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
|
|
||||||
const vector<std::intptr_t>& a)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<std::intptr_t>( std::get<N>(p).get() ) == a[N] and
|
|
||||||
RPackNum<N-1>::checkIfCreated(p,a);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
template <class MIndex>
|
template <class MIndex>
|
||||||
inline std::string RPackNum<N>::getStringMeta(const MIndex& mi)
|
inline std::string RPackNum<N>::getStringMeta(const MIndex& mi)
|
||||||
|
@ -125,16 +71,6 @@ namespace MultiArrayHelper
|
||||||
return RPackNum<N-1>::getStringMeta(mi) + "," + mi.template getPtr<N>()->stringMeta();
|
return RPackNum<N-1>::getStringMeta(mi) + "," + mi.template getPtr<N>()->stringMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class... Ranges>
|
|
||||||
inline void RPackNum<N>::fillRangeDataVec(vector<char>& out,
|
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& tp)
|
|
||||||
{
|
|
||||||
vector<char> part = std::get<sizeof...(Ranges)-N-1>(tp)->data();
|
|
||||||
out.insert(out.end(), part.begin(), part.end());
|
|
||||||
RPackNum<N-1>::fillRangeDataVec(out, tp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
template <size_t SIZE, class Range, class... Ranges>
|
template <size_t SIZE, class Range, class... Ranges>
|
||||||
inline bool RPackNum<N>::compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec)
|
inline bool RPackNum<N>::compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec)
|
||||||
|
@ -183,38 +119,12 @@ namespace MultiArrayHelper
|
||||||
return std::get<0>(iPtrTup)->pos() * std::get<1>(blockSize);
|
return std::get<0>(iPtrTup)->pos() * std::get<1>(blockSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Pack, class IndexType>
|
|
||||||
void RPackNum<0>::swapIndices(Pack& ipack, const std::shared_ptr<IndexType>& nind)
|
|
||||||
{
|
|
||||||
std::get<std::tuple_size<Pack>::value-1>(ipack) = nind;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Pack, class... Indices>
|
|
||||||
void RPackNum<0>::swapIndices(Pack& ipack, const std::tuple<std::shared_ptr<Indices>...>& ninds)
|
|
||||||
{
|
|
||||||
std::get<0>(ipack) = std::get<0>(ninds);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
size_t RPackNum<0>::blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack)
|
size_t RPackNum<0>::blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
inline void RPackNum<0>::RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
|
||||||
vector<std::intptr_t>& v)
|
|
||||||
{
|
|
||||||
v[0] = reinterpret_cast<std::intptr_t>( std::get<0>(rst).get() );;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
inline void RPackNum<0>::RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
|
||||||
vector<std::shared_ptr<RangeBase> >& v)
|
|
||||||
{
|
|
||||||
setRangeToVec(v, std::get<0>(rst));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Index>
|
template <class Index>
|
||||||
inline void RPackNum<0>::getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx)
|
inline void RPackNum<0>::getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx)
|
||||||
{
|
{
|
||||||
|
@ -227,35 +137,12 @@ namespace MultiArrayHelper
|
||||||
sx *= max;
|
sx *= max;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class RangeTuple, typename... SIZET>
|
|
||||||
inline void RPackNum<0>::resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
|
|
||||||
RangeTuple& rtp, size_t off, size_t size)
|
|
||||||
{
|
|
||||||
constexpr size_t tps = std::tuple_size<RangeTuple>::value;
|
|
||||||
resolveSetRange(std::get<tps-1>(rtp), orig, off, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
inline bool RPackNum<0>::checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
|
|
||||||
const vector<std::intptr_t>& a)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<std::intptr_t>( std::get<0>(p).get() ) == a[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MIndex>
|
template <class MIndex>
|
||||||
inline std::string RPackNum<0>::getStringMeta(const MIndex& mi)
|
inline std::string RPackNum<0>::getStringMeta(const MIndex& mi)
|
||||||
{
|
{
|
||||||
return mi.template getPtr<0>()->stringMeta();
|
return mi.template getPtr<0>()->stringMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
inline void RPackNum<0>::fillRangeDataVec(vector<char>& out,
|
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& tp)
|
|
||||||
{
|
|
||||||
vector<char> part = std::get<sizeof...(Ranges)-1>(tp)->data();
|
|
||||||
out.insert(out.end(), part.begin(), part.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t SIZE, class Range>
|
template <size_t SIZE, class Range>
|
||||||
inline bool RPackNum<0>::compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec)
|
inline bool RPackNum<0>::compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec)
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,43 +106,16 @@ namespace MultiArrayHelper
|
||||||
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
|
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
|
||||||
const std::array<size_t,sizeof...(Indices)+1>& blockSize);
|
const std::array<size_t,sizeof...(Indices)+1>& blockSize);
|
||||||
|
|
||||||
template <class Pack, class IndexType, class... Indices>
|
|
||||||
static void swapIndices(Pack& ipack, const std::shared_ptr<IndexType>& nind,
|
|
||||||
const std::shared_ptr<Indices>&... ninds);
|
|
||||||
|
|
||||||
template <class Pack, class... Indices>
|
|
||||||
static void swapIndices(Pack& ipack, const std::tuple<std::shared_ptr<Indices>...>& ninds);
|
|
||||||
|
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
static size_t blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack);
|
static size_t blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack);
|
||||||
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
|
||||||
vector<std::shared_ptr<RangeBase> >& v);
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
|
||||||
vector<std::intptr_t>& v);
|
|
||||||
|
|
||||||
template <class Index>
|
template <class Index>
|
||||||
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);
|
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);
|
||||||
|
|
||||||
template <class RangeTuple, typename... SIZET>
|
|
||||||
static inline void resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
|
|
||||||
RangeTuple& rtp, size_t off, size_t size, SIZET... sizes);
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline bool checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
|
|
||||||
const vector<std::intptr_t>& a);
|
|
||||||
|
|
||||||
template <class MIndex>
|
template <class MIndex>
|
||||||
static inline std::string getStringMeta(const MIndex& mi);
|
static inline std::string getStringMeta(const MIndex& mi);
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline void fillRangeDataVec(vector<char>& out,
|
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& tp);
|
|
||||||
|
|
||||||
template <size_t SIZE, class Range, class... Ranges>
|
template <size_t SIZE, class Range, class... Ranges>
|
||||||
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec);
|
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec);
|
||||||
|
|
||||||
|
@ -168,41 +141,15 @@ namespace MultiArrayHelper
|
||||||
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
|
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
|
||||||
const std::array<size_t,sizeof...(Indices)+1>& blockSize);
|
const std::array<size_t,sizeof...(Indices)+1>& blockSize);
|
||||||
|
|
||||||
template <class Pack, class IndexType>
|
|
||||||
static void swapIndices(Pack& ipack, const std::shared_ptr<IndexType>& nind);
|
|
||||||
|
|
||||||
template <class Pack, class... Indices>
|
|
||||||
static void swapIndices(Pack& ipack, const std::tuple<std::shared_ptr<Indices>...>& ninds);
|
|
||||||
|
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
static size_t blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack);
|
static size_t blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack);
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
|
||||||
vector<std::intptr_t>& v);
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
|
||||||
vector<std::shared_ptr<RangeBase> >& v);
|
|
||||||
|
|
||||||
template <class Index>
|
template <class Index>
|
||||||
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);
|
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);
|
||||||
|
|
||||||
template <class RangeTuple, typename... SIZET>
|
|
||||||
static inline void resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
|
|
||||||
RangeTuple& rtp, size_t off, size_t size);
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline bool checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
|
|
||||||
const vector<std::intptr_t>& a);
|
|
||||||
|
|
||||||
template <class MIndex>
|
template <class MIndex>
|
||||||
static inline std::string getStringMeta(const MIndex& mi);
|
static inline std::string getStringMeta(const MIndex& mi);
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline void fillRangeDataVec(vector<char>& out,
|
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& tp);
|
|
||||||
|
|
||||||
template <size_t SIZE, class Range>
|
template <size_t SIZE, class Range>
|
||||||
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec);
|
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue