map range: allow more general out ranges

This commit is contained in:
Christian Zimmermann 2021-01-09 00:45:24 +01:00
parent b8071fff94
commit cfb3d4919b
7 changed files with 192 additions and 195 deletions

View file

@ -99,18 +99,18 @@ namespace MultiArrayTools
template <SpaceType STYPE, class Op, class MA, class... RangeTypes> template <SpaceType STYPE, class Op, class MA, class... RangeTypes>
auto mkGenMapR(const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges) auto mkGenMapR(const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges)
-> std::shared_ptr<GenMapRange<Op,STYPE,RangeTypes...> > -> std::shared_ptr<GenMapRange<MapORType<Op,STYPE>,Op,STYPE,RangeTypes...> >
{ {
GenMapRangeFactory<Op,STYPE,RangeTypes...> mrf(f, ranges... ); GenMapRangeFactory<MapORType<Op,STYPE>,Op,STYPE,RangeTypes...> mrf(f, ranges... );
return createExplicit( mrf ); return createExplicit( mrf );
} }
template <SpaceType STYPE, class Op, class MA, class... RangeTypes> template <SpaceType STYPE, class ORType, class Op, class MA, class... RangeTypes>
auto mkGenMapRwith(const std::shared_ptr<MapORType<Op,STYPE>>& outr, const std::tuple<Op,MA>& f, auto mkGenMapRwith(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& f,
std::shared_ptr<RangeTypes>... ranges) std::shared_ptr<RangeTypes>... ranges)
-> std::shared_ptr<GenMapRange<Op,STYPE,RangeTypes...> > -> std::shared_ptr<GenMapRange<ORType,Op,STYPE,RangeTypes...> >
{ {
GenMapRangeFactory<Op,STYPE,RangeTypes...> mrf(outr, f, ranges... ); GenMapRangeFactory<ORType,Op,STYPE,RangeTypes...> mrf(outr, f, ranges... );
return createExplicit( mrf ); return createExplicit( mrf );
} }
@ -130,8 +130,8 @@ namespace MultiArrayTools
return mkGenMapR<SpaceType::ANY>(f, ranges... ); return mkGenMapR<SpaceType::ANY>(f, ranges... );
} }
template <class Op, class MA, class... RangeTypes> template <class ORType, class Op, class MA, class... RangeTypes>
auto mkMapRwith(const std::shared_ptr<MapORType<Op,SpaceType::ANY>>& outr, const std::tuple<Op,MA>& f, auto mkMapRwith(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& f,
std::shared_ptr<RangeTypes>... ranges) std::shared_ptr<RangeTypes>... ranges)
-> decltype( mkGenMapRwith<SpaceType::ANY>(outr, f, ranges... ) ) -> decltype( mkGenMapRwith<SpaceType::ANY>(outr, f, ranges... ) )
{ {
@ -145,8 +145,8 @@ namespace MultiArrayTools
return mkMapR( mkMapOp( func, is... ), is->range()... ); return mkMapR( mkMapOp( func, is... ), is->range()... );
} }
template <class TarRange, class Func, class... Indices> template <class ORType, class Func, class... Indices>
auto mkMapRwith(const std::shared_ptr<MapORType<Func,SpaceType::ANY>>& outr, const std::shared_ptr<Func>& func, const std::shared_ptr<Indices>&... is) auto mkMapRwith(const std::shared_ptr<ORType>& outr, const std::shared_ptr<Func>& func, const std::shared_ptr<Indices>&... is)
-> decltype( mkMapRwith(outr, mkMapOp( func, is... ), is->range()... ) ) -> decltype( mkMapRwith(outr, mkMapOp( func, is... ), is->range()... ) )
{ {
return mkMapRwith(outr, mkMapOp( func, is... ), is->range()... ); return mkMapRwith(outr, mkMapOp( func, is... ), is->range()... );

View file

@ -28,17 +28,17 @@ namespace MultiArrayTools
auto mkMulti(std::shared_ptr<RangeTypes>... ranges) auto mkMulti(std::shared_ptr<RangeTypes>... ranges)
-> std::shared_ptr<MultiRange<RangeTypes...> >; -> std::shared_ptr<MultiRange<RangeTypes...> >;
template <SpaceType STYPE, class Op, class MA, class... RangeTypes>
auto mkGenMapR(const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges)
-> std::shared_ptr<GenMapRange<Op,STYPE,RangeTypes...> >;
template <class Op, SpaceType XSTYPE> template <class Op, SpaceType XSTYPE>
using MapORType = SingleRange<typename Op::value_type,XSTYPE>; using MapORType = SingleRange<typename Op::value_type,XSTYPE>;
template <SpaceType STYPE, class Op, class MA, class... RangeTypes> template <SpaceType STYPE, class Op, class MA, class... RangeTypes>
auto mkGenMapRwith(const std::shared_ptr<MapORType<Op,STYPE>>& outr, const std::tuple<Op,MA>& f, auto mkGenMapR(const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges)
-> std::shared_ptr<GenMapRange<MapORType<Op,STYPE>,Op,STYPE,RangeTypes...> >;
template <SpaceType STYPE, class ORType, class Op, class MA, class... RangeTypes>
auto mkGenMapRwith(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& f,
std::shared_ptr<RangeTypes>... ranges) std::shared_ptr<RangeTypes>... ranges)
-> std::shared_ptr<GenMapRange<Op,STYPE,RangeTypes...> >; -> std::shared_ptr<GenMapRange<ORType,Op,STYPE,RangeTypes...> >;
template <SpaceType STYPE, class Op, class MA, class... IndexTypes> template <SpaceType STYPE, class Op, class MA, class... IndexTypes>
auto mkGenMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices) auto mkGenMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices)
@ -48,23 +48,18 @@ namespace MultiArrayTools
auto mkMapR(const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges) auto mkMapR(const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges)
-> decltype( mkGenMapR<SpaceType::ANY>(f, ranges... ) ); -> decltype( mkGenMapR<SpaceType::ANY>(f, ranges... ) );
template <class Op, class MA, class... RangeTypes> template <class ORType, class Op, class MA, class... RangeTypes>
auto mkMapRwith(const std::shared_ptr<MapORType<Op,SpaceType::ANY>>& outr, const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges) auto mkMapRwith(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges)
-> decltype( mkGenMapRwith<SpaceType::ANY>(outr, f, ranges... ) ); -> decltype( mkGenMapRwith<SpaceType::ANY>(outr, f, ranges... ) );
template <class Func, class... Indices> template <class Func, class... Indices>
auto mkMapR(const std::shared_ptr<Func>& func, const std::shared_ptr<Indices>&... is) auto mkMapR(const std::shared_ptr<Func>& func, const std::shared_ptr<Indices>&... is)
-> decltype( mkMapR( mkMapOp( func, is... ), is->range()... ) ); -> decltype( mkMapR( mkMapOp( func, is... ), is->range()... ) );
template <class TarRange, class Func, class... Indices> template <class ORType, class Func, class... Indices>
auto mkMapRwith(const std::shared_ptr<MapORType<Func,SpaceType::ANY>>& outr, const std::shared_ptr<Func>& func, const std::shared_ptr<Indices>&... is) auto mkMapRwith(const std::shared_ptr<ORType>& outr, const std::shared_ptr<Func>& func, const std::shared_ptr<Indices>&... is)
-> decltype( mkMapRwith(outr, mkMapOp( func, is... ), is->range()... ) ); -> decltype( mkMapRwith(outr, mkMapOp( func, is... ), is->range()... ) );
template <class Op, class MA, class... RangeTypes>
auto mkMapRwith(const std::shared_ptr<MapORType<Op,SpaceType::ANY>>& outr, const std::tuple<Op,MA>& f,
std::shared_ptr<RangeTypes>... ranges)
-> decltype( mkGenMapRwith<SpaceType::ANY>(outr, f, ranges... ) );
template <class Op, class MA, class... IndexTypes> template <class Op, class MA, class... IndexTypes>
auto mkMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices) auto mkMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices)
-> decltype( mkGenMapI<SpaceType::ANY>(f, indices... ) ); -> decltype( mkGenMapI<SpaceType::ANY>(f, indices... ) );

View file

@ -90,10 +90,10 @@ namespace MultiArrayTools
} }
*/ */
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <class MRange> template <class MRange>
GenMapIndex<Op,XSTYPE,Indices...>::GenMapIndex(const std::shared_ptr<MRange>& range) : GenMapIndex<OIType,Op,XSTYPE,Indices...>::GenMapIndex(const std::shared_ptr<MRange>& range) :
IndexInterface<GenMapIndex<Op,XSTYPE,Indices...>,typename Op::value_type>(range, 0) IndexInterface<GenMapIndex<OIType,Op,XSTYPE,Indices...>,typename Op::value_type>(range, 0)
{ {
RPackNum<sizeof...(Indices)-1>::construct(mIPack, *range); RPackNum<sizeof...(Indices)-1>::construct(mIPack, *range);
IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack); IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack);
@ -103,9 +103,9 @@ namespace MultiArrayTools
( std::dynamic_pointer_cast<RangeType>( IB::mRangePtr )->outRange()->begin() ); ( std::dynamic_pointer_cast<RangeType>( IB::mRangePtr )->outRange()->begin() );
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t DIR> template <size_t DIR>
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::up() GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::up()
{ {
static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices"); static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices");
IB::mPos += RPackNum<sizeof...(Indices)-DIR-1>::blockSize( mIPack ); IB::mPos += RPackNum<sizeof...(Indices)-DIR-1>::blockSize( mIPack );
@ -113,9 +113,9 @@ namespace MultiArrayTools
return *this; return *this;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t DIR> template <size_t DIR>
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::down() GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::down()
{ {
static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices"); static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices");
IB::mPos -= RPackNum<sizeof...(Indices)-DIR-1>::blockSize( mIPack ); IB::mPos -= RPackNum<sizeof...(Indices)-DIR-1>::blockSize( mIPack );
@ -123,42 +123,42 @@ namespace MultiArrayTools
return *this; return *this;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t N> template <size_t N>
auto GenMapIndex<Op,XSTYPE,Indices...>::get() const -> decltype( *std::get<N>( mIPack ) )& auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::get() const -> decltype( *std::get<N>( mIPack ) )&
{ {
return *std::get<N>(mIPack); return *std::get<N>(mIPack);
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t N> template <size_t N>
auto GenMapIndex<Op,XSTYPE,Indices...>::getPtr() const -> decltype( std::get<N>( mIPack ) )& auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::getPtr() const -> decltype( std::get<N>( mIPack ) )&
{ {
return std::get<N>(mIPack); return std::get<N>(mIPack);
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
auto GenMapIndex<Op,XSTYPE,Indices...>::outIndex() const -> std::shared_ptr<OIType> auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::outIndex() const -> std::shared_ptr<OIType>
{ {
return mOutIndex; return mOutIndex;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<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>::swapIndices(mIPack, indices...);
RPackNum<sizeof...(Indices)-1>::setIndexPack(mIPack, IB::mPos); RPackNum<sizeof...(Indices)-1>::setIndexPack(mIPack, IB::mPos);
return *this; return *this;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
IndexType GenMapIndex<Op,XSTYPE,Indices...>::type() const IndexType GenMapIndex<OIType,Op,XSTYPE,Indices...>::type() const
{ {
return IndexType::MULTI; return IndexType::MULTI;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::operator=(size_t pos) GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator=(size_t pos)
{ {
(*mOutIndex) = pos; (*mOutIndex) = pos;
IB::mPos = mOutIndex->pos(); IB::mPos = mOutIndex->pos();
@ -166,8 +166,8 @@ namespace MultiArrayTools
return *this; return *this;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::operator++() GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator++()
{ {
//RPackNum<sizeof...(Indices)-1>::pp( mIPack ); //RPackNum<sizeof...(Indices)-1>::pp( mIPack );
++(*mOutIndex); ++(*mOutIndex);
@ -175,8 +175,8 @@ namespace MultiArrayTools
return *this; return *this;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::operator--() GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator--()
{ {
//RPackNum<sizeof...(Indices)-1>::mm( mIPack ); //RPackNum<sizeof...(Indices)-1>::mm( mIPack );
--(*mOutIndex); --(*mOutIndex);
@ -184,8 +184,8 @@ namespace MultiArrayTools
return *this; return *this;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
int GenMapIndex<Op,XSTYPE,Indices...>::pp(std::intptr_t idxPtrNum) int GenMapIndex<OIType,Op,XSTYPE,Indices...>::pp(std::intptr_t idxPtrNum)
{ {
//int tmp = RPackNum<sizeof...(Indices)-1>::pp(mIPack, mBlockSizes, idxPtrNum); //int tmp = RPackNum<sizeof...(Indices)-1>::pp(mIPack, mBlockSizes, idxPtrNum);
mOutIndex->pp(idxPtrNum); mOutIndex->pp(idxPtrNum);
@ -194,8 +194,8 @@ namespace MultiArrayTools
return 1; return 1;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
int GenMapIndex<Op,XSTYPE,Indices...>::mm(std::intptr_t idxPtrNum) int GenMapIndex<OIType,Op,XSTYPE,Indices...>::mm(std::intptr_t idxPtrNum)
{ {
//int tmp = RPackNum<sizeof...(Indices)-1>::mm(mIPack, mBlockSizes, idxPtrNum); //int tmp = RPackNum<sizeof...(Indices)-1>::mm(mIPack, mBlockSizes, idxPtrNum);
mOutIndex->mm(idxPtrNum); mOutIndex->mm(idxPtrNum);
@ -204,14 +204,14 @@ namespace MultiArrayTools
return 1; return 1;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
std::string GenMapIndex<Op,XSTYPE,Indices...>::stringMeta() const std::string GenMapIndex<OIType,Op,XSTYPE,Indices...>::stringMeta() const
{ {
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr )->stringMeta(IB::mPos); return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr )->stringMeta(IB::mPos);
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
typename GenMapIndex<Op,XSTYPE,Indices...>::MetaType GenMapIndex<Op,XSTYPE,Indices...>::meta() const typename GenMapIndex<OIType,Op,XSTYPE,Indices...>::MetaType GenMapIndex<OIType,Op,XSTYPE,Indices...>::meta() const
{ {
//MetaType metaTuple; //MetaType metaTuple;
//RPackNum<sizeof...(Indices)-1>::getMetaPos(metaTuple, mIPack); //RPackNum<sizeof...(Indices)-1>::getMetaPos(metaTuple, mIPack);
@ -219,8 +219,8 @@ namespace MultiArrayTools
return mOutIndex->meta(); return mOutIndex->meta();
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::at(const MetaType& metaPos) GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::at(const MetaType& metaPos)
{ {
//RPackNum<sizeof...(Indices)-1>::setMeta(mIPack, metaPos); //RPackNum<sizeof...(Indices)-1>::setMeta(mIPack, metaPos);
//IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack); //IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack);
@ -229,46 +229,46 @@ namespace MultiArrayTools
return *this; return *this;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
size_t GenMapIndex<Op,XSTYPE,Indices...>::posAt(const MetaType& metaPos) const size_t GenMapIndex<OIType,Op,XSTYPE,Indices...>::posAt(const MetaType& metaPos) const
{ {
return range()->outRange()->getMeta(metaPos); return range()->outRange()->getMeta(metaPos);
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
size_t GenMapIndex<Op,XSTYPE,Indices...>::dim() const size_t GenMapIndex<OIType,Op,XSTYPE,Indices...>::dim() const
{ {
return sizeof...(Indices); return sizeof...(Indices);
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
bool GenMapIndex<Op,XSTYPE,Indices...>::first() const bool GenMapIndex<OIType,Op,XSTYPE,Indices...>::first() const
{ {
return IB::mPos == 0; return IB::mPos == 0;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
bool GenMapIndex<Op,XSTYPE,Indices...>::last() const bool GenMapIndex<OIType,Op,XSTYPE,Indices...>::last() const
{ {
return IB::mPos == IB::mMax - 1; return IB::mPos == IB::mMax - 1;
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
std::shared_ptr<typename GenMapIndex<Op,XSTYPE,Indices...>::RangeType> std::shared_ptr<typename GenMapIndex<OIType,Op,XSTYPE,Indices...>::RangeType>
GenMapIndex<Op,XSTYPE,Indices...>::range() const GenMapIndex<OIType,Op,XSTYPE,Indices...>::range() const
{ {
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr ); return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr );
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t N> template <size_t N>
auto GenMapIndex<Op,XSTYPE,Indices...>::getPtr() -> decltype( std::get<N>( mIPack ) )& auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::getPtr() -> decltype( std::get<N>( mIPack ) )&
{ {
return std::get<N>(mIPack); return std::get<N>(mIPack);
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
size_t GenMapIndex<Op,XSTYPE,Indices...>::getStepSize(size_t n) const size_t GenMapIndex<OIType,Op,XSTYPE,Indices...>::getStepSize(size_t n) const
{ {
if(n >= sizeof...(Indices)){ if(n >= sizeof...(Indices)){
assert(0); assert(0);
@ -277,14 +277,14 @@ namespace MultiArrayTools
return mBlockSizes[n+1]; return mBlockSizes[n+1];
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
std::string GenMapIndex<Op,XSTYPE,Indices...>::id() const std::string GenMapIndex<OIType,Op,XSTYPE,Indices...>::id() const
{ {
return std::string("mul") + std::to_string(IB::mId); return std::string("mul") + std::to_string(IB::mId);
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
void GenMapIndex<Op,XSTYPE,Indices...>::print(size_t offset) const void GenMapIndex<OIType,Op,XSTYPE,Indices...>::print(size_t offset) const
{ {
if(offset == 0){ if(offset == 0){
std::cout << " === " << std::endl; std::cout << " === " << std::endl;
@ -295,29 +295,29 @@ namespace MultiArrayTools
RPackNum<sizeof...(Indices)-1>::printIndex(mIPack, offset+1); RPackNum<sizeof...(Indices)-1>::printIndex(mIPack, offset+1);
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <class Exprs> template <class Exprs>
auto GenMapIndex<Op,XSTYPE,Indices...>::ifor(size_t step, Exprs exs) const auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::ifor(size_t step, Exprs exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkForh -> decltype(RPackNum<sizeof...(Indices)-1>::mkForh
(step, mIPack, mBlockSizes, OpExpr<Op,GenMapIndex<Op,XSTYPE,Indices...>,Exprs,XSTYPE> (step, mIPack, mBlockSizes, OpExpr<Op,GenMapIndex<OIType,Op,XSTYPE,Indices...>,Exprs,XSTYPE>
( range()->map(), this, step, exs ) ) ) ( range()->map(), this, step, exs ) ) )
{ {
return RPackNum<sizeof...(Indices)-1>::mkForh return RPackNum<sizeof...(Indices)-1>::mkForh
(0, mIPack, mBlockSizes, OpExpr<Op,GenMapIndex<Op,XSTYPE,Indices...>,Exprs,XSTYPE> (0, mIPack, mBlockSizes, OpExpr<Op,GenMapIndex<OIType,Op,XSTYPE,Indices...>,Exprs,XSTYPE>
( range()->map(), this, step, exs ) ); ( range()->map(), this, step, exs ) );
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <class Exprs> template <class Exprs>
auto GenMapIndex<Op,XSTYPE,Indices...>::pifor(size_t step, Exprs exs) const auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::pifor(size_t step, Exprs exs) const
-> decltype(ifor(step, exs)) -> decltype(ifor(step, exs))
{ {
return ifor(step, exs); return ifor(step, exs);
} }
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <class Exprs> template <class Exprs>
auto GenMapIndex<Op,XSTYPE,Indices...>::iforh(size_t step, Exprs exs) const auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::iforh(size_t step, Exprs exs) const
-> decltype(ifor(step, exs)) -> decltype(ifor(step, exs))
{ {
return ifor(step, exs); return ifor(step, exs);
@ -327,54 +327,54 @@ namespace MultiArrayTools
* MapRangeFactory * * MapRangeFactory *
*************************/ *************************/
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA> template <class MA>
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::shared_ptr<ORType>& outr, GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::shared_ptr<ORType>& outr,
const std::tuple<Op,MA>& mapf, const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... rs) const std::shared_ptr<Ranges>&... rs)
{ {
mProd = std::shared_ptr< GenMapRange<Op,XSTYPE,Ranges...> > mProd = std::shared_ptr< GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( new GenMapRange<Op,XSTYPE,Ranges...>( outr, mapf, rs... ) ); ( new GenMapRange<ORType,Op,XSTYPE,Ranges...>( outr, mapf, rs... ) );
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA> template <class MA>
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::shared_ptr<ORType>& outr, GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::shared_ptr<ORType>& outr,
const std::tuple<Op,MA>& mapf, const std::tuple<Op,MA>& mapf,
const typename GenMapRange<Op,XSTYPE,Ranges...>::Space& st) const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& st)
{ {
mProd = std::shared_ptr< GenMapRange<Op,XSTYPE,Ranges...> > mProd = std::shared_ptr< GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( new GenMapRange<Op,XSTYPE,Ranges...>( outr, mapf, st ) ); ( new GenMapRange<ORType,Op,XSTYPE,Ranges...>( outr, mapf, st ) );
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA> template <class MA>
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf, GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... rs) const std::shared_ptr<Ranges>&... rs)
{ {
mProd = std::shared_ptr< GenMapRange<Op,XSTYPE,Ranges...> > mProd = std::shared_ptr< GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( new GenMapRange<Op,XSTYPE,Ranges...>( mapf, rs... ) ); ( new GenMapRange<ORType,Op,XSTYPE,Ranges...>( mapf, rs... ) );
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA> template <class MA>
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf, GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
const typename GenMapRange<Op,XSTYPE,Ranges...>::Space& st) const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& st)
{ {
mProd = std::shared_ptr< GenMapRange<Op,XSTYPE,Ranges...> > mProd = std::shared_ptr< GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( new GenMapRange<Op,XSTYPE,Ranges...>( mapf, st ) ); ( new GenMapRange<ORType,Op,XSTYPE,Ranges...>( mapf, st ) );
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
std::shared_ptr<RangeBase> GenMapRangeFactory<Op,XSTYPE,Ranges...>::create() std::shared_ptr<RangeBase> GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::create()
{ {
mProd = checkIfCreated( std::dynamic_pointer_cast<oType>( mProd )->mSpace ); mProd = checkIfCreated( std::dynamic_pointer_cast<oType>( mProd )->mSpace );
setSelf(); setSelf();
return mProd; return mProd;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
std::shared_ptr<RangeBase> GenMapRangeFactory<Op,XSTYPE,Ranges...>::checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& ptp) std::shared_ptr<RangeBase> GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& ptp)
{ {
std::shared_ptr<RangeBase> out; std::shared_ptr<RangeBase> out;
bool check = false; bool check = false;
@ -463,9 +463,9 @@ namespace MultiArrayTools
} }
}; };
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA> template <class MA>
void GenMapRange<Op,XSTYPE,Ranges...>::mkOutRange(const MA& mapf) void GenMapRange<ORType,Op,XSTYPE,Ranges...>::mkOutRange(const MA& mapf)
{ {
//FunctionalMultiArray<typename MapF::value_type,MapF,Ranges...> fma(mSpace, mMapf); //FunctionalMultiArray<typename MapF::value_type,MapF,Ranges...> fma(mSpace, mMapf);
OutRangeMaker<XSTYPE>::mk(mOutRange,mMapMult,mapf); OutRangeMaker<XSTYPE>::mk(mOutRange,mMapMult,mapf);
@ -477,9 +477,9 @@ namespace MultiArrayTools
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA> template <class MA>
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf, GenMapRange<ORType,Op,XSTYPE,Ranges...>::GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... rs) : const std::shared_ptr<Ranges>&... rs) :
mSpace(std::make_tuple(rs...)), mSpace(std::make_tuple(rs...)),
mMapf(std::get<0>(mapf)), mMapf(std::get<0>(mapf)),
@ -495,9 +495,9 @@ namespace MultiArrayTools
} }
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA> template <class MA>
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf, GenMapRange<ORType,Op,XSTYPE,Ranges...>::GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
const Space& space) : const Space& space) :
mSpace(space), mSpace(space),
mMapf(std::get<0>(mapf)), mMapf(std::get<0>(mapf)),
@ -513,9 +513,9 @@ namespace MultiArrayTools
} }
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA> template <class MA>
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf, GenMapRange<ORType,Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... rs) : const std::shared_ptr<Ranges>&... rs) :
mSpace(std::make_tuple(rs...)), mSpace(std::make_tuple(rs...)),
mMapf(std::get<0>(mapf)) mMapf(std::get<0>(mapf))
@ -523,76 +523,76 @@ namespace MultiArrayTools
mkOutRange(std::get<1>(mapf)); mkOutRange(std::get<1>(mapf));
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA> template <class MA>
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf, const Space& space) : GenMapRange<ORType,Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf, const Space& space) :
mSpace( space ), mSpace( space ),
mMapf(std::get<0>(mapf)) mMapf(std::get<0>(mapf))
{ {
mkOutRange(std::get<1>(mapf)); mkOutRange(std::get<1>(mapf));
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <size_t N> template <size_t N>
auto GenMapRange<Op,XSTYPE,Ranges...>::get() const -> decltype( *std::get<N>( mSpace ) )& auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::get() const -> decltype( *std::get<N>( mSpace ) )&
{ {
return *std::get<N>(mSpace); return *std::get<N>(mSpace);
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <size_t N> template <size_t N>
auto GenMapRange<Op,XSTYPE,Ranges...>::getPtr() const -> decltype( std::get<N>( mSpace ) )& auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::getPtr() const -> decltype( std::get<N>( mSpace ) )&
{ {
return std::get<N>(mSpace); return std::get<N>(mSpace);
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
auto GenMapRange<Op,XSTYPE,Ranges...>::outRange() const -> std::shared_ptr<ORType> auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::outRange() const -> std::shared_ptr<ORType>
{ {
return mOutRange; return mOutRange;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
const Op& GenMapRange<Op,XSTYPE,Ranges...>::map() const const Op& GenMapRange<ORType,Op,XSTYPE,Ranges...>::map() const
{ {
return mMapf; return mMapf;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
size_t GenMapRange<Op,XSTYPE,Ranges...>::dim() const size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::dim() const
{ {
return sdim; return sdim;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
size_t GenMapRange<Op,XSTYPE,Ranges...>::size() const size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::size() const
{ {
return mOutRange->size(); return mOutRange->size();
//return RPackNum<sizeof...(Ranges)-1>::getSize(mSpace); //return RPackNum<sizeof...(Ranges)-1>::getSize(mSpace);
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
SpaceType GenMapRange<Op,XSTYPE,Ranges...>::spaceType() const SpaceType GenMapRange<ORType,Op,XSTYPE,Ranges...>::spaceType() const
{ {
return SpaceType::ANY; return SpaceType::ANY;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
const typename GenMapRange<Op,XSTYPE,Ranges...>::Space& GenMapRange<Op,XSTYPE,Ranges...>::space() const const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& GenMapRange<ORType,Op,XSTYPE,Ranges...>::space() const
{ {
return mSpace; return mSpace;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
vector<size_t> GenMapRange<Op,XSTYPE,Ranges...>::typeNum() const vector<size_t> GenMapRange<ORType,Op,XSTYPE,Ranges...>::typeNum() const
{ {
vector<size_t> o; vector<size_t> o;
RPackNum<sizeof...(Ranges)-1>::getTypeNum(o,mSpace); RPackNum<sizeof...(Ranges)-1>::getTypeNum(o,mSpace);
return o; return o;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
size_t GenMapRange<Op,XSTYPE,Ranges...>::cmeta(char* target, size_t pos) const size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::cmeta(char* target, size_t pos) const
{ {
//MetaType* xtarget = reinterpret_cast<MetaType*>(target); //MetaType* xtarget = reinterpret_cast<MetaType*>(target);
assert(0); assert(0);
@ -600,22 +600,22 @@ namespace MultiArrayTools
//return RPackNum<sizeof...(Ranges)-1>::getCMeta(xtarget,pos,mSpace,cmetaSize()); //return RPackNum<sizeof...(Ranges)-1>::getCMeta(xtarget,pos,mSpace,cmetaSize());
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
size_t GenMapRange<Op,XSTYPE,Ranges...>::cmetaSize() const size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::cmetaSize() const
{ {
return RPackNum<sizeof...(Ranges)-1>::getCMetaSize(mSpace); return RPackNum<sizeof...(Ranges)-1>::getCMetaSize(mSpace);
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
std::string GenMapRange<Op,XSTYPE,Ranges...>::stringMeta(size_t pos) const std::string GenMapRange<ORType,Op,XSTYPE,Ranges...>::stringMeta(size_t pos) const
{ {
auto i = begin(); auto i = begin();
i = pos; i = pos;
return "[ " + RPackNum<sizeof...(Ranges)-1>::getStringMeta(i) + " ]"; return "[ " + RPackNum<sizeof...(Ranges)-1>::getStringMeta(i) + " ]";
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
vector<char> GenMapRange<Op,XSTYPE,Ranges...>::data() const vector<char> GenMapRange<ORType,Op,XSTYPE,Ranges...>::data() const
{ {
DataHeader h = dataHeader(); DataHeader h = dataHeader();
vector<char> out; vector<char> out;
@ -626,8 +626,8 @@ namespace MultiArrayTools
return out; return out;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
DataHeader GenMapRange<Op,XSTYPE,Ranges...>::dataHeader() const DataHeader GenMapRange<ORType,Op,XSTYPE,Ranges...>::dataHeader() const
{ {
DataHeader h; DataHeader h;
h.spaceType = static_cast<int>( SpaceType::ANY ); h.spaceType = static_cast<int>( SpaceType::ANY );
@ -636,56 +636,56 @@ namespace MultiArrayTools
return h; return h;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
typename GenMapRange<Op,XSTYPE,Ranges...>::IndexType GenMapRange<Op,XSTYPE,Ranges...>::begin() const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::IndexType GenMapRange<ORType,Op,XSTYPE,Ranges...>::begin() const
{ {
GenMapIndex<Op,XSTYPE,typename Ranges::IndexType...> GenMapIndex<typename ORType::IndexType,Op,XSTYPE,typename Ranges::IndexType...>
i( std::dynamic_pointer_cast<GenMapRange<Op,XSTYPE,Ranges...> > i( std::dynamic_pointer_cast<GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) ); ( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = 0; i = 0;
return i; return i;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
typename GenMapRange<Op,XSTYPE,Ranges...>::IndexType GenMapRange<Op,XSTYPE,Ranges...>::end() const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::IndexType GenMapRange<ORType,Op,XSTYPE,Ranges...>::end() const
{ {
GenMapIndex<Op,XSTYPE,typename Ranges::IndexType...> GenMapIndex<typename ORType::IndexType,Op,XSTYPE,typename Ranges::IndexType...>
i( std::dynamic_pointer_cast<GenMapRange<Op,XSTYPE,Ranges...> > i( std::dynamic_pointer_cast<GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis )) ); ( std::shared_ptr<RangeBase>( RB::mThis )) );
i = size(); i = size();
return i; return i;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
auto GenMapRange<Op,XSTYPE,Ranges...>::mapMultiplicity() const auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::mapMultiplicity() const
-> const MultiArray<size_t,ORType>& -> const MultiArray<size_t,ORType>&
{ {
return mMapMult; return mMapMult;
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
auto GenMapRange<Op,XSTYPE,Ranges...>::explMapMultiplicity() const auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::explMapMultiplicity() const
-> ConstSlice<size_t,GenMapRange> -> ConstSlice<size_t,GenMapRange>
{ {
/* /*
auto tmp = mMapMult; auto tmp = mMapMult;
return tmp.format( std::dynamic_pointer_cast<GenMapRange<Op,XSTYPE,Ranges...> > return tmp.format( std::dynamic_pointer_cast<GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis )) ); ( std::shared_ptr<RangeBase>( RB::mThis )) );
*/ */
return mMapMult.slformat(std::dynamic_pointer_cast<GenMapRange<Op,XSTYPE,Ranges...> > return mMapMult.slformat(std::dynamic_pointer_cast<GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis ))); ( std::shared_ptr<RangeBase>( RB::mThis )));
} }
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
vector<size_t> GenMapRange<Op,XSTYPE,Ranges...>::mapPos() const vector<size_t> GenMapRange<ORType,Op,XSTYPE,Ranges...>::mapPos() const
{ {
return mMapPos; return mMapPos;
} }
/* /*
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class... ERanges> template <class... ERanges>
auto GenMapRange<Op,XSTYPE,Ranges...>::cat(const std::shared_ptr<MapRange<ERanges...> >& erange) auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::cat(const std::shared_ptr<MapRange<ERanges...> >& erange)
-> std::shared_ptr<GenMapRange<Ranges...,ERanges...> > -> std::shared_ptr<GenMapRange<Ranges...,ERanges...> >
{ {
auto crange = std::tuple_cat(mSpace, erange->space()); auto crange = std::tuple_cat(mSpace, erange->space());

View file

@ -87,26 +87,27 @@ namespace MultiArrayTools
}; };
template <class Op, SpaceType XSTYPE, class... Indices> template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
class GenMapIndex : public IndexInterface<GenMapIndex<Op,XSTYPE,Indices...>, class GenMapIndex : public IndexInterface<GenMapIndex<OIType,Op,XSTYPE,Indices...>,
typename Op::value_type> typename Op::value_type>
//std::tuple<typename Indices::MetaType...> > //std::tuple<typename Indices::MetaType...> >
{ {
public: public:
typedef IndexInterface<GenMapIndex<Op,XSTYPE,Indices...>, typedef IndexInterface<GenMapIndex<OIType,Op,XSTYPE,Indices...>,
typename Op::value_type> IB; typename Op::value_type> IB;
//std::tuple<typename Indices::MetaType...> > IB; //std::tuple<typename Indices::MetaType...> > IB;
typedef std::tuple<std::shared_ptr<Indices>...> IndexPack; typedef std::tuple<std::shared_ptr<Indices>...> IndexPack;
//typedef std::tuple<typename Indices::MetaType...> MetaType; //typedef std::tuple<typename Indices::MetaType...> MetaType;
typedef typename Op::value_type MetaType; typedef typename Op::value_type MetaType;
typedef GenMapRange<Op,XSTYPE,typename Indices::RangeType...> RangeType; typedef GenMapRange<typename OIType::RangeType,Op,XSTYPE,typename Indices::RangeType...> RangeType;
typedef GenMapIndex IType; typedef GenMapIndex IType;
typedef SingleIndex<typename Op::value_type,XSTYPE> OIType; //typedef SingleIndex<typename Op::value_type,XSTYPE> OIType;
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 mkTotalDim<Indices...>(); }
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;
static constexpr bool PARALLEL = false; static constexpr bool PARALLEL = false;
@ -207,12 +208,12 @@ namespace MultiArrayTools
*************************/ *************************/
// NOT THREAD SAVE // NOT THREAD SAVE
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
class GenMapRangeFactory : public RangeFactoryBase class GenMapRangeFactory : public RangeFactoryBase
{ {
public: public:
typedef SingleRange<typename Op::value_type,XSTYPE> ORType; //typedef SingleRange<typename Op::value_type,XSTYPE> ORType;
typedef GenMapRange<Op,XSTYPE,Ranges...> oType; typedef GenMapRange<ORType,Op,XSTYPE,Ranges...> oType;
GenMapRangeFactory() = delete; GenMapRangeFactory() = delete;
@ -222,14 +223,14 @@ namespace MultiArrayTools
template <class MA> template <class MA>
GenMapRangeFactory(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf, GenMapRangeFactory(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
const typename GenMapRange<Op,XSTYPE,Ranges...>::Space& st); const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& st);
template <class MA> template <class MA>
GenMapRangeFactory(const std::tuple<Op,MA>& mapf, const std::shared_ptr<Ranges>&... rs); GenMapRangeFactory(const std::tuple<Op,MA>& mapf, const std::shared_ptr<Ranges>&... rs);
template <class MA> template <class MA>
GenMapRangeFactory(const std::tuple<Op,MA>& mapf, GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
const typename GenMapRange<Op,XSTYPE,Ranges...>::Space& space); const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& space);
virtual std::shared_ptr<RangeBase> create() override; virtual std::shared_ptr<RangeBase> create() override;
@ -243,16 +244,16 @@ namespace MultiArrayTools
* MapRange * * MapRange *
******************/ ******************/
template <class Op, SpaceType XSTYPE, class... Ranges> template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
class GenMapRange : public RangeInterface<GenMapIndex<Op,XSTYPE,typename Ranges::IndexType...> > class GenMapRange : public RangeInterface<GenMapIndex<typename ORType::IndexType,Op,XSTYPE,typename Ranges::IndexType...> >
{ {
public: public:
typedef RangeBase RB; typedef RangeBase RB;
typedef std::tuple<std::shared_ptr<Ranges>...> Space; typedef std::tuple<std::shared_ptr<Ranges>...> Space;
typedef GenMapIndex<Op,XSTYPE,typename Ranges::IndexType...> IndexType; typedef GenMapIndex<typename ORType::IndexType,Op,XSTYPE,typename Ranges::IndexType...> IndexType;
typedef GenMapRange RangeType; //typedef GenMapRange RangeType;
typedef SingleRange<typename Op::value_type,XSTYPE> ORType; //typedef SingleRange<typename Op::value_type,XSTYPE> ORType;
typedef SingleRangeFactory<typename Op::value_type,XSTYPE> ORFType; //typedef SingleRangeFactory<typename Op::value_type,XSTYPE> ORFType;
typedef typename Op::value_type MetaType; typedef typename Op::value_type MetaType;
//typedef typename RangeInterface<MapIndex<typename Ranges::IndexType...> >::IndexType IndexType; //typedef typename RangeInterface<MapIndex<typename Ranges::IndexType...> >::IndexType IndexType;
@ -326,7 +327,7 @@ namespace MultiArrayTools
auto cat(const std::shared_ptr<GenMapRange<ERanges...> >& erange) auto cat(const std::shared_ptr<GenMapRange<ERanges...> >& erange)
-> std::shared_ptr<GenMapRange<Ranges...,ERanges...> >; -> std::shared_ptr<GenMapRange<Ranges...,ERanges...> >;
*/ */
friend GenMapRangeFactory<Op,XSTYPE,Ranges...>; friend GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>;
static constexpr bool HASMETACONT = false; static constexpr bool HASMETACONT = false;
static constexpr bool defaultable = false; static constexpr bool defaultable = false;
@ -335,17 +336,17 @@ namespace MultiArrayTools
}; };
// for legacy // for legacy
template <class Op, class... Indices> template <class OIType, class Op, class... Indices>
using MapIndex = GenMapIndex<Op,SpaceType::ANY,Indices...>; using MapIndex = GenMapIndex<OIType,Op,SpaceType::ANY,Indices...>;
template <class Op, class... Ranges> template <class ORType, class Op, class... Ranges>
using MapRangeFactory = GenMapRangeFactory<Op,SpaceType::ANY,Ranges...>; using MapRangeFactory = GenMapRangeFactory<ORType,Op,SpaceType::ANY,Ranges...>;
template <class Op, class... Ranges> template <class ORType, class Op, class... Ranges>
using MapRange = GenMapRange<Op,SpaceType::ANY,Ranges...>; using MapRange = GenMapRange<ORType,Op,SpaceType::ANY,Ranges...>;
template <class Op, class... Indices> template <class OIType, class Op, class... Indices>
auto mapResult/*<MapIndex<Op,Indices...> >*/(const std::shared_ptr<MapIndex<Op,Indices...> >& ind) auto mapResult/*<MapIndex<Op,Indices...> >*/(const std::shared_ptr<MapIndex<OIType,Op,Indices...> >& ind)
-> decltype(ind->outIndex()) -> decltype(ind->outIndex())
{ {
return ind->outIndex(); return ind->outIndex();

View file

@ -14,7 +14,7 @@ namespace MultiArrayTools
{ {
public: public:
template <class MapF, SpaceType XSTYPE, class... Ranges> template <class ORType, class MapF, SpaceType XSTYPE, class... Ranges>
friend class GenMapRangeFactory; friend class GenMapRangeFactory;
private: private:

View file

@ -79,15 +79,15 @@ namespace MultiArrayTools
class ConstSliceDef; class ConstSliceDef;
// map_range.h // map_range.h
template <class MapF, SpaceType XSTYPE, class... Indices> template <class OITpye, class MapF, SpaceType XSTYPE, class... Indices>
class GenMapIndex; class GenMapIndex;
// map_range.h // map_range.h
template <class MapF, SpaceType XSTYPE, class... Ranges> template <class ORType, class MapF, SpaceType XSTYPE, class... Ranges>
class GenMapRangeFactory; class GenMapRangeFactory;
// map_range.h // map_range.h
template <class MapF, SpaceType XSTYPE, class... Ranges> template <class ORType, class MapF, SpaceType XSTYPE, class... Ranges>
class GenMapRange; class GenMapRange;
} }

View file

@ -55,7 +55,8 @@ namespace
typedef std::remove_reference<decltype(*mkMapR( mkMapOp(std::make_shared<plus<size_t>>(),getIndex(sr1ptr),getIndex(sr2ptr)) , sr1ptr, sr2ptr ))>::type MpRange; typedef std::remove_reference<decltype(*mkMapR( mkMapOp(std::make_shared<plus<size_t>>(),getIndex(sr1ptr),getIndex(sr2ptr)) , sr1ptr, sr2ptr ))>::type MpRange;
std::shared_ptr<MpRange> mpr1ptr; std::shared_ptr<MpRange> mpr1ptr;
typedef MpRange::ORType TRange; //typedef MpRange::ORType TRange;
typedef std::remove_reference<decltype(*mpr1ptr->outRange())>::type TRange;
MapTest() MapTest()
{ {