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