map range: take operation as argument
This commit is contained in:
parent
45d25a4d76
commit
fe4275766a
5 changed files with 260 additions and 229 deletions
|
@ -45,26 +45,16 @@ namespace MultiArrayTools
|
|||
return mi;
|
||||
}
|
||||
|
||||
template <SpaceType STYPE, class Func, class... RangeTypes>
|
||||
auto mkGenMapR(const std::shared_ptr<Func>& f, std::shared_ptr<RangeTypes>... ranges)
|
||||
-> std::shared_ptr<GenMapRange<FunctionalMultiArray<typename Func::value_type,Func,RangeTypes...>,
|
||||
STYPE,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...> >
|
||||
{
|
||||
typedef FunctionalMultiArray<typename Func::value_type,Func,RangeTypes...> FMA;
|
||||
std::shared_ptr<GenMapRangeFactory<FMA,STYPE,RangeTypes...>> mrfptr;
|
||||
if(Func::FISSTATIC){
|
||||
FMA fma(ranges...);
|
||||
mrfptr = std::make_shared<GenMapRangeFactory<FMA,STYPE,RangeTypes...> >( fma, ranges... );
|
||||
}
|
||||
else {
|
||||
FMA fma(ranges...,f);
|
||||
mrfptr = std::make_shared<GenMapRangeFactory<FMA,STYPE,RangeTypes...> >( fma, ranges... );
|
||||
}
|
||||
return std::dynamic_pointer_cast<GenMapRange<FMA,STYPE,RangeTypes...> >( mrfptr->create() );
|
||||
GenMapRangeFactory<Op,STYPE,RangeTypes...> mrf(f, ranges... );
|
||||
return createExplicit( mrf );
|
||||
}
|
||||
|
||||
template <SpaceType STYPE, class Func, class... IndexTypes>
|
||||
auto mkGenMapI(const std::shared_ptr<Func>& f, std::shared_ptr<IndexTypes>... indices)
|
||||
template <SpaceType STYPE, class Op, class MA, class... IndexTypes>
|
||||
auto mkGenMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices)
|
||||
-> decltype( getIndex( mkGenMapR<STYPE>( f, indices->range()... ) ) )
|
||||
{
|
||||
auto mi = getIndex( mkGenMapR<STYPE>( f, indices->range()... ) );
|
||||
|
@ -72,15 +62,15 @@ namespace MultiArrayTools
|
|||
return mi;
|
||||
}
|
||||
|
||||
template <class Func, class... RangeTypes>
|
||||
auto mkMapR(const std::shared_ptr<Func>& f, std::shared_ptr<RangeTypes>... ranges)
|
||||
template <class Op, class MA, class... RangeTypes>
|
||||
auto mkMapR(const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges)
|
||||
-> decltype( mkGenMapR<SpaceType::ANY>(f, ranges... ) )
|
||||
{
|
||||
return mkGenMapR<SpaceType::ANY>(f, ranges... );
|
||||
}
|
||||
|
||||
template <class Func, class... IndexTypes>
|
||||
auto mkMapI(const std::shared_ptr<Func>& f, std::shared_ptr<IndexTypes>... indices)
|
||||
template <class Op, class MA, class... IndexTypes>
|
||||
auto mkMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices)
|
||||
-> decltype( mkGenMapI<SpaceType::ANY>(f, indices... ) )
|
||||
{
|
||||
return mkGenMapI<SpaceType::ANY>(f, indices... );
|
||||
|
|
|
@ -27,23 +27,22 @@ namespace MultiArrayTools
|
|||
auto mkMulti(std::shared_ptr<RangeTypes>... ranges)
|
||||
-> std::shared_ptr<MultiRange<RangeTypes...> >;
|
||||
|
||||
template <SpaceType STYPE, class Func, class... RangeTypes>
|
||||
auto mkGenMapR(const std::shared_ptr<Func>& f, std::shared_ptr<RangeTypes>... ranges)
|
||||
-> std::shared_ptr<GenMapRange<FunctionalMultiArray<typename Func::value_type,Func,RangeTypes...>,
|
||||
STYPE,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 <SpaceType STYPE, class Func, class... IndexTypes>
|
||||
auto mkGenMapI(const std::shared_ptr<Func>& f, std::shared_ptr<IndexTypes>... indices)
|
||||
template <SpaceType STYPE, class Op, class MA, class... IndexTypes>
|
||||
auto mkGenMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices)
|
||||
-> decltype( getIndex( mkGenMapR<STYPE>( f, indices->range()... ) ) );
|
||||
|
||||
template <class Func, class... RangeTypes>
|
||||
auto mkMapR(const std::shared_ptr<Func>& f, std::shared_ptr<RangeTypes>... ranges)
|
||||
template <class Op, class MA, class... RangeTypes>
|
||||
auto mkMapR(const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges)
|
||||
-> decltype( mkGenMapR<SpaceType::ANY>(f, ranges... ) );
|
||||
|
||||
template <class Func, class... IndexTypes>
|
||||
auto mkMapI(const std::shared_ptr<Func>& f, std::shared_ptr<IndexTypes>... indices)
|
||||
template <class Op, class MA, class... IndexTypes>
|
||||
auto mkMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices)
|
||||
-> decltype( mkGenMapI<SpaceType::ANY>(f, indices... ) );
|
||||
|
||||
|
||||
template <class... IndexTypes>
|
||||
auto mkMIndex(std::shared_ptr<IndexTypes>... indices)
|
||||
-> decltype( getIndex( mkMulti( indices.range()... ) ) );
|
||||
|
|
|
@ -14,12 +14,12 @@ namespace MultiArrayTools
|
|||
* OpExpr *
|
||||
**************/
|
||||
|
||||
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
||||
OpExpr<MapF,IndexPack,Expr,STYPE>::OpExpr(const MapF& mapf, const IndexPack& ipack,
|
||||
template <class Op, class IndexPack, class Expr, SpaceType STYPE>
|
||||
OpExpr<Op,IndexPack,Expr,STYPE>::OpExpr(const Op& mapf, const IndexPack& ipack,
|
||||
const std::shared_ptr<OIType>& oind, size_t step, Expr ex) :
|
||||
mIndPtr(oind.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
||||
mStep(step), mExpr( ex ),
|
||||
mOp(mkMapOp(mapf, ipack)),
|
||||
mOp(mapf),
|
||||
//mExt(ex.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
||||
mExt( mOp.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr ) ).extend
|
||||
( ex.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr ) ) ) )
|
||||
|
@ -27,8 +27,8 @@ namespace MultiArrayTools
|
|||
assert(mIndPtr != nullptr);
|
||||
}
|
||||
|
||||
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
||||
inline void OpExpr<MapF,IndexPack,Expr,STYPE>::operator()(size_t mlast,
|
||||
template <class Op, class IndexPack, class Expr, SpaceType STYPE>
|
||||
inline void OpExpr<Op,IndexPack,Expr,STYPE>::operator()(size_t mlast,
|
||||
ExtType last)
|
||||
{
|
||||
constexpr size_t NEXT = Op::SIZE;
|
||||
|
@ -41,8 +41,8 @@ namespace MultiArrayTools
|
|||
mExpr(mnpos, Getter<NEXT>::template getX<ExtType>( npos ) );
|
||||
}
|
||||
|
||||
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
||||
inline void OpExpr<MapF,IndexPack,Expr,STYPE>::operator()(size_t mlast)
|
||||
template <class Op, class IndexPack, class Expr, SpaceType STYPE>
|
||||
inline void OpExpr<Op,IndexPack,Expr,STYPE>::operator()(size_t mlast)
|
||||
{
|
||||
const ExtType last;
|
||||
constexpr size_t NEXT = Op::SIZE;
|
||||
|
@ -53,8 +53,8 @@ namespace MultiArrayTools
|
|||
mExpr(mnpos, Getter<NEXT>::template getX<ExtType>( npos ));
|
||||
}
|
||||
|
||||
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
||||
auto OpExpr<MapF,IndexPack,Expr,STYPE>::rootSteps(std::intptr_t iPtrNum) const
|
||||
template <class Op, class IndexPack, class Expr, SpaceType STYPE>
|
||||
auto OpExpr<Op,IndexPack,Expr,STYPE>::rootSteps(std::intptr_t iPtrNum) const
|
||||
-> ExtType
|
||||
{
|
||||
return mOp.rootSteps(iPtrNum).extend( mExpr.rootSteps(iPtrNum) );
|
||||
|
@ -88,10 +88,10 @@ namespace MultiArrayTools
|
|||
}
|
||||
*/
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
template <class MRange>
|
||||
GenMapIndex<MapF,XSTYPE,Indices...>::GenMapIndex(const std::shared_ptr<MRange>& range) :
|
||||
IndexInterface<GenMapIndex<MapF,XSTYPE,Indices...>,std::tuple<typename Indices::MetaType...> >(range, 0)
|
||||
GenMapIndex<Op,XSTYPE,Indices...>::GenMapIndex(const std::shared_ptr<MRange>& range) :
|
||||
IndexInterface<GenMapIndex<Op,XSTYPE,Indices...>,std::tuple<typename Indices::MetaType...> >(range, 0)
|
||||
{
|
||||
RPackNum<sizeof...(Indices)-1>::construct(mIPack, *range);
|
||||
IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack);
|
||||
|
@ -101,9 +101,9 @@ namespace MultiArrayTools
|
|||
( std::dynamic_pointer_cast<RangeType>( IB::mRangePtr )->outRange()->begin() );
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
template <size_t DIR>
|
||||
GenMapIndex<MapF,XSTYPE,Indices...>& GenMapIndex<MapF,XSTYPE,Indices...>::up()
|
||||
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::up()
|
||||
{
|
||||
static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices");
|
||||
IB::mPos += RPackNum<sizeof...(Indices)-DIR-1>::blockSize( mIPack );
|
||||
|
@ -111,9 +111,9 @@ namespace MultiArrayTools
|
|||
return *this;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
template <size_t DIR>
|
||||
GenMapIndex<MapF,XSTYPE,Indices...>& GenMapIndex<MapF,XSTYPE,Indices...>::down()
|
||||
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::down()
|
||||
{
|
||||
static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices");
|
||||
IB::mPos -= RPackNum<sizeof...(Indices)-DIR-1>::blockSize( mIPack );
|
||||
|
@ -121,136 +121,136 @@ namespace MultiArrayTools
|
|||
return *this;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
template <size_t N>
|
||||
auto GenMapIndex<MapF,XSTYPE,Indices...>::get() const -> decltype( *std::get<N>( mIPack ) )&
|
||||
auto GenMapIndex<Op,XSTYPE,Indices...>::get() const -> decltype( *std::get<N>( mIPack ) )&
|
||||
{
|
||||
return *std::get<N>(mIPack);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
template <size_t N>
|
||||
auto GenMapIndex<MapF,XSTYPE,Indices...>::getPtr() const -> decltype( std::get<N>( mIPack ) )&
|
||||
auto GenMapIndex<Op,XSTYPE,Indices...>::getPtr() const -> decltype( std::get<N>( mIPack ) )&
|
||||
{
|
||||
return std::get<N>(mIPack);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
auto GenMapIndex<MapF,XSTYPE,Indices...>::outIndex() const -> std::shared_ptr<OIType>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
auto GenMapIndex<Op,XSTYPE,Indices...>::outIndex() const -> std::shared_ptr<OIType>
|
||||
{
|
||||
return mOutIndex;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<MapF,XSTYPE,Indices...>& GenMapIndex<MapF,XSTYPE,Indices...>::operator()(std::shared_ptr<Indices>&... indices)
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::operator()(std::shared_ptr<Indices>&... indices)
|
||||
{
|
||||
RPackNum<sizeof...(Indices)-1>::swapIndices(mIPack, indices...);
|
||||
RPackNum<sizeof...(Indices)-1>::setIndexPack(mIPack, IB::mPos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
IndexType GenMapIndex<MapF,XSTYPE,Indices...>::type() const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
IndexType GenMapIndex<Op,XSTYPE,Indices...>::type() const
|
||||
{
|
||||
return IndexType::MULTI;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<MapF,XSTYPE,Indices...>& GenMapIndex<MapF,XSTYPE,Indices...>::operator=(size_t pos)
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::operator=(size_t pos)
|
||||
{
|
||||
IB::mPos = pos;
|
||||
RPackNum<sizeof...(Indices)-1>::setIndexPack(mIPack, pos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<MapF,XSTYPE,Indices...>& GenMapIndex<MapF,XSTYPE,Indices...>::operator++()
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::operator++()
|
||||
{
|
||||
RPackNum<sizeof...(Indices)-1>::pp( mIPack );
|
||||
++IB::mPos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<MapF,XSTYPE,Indices...>& GenMapIndex<MapF,XSTYPE,Indices...>::operator--()
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::operator--()
|
||||
{
|
||||
RPackNum<sizeof...(Indices)-1>::mm( mIPack );
|
||||
--IB::mPos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
int GenMapIndex<MapF,XSTYPE,Indices...>::pp(std::intptr_t idxPtrNum)
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
int GenMapIndex<Op,XSTYPE,Indices...>::pp(std::intptr_t idxPtrNum)
|
||||
{
|
||||
int tmp = RPackNum<sizeof...(Indices)-1>::pp(mIPack, mBlockSizes, idxPtrNum);
|
||||
IB::mPos += tmp;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
int GenMapIndex<MapF,XSTYPE,Indices...>::mm(std::intptr_t idxPtrNum)
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
int GenMapIndex<Op,XSTYPE,Indices...>::mm(std::intptr_t idxPtrNum)
|
||||
{
|
||||
int tmp = RPackNum<sizeof...(Indices)-1>::mm(mIPack, mBlockSizes, idxPtrNum);
|
||||
IB::mPos -= tmp;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
std::string GenMapIndex<MapF,XSTYPE,Indices...>::stringMeta() const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
std::string GenMapIndex<Op,XSTYPE,Indices...>::stringMeta() const
|
||||
{
|
||||
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr )->stringMeta(IB::mPos);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
typename GenMapIndex<MapF,XSTYPE,Indices...>::MetaType GenMapIndex<MapF,XSTYPE,Indices...>::meta() const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
typename GenMapIndex<Op,XSTYPE,Indices...>::MetaType GenMapIndex<Op,XSTYPE,Indices...>::meta() const
|
||||
{
|
||||
MetaType metaTuple;
|
||||
RPackNum<sizeof...(Indices)-1>::getMetaPos(metaTuple, mIPack);
|
||||
return metaTuple;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<MapF,XSTYPE,Indices...>& GenMapIndex<MapF,XSTYPE,Indices...>::at(const MetaType& metaPos)
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
GenMapIndex<Op,XSTYPE,Indices...>& GenMapIndex<Op,XSTYPE,Indices...>::at(const MetaType& metaPos)
|
||||
{
|
||||
RPackNum<sizeof...(Indices)-1>::setMeta(mIPack, metaPos);
|
||||
IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
size_t GenMapIndex<MapF,XSTYPE,Indices...>::dim() const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
size_t GenMapIndex<Op,XSTYPE,Indices...>::dim() const
|
||||
{
|
||||
return sizeof...(Indices);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
bool GenMapIndex<MapF,XSTYPE,Indices...>::first() const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
bool GenMapIndex<Op,XSTYPE,Indices...>::first() const
|
||||
{
|
||||
return IB::mPos == 0;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
bool GenMapIndex<MapF,XSTYPE,Indices...>::last() const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
bool GenMapIndex<Op,XSTYPE,Indices...>::last() const
|
||||
{
|
||||
return IB::mPos == IB::mMax - 1;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
std::shared_ptr<typename GenMapIndex<MapF,XSTYPE,Indices...>::RangeType>
|
||||
GenMapIndex<MapF,XSTYPE,Indices...>::range() const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
std::shared_ptr<typename GenMapIndex<Op,XSTYPE,Indices...>::RangeType>
|
||||
GenMapIndex<Op,XSTYPE,Indices...>::range() const
|
||||
{
|
||||
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr );
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
template <size_t N>
|
||||
auto GenMapIndex<MapF,XSTYPE,Indices...>::getPtr() -> decltype( std::get<N>( mIPack ) )&
|
||||
auto GenMapIndex<Op,XSTYPE,Indices...>::getPtr() -> decltype( std::get<N>( mIPack ) )&
|
||||
{
|
||||
return std::get<N>(mIPack);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
size_t GenMapIndex<MapF,XSTYPE,Indices...>::getStepSize(size_t n) const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
size_t GenMapIndex<Op,XSTYPE,Indices...>::getStepSize(size_t n) const
|
||||
{
|
||||
if(n >= sizeof...(Indices)){
|
||||
assert(0);
|
||||
|
@ -259,14 +259,14 @@ namespace MultiArrayTools
|
|||
return mBlockSizes[n+1];
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
std::string GenMapIndex<MapF,XSTYPE,Indices...>::id() const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
std::string GenMapIndex<Op,XSTYPE,Indices...>::id() const
|
||||
{
|
||||
return std::string("mul") + std::to_string(IB::mId);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
void GenMapIndex<MapF,XSTYPE,Indices...>::print(size_t offset) const
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
void GenMapIndex<Op,XSTYPE,Indices...>::print(size_t offset) const
|
||||
{
|
||||
if(offset == 0){
|
||||
std::cout << " === " << std::endl;
|
||||
|
@ -277,30 +277,30 @@ namespace MultiArrayTools
|
|||
RPackNum<sizeof...(Indices)-1>::printIndex(mIPack, offset+1);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
template <class Exprs>
|
||||
auto GenMapIndex<MapF,XSTYPE,Indices...>::ifor(size_t step, Exprs exs) const
|
||||
auto GenMapIndex<Op,XSTYPE,Indices...>::ifor(size_t step, Exprs exs) const
|
||||
-> decltype(RPackNum<sizeof...(Indices)-1>::mkForh
|
||||
(step, mIPack, mBlockSizes, OpExpr<MapF,IndexPack,Exprs,XSTYPE>
|
||||
(step, mIPack, mBlockSizes, OpExpr<Op,IndexPack,Exprs,XSTYPE>
|
||||
( range()->map(), mIPack, mOutIndex, step, exs ) ) )
|
||||
{
|
||||
return RPackNum<sizeof...(Indices)-1>::mkForh
|
||||
(step, mIPack, mBlockSizes, OpExpr<MapF,IndexPack,Exprs,XSTYPE>
|
||||
(step, mIPack, mBlockSizes, OpExpr<Op,IndexPack,Exprs,XSTYPE>
|
||||
( range()->map(), mIPack, mOutIndex, step, exs ) );
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
template <class Exprs>
|
||||
auto GenMapIndex<MapF,XSTYPE,Indices...>::pifor(size_t step, Exprs exs) const
|
||||
auto GenMapIndex<Op,XSTYPE,Indices...>::pifor(size_t step, Exprs exs) const
|
||||
-> decltype(ifor(step, exs))
|
||||
{
|
||||
return ifor(step, exs);
|
||||
}
|
||||
|
||||
/*
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
template <class Exprs>
|
||||
auto GenMapIndex<MapF,XSTYPE,Indices...>::iforh(Exprs exs) const
|
||||
auto GenMapIndex<Op,XSTYPE,Indices...>::iforh(Exprs exs) const
|
||||
-> decltype(RPackNum<sizeof...(Indices)-1>::mkForh(mIPack, exs))
|
||||
{
|
||||
return RPackNum<sizeof...(Indices)-1>::mkForh(mIPack, exs);
|
||||
|
@ -310,30 +310,34 @@ namespace MultiArrayTools
|
|||
* MapRangeFactory *
|
||||
*************************/
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
GenMapRangeFactory<MapF,XSTYPE,Ranges...>::GenMapRangeFactory(const MapF& mapf, const std::shared_ptr<Ranges>&... rs)
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
template <class MA>
|
||||
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
|
||||
const std::shared_ptr<Ranges>&... rs)
|
||||
{
|
||||
mProd = std::shared_ptr< GenMapRange<MapF,XSTYPE,Ranges...> >
|
||||
( new GenMapRange<MapF,XSTYPE,Ranges...>( mapf, rs... ) );
|
||||
mProd = std::shared_ptr< GenMapRange<Op,XSTYPE,Ranges...> >
|
||||
( new GenMapRange<Op,XSTYPE,Ranges...>( mapf, rs... ) );
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
GenMapRangeFactory<MapF,XSTYPE,Ranges...>::GenMapRangeFactory(const MapF& mapf, const typename GenMapRange<MapF,XSTYPE,Ranges...>::Space& st)
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
template <class MA>
|
||||
GenMapRangeFactory<Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
|
||||
const typename GenMapRange<Op,XSTYPE,Ranges...>::Space& st)
|
||||
{
|
||||
mProd = std::shared_ptr< GenMapRange<MapF,XSTYPE,Ranges...> >
|
||||
( new GenMapRange<MapF,XSTYPE,Ranges...>( mapf, st ) );
|
||||
mProd = std::shared_ptr< GenMapRange<Op,XSTYPE,Ranges...> >
|
||||
( new GenMapRange<Op,XSTYPE,Ranges...>( mapf, st ) );
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
std::shared_ptr<RangeBase> GenMapRangeFactory<MapF,XSTYPE,Ranges...>::create()
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
std::shared_ptr<RangeBase> GenMapRangeFactory<Op,XSTYPE,Ranges...>::create()
|
||||
{
|
||||
mProd = checkIfCreated( std::dynamic_pointer_cast<oType>( mProd )->mSpace );
|
||||
setSelf();
|
||||
return mProd;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
std::shared_ptr<RangeBase> GenMapRangeFactory<MapF,XSTYPE,Ranges...>::checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& ptp)
|
||||
template <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> out;
|
||||
bool check = false;
|
||||
|
@ -421,111 +425,115 @@ namespace MultiArrayTools
|
|||
mapMult = MultiArray<size_t,ORType>( outRange, outmult );
|
||||
}
|
||||
};
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
void GenMapRange<MapF,XSTYPE,Ranges...>::mkOutRange()
|
||||
//!!!!!
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
template <class MA>
|
||||
void GenMapRange<Op,XSTYPE,Ranges...>::mkOutRange(const MA& mapf)
|
||||
{
|
||||
//FunctionalMultiArray<typename MapF::value_type,MapF,Ranges...> fma(mSpace, mMapf);
|
||||
OutRangeMaker<XSTYPE>::mk(mOutRange,mMapMult,mMapf);
|
||||
OutRangeMaker<XSTYPE>::mk(mOutRange,mMapMult,mapf);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
GenMapRange<MapF,XSTYPE,Ranges...>::GenMapRange(const MapF& mapf, const std::shared_ptr<Ranges>&... rs) :
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
template <class MA>
|
||||
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf,
|
||||
const std::shared_ptr<Ranges>&... rs) :
|
||||
mSpace(std::make_tuple(rs...)),
|
||||
mMapf(mapf)
|
||||
mMapf(std::get<0>(mapf))
|
||||
{
|
||||
mkOutRange();
|
||||
mkOutRange(std::get<1>(mapf));
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
GenMapRange<MapF,XSTYPE,Ranges...>::GenMapRange(const MapF& mapf, const Space& space) :
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
template <class MA>
|
||||
GenMapRange<Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf, const Space& space) :
|
||||
mSpace( space ),
|
||||
mMapf(mapf)
|
||||
mMapf(std::get<0>(mapf))
|
||||
{
|
||||
mkOutRange();
|
||||
mkOutRange(std::get<1>(mapf));
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
template <size_t N>
|
||||
auto GenMapRange<MapF,XSTYPE,Ranges...>::get() const -> decltype( *std::get<N>( mSpace ) )&
|
||||
auto GenMapRange<Op,XSTYPE,Ranges...>::get() const -> decltype( *std::get<N>( mSpace ) )&
|
||||
{
|
||||
return *std::get<N>(mSpace);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
template <size_t N>
|
||||
auto GenMapRange<MapF,XSTYPE,Ranges...>::getPtr() const -> decltype( std::get<N>( mSpace ) )&
|
||||
auto GenMapRange<Op,XSTYPE,Ranges...>::getPtr() const -> decltype( std::get<N>( mSpace ) )&
|
||||
{
|
||||
return std::get<N>(mSpace);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
auto GenMapRange<MapF,XSTYPE,Ranges...>::outRange() const -> std::shared_ptr<ORType>
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
auto GenMapRange<Op,XSTYPE,Ranges...>::outRange() const -> std::shared_ptr<ORType>
|
||||
{
|
||||
return mOutRange;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
const MapF& GenMapRange<MapF,XSTYPE,Ranges...>::map() const
|
||||
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
const Op& GenMapRange<Op,XSTYPE,Ranges...>::map() const
|
||||
{
|
||||
return mMapf;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
size_t GenMapRange<MapF,XSTYPE,Ranges...>::dim() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
size_t GenMapRange<Op,XSTYPE,Ranges...>::dim() const
|
||||
{
|
||||
return sdim;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
size_t GenMapRange<MapF,XSTYPE,Ranges...>::size() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
size_t GenMapRange<Op,XSTYPE,Ranges...>::size() const
|
||||
{
|
||||
return mOutRange->size();
|
||||
//return RPackNum<sizeof...(Ranges)-1>::getSize(mSpace);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
SpaceType GenMapRange<MapF,XSTYPE,Ranges...>::spaceType() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
SpaceType GenMapRange<Op,XSTYPE,Ranges...>::spaceType() const
|
||||
{
|
||||
return SpaceType::ANY;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
const typename GenMapRange<MapF,XSTYPE,Ranges...>::Space& GenMapRange<MapF,XSTYPE,Ranges...>::space() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
const typename GenMapRange<Op,XSTYPE,Ranges...>::Space& GenMapRange<Op,XSTYPE,Ranges...>::space() const
|
||||
{
|
||||
return mSpace;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
vector<size_t> GenMapRange<MapF,XSTYPE,Ranges...>::typeNum() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
vector<size_t> GenMapRange<Op,XSTYPE,Ranges...>::typeNum() const
|
||||
{
|
||||
vector<size_t> o;
|
||||
RPackNum<sizeof...(Ranges)-1>::getTypeNum(o,mSpace);
|
||||
return o;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
size_t GenMapRange<MapF,XSTYPE,Ranges...>::cmeta(char* target, size_t pos) const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
size_t GenMapRange<Op,XSTYPE,Ranges...>::cmeta(char* target, size_t pos) const
|
||||
{
|
||||
return RPackNum<sizeof...(Ranges)-1>::getCMeta(target,pos,mSpace,cmetaSize());
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
size_t GenMapRange<MapF,XSTYPE,Ranges...>::cmetaSize() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
size_t GenMapRange<Op,XSTYPE,Ranges...>::cmetaSize() const
|
||||
{
|
||||
return RPackNum<sizeof...(Ranges)-1>::getCMetaSize(mSpace);
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
std::string GenMapRange<MapF,XSTYPE,Ranges...>::stringMeta(size_t pos) const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
std::string GenMapRange<Op,XSTYPE,Ranges...>::stringMeta(size_t pos) const
|
||||
{
|
||||
auto i = begin();
|
||||
i = pos;
|
||||
return "[ " + RPackNum<sizeof...(Ranges)-1>::getStringMeta(i) + " ]";
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
vector<char> GenMapRange<MapF,XSTYPE,Ranges...>::data() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
vector<char> GenMapRange<Op,XSTYPE,Ranges...>::data() const
|
||||
{
|
||||
DataHeader h = dataHeader();
|
||||
vector<char> out;
|
||||
|
@ -536,8 +544,8 @@ namespace MultiArrayTools
|
|||
return out;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
DataHeader GenMapRange<MapF,XSTYPE,Ranges...>::dataHeader() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
DataHeader GenMapRange<Op,XSTYPE,Ranges...>::dataHeader() const
|
||||
{
|
||||
DataHeader h;
|
||||
h.spaceType = static_cast<int>( SpaceType::ANY );
|
||||
|
@ -546,44 +554,44 @@ namespace MultiArrayTools
|
|||
return h;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
typename GenMapRange<MapF,XSTYPE,Ranges...>::IndexType GenMapRange<MapF,XSTYPE,Ranges...>::begin() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
typename GenMapRange<Op,XSTYPE,Ranges...>::IndexType GenMapRange<Op,XSTYPE,Ranges...>::begin() const
|
||||
{
|
||||
GenMapIndex<MapF,XSTYPE,typename Ranges::IndexType...>
|
||||
i( std::dynamic_pointer_cast<GenMapRange<MapF,XSTYPE,Ranges...> >
|
||||
GenMapIndex<Op,XSTYPE,typename Ranges::IndexType...>
|
||||
i( std::dynamic_pointer_cast<GenMapRange<Op,XSTYPE,Ranges...> >
|
||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||
i = 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
typename GenMapRange<MapF,XSTYPE,Ranges...>::IndexType GenMapRange<MapF,XSTYPE,Ranges...>::end() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
typename GenMapRange<Op,XSTYPE,Ranges...>::IndexType GenMapRange<Op,XSTYPE,Ranges...>::end() const
|
||||
{
|
||||
GenMapIndex<MapF,XSTYPE,typename Ranges::IndexType...>
|
||||
i( std::dynamic_pointer_cast<GenMapRange<MapF,XSTYPE,Ranges...> >
|
||||
GenMapIndex<Op,XSTYPE,typename Ranges::IndexType...>
|
||||
i( std::dynamic_pointer_cast<GenMapRange<Op,XSTYPE,Ranges...> >
|
||||
( std::shared_ptr<RangeBase>( RB::mThis )) );
|
||||
i = size();
|
||||
return i;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
auto GenMapRange<MapF,XSTYPE,Ranges...>::mapMultiplicity() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
auto GenMapRange<Op,XSTYPE,Ranges...>::mapMultiplicity() const
|
||||
-> const MultiArray<size_t,ORType>&
|
||||
{
|
||||
return mMapMult;
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
auto GenMapRange<MapF,XSTYPE,Ranges...>::explMapMultiplicity() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
auto GenMapRange<Op,XSTYPE,Ranges...>::explMapMultiplicity() const
|
||||
-> MultiArray<size_t,GenMapRange>
|
||||
{
|
||||
auto tmp = mMapMult;
|
||||
return tmp.format( std::dynamic_pointer_cast<GenMapRange<MapF,XSTYPE,Ranges...> >
|
||||
return tmp.format( std::dynamic_pointer_cast<GenMapRange<Op,XSTYPE,Ranges...> >
|
||||
( std::shared_ptr<RangeBase>( RB::mThis )) );
|
||||
}
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
vector<size_t> GenMapRange<MapF,XSTYPE,Ranges...>::mapPos() const
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
vector<size_t> GenMapRange<Op,XSTYPE,Ranges...>::mapPos() const
|
||||
{
|
||||
auto i = mMapf.begin();
|
||||
vector<size_t> out(i.max());
|
||||
|
@ -594,9 +602,9 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
/*
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
template <class... ERanges>
|
||||
auto GenMapRange<MapF,XSTYPE,Ranges...>::cat(const std::shared_ptr<MapRange<ERanges...> >& erange)
|
||||
auto GenMapRange<Op,XSTYPE,Ranges...>::cat(const std::shared_ptr<MapRange<ERanges...> >& erange)
|
||||
-> std::shared_ptr<GenMapRange<Ranges...,ERanges...> >
|
||||
{
|
||||
auto crange = std::tuple_cat(mSpace, erange->space());
|
||||
|
|
|
@ -26,20 +26,35 @@ namespace MultiArrayTools
|
|||
using namespace MultiArrayHelper;
|
||||
}
|
||||
|
||||
template <class MA, class... Indices>
|
||||
auto mkMapOp(const MA& ma,
|
||||
const std::tuple<std::shared_ptr<Indices>...>& itp)
|
||||
-> decltype(PackNum<sizeof...(Indices)-1>::mkMapOp(ma, itp))
|
||||
|
||||
template <class Func, class... Indices>
|
||||
auto mkMapOp(const std::shared_ptr<Func>& func,
|
||||
const std::shared_ptr<Indices>&... is)
|
||||
-> decltype(std::make_tuple(FunctionalMultiArray<typename Func::value_type,Func,
|
||||
typename Indices::RangeType...>().exec(is...),
|
||||
FunctionalMultiArray<typename Func::value_type,Func,
|
||||
typename Indices::RangeType...>()))
|
||||
{
|
||||
return PackNum<sizeof...(Indices)-1>::mkMapOp(ma, itp);
|
||||
typedef FunctionalMultiArray<typename Func::value_type,Func,typename Indices::RangeType...> FMA;
|
||||
if(Func::FISSTATIC){
|
||||
FMA fma(is->range()...);
|
||||
return std::make_tuple(fma.exec(is...),fma);
|
||||
}
|
||||
else {
|
||||
FMA fma(is->range()...,func);
|
||||
return std::make_tuple(fma.exec(is...),fma);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class MapF, class IndexPack, class Expr, SpaceType STYPE = SpaceType::ANY>
|
||||
|
||||
template <class Op, class IndexPack, class Expr, SpaceType STYPE = SpaceType::ANY>
|
||||
//template <class MapF, class IndexPack, class Expr, SpaceType STYPE = SpaceType::ANY>
|
||||
class OpExpr
|
||||
{
|
||||
public:
|
||||
typedef decltype(mkMapOp(std::declval<MapF>(), std::declval<IndexPack>())) Op;
|
||||
typedef SingleIndex<typename MapF::value_type,STYPE> OIType;
|
||||
//typedef decltype(mkMapOp(std::declval<MapF>(), std::declval<IndexPack>())) Op;
|
||||
typedef SingleIndex<typename Op::value_type,STYPE> OIType;
|
||||
//typedef typename MapF::IndexPack IndexPack;
|
||||
static constexpr size_t LAYER = Expr::LAYER + 1;
|
||||
static constexpr size_t SIZE = Expr::SIZE + Op::SIZE;
|
||||
|
@ -62,8 +77,9 @@ namespace MultiArrayTools
|
|||
OpExpr(OpExpr&& in) = default;
|
||||
OpExpr& operator=(const OpExpr& in) = default;
|
||||
OpExpr& operator=(OpExpr&& in) = default;
|
||||
|
||||
OpExpr(const MapF& mapf, const IndexPack& ipack, const std::shared_ptr<OIType>& oind, size_t step, Expr ex);
|
||||
|
||||
OpExpr(const Op& mapf, const IndexPack& ipack, const std::shared_ptr<OIType>& oind, size_t step, Expr ex);
|
||||
//OpExpr(const MapF& mapf, const IndexPack& ipack, const std::shared_ptr<OIType>& oind, size_t step, Expr ex);
|
||||
|
||||
inline void operator()(size_t mlast, ExtType last);
|
||||
inline void operator()(size_t mlast = 0);
|
||||
|
@ -72,19 +88,19 @@ namespace MultiArrayTools
|
|||
|
||||
};
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Indices>
|
||||
class GenMapIndex : public IndexInterface<GenMapIndex<MapF,XSTYPE,Indices...>,
|
||||
template <class Op, SpaceType XSTYPE, class... Indices>
|
||||
class GenMapIndex : public IndexInterface<GenMapIndex<Op,XSTYPE,Indices...>,
|
||||
std::tuple<typename Indices::MetaType...> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef IndexInterface<GenMapIndex<MapF,XSTYPE,Indices...>,
|
||||
typedef IndexInterface<GenMapIndex<Op,XSTYPE,Indices...>,
|
||||
std::tuple<typename Indices::MetaType...> > IB;
|
||||
typedef std::tuple<std::shared_ptr<Indices>...> IndexPack;
|
||||
typedef std::tuple<typename Indices::MetaType...> MetaType;
|
||||
typedef GenMapRange<MapF,XSTYPE,typename Indices::RangeType...> RangeType;
|
||||
typedef GenMapRange<Op,XSTYPE,typename Indices::RangeType...> RangeType;
|
||||
typedef GenMapIndex IType;
|
||||
typedef SingleIndex<typename MapF::value_type,XSTYPE> OIType;
|
||||
typedef SingleIndex<typename Op::value_type,XSTYPE> OIType;
|
||||
|
||||
static constexpr IndexType sType() { return IndexType::MULTI; }
|
||||
static constexpr size_t sDim() { return sizeof...(Indices); }
|
||||
|
@ -168,7 +184,7 @@ namespace MultiArrayTools
|
|||
template <class Exprs>
|
||||
auto ifor(size_t step, Exprs exs) const
|
||||
-> decltype(RPackNum<sizeof...(Indices)-1>::mkForh
|
||||
(step, mIPack, mBlockSizes, OpExpr<MapF,IndexPack,Exprs,XSTYPE>( range()->map(), mIPack, mOutIndex, step, exs ) ) );
|
||||
(step, mIPack, mBlockSizes, OpExpr<Op,IndexPack,Exprs,XSTYPE>( range()->map(), mIPack, mOutIndex, step, exs ) ) );
|
||||
// first step arg not used!
|
||||
|
||||
template <class Exprs>
|
||||
|
@ -188,15 +204,20 @@ namespace MultiArrayTools
|
|||
*************************/
|
||||
|
||||
// NOT THREAD SAVE
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
class GenMapRangeFactory : public RangeFactoryBase
|
||||
{
|
||||
public:
|
||||
typedef GenMapRange<MapF,XSTYPE,Ranges...> oType;
|
||||
typedef GenMapRange<Op,XSTYPE,Ranges...> oType;
|
||||
|
||||
GenMapRangeFactory() = delete;
|
||||
GenMapRangeFactory(const MapF& mapf, const std::shared_ptr<Ranges>&... rs);
|
||||
GenMapRangeFactory(const MapF& mapf, const typename GenMapRange<MapF,XSTYPE,Ranges...>::Space& space);
|
||||
|
||||
template <class MA>
|
||||
GenMapRangeFactory(const std::tuple<Op,MA>& mapf, const std::shared_ptr<Ranges>&... rs);
|
||||
|
||||
template <class MA>
|
||||
GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
|
||||
const typename GenMapRange<Op,XSTYPE,Ranges...>::Space& space);
|
||||
|
||||
virtual std::shared_ptr<RangeBase> create() override;
|
||||
|
||||
|
@ -210,33 +231,38 @@ namespace MultiArrayTools
|
|||
* MapRange *
|
||||
******************/
|
||||
|
||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||
class GenMapRange : public RangeInterface<GenMapIndex<MapF,XSTYPE,typename Ranges::IndexType...> >
|
||||
template <class Op, SpaceType XSTYPE, class... Ranges>
|
||||
class GenMapRange : public RangeInterface<GenMapIndex<Op,XSTYPE,typename Ranges::IndexType...> >
|
||||
{
|
||||
public:
|
||||
typedef RangeBase RB;
|
||||
typedef std::tuple<std::shared_ptr<Ranges>...> Space;
|
||||
typedef GenMapIndex<MapF,XSTYPE,typename Ranges::IndexType...> IndexType;
|
||||
typedef GenMapIndex<Op,XSTYPE,typename Ranges::IndexType...> IndexType;
|
||||
typedef GenMapRange RangeType;
|
||||
typedef SingleRange<typename MapF::value_type,XSTYPE> ORType;
|
||||
typedef SingleRangeFactory<typename MapF::value_type,XSTYPE> ORFType;
|
||||
typedef SingleRange<typename Op::value_type,XSTYPE> ORType;
|
||||
typedef SingleRangeFactory<typename Op::value_type,XSTYPE> ORFType;
|
||||
//typedef typename RangeInterface<MapIndex<typename Ranges::IndexType...> >::IndexType IndexType;
|
||||
|
||||
protected:
|
||||
GenMapRange() = delete;
|
||||
GenMapRange(const GenMapRange& in) = delete;
|
||||
GenMapRange& operator=(const GenMapRange& in) = delete;
|
||||
|
||||
GenMapRange(const MapF& mapf, const std::shared_ptr<Ranges>&... rs);
|
||||
GenMapRange(const MapF& mapf, const Space& space);
|
||||
|
||||
template <class MA>
|
||||
GenMapRange(const std::tuple<Op,MA>& mapf, const Space& space);
|
||||
|
||||
template <class MA>
|
||||
GenMapRange(const std::tuple<Op,MA>& mapf, const std::shared_ptr<Ranges>&... rs);
|
||||
|
||||
Space mSpace;
|
||||
MapF mMapf;
|
||||
Op mMapf;
|
||||
//Op mMapf;
|
||||
std::shared_ptr<ORType> mOutRange;
|
||||
MultiArray<size_t,ORType> mMapMult;
|
||||
|
||||
private:
|
||||
void mkOutRange();
|
||||
template <class MA>
|
||||
void mkOutRange(const MA& mapf);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -249,7 +275,7 @@ namespace MultiArrayTools
|
|||
auto getPtr() const -> decltype( std::get<N>( mSpace ) )&;
|
||||
|
||||
std::shared_ptr<ORType> outRange() const;
|
||||
const MapF& map() const;
|
||||
const Op& map() const;
|
||||
|
||||
virtual size_t dim() const final;
|
||||
virtual size_t size() const final;
|
||||
|
@ -278,31 +304,30 @@ namespace MultiArrayTools
|
|||
auto cat(const std::shared_ptr<GenMapRange<ERanges...> >& erange)
|
||||
-> std::shared_ptr<GenMapRange<Ranges...,ERanges...> >;
|
||||
*/
|
||||
friend GenMapRangeFactory<MapF,XSTYPE,Ranges...>;
|
||||
friend GenMapRangeFactory<Op,XSTYPE,Ranges...>;
|
||||
|
||||
static constexpr bool HASMETACONT = false;
|
||||
static constexpr bool defaultable = false;
|
||||
static constexpr size_t ISSTATIC = SubProp<MapF,Ranges...>::ISSTATIC;
|
||||
static constexpr size_t SIZE = SubProp<MapF,Ranges...>::SIZE;
|
||||
static constexpr size_t ISSTATIC = SubProp<Op,Ranges...>::ISSTATIC;
|
||||
static constexpr size_t SIZE = SubProp<Op,Ranges...>::SIZE;
|
||||
};
|
||||
|
||||
// for legacy
|
||||
template <class MapF, class... Indices>
|
||||
using MapIndex = GenMapIndex<MapF,SpaceType::ANY,Indices...>;
|
||||
template <class Op, class... Indices>
|
||||
using MapIndex = GenMapIndex<Op,SpaceType::ANY,Indices...>;
|
||||
|
||||
template <class MapF, class... Ranges>
|
||||
using MapRangeFactory = GenMapRangeFactory<MapF,SpaceType::ANY,Ranges...>;
|
||||
template <class Op, class... Ranges>
|
||||
using MapRangeFactory = GenMapRangeFactory<Op,SpaceType::ANY,Ranges...>;
|
||||
|
||||
template <class MapF, class... Ranges>
|
||||
using MapRange = GenMapRange<MapF,SpaceType::ANY,Ranges...>;
|
||||
template <class Op, class... Ranges>
|
||||
using MapRange = GenMapRange<Op,SpaceType::ANY,Ranges...>;
|
||||
|
||||
template <class MapF, class... Indices>
|
||||
auto mapResult/*<MapIndex<MapF,Indices...> >*/(const std::shared_ptr<MapIndex<MapF,Indices...> >& ind)
|
||||
template <class Op, class... Indices>
|
||||
auto mapResult/*<MapIndex<Op,Indices...> >*/(const std::shared_ptr<MapIndex<Op,Indices...> >& ind)
|
||||
-> decltype(ind->outIndex())
|
||||
{
|
||||
return ind->outIndex();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -197,14 +197,30 @@ namespace {
|
|||
|
||||
typedef SingleRangeFactory<size_t,SpaceType::ANY> SRF;
|
||||
typedef SRF::oType SRange;
|
||||
|
||||
typedef typename SRange::IndexType SIndex;
|
||||
/*
|
||||
typedef FunctionalMultiArray<size_t,plus<size_t>,SRange,SRange> MapF;
|
||||
|
||||
typedef MapRangeFactory<MapF,SRange,SRange> MpRF;
|
||||
typedef MpRF::oType MpRange;
|
||||
|
||||
typedef MpRange::ORType TRange;
|
||||
*/
|
||||
|
||||
|
||||
std::shared_ptr<SRange> sr1ptr;
|
||||
std::shared_ptr<SRange> sr2ptr;
|
||||
std::shared_ptr<SIndex> si1ptr;
|
||||
std::shared_ptr<SIndex> si2ptr;
|
||||
|
||||
//std::shared_ptr<MpRange> mpr1ptr;
|
||||
vector<double> v1 = { -31.71, -77.16, -18.81,
|
||||
-67.06, 72.31, -54.48,
|
||||
-50.91, -11.62, -59.57,
|
||||
-42.53, 80.41, 6.35 };
|
||||
|
||||
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;
|
||||
typedef MpRange::ORType TRange;
|
||||
|
||||
MapTest()
|
||||
{
|
||||
SRF srf1( { 1, 3, 7, 10 } );
|
||||
|
@ -212,20 +228,12 @@ namespace {
|
|||
|
||||
sr1ptr = std::dynamic_pointer_cast<SRange>( srf1.create() );
|
||||
sr2ptr = std::dynamic_pointer_cast<SRange>( srf2.create() );
|
||||
|
||||
MapF map(sr1ptr,sr2ptr);
|
||||
MpRF mprf1( map, sr1ptr, sr2ptr );
|
||||
|
||||
mpr1ptr = std::dynamic_pointer_cast<MpRange>( mprf1.create() );
|
||||
si1ptr = getIndex(sr1ptr);
|
||||
si2ptr = getIndex(sr2ptr);
|
||||
|
||||
mpr1ptr = mkMapR( mkMapOp(std::make_shared<plus<size_t>>(),si1ptr,si2ptr) , sr1ptr, sr2ptr );
|
||||
}
|
||||
|
||||
std::shared_ptr<SRange> sr1ptr;
|
||||
std::shared_ptr<SRange> sr2ptr;
|
||||
std::shared_ptr<MpRange> mpr1ptr;
|
||||
vector<double> v1 = { -31.71, -77.16, -18.81,
|
||||
-67.06, 72.31, -54.48,
|
||||
-50.91, -11.62, -59.57,
|
||||
-42.53, 80.41, 6.35 };
|
||||
};
|
||||
|
||||
class OpTest_Performance : public ::testing::Test
|
||||
|
@ -358,8 +366,9 @@ namespace {
|
|||
|
||||
auto ii1 = getIndex( rptr<0>( ma1 ) );
|
||||
auto ii2 = getIndex( rptr<1>( ma1 ) );
|
||||
|
||||
auto mr = mkMapR(std::make_shared<plus<size_t>>(),sr1ptr,sr2ptr);
|
||||
|
||||
auto mr = mkMapR( mkMapOp(std::make_shared<plus<size_t>>(),ii1,ii2) , sr1ptr, sr2ptr );
|
||||
//auto mr = mkMapR(std::make_shared<plus<size_t>>(),sr1ptr,sr2ptr);
|
||||
MultiArray<double,MpRange> res(mr);
|
||||
MultiArray<double,MpRange> res2(mr);
|
||||
auto jj = getIndex( mr );
|
||||
|
|
Loading…
Reference in a new issue