map range: enable creation on arbitrary target range (of same type with real target space as sub-space)
This commit is contained in:
parent
6ee89f6bff
commit
49dd9ef548
4 changed files with 104 additions and 1 deletions
|
@ -53,6 +53,15 @@ namespace MultiArrayTools
|
||||||
return createExplicit( mrf );
|
return createExplicit( mrf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
std::shared_ptr<RangeTypes>... ranges)
|
||||||
|
-> std::shared_ptr<GenMapRange<Op,STYPE,RangeTypes...> >
|
||||||
|
{
|
||||||
|
GenMapRangeFactory<Op,STYPE,RangeTypes...> mrf(outr, f, ranges... );
|
||||||
|
return createExplicit( mrf );
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
-> decltype( getIndex( mkGenMapR<STYPE>( f, indices->range()... ) ) )
|
-> decltype( getIndex( mkGenMapR<STYPE>( f, indices->range()... ) ) )
|
||||||
|
@ -69,6 +78,14 @@ namespace MultiArrayTools
|
||||||
return mkGenMapR<SpaceType::ANY>(f, ranges... );
|
return mkGenMapR<SpaceType::ANY>(f, ranges... );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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... ) )
|
||||||
|
{
|
||||||
|
return 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... ) )
|
||||||
|
|
|
@ -32,6 +32,14 @@ namespace MultiArrayTools
|
||||||
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<Op,STYPE,RangeTypes...> >;
|
||||||
|
|
||||||
|
template <class Op, SpaceType XSTYPE>
|
||||||
|
using MapORType = SingleRange<typename Op::value_type,XSTYPE>;
|
||||||
|
|
||||||
|
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,
|
||||||
|
std::shared_ptr<RangeTypes>... ranges)
|
||||||
|
-> std::shared_ptr<GenMapRange<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)
|
||||||
-> decltype( getIndex( mkGenMapR<STYPE>( f, indices->range()... ) ) );
|
-> decltype( getIndex( mkGenMapR<STYPE>( f, indices->range()... ) ) );
|
||||||
|
@ -40,6 +48,11 @@ 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>
|
||||||
|
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... ) );
|
||||||
|
|
|
@ -327,6 +327,26 @@ namespace MultiArrayTools
|
||||||
* MapRangeFactory *
|
* MapRangeFactory *
|
||||||
*************************/
|
*************************/
|
||||||
|
|
||||||
|
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||||
|
template <class MA>
|
||||||
|
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::shared_ptr<ORType>& outr,
|
||||||
|
const std::tuple<Op,MA>& mapf,
|
||||||
|
const std::shared_ptr<Ranges>&... rs)
|
||||||
|
{
|
||||||
|
mProd = std::shared_ptr< GenMapRange<Op,XSTYPE,Ranges...> >
|
||||||
|
( new GenMapRange<Op,XSTYPE,Ranges...>( outr, mapf, rs... ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||||
|
template <class MA>
|
||||||
|
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::shared_ptr<ORType>& outr,
|
||||||
|
const std::tuple<Op,MA>& mapf,
|
||||||
|
const typename GenMapRange<Op,XSTYPE,Ranges...>::Space& st)
|
||||||
|
{
|
||||||
|
mProd = std::shared_ptr< GenMapRange<Op,XSTYPE,Ranges...> >
|
||||||
|
( new GenMapRange<Op,XSTYPE,Ranges...>( outr, mapf, st ) );
|
||||||
|
}
|
||||||
|
|
||||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||||
template <class MA>
|
template <class MA>
|
||||||
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
|
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
|
||||||
|
@ -457,6 +477,42 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||||
|
template <class MA>
|
||||||
|
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
|
||||||
|
const std::shared_ptr<Ranges>&... rs) :
|
||||||
|
mSpace(std::make_tuple(rs...)),
|
||||||
|
mMapf(std::get<0>(mapf)),
|
||||||
|
mOutRange(outr),
|
||||||
|
mMapMult(mOutRange,0),
|
||||||
|
mMapPos(std::get<1>(mapf).size(),mOutRange->size())
|
||||||
|
{
|
||||||
|
auto& ma = std::get<1>(mapf);
|
||||||
|
auto jj = mMapMult.begin();
|
||||||
|
for(auto ii = ma.begin(); ii.pos() != ii.max(); ++ii){
|
||||||
|
++mMapMult[jj.at(ma[ii])];
|
||||||
|
mMapPos[ii.pos()] = jj.pos();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||||
|
template <class MA>
|
||||||
|
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
|
||||||
|
const Space& space) :
|
||||||
|
mSpace(space),
|
||||||
|
mMapf(std::get<0>(mapf)),
|
||||||
|
mOutRange(outr),
|
||||||
|
mMapMult(mOutRange,0),
|
||||||
|
mMapPos(std::get<1>(mapf).size(),mOutRange->size())
|
||||||
|
{
|
||||||
|
auto& ma = std::get<1>(mapf);
|
||||||
|
auto jj = mMapMult.begin();
|
||||||
|
for(auto ii = ma.begin(); ii.pos() != ii.max(); ++ii){
|
||||||
|
++mMapMult[jj.at(ma[ii])];
|
||||||
|
mMapPos[ii.pos()] = jj.pos();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||||
template <class MA>
|
template <class MA>
|
||||||
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf,
|
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf,
|
||||||
|
|
|
@ -211,10 +211,19 @@ namespace MultiArrayTools
|
||||||
class GenMapRangeFactory : public RangeFactoryBase
|
class GenMapRangeFactory : public RangeFactoryBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef SingleRange<typename Op::value_type,XSTYPE> ORType;
|
||||||
typedef GenMapRange<Op,XSTYPE,Ranges...> oType;
|
typedef GenMapRange<Op,XSTYPE,Ranges...> oType;
|
||||||
|
|
||||||
GenMapRangeFactory() = delete;
|
GenMapRangeFactory() = delete;
|
||||||
|
|
||||||
|
template <class MA>
|
||||||
|
GenMapRangeFactory(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
|
||||||
|
const std::shared_ptr<Ranges>&... rs);
|
||||||
|
|
||||||
|
template <class MA>
|
||||||
|
GenMapRangeFactory(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
|
||||||
|
const typename GenMapRange<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);
|
||||||
|
|
||||||
|
@ -252,6 +261,14 @@ namespace MultiArrayTools
|
||||||
GenMapRange(const GenMapRange& in) = delete;
|
GenMapRange(const GenMapRange& in) = delete;
|
||||||
GenMapRange& operator=(const GenMapRange& in) = delete;
|
GenMapRange& operator=(const GenMapRange& in) = delete;
|
||||||
|
|
||||||
|
template <class MA>
|
||||||
|
GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
|
||||||
|
const std::shared_ptr<Ranges>&... rs);
|
||||||
|
|
||||||
|
template <class MA>
|
||||||
|
GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
|
||||||
|
const Space& space);
|
||||||
|
|
||||||
template <class MA>
|
template <class MA>
|
||||||
GenMapRange(const std::tuple<Op,MA>& mapf, const Space& space);
|
GenMapRange(const std::tuple<Op,MA>& mapf, const Space& space);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue