completely remove rpacknum
This commit is contained in:
parent
6dc926f234
commit
c5b9e84486
16 changed files with 251 additions and 517 deletions
|
@ -606,7 +606,7 @@ namespace MultiArrayTools
|
||||||
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
|
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
|
||||||
size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::cmetaSize() const
|
size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::cmetaSize() const
|
||||||
{
|
{
|
||||||
return RPackNum<sizeof...(Ranges)-1>::getCMetaSize(mSpace);
|
return RangeHelper::getCMetaSize<0>(mSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
|
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
|
||||||
|
@ -614,7 +614,7 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
auto i = begin();
|
auto i = begin();
|
||||||
i = pos;
|
i = pos;
|
||||||
return "[ " + RPackNum<sizeof...(Ranges)-1>::getStringMeta(i) + " ]";
|
return "[ " + RangeHelper::getStringMeta<0>(i) + " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
|
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
|
||||||
|
@ -631,7 +631,6 @@ namespace MultiArrayTools
|
||||||
out.insert(out.end(), part.begin(), part.end());
|
out.insert(out.end(), part.begin(), part.end());
|
||||||
return 0;
|
return 0;
|
||||||
} );
|
} );
|
||||||
//RPackNum<sizeof...(Ranges)-1>::fillRangeDataVec(out, mSpace);
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "ranges/range_base.h"
|
#include "ranges/range_base.h"
|
||||||
#include "ranges/index_base.h"
|
#include "ranges/index_base.h"
|
||||||
|
|
||||||
#include "ranges/rpack_num.h"
|
|
||||||
#include "map_range_factory_product_map.h"
|
#include "map_range_factory_product_map.h"
|
||||||
#include "ranges/x_to_string.h"
|
#include "ranges/x_to_string.h"
|
||||||
#include "ranges/type_map.h"
|
#include "ranges/type_map.h"
|
||||||
|
@ -116,7 +115,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
static constexpr IndexType sType() { return IndexType::SINGLE; }
|
static constexpr IndexType sType() { return IndexType::SINGLE; }
|
||||||
static constexpr size_t sDim() { return sizeof...(Indices); }
|
static constexpr size_t sDim() { return sizeof...(Indices); }
|
||||||
static constexpr size_t totalDim() { return mkTotalDim<Indices...>(); }
|
static constexpr size_t totalDim() { return (... * Indices::totalDim()); }
|
||||||
static void check_type() { static_assert( std::is_same<typename OIType::MetaType,typename Op::value_type>::value, "inconsitent value types" ); }
|
static void check_type() { static_assert( std::is_same<typename OIType::MetaType,typename Op::value_type>::value, "inconsitent value types" ); }
|
||||||
|
|
||||||
static constexpr SpaceType STYPE = XSTYPE;
|
static constexpr SpaceType STYPE = XSTYPE;
|
||||||
|
@ -329,8 +328,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
static constexpr bool HASMETACONT = false;
|
static constexpr bool HASMETACONT = false;
|
||||||
static constexpr bool defaultable = false;
|
static constexpr bool defaultable = false;
|
||||||
static constexpr size_t ISSTATIC = SubProp<Op,Ranges...>::ISSTATIC;
|
static constexpr size_t ISSTATIC = Op::ISSTATIC & (... & Ranges::ISSTATIC);
|
||||||
static constexpr size_t SIZE = SubProp<Op,Ranges...>::SIZE;
|
static constexpr size_t SIZE = Op::SIZE * (... * Ranges::SIZE);
|
||||||
};
|
};
|
||||||
|
|
||||||
// for legacy
|
// for legacy
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
#include "multi_array_operation.h"
|
#include "multi_array_operation.h"
|
||||||
#include "xfor/exttype.h"
|
#include "xfor/exttype.h"
|
||||||
|
#include "ranges/range_helper.h"
|
||||||
|
|
||||||
|
|
||||||
/* ========================= *
|
/* ========================= *
|
||||||
|
@ -380,8 +381,7 @@ namespace MultiArrayTools
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
MExt<None> ConstOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
|
MExt<None> ConstOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
return MExt<None>(getStepSize( mIndex, iPtrNum ));
|
return MExt<None>(RangeHelper::getStepSize( mIndex, iPtrNum ));
|
||||||
//return MExt<None>(getStepSize( getRootIndices( mIndex->info() ), iPtrNum ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -478,8 +478,7 @@ namespace MultiArrayTools
|
||||||
template <class Range>
|
template <class Range>
|
||||||
MExt<None> MetaOperationRoot<Range>::rootSteps(std::intptr_t iPtrNum) const
|
MExt<None> MetaOperationRoot<Range>::rootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
return MExt<None>(getStepSize( *mIndex, iPtrNum ));
|
return MExt<None>(RangeHelper::getStepSize( *mIndex, iPtrNum ));
|
||||||
//return MExt<None>(getStepSize( getRootIndices( mIndex->info() ), iPtrNum ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -691,7 +690,7 @@ namespace MultiArrayTools
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
MExt<None> OperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
|
MExt<None> OperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
return MExt<None>(getStepSize( mIndex, iPtrNum ));
|
return MExt<None>(RangeHelper::getStepSize( mIndex, iPtrNum ));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
|
@ -868,8 +867,7 @@ namespace MultiArrayTools
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
MExt<None> ParallelOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
|
MExt<None> ParallelOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
return MExt<None>(getStepSize( mIndex, iPtrNum ));
|
return MExt<None>(RangeHelper::getStepSize( mIndex, iPtrNum ));
|
||||||
//return MExt<None>(getStepSize( mIndex.info(), iPtrNum ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
|
|
|
@ -187,11 +187,6 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
rp = std::dynamic_pointer_cast<AnonymousRange>( arf.create() );
|
rp = std::dynamic_pointer_cast<AnonymousRange>( arf.create() );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
namespace MultiArrayHelper
|
|
||||||
{
|
|
||||||
using namespace MultiArrayTools;
|
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -204,7 +199,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
|
@ -255,7 +250,6 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
||||||
RangeHelper::resolveRangeType<0>(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() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
#include "ranges/range_base.h"
|
#include "ranges/range_base.h"
|
||||||
#include "ranges/index_base.h"
|
#include "ranges/index_base.h"
|
||||||
|
|
||||||
#include "rpack_num.h"
|
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -30,7 +28,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
static constexpr IndexType sType() { return IndexType::CONT; }
|
static constexpr IndexType sType() { return IndexType::CONT; }
|
||||||
static constexpr size_t sDim() { return sizeof...(Indices); }
|
static constexpr size_t sDim() { return sizeof...(Indices); }
|
||||||
static constexpr size_t totalDim() { return mkTotalDim<Indices...>(); }
|
static constexpr size_t totalDim() { return (... * Indices::totalDim()); }
|
||||||
|
|
||||||
static constexpr SpaceType STYPE = SpaceType::ANY;
|
static constexpr SpaceType STYPE = SpaceType::ANY;
|
||||||
static constexpr bool PARALLEL = std::tuple_element<0,std::tuple<Indices...>>::type::PARALLEL;
|
static constexpr bool PARALLEL = std::tuple_element<0,std::tuple<Indices...>>::type::PARALLEL;
|
||||||
|
@ -232,7 +230,7 @@ namespace MultiArrayTools
|
||||||
IB::mPos = sfor_m<sizeof...(Indices),0>
|
IB::mPos = sfor_m<sizeof...(Indices),0>
|
||||||
( [&](auto i) { return std::get<i>(mIPack); },
|
( [&](auto i) { return std::get<i>(mIPack); },
|
||||||
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
|
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
|
||||||
mCPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack, mBlockSizes);
|
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Indices>
|
template <typename T, class... Indices>
|
||||||
|
@ -253,7 +251,7 @@ namespace MultiArrayTools
|
||||||
IB::mPos = sfor_m<sizeof...(Indices),0>
|
IB::mPos = sfor_m<sizeof...(Indices),0>
|
||||||
( [&](auto i) { return std::get<i>(mIPack); },
|
( [&](auto i) { return std::get<i>(mIPack); },
|
||||||
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
|
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
|
||||||
mCPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack, mBlockSizes);
|
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
|
||||||
mNonTrivialBlocks = true;
|
mNonTrivialBlocks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +272,7 @@ namespace MultiArrayTools
|
||||||
IB::mPos = sfor_m<sizeof...(Indices),0>
|
IB::mPos = sfor_m<sizeof...(Indices),0>
|
||||||
( [&](auto i) { return std::get<i>(mIPack); },
|
( [&](auto i) { return std::get<i>(mIPack); },
|
||||||
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
|
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
|
||||||
mCPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack, mBlockSizes);
|
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +330,7 @@ namespace MultiArrayTools
|
||||||
else { ++si; return false; }
|
else { ++si; return false; }
|
||||||
return false;
|
return false;
|
||||||
} );
|
} );
|
||||||
mCPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack, mBlockSizes);
|
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
|
||||||
++IB::mPos;
|
++IB::mPos;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +350,7 @@ namespace MultiArrayTools
|
||||||
else { --si; return false; }
|
else { --si; return false; }
|
||||||
return false;
|
return false;
|
||||||
} );
|
} );
|
||||||
mCPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack, mBlockSizes);
|
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
|
||||||
--IB::mPos;
|
--IB::mPos;
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
@ -363,14 +361,14 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
IB::mPos = pos;
|
IB::mPos = pos;
|
||||||
RangeHelper::setIndexPack<sizeof...(Indices)-1>(mIPack, pos);
|
RangeHelper::setIndexPack<sizeof...(Indices)-1>(mIPack, pos);
|
||||||
mCPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack, mBlockSizes);
|
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Indices>
|
template <typename T, class... Indices>
|
||||||
int ContainerIndex<T,Indices...>::pp(std::intptr_t idxPtrNum)
|
int ContainerIndex<T,Indices...>::pp(std::intptr_t idxPtrNum)
|
||||||
{
|
{
|
||||||
const int tmp = ppx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
|
const int tmp = RangeHelper::ppx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
|
||||||
IB::mPos += tmp;
|
IB::mPos += tmp;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +376,7 @@ namespace MultiArrayTools
|
||||||
template <typename T, class... Indices>
|
template <typename T, class... Indices>
|
||||||
int ContainerIndex<T,Indices...>::mm(std::intptr_t idxPtrNum)
|
int ContainerIndex<T,Indices...>::mm(std::intptr_t idxPtrNum)
|
||||||
{
|
{
|
||||||
const int tmp = mmx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
|
const int tmp = RangeHelper::mmx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
|
||||||
IB::mPos -= tmp;
|
IB::mPos -= tmp;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -403,7 +401,7 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
sfor_pn<0,sizeof...(Indices)>
|
sfor_pn<0,sizeof...(Indices)>
|
||||||
( [&](auto i) { std::get<i>(mIPack)->at( std::get<i>(metaPos) ); return 0; } );
|
( [&](auto i) { std::get<i>(mIPack)->at( std::get<i>(metaPos) ); return 0; } );
|
||||||
IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack, mBlockSizes);
|
IB::mPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
#include "ranges/dynamic_range.h"
|
#include "ranges/dynamic_range.h"
|
||||||
//#include "ranges/dynamic_meta.h"
|
|
||||||
|
|
||||||
//#include "rpack_num.h"
|
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
@ -184,7 +181,6 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
||||||
RangeHelper::resolveRangeType<0>(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() );
|
||||||
}
|
}
|
||||||
|
@ -209,16 +205,6 @@ namespace MultiArrayTools
|
||||||
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,
|
||||||
|
@ -245,7 +231,8 @@ namespace MultiArrayHelper
|
||||||
sx *= max;
|
sx *= max;
|
||||||
}
|
}
|
||||||
return ss;
|
return ss;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,11 @@
|
||||||
|
|
||||||
#include "xfor/xfor.h"
|
#include "xfor/xfor.h"
|
||||||
|
|
||||||
//#include "ranges/rpheader.h"
|
|
||||||
#include "ranges/x_to_string.h"
|
#include "ranges/x_to_string.h"
|
||||||
#include "ranges/type_map.h"
|
#include "ranges/type_map.h"
|
||||||
#include "ranges/dynamic_meta.h"
|
#include "ranges/dynamic_meta.h"
|
||||||
|
|
||||||
#include "index_wrapper.h"
|
#include "index_wrapper.h"
|
||||||
#include "rpack_num.h"
|
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
@ -228,12 +226,10 @@ namespace MultiArrayTools
|
||||||
} // namespace MultiArrayTools
|
} // 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,
|
||||||
|
@ -246,7 +242,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline size_t getStepSize<DynamicIndex>(const DynamicIndex& ii, std::intptr_t j);
|
inline size_t getStepSize<DynamicIndex>(const DynamicIndex& ii, std::intptr_t j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#include "dynamic_range.cc.h"
|
//#include "dynamic_range.cc.h"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
#include "index_wrapper.h"
|
#include "index_wrapper.h"
|
||||||
#include "rpack_num.h"
|
#include "range_helper.h"
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
@ -117,9 +117,9 @@ namespace MultiArrayTools
|
||||||
template <class Index>
|
template <class Index>
|
||||||
size_t IndexWrapper<Index>::getStepSizeComp(std::intptr_t j) const
|
size_t IndexWrapper<Index>::getStepSizeComp(std::intptr_t j) const
|
||||||
{
|
{
|
||||||
size_t out = MultiArrayHelper::getStepSize(*mI, j);
|
size_t out = RangeHelper::getStepSize(*mI, j);
|
||||||
if(out == 0){
|
if(out == 0){
|
||||||
out = MultiArrayHelper::getStepSize(*mCI, j);
|
out = RangeHelper::getStepSize(*mCI, j);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,9 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
//#include "base_def.h"
|
|
||||||
#include "ranges/range_base.h"
|
#include "ranges/range_base.h"
|
||||||
#include "ranges/index_base.h"
|
#include "ranges/index_base.h"
|
||||||
|
|
||||||
#include "ranges/rpack_num.h"
|
|
||||||
#include "ranges/range_helper.h"
|
#include "ranges/range_helper.h"
|
||||||
#include "ranges/multi_range_factory_product_map.h"
|
#include "ranges/multi_range_factory_product_map.h"
|
||||||
#include "ranges/x_to_string.h"
|
#include "ranges/x_to_string.h"
|
||||||
|
@ -42,7 +40,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
static constexpr IndexType sType() { return IndexType::MULTI; }
|
static constexpr IndexType sType() { return IndexType::MULTI; }
|
||||||
static constexpr size_t sDim() { return sizeof...(Indices); }
|
static constexpr size_t sDim() { return sizeof...(Indices); }
|
||||||
static constexpr size_t totalDim() { return mkTotalDim<Indices...>(); }
|
static constexpr size_t totalDim() { return (... * Indices::totalDim()); }
|
||||||
|
|
||||||
static constexpr SpaceType STYPE = SpaceType::ANY;
|
static constexpr SpaceType STYPE = SpaceType::ANY;
|
||||||
static constexpr bool PARALLEL = std::tuple_element<0,std::tuple<Indices...>>::type::PARALLEL;
|
static constexpr bool PARALLEL = std::tuple_element<0,std::tuple<Indices...>>::type::PARALLEL;
|
||||||
|
@ -217,8 +215,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
static constexpr bool HASMETACONT = false;
|
static constexpr bool HASMETACONT = false;
|
||||||
static constexpr bool defaultable = false;
|
static constexpr bool defaultable = false;
|
||||||
static constexpr size_t ISSTATIC = SubProp<Ranges...>::ISSTATIC;
|
static constexpr size_t ISSTATIC = (... & Ranges::ISSTATIC);
|
||||||
static constexpr size_t SIZE = SubProp<Ranges...>::SIZE;
|
static constexpr size_t SIZE = (... * Ranges::SIZE);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -388,7 +386,7 @@ namespace MultiArrayTools
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
int MultiIndex<Indices...>::pp(std::intptr_t idxPtrNum)
|
int MultiIndex<Indices...>::pp(std::intptr_t idxPtrNum)
|
||||||
{
|
{
|
||||||
const int tmp = ppx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
|
const int tmp = RangeHelper::ppx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
|
||||||
IB::mPos += tmp;
|
IB::mPos += tmp;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -396,7 +394,7 @@ namespace MultiArrayTools
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
int MultiIndex<Indices...>::mm(std::intptr_t idxPtrNum)
|
int MultiIndex<Indices...>::mm(std::intptr_t idxPtrNum)
|
||||||
{
|
{
|
||||||
const int tmp = mmx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
|
const int tmp = RangeHelper::mmx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
|
||||||
IB::mPos -= tmp;
|
IB::mPos -= tmp;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -625,13 +623,13 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
const size_t off = cmetaSize();
|
const size_t off = cmetaSize();
|
||||||
MetaType* xtarget = reinterpret_cast<MetaType*>(target);
|
MetaType* xtarget = reinterpret_cast<MetaType*>(target);
|
||||||
return RPackNum<sizeof...(Ranges)-1>::getCMeta(xtarget,pos,mSpace,off);
|
return RangeHelper::getCMeta<sizeof...(Ranges)-1>(xtarget,pos,mSpace,off);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
size_t MultiRange<Ranges...>::cmetaSize() const
|
size_t MultiRange<Ranges...>::cmetaSize() const
|
||||||
{
|
{
|
||||||
return RPackNum<sizeof...(Ranges)-1>::getCMetaSize(mSpace);
|
return RangeHelper::getCMetaSize<0>(mSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
|
@ -639,7 +637,7 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
auto i = begin();
|
auto i = begin();
|
||||||
i = pos;
|
i = pos;
|
||||||
return "[" + RPackNum<sizeof...(Ranges)-1>::getStringMeta(i) + "]";
|
return "[" + RangeHelper::getStringMeta<0>(i) + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
|
@ -656,7 +654,6 @@ namespace MultiArrayTools
|
||||||
out.insert(out.end(), part.begin(), part.end());
|
out.insert(out.end(), part.begin(), part.end());
|
||||||
return 0;
|
return 0;
|
||||||
} );
|
} );
|
||||||
//RPackNum<sizeof...(Ranges)-1>::fillRangeDataVec(out, mSpace);
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,72 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
namespace RangeHelper
|
namespace RangeHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template <size_t I, class... Indices>
|
||||||
|
int ppx(std::tuple<std::shared_ptr<Indices>...>& ip,
|
||||||
|
std::array<size_t,sizeof...(Indices)+1>& bs,
|
||||||
|
std::intptr_t idxPtrNum)
|
||||||
|
{
|
||||||
|
auto& siPtr = std::get<I>(ip);
|
||||||
|
if(reinterpret_cast<std::intptr_t>(siPtr.get()) == idxPtrNum){
|
||||||
|
if constexpr(I != 0){
|
||||||
|
return ppx<I-1>(ip, bs, idxPtrNum);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return std::get<0>(bs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const int tmp = siPtr->pp(idxPtrNum);
|
||||||
|
if constexpr(I != 0){
|
||||||
|
if(siPtr->pos() == siPtr->max()){
|
||||||
|
(*siPtr) = 0;
|
||||||
|
return ppx<I-1>(ip, bs, idxPtrNum) - siPtr->max() + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmp * std::get<I+1>(bs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t I, class... Indices>
|
||||||
|
int mmx(std::tuple<std::shared_ptr<Indices>...>& ip,
|
||||||
|
std::array<size_t,sizeof...(Indices)+1>& bs,
|
||||||
|
std::intptr_t idxPtrNum)
|
||||||
|
{
|
||||||
|
auto& siPtr = std::get<I>(ip);
|
||||||
|
if(reinterpret_cast<std::intptr_t>(siPtr.get()) == idxPtrNum){
|
||||||
|
if constexpr(I != 0){
|
||||||
|
return mmx<I-1>(ip, bs, idxPtrNum);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return std::get<0>(bs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const int tmp = siPtr->mm(idxPtrNum);
|
||||||
|
if constexpr(I != 0){
|
||||||
|
if(siPtr->pos() == siPtr->max()){
|
||||||
|
(*siPtr) = siPtr->max() - 1;
|
||||||
|
return mmx<I-1>(ip, bs, idxPtrNum) - siPtr->max() + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmp * std::get<I+1>(bs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t N, class... Indices>
|
||||||
|
inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
|
||||||
|
const std::array<size_t,sizeof...(Indices)+1>& blockSize)
|
||||||
|
{
|
||||||
|
if constexpr(N != 0){
|
||||||
|
return makePos<N-1>(iPtrTup, blockSize) +
|
||||||
|
std::get<N>(iPtrTup)->pos() * std::get<N+1>(blockSize);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return std::get<0>(iPtrTup)->pos() * std::get<1>(blockSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -14,6 +80,13 @@ namespace MultiArrayTools
|
||||||
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>
|
||||||
|
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
||||||
|
std::shared_ptr<Range> r)
|
||||||
|
{
|
||||||
|
v.insert(v.begin(), r);
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +181,103 @@ namespace MultiArrayTools
|
||||||
::MultiArrayTools::RangeHelper::resolveSetRange(std::get<N>(rtp), orig, off, size);
|
::MultiArrayTools::RangeHelper::resolveSetRange(std::get<N>(rtp), orig, off, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <size_t N, class MetaType, class... Ranges>
|
||||||
|
inline size_t getCMeta(MetaType* xtarget, size_t pos,
|
||||||
|
const std::tuple<std::shared_ptr<Ranges>...>& stp, size_t off)
|
||||||
|
{
|
||||||
|
//constexpr size_t NN = sizeof...(Ranges);
|
||||||
|
auto& r = *std::get<N>(stp);
|
||||||
|
const size_t ownPos = pos % r.size();
|
||||||
|
const size_t s = r.cmetaSize();
|
||||||
|
off -= s;
|
||||||
|
r.cmeta(reinterpret_cast<char*>(&std::get<N>(*xtarget)), ownPos);
|
||||||
|
if constexpr(N != 0){
|
||||||
|
return s + getCMeta<N-1>(xtarget, (pos - ownPos) / r.size(), stp, off);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(off == 0);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t N, class... Ranges>
|
||||||
|
inline size_t getCMetaSize(const std::tuple<std::shared_ptr<Ranges>...>& stp)
|
||||||
|
{
|
||||||
|
auto& r = *std::get<N>(stp);
|
||||||
|
if constexpr(N < sizeof...(Ranges)-1){
|
||||||
|
return r.cmetaSize() + getCMetaSize<N+1>(stp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return r.cmetaSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t N, class MIndex>
|
||||||
|
inline std::string getStringMeta(const MIndex& mi)
|
||||||
|
{
|
||||||
|
if constexpr(N < MIndex::sDim()-1){
|
||||||
|
return mi.template getPtr<N>()->stringMeta() + "," + getStringMeta<N+1>(mi);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return mi.template getPtr<N>()->stringMeta();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Index>
|
||||||
|
inline size_t getStepSize(const Index& ii, std::intptr_t j);
|
||||||
|
|
||||||
|
template <size_t N, class Index>
|
||||||
|
inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx)
|
||||||
|
{
|
||||||
|
const auto& ni = ii.template get<N>();
|
||||||
|
const size_t max = ni.max();
|
||||||
|
const size_t tmp = getStepSize(ni, j);
|
||||||
|
ss += tmp * ii.template getBlockSize<N+1>();
|
||||||
|
sx *= max;
|
||||||
|
if constexpr(N != 0){
|
||||||
|
getStepSizeX<N-1>(ii, j, ss, sx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Index>
|
||||||
|
inline size_t getStepSize(const Index& ii, std::intptr_t j)
|
||||||
|
{
|
||||||
|
constexpr IndexType IT = Index::sType();
|
||||||
|
if constexpr(IT == IndexType::SINGLE){
|
||||||
|
const std::intptr_t ip = reinterpret_cast<std::intptr_t>(&ii);
|
||||||
|
return ip == j ? 1 : 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
size_t ss = 0;
|
||||||
|
size_t sx = 1;
|
||||||
|
constexpr size_t DIM = Index::sDim();
|
||||||
|
getStepSizeX<DIM-1>(ii, j, ss, sx);
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <size_t N, size_t SIZE, class Range, class... Ranges>
|
||||||
|
inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec)
|
||||||
|
{
|
||||||
|
if constexpr(N != 0){
|
||||||
|
return rbvec[SIZE-N-1]->spaceType() == Range::STYPE and compareSpaceTypes<N-1,SIZE,Ranges...>(rbvec);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return rbvec[SIZE-N-1]->spaceType() == Range::STYPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t N, class... Ranges>
|
||||||
|
inline void setSpace(const vector<std::shared_ptr<RangeBase> >& rbvec,
|
||||||
|
std::tuple<std::shared_ptr<Ranges>...>& stp)
|
||||||
|
{
|
||||||
|
typedef typename std::remove_reference<decltype(*std::get<N>( stp ))>::type RType;
|
||||||
|
std::get<N>( stp ) = std::dynamic_pointer_cast<RType>( rbvec[N] );
|
||||||
|
if constexpr(N != 0){
|
||||||
|
setSpace<N-1>(rbvec, stp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace RangeHelper
|
} // namespace RangeHelper
|
||||||
} // namespace MultiArrayTools
|
} // namespace MultiArrayTools
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include "rpack_num.cc.h"
|
|
||||||
#include "ranges/dynamic_range.cc.h"
|
#include "ranges/dynamic_range.cc.h"
|
||||||
#include "ranges/index_wrapper.cc.h"
|
#include "ranges/index_wrapper.cc.h"
|
||||||
|
|
|
@ -1,210 +0,0 @@
|
||||||
|
|
||||||
#include "rpack_num.h"
|
|
||||||
|
|
||||||
namespace MultiArrayHelper
|
|
||||||
{
|
|
||||||
using namespace MultiArrayTools;
|
|
||||||
|
|
||||||
template <class Index1>
|
|
||||||
size_t mkTotalDim()
|
|
||||||
{
|
|
||||||
return Index1::totalDim();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Index1, class Index2, class... Indices>
|
|
||||||
size_t mkTotalDim()
|
|
||||||
{
|
|
||||||
return Index1::totalDim() * mkTotalDim<Index2,Indices...>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
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 <class Range>
|
|
||||||
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
|
||||||
std::shared_ptr<Range> r)
|
|
||||||
{
|
|
||||||
v.insert(v.begin(), r);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class... Indices>
|
|
||||||
inline size_t RPackNum<N>::makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
|
|
||||||
const std::array<size_t,sizeof...(Indices)+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... Indices>
|
|
||||||
size_t RPackNum<N>::blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack)
|
|
||||||
{
|
|
||||||
return std::get<sizeof...(Indices)-N>(pack)->max() * RPackNum<N-1>::blockSize(pack);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class Index>
|
|
||||||
inline void RPackNum<N>::getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx)
|
|
||||||
{
|
|
||||||
//constexpr size_t DIM = Index::sDim();
|
|
||||||
const auto& ni = ii.template get<N>();
|
|
||||||
const size_t max = ni.max();
|
|
||||||
const size_t tmp = getStepSize(ni, j);
|
|
||||||
//ss += tmp * sx;
|
|
||||||
ss += tmp * ii.template getBlockSize<N+1>();
|
|
||||||
sx *= max;
|
|
||||||
RPackNum<N-1>::getStepSizeX(ii, j, ss, sx);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class MIndex>
|
|
||||||
inline std::string RPackNum<N>::getStringMeta(const MIndex& mi)
|
|
||||||
{
|
|
||||||
return RPackNum<N-1>::getStringMeta(mi) + "," + mi.template getPtr<N>()->stringMeta();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <size_t SIZE, class Range, class... Ranges>
|
|
||||||
inline bool RPackNum<N>::compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec)
|
|
||||||
{
|
|
||||||
return rbvec[SIZE-N-1]->spaceType() == Range::STYPE and RPackNum<N-1>::template compareSpaceTypes<SIZE,Ranges...>(rbvec);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class... Ranges>
|
|
||||||
inline void RPackNum<N>::setSpace(const vector<std::shared_ptr<RangeBase> >& rbvec,
|
|
||||||
std::tuple<std::shared_ptr<Ranges>...>& stp)
|
|
||||||
{
|
|
||||||
typedef typename std::remove_reference<decltype(*std::get<N>( stp ))>::type RType;
|
|
||||||
std::get<N>( stp ) = std::dynamic_pointer_cast<RType>( rbvec[N] );
|
|
||||||
RPackNum<N-1>::setSpace(rbvec, stp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class MetaType, class... Ranges>
|
|
||||||
inline size_t RPackNum<N>::getCMeta(MetaType* xtarget, size_t pos,
|
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& stp, size_t off)
|
|
||||||
{
|
|
||||||
//constexpr size_t NN = sizeof...(Ranges);
|
|
||||||
auto& r = *std::get<N>(stp);
|
|
||||||
const size_t ownPos = pos % r.size();
|
|
||||||
const size_t s = r.cmetaSize();
|
|
||||||
off -= s;
|
|
||||||
r.cmeta(reinterpret_cast<char*>(&std::get<N>(*xtarget)), ownPos);
|
|
||||||
return s + RPackNum<N-1>::getCMeta(xtarget, (pos - ownPos) / r.size(), stp, off);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
template <class... Ranges>
|
|
||||||
inline size_t RPackNum<N>::getCMetaSize(const std::tuple<std::shared_ptr<Ranges>...>& stp)
|
|
||||||
{
|
|
||||||
constexpr size_t NN = sizeof...(Ranges);
|
|
||||||
auto& r = *std::get<NN-N-1>(stp);
|
|
||||||
return r.cmetaSize() + RPackNum<N-1>::getCMetaSize(stp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <class... Indices>
|
|
||||||
inline size_t RPackNum<0>::makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
|
|
||||||
const std::array<size_t,sizeof...(Indices)+1>& blockSize)
|
|
||||||
{
|
|
||||||
return std::get<0>(iPtrTup)->pos() * std::get<1>(blockSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class... Indices>
|
|
||||||
size_t RPackNum<0>::blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Index>
|
|
||||||
inline void RPackNum<0>::getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx)
|
|
||||||
{
|
|
||||||
//constexpr size_t DIM = Index::sDim();
|
|
||||||
const auto& ni = ii.template get<0>();
|
|
||||||
const size_t max = ni.max();
|
|
||||||
const size_t tmp = getStepSize(ni, j);
|
|
||||||
//ss += tmp * sx;
|
|
||||||
ss += tmp * ii.template getBlockSize<1>();
|
|
||||||
sx *= max;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MIndex>
|
|
||||||
inline std::string RPackNum<0>::getStringMeta(const MIndex& mi)
|
|
||||||
{
|
|
||||||
return mi.template getPtr<0>()->stringMeta();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t SIZE, class Range>
|
|
||||||
inline bool RPackNum<0>::compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec)
|
|
||||||
{
|
|
||||||
return rbvec[SIZE-1]->spaceType() == Range::STYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
inline void RPackNum<0>::setSpace(const vector<std::shared_ptr<RangeBase> >& rbvec,
|
|
||||||
std::tuple<std::shared_ptr<Ranges>...>& stp)
|
|
||||||
{
|
|
||||||
typedef typename std::remove_reference<decltype(*std::get<0>( stp ))>::type RType;
|
|
||||||
std::get<0>( stp ) = std::dynamic_pointer_cast<RType>( rbvec[0] );
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MetaType, class... Ranges>
|
|
||||||
inline size_t RPackNum<0>::getCMeta(MetaType* xtarget, size_t pos,
|
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& stp, size_t off)
|
|
||||||
{
|
|
||||||
//constexpr size_t NN = sizeof...(Ranges);
|
|
||||||
auto& r = *std::get<0>(stp);
|
|
||||||
const size_t ownPos = pos % r.size();
|
|
||||||
const size_t s = r.cmetaSize();
|
|
||||||
off -= s;
|
|
||||||
assert(off == 0);
|
|
||||||
r.cmeta(reinterpret_cast<char*>(&std::get<0>(*xtarget)), ownPos);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
inline size_t RPackNum<0>::getCMetaSize(const std::tuple<std::shared_ptr<Ranges>...>& stp)
|
|
||||||
{
|
|
||||||
constexpr size_t NN = sizeof...(Ranges);
|
|
||||||
auto& r = *std::get<NN-1>(stp);
|
|
||||||
return r.cmetaSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <IndexType IT>
|
|
||||||
template <class Index>
|
|
||||||
inline size_t SSG<IT>::getStepSize(const Index& ii, std::intptr_t j)
|
|
||||||
{
|
|
||||||
size_t ss = 0;
|
|
||||||
size_t sx = 1;
|
|
||||||
constexpr size_t DIM = Index::sDim();
|
|
||||||
RPackNum<DIM-1>::getStepSizeX(ii, j, ss, sx);
|
|
||||||
return ss;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Index>
|
|
||||||
inline size_t SSG<IndexType::SINGLE>::getStepSize(const Index& ii, std::intptr_t j)
|
|
||||||
{
|
|
||||||
const std::intptr_t ip = reinterpret_cast<std::intptr_t>(&ii);
|
|
||||||
return ip == j ? 1 : 0;
|
|
||||||
//return ii.ptrNum() == j ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Index>
|
|
||||||
inline size_t getStepSize(const Index& ii, std::intptr_t j)
|
|
||||||
{
|
|
||||||
constexpr IndexType IT = Index::sType();
|
|
||||||
return SSG<IT>::getStepSize(ii, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace MultiArrayHelper
|
|
|
@ -1,188 +0,0 @@
|
||||||
|
|
||||||
#ifndef __rpack_num_h__
|
|
||||||
#define __rpack_num_h__
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include "ranges/rbase_def.h"
|
|
||||||
#include "ranges/index_base.h"
|
|
||||||
#include "ranges/x_to_string.h"
|
|
||||||
|
|
||||||
namespace MultiArrayHelper
|
|
||||||
{
|
|
||||||
using namespace MultiArrayTools;
|
|
||||||
|
|
||||||
template <size_t I, class... Indices>
|
|
||||||
int ppx(std::tuple<std::shared_ptr<Indices>...>& ip,
|
|
||||||
std::array<size_t,sizeof...(Indices)+1>& bs,
|
|
||||||
std::intptr_t idxPtrNum)
|
|
||||||
{
|
|
||||||
auto& siPtr = std::get<I>(ip);
|
|
||||||
if(reinterpret_cast<std::intptr_t>(siPtr.get()) == idxPtrNum){
|
|
||||||
if constexpr(I != 0){
|
|
||||||
return ppx<I-1>(ip, bs, idxPtrNum);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return std::get<0>(bs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const int tmp = siPtr->pp(idxPtrNum);
|
|
||||||
if constexpr(I != 0){
|
|
||||||
if(siPtr->pos() == siPtr->max()){
|
|
||||||
(*siPtr) = 0;
|
|
||||||
return ppx<I-1>(ip, bs, idxPtrNum) - siPtr->max() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tmp * std::get<I+1>(bs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t I, class... Indices>
|
|
||||||
int mmx(std::tuple<std::shared_ptr<Indices>...>& ip,
|
|
||||||
std::array<size_t,sizeof...(Indices)+1>& bs,
|
|
||||||
std::intptr_t idxPtrNum)
|
|
||||||
{
|
|
||||||
auto& siPtr = std::get<I>(ip);
|
|
||||||
if(reinterpret_cast<std::intptr_t>(siPtr.get()) == idxPtrNum){
|
|
||||||
if constexpr(I != 0){
|
|
||||||
return mmx<I-1>(ip, bs, idxPtrNum);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return std::get<0>(bs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const int tmp = siPtr->mm(idxPtrNum);
|
|
||||||
if constexpr(I != 0){
|
|
||||||
if(siPtr->pos() == siPtr->max()){
|
|
||||||
(*siPtr) = siPtr->max() - 1;
|
|
||||||
return mmx<I-1>(ip, bs, idxPtrNum) - siPtr->max() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tmp * std::get<I+1>(bs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Index1>
|
|
||||||
size_t mkTotalDim();
|
|
||||||
|
|
||||||
template <class Index1, class Index2, class... Indices>
|
|
||||||
size_t mkTotalDim();
|
|
||||||
|
|
||||||
|
|
||||||
template <class RangeType, class... Ranges>
|
|
||||||
struct SubProp
|
|
||||||
{
|
|
||||||
static constexpr size_t ISSTATIC = RangeType::ISSTATIC & SubProp<Ranges...>::ISSTATIC;
|
|
||||||
static constexpr size_t SIZE = RangeType::SIZE * SubProp<Ranges...>::SIZE;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct SubProp<None>
|
|
||||||
{
|
|
||||||
static constexpr size_t ISSTATIC = 1;
|
|
||||||
static constexpr size_t SIZE = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class Index>
|
|
||||||
inline size_t getStepSize(const Index& ii, std::intptr_t j);
|
|
||||||
|
|
||||||
|
|
||||||
template <class Range>
|
|
||||||
inline void resolveSetRange(std::shared_ptr<Range>& rp, const vector<std::shared_ptr<RangeBase> >& orig,
|
|
||||||
size_t origpos, size_t size);
|
|
||||||
|
|
||||||
template <class Range>
|
|
||||||
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
|
||||||
std::shared_ptr<Range> r);
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
struct RPackNum
|
|
||||||
{
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
template <class... Indices>
|
|
||||||
static size_t blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack);
|
|
||||||
|
|
||||||
|
|
||||||
template <class Index>
|
|
||||||
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);
|
|
||||||
|
|
||||||
template <class MIndex>
|
|
||||||
static inline std::string getStringMeta(const MIndex& mi);
|
|
||||||
|
|
||||||
template <size_t SIZE, class Range, class... Ranges>
|
|
||||||
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec);
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline void setSpace(const vector<std::shared_ptr<RangeBase> >& rbvec,
|
|
||||||
std::tuple<std::shared_ptr<Ranges>...>& stp);
|
|
||||||
|
|
||||||
template <class MetaType, class... Ranges>
|
|
||||||
static inline size_t getCMeta(MetaType* xtarget, size_t pos,
|
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& stp, size_t off);
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline size_t getCMetaSize(const std::tuple<std::shared_ptr<Ranges>...>& stp);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct RPackNum<0>
|
|
||||||
{
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
template <class... Indices>
|
|
||||||
static size_t blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack);
|
|
||||||
|
|
||||||
template <class Index>
|
|
||||||
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);
|
|
||||||
|
|
||||||
template <class MIndex>
|
|
||||||
static inline std::string getStringMeta(const MIndex& mi);
|
|
||||||
|
|
||||||
template <size_t SIZE, class Range>
|
|
||||||
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec);
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline void setSpace(const vector<std::shared_ptr<RangeBase> >& rbvec,
|
|
||||||
std::tuple<std::shared_ptr<Ranges>...>& stp);
|
|
||||||
|
|
||||||
template <class MetaType, class... Ranges>
|
|
||||||
static inline size_t getCMeta(MetaType* xtarget, size_t pos,
|
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& stp, size_t off);
|
|
||||||
|
|
||||||
template <class... Ranges>
|
|
||||||
static inline size_t getCMetaSize(const std::tuple<std::shared_ptr<Ranges>...>& stp);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template <IndexType IT>
|
|
||||||
struct SSG
|
|
||||||
{
|
|
||||||
template <class Index>
|
|
||||||
static inline size_t getStepSize(const Index& ii, std::intptr_t j);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct SSG<IndexType::SINGLE>
|
|
||||||
{
|
|
||||||
template <class Index>
|
|
||||||
static inline size_t getStepSize(const Index& ii, std::intptr_t j);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace MultiArrayHelper
|
|
||||||
|
|
||||||
//#include "rpack_num.cc.h"
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -9,16 +9,12 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "base_def.h"
|
#include "base_def.h"
|
||||||
//#include "ranges/rpack_num.h"
|
|
||||||
#include "ranges/index_base.h"
|
#include "ranges/index_base.h"
|
||||||
#include "ranges/range_base.h"
|
#include "ranges/range_base.h"
|
||||||
#include "ranges/x_to_string.h"
|
#include "ranges/x_to_string.h"
|
||||||
#include "ranges/type_map.h"
|
#include "ranges/type_map.h"
|
||||||
|
|
||||||
#include "xfor/for_type.h"
|
#include "xfor/for_type.h"
|
||||||
//#include "xfor/xfor.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "base_def.h"
|
#include "base_def.h"
|
||||||
//#include "ranges/rpack_num.h"
|
|
||||||
#include "ranges/index_base.h"
|
#include "ranges/index_base.h"
|
||||||
#include "ranges/range_base.h"
|
#include "ranges/range_base.h"
|
||||||
#include "ranges/x_to_string.h"
|
#include "ranges/x_to_string.h"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "ranges/range_base.h"
|
#include "ranges/range_base.h"
|
||||||
#include "ranges/ranges_header.cc.h"
|
#include "ranges/ranges_header.cc.h"
|
||||||
|
#include "ranges/range_helper.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -23,8 +24,7 @@ namespace MultiArrayTools
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
inline bool compareSpaceTypes(const RVEC& rvec)
|
inline bool compareSpaceTypes(const RVEC& rvec)
|
||||||
{
|
{
|
||||||
return RPackNum<sizeof...(Ranges)-1>::
|
return RangeHelper::compareSpaceTypes<sizeof...(Ranges)-1,sizeof...(Ranges),Ranges...>(rvec);
|
||||||
template compareSpaceTypes<sizeof...(Ranges),Ranges...>(rvec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
|
@ -32,7 +32,7 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
if(compareSpaceTypes<Ranges...>(rvec)) {
|
if(compareSpaceTypes<Ranges...>(rvec)) {
|
||||||
STP<Ranges...> stp;
|
STP<Ranges...> stp;
|
||||||
RPackNum<sizeof...(Ranges)-1>::setSpace(rvec, stp);
|
RangeHelper::setSpace<sizeof...(Ranges)-1>(rvec, stp);
|
||||||
fptr = std::make_shared<MultiRangeFactory<Ranges...> >(stp);
|
fptr = std::make_shared<MultiRangeFactory<Ranges...> >(stp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue