2018-10-30 15:06:29 +01:00
|
|
|
|
|
|
|
#include "helper_tools.h"
|
|
|
|
|
|
|
|
namespace MultiArrayTools
|
|
|
|
{
|
|
|
|
template <typename... T>
|
|
|
|
std::ostream& operator<<(std::ostream& out, const std::tuple<T...>& tp)
|
|
|
|
{
|
|
|
|
PackNum<sizeof...(T)-1>::printTuple(out, tp);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class RangeType>
|
|
|
|
auto getIndex(std::shared_ptr<RangeType> range)
|
|
|
|
-> std::shared_ptr<typename RangeType::IndexType>
|
|
|
|
{
|
|
|
|
return std::make_shared<typename RangeType::IndexType>(range);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class RangeType>
|
|
|
|
auto getIndex()
|
|
|
|
-> std::shared_ptr<typename RangeType::IndexType>
|
|
|
|
{
|
|
|
|
static_assert( RangeType::defaultable,
|
|
|
|
/*typeid(typename RangeType).name() + */" is not defaultable" );
|
|
|
|
static auto f = RangeType::factory();
|
|
|
|
static auto r = std::dynamic_pointer_cast<RangeType>( f.create() );
|
|
|
|
return std::make_shared<typename RangeType::IndexType>(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class... RangeTypes>
|
|
|
|
auto mkMulti(std::shared_ptr<RangeTypes>... ranges)
|
|
|
|
-> std::shared_ptr<MultiRange<RangeTypes...> >
|
|
|
|
{
|
|
|
|
MultiRangeFactory<RangeTypes...> mrf( ranges... );
|
|
|
|
return std::dynamic_pointer_cast<MultiRange<RangeTypes...> >( mrf.create() );
|
|
|
|
}
|
|
|
|
|
2020-08-29 23:36:01 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
template <size_t N>
|
|
|
|
struct IndexToRangeTuple
|
|
|
|
{
|
|
|
|
template <class... IndexTypes>
|
|
|
|
static inline void set(std::tuple<std::shared_ptr<typename IndexTypes::RangeType>...>& out,
|
|
|
|
const std::tuple<std::shared_ptr<IndexTypes>...>& indices)
|
|
|
|
{
|
|
|
|
std::get<N>(out) = std::get<N>(indices)->range();
|
|
|
|
IndexToRangeTuple<N-1>::set(out,indices);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct IndexToRangeTuple<0>
|
|
|
|
{
|
|
|
|
template <class... IndexTypes>
|
|
|
|
static inline void set(std::tuple<std::shared_ptr<typename IndexTypes::RangeType>...>& out,
|
|
|
|
const std::tuple<std::shared_ptr<IndexTypes>...>& indices)
|
|
|
|
{
|
|
|
|
std::get<0>(out) = std::get<0>(indices)->range();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class... IndexTypes>
|
|
|
|
auto indexToRangeTuple(const std::tuple<std::shared_ptr<IndexTypes>...>& indices)
|
|
|
|
-> std::tuple<std::shared_ptr<typename IndexTypes::RangeType>...>
|
|
|
|
{
|
|
|
|
std::tuple<std::shared_ptr<typename IndexTypes::RangeType>...> out;
|
|
|
|
IndexToRangeTuple<sizeof...(IndexTypes)-1>::set(out, indices);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
template <class... IndexTypes>
|
|
|
|
auto mkMIndex(std::shared_ptr<IndexTypes>... indices)
|
|
|
|
-> decltype( getIndex( mkMulti( indices->range()... ) ) )
|
|
|
|
{
|
|
|
|
auto mi = getIndex( mkMulti( indices->range()... ) );
|
|
|
|
(*mi)( indices... );
|
|
|
|
return mi;
|
|
|
|
}
|
|
|
|
|
2020-08-29 23:36:01 +02:00
|
|
|
template <class... IndexTypes>
|
|
|
|
auto mkMIndex(const std::tuple<std::shared_ptr<IndexTypes>...>& indices)
|
|
|
|
-> decltype( getIndex( mkMulti( indexToRangeTuple(indices) ) ) )
|
|
|
|
{
|
|
|
|
auto mi = getIndex( mkMulti( indexToRangeTuple(indices) ) );
|
|
|
|
(*mi)( indices );
|
|
|
|
return mi;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-13 01:00:35 +02:00
|
|
|
template <class Index>
|
|
|
|
auto mkIndexW(const std::shared_ptr<Index>& ind)
|
|
|
|
-> std::shared_ptr<IndexW>
|
|
|
|
{
|
|
|
|
return std::make_shared<IndexWrapper<Index>>(ind);
|
|
|
|
}
|
|
|
|
|
2019-03-29 12:58:39 +01:00
|
|
|
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...> >
|
2018-10-30 15:06:29 +01:00
|
|
|
{
|
2019-03-29 12:58:39 +01:00
|
|
|
GenMapRangeFactory<Op,STYPE,RangeTypes...> mrf(f, ranges... );
|
|
|
|
return createExplicit( mrf );
|
2018-10-30 15:06:29 +01:00
|
|
|
}
|
|
|
|
|
2019-09-17 14:24:01 +02:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2019-03-29 12:58:39 +01:00
|
|
|
template <SpaceType STYPE, class Op, class MA, class... IndexTypes>
|
|
|
|
auto mkGenMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices)
|
2019-02-06 14:11:17 +01:00
|
|
|
-> decltype( getIndex( mkGenMapR<STYPE>( f, indices->range()... ) ) )
|
2018-10-30 15:06:29 +01:00
|
|
|
{
|
2019-02-06 14:11:17 +01:00
|
|
|
auto mi = getIndex( mkGenMapR<STYPE>( f, indices->range()... ) );
|
2018-10-30 15:06:29 +01:00
|
|
|
(*mi)(indices...);
|
|
|
|
return mi;
|
|
|
|
}
|
2019-02-06 13:01:14 +01:00
|
|
|
|
2019-03-29 12:58:39 +01:00
|
|
|
template <class Op, class MA, class... RangeTypes>
|
|
|
|
auto mkMapR(const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges)
|
2019-02-06 13:01:14 +01:00
|
|
|
-> decltype( mkGenMapR<SpaceType::ANY>(f, ranges... ) )
|
|
|
|
{
|
|
|
|
return mkGenMapR<SpaceType::ANY>(f, ranges... );
|
|
|
|
}
|
|
|
|
|
2019-09-17 14:24:01 +02:00
|
|
|
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... );
|
|
|
|
}
|
|
|
|
|
2021-01-08 21:40:20 +01:00
|
|
|
template <class Func, class... Indices>
|
|
|
|
auto mkMapR(const std::shared_ptr<Func>& func, const std::shared_ptr<Indices>&... is)
|
|
|
|
-> decltype( mkMapR( mkMapOp( func, is... ), is->range()... ) )
|
|
|
|
{
|
|
|
|
return mkMapR( mkMapOp( func, is... ), is->range()... );
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class TarRange, 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)
|
|
|
|
-> decltype( mkMapRwith(outr, mkMapOp( func, is... ), is->range()... ) )
|
|
|
|
{
|
|
|
|
return mkMapRwith(outr, mkMapOp( func, is... ), is->range()... );
|
|
|
|
}
|
|
|
|
|
2019-03-29 12:58:39 +01:00
|
|
|
template <class Op, class MA, class... IndexTypes>
|
|
|
|
auto mkMapI(const std::tuple<Op,MA>& f, std::shared_ptr<IndexTypes>... indices)
|
2019-02-06 13:01:14 +01:00
|
|
|
-> decltype( mkGenMapI<SpaceType::ANY>(f, indices... ) )
|
|
|
|
{
|
|
|
|
return mkGenMapI<SpaceType::ANY>(f, indices... );
|
|
|
|
}
|
2018-10-30 15:06:29 +01:00
|
|
|
|
|
|
|
template <class... RangeTypes>
|
|
|
|
auto mkMulti(std::tuple<std::shared_ptr<RangeTypes>...> rangesTuple)
|
2020-08-29 23:36:01 +02:00
|
|
|
-> std::shared_ptr<MultiRange<RangeTypes...>>
|
2018-10-30 15:06:29 +01:00
|
|
|
{
|
|
|
|
MultiRangeFactory<RangeTypes...> mrf( rangesTuple );
|
|
|
|
return std::dynamic_pointer_cast<MultiRange<RangeTypes...> >( mrf.create() );
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class RangeFactory>
|
|
|
|
auto createExplicit(RangeFactory& rf)
|
|
|
|
-> std::shared_ptr<typename RangeFactory::oType>
|
|
|
|
{
|
|
|
|
return std::dynamic_pointer_cast<typename RangeFactory::oType>( rf.create() );
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class RangeFactory>
|
|
|
|
auto createExplicit(std::shared_ptr<RangeFactory> rfp)
|
|
|
|
-> std::shared_ptr<typename RangeFactory::oType>
|
|
|
|
{
|
|
|
|
return std::dynamic_pointer_cast<typename RangeFactory::oType>( rfp->create() );
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Range>
|
2019-02-13 21:59:13 +01:00
|
|
|
auto createRange(const vector<char>& cvec)
|
2018-10-30 15:06:29 +01:00
|
|
|
-> std::shared_ptr<Range>
|
|
|
|
{
|
|
|
|
const char* dp = cvec.data();
|
|
|
|
auto ff = createRangeFactory(&dp);
|
|
|
|
auto rbptr = ff->create();
|
|
|
|
assert(rbptr->spaceType() == Range::STYPE);
|
|
|
|
// CATCH CAST ERROR HERE !!!
|
|
|
|
return std::dynamic_pointer_cast<Range>( rbptr );
|
|
|
|
}
|
|
|
|
|
2019-03-27 19:00:16 +01:00
|
|
|
inline auto createRange(const vector<char>* cvec, int metaType, size_t size)
|
|
|
|
-> std::shared_ptr<RangeBase>
|
|
|
|
{
|
|
|
|
auto f = createSingleRangeFactory(cvec, metaType, size);
|
|
|
|
return f->create();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline auto createRangeA(const vector<char>* cvec, int metaType, size_t size)
|
|
|
|
-> std::shared_ptr<AnonymousRange>
|
|
|
|
{
|
|
|
|
AnonymousRangeFactory arf(createRange(cvec, metaType, size));
|
|
|
|
return createExplicit(arf);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline auto cvecMetaCast(const std::shared_ptr<SingleRange<vector<char>,SpaceType::ANY>>& r, int metaType)
|
|
|
|
-> std::shared_ptr<RangeBase>
|
|
|
|
{
|
|
|
|
return createRange(&r->get(0), metaType, r->size());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline auto cvecMetaCastA(const std::shared_ptr<SingleRange<vector<char>,SpaceType::ANY>>& r, int metaType)
|
|
|
|
-> std::shared_ptr<AnonymousRange>
|
|
|
|
{
|
|
|
|
return createRangeA(&r->get(0), metaType, r->size());
|
|
|
|
}
|
|
|
|
|
2019-03-13 19:17:22 +01:00
|
|
|
template <class Range, typename... Args>
|
2019-03-14 19:10:06 +01:00
|
|
|
auto createRangeE(Args&&... args)
|
2019-03-13 19:17:22 +01:00
|
|
|
-> std::shared_ptr<Range>
|
|
|
|
{
|
2019-03-14 19:10:06 +01:00
|
|
|
typename Range::FType f(args...);
|
2019-03-13 19:17:22 +01:00
|
|
|
return createExplicit(f);
|
|
|
|
}
|
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
template <size_t N, class MArray>
|
|
|
|
auto rptr(const MArray& ma)
|
|
|
|
-> decltype(ma.template getRangePtr<N>())
|
|
|
|
{
|
|
|
|
return ma.template getRangePtr<N>();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <class MArray>
|
2018-11-01 22:11:08 +01:00
|
|
|
auto dynamic(const MArray& ma, bool slice)
|
2020-07-08 17:55:51 +02:00
|
|
|
-> std::shared_ptr<MultiArrayBase<typename MArray::value_type,DynamicRange>>
|
2018-11-01 22:11:08 +01:00
|
|
|
{
|
2020-07-08 17:55:51 +02:00
|
|
|
DynamicRangeFactory drf(ma.range()->space());
|
2018-11-01 22:11:08 +01:00
|
|
|
if(slice){
|
2020-07-08 17:55:51 +02:00
|
|
|
return std::make_shared<ConstSlice<typename MArray::value_type,DynamicRange>>
|
|
|
|
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
|
2018-11-01 22:11:08 +01:00
|
|
|
ma.data() );
|
|
|
|
}
|
|
|
|
else {
|
2020-07-08 17:55:51 +02:00
|
|
|
return std::make_shared<MultiArray<typename MArray::value_type,DynamicRange>>
|
|
|
|
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
|
2018-11-01 22:11:08 +01:00
|
|
|
ma.vdata() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <class MArray>
|
2019-07-12 18:11:22 +02:00
|
|
|
auto mdynamic(MArray& ma, bool slice)
|
2020-07-08 17:55:51 +02:00
|
|
|
-> std::shared_ptr<MutableMultiArrayBase<typename MArray::value_type,DynamicRange>>
|
2019-07-12 18:11:22 +02:00
|
|
|
{
|
2020-07-08 17:55:51 +02:00
|
|
|
DynamicRangeFactory drf(ma.range()->space());
|
2019-07-12 18:11:22 +02:00
|
|
|
if(slice){
|
2020-07-08 17:55:51 +02:00
|
|
|
return std::make_shared<Slice<typename MArray::value_type,DynamicRange>>
|
|
|
|
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
|
2019-07-12 18:11:22 +02:00
|
|
|
ma.data() );
|
|
|
|
}
|
|
|
|
else {
|
2020-07-08 17:55:51 +02:00
|
|
|
return std::make_shared<MultiArray<typename MArray::value_type,DynamicRange>>
|
|
|
|
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
|
2019-07-12 18:11:22 +02:00
|
|
|
ma.vdata() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:03:35 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
template <size_t N>
|
|
|
|
struct CopyRanges
|
|
|
|
{
|
|
|
|
template <class Space1, class Space2>
|
|
|
|
static inline void exec(const Space1& space1, Space2& space2)
|
|
|
|
{
|
|
|
|
std::get<N>(space2) = std::get<N>(space1);
|
|
|
|
CopyRanges<N-1>::exec(space1,space2);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct CopyRanges<0>
|
|
|
|
{
|
|
|
|
template <class Space1, class Space2>
|
|
|
|
static inline void exec(const Space1& space1, Space2& space2)
|
|
|
|
{
|
|
|
|
std::get<0>(space2) = std::get<0>(space1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <typename T, class Range1, class... RangeTypes>
|
2019-05-15 20:37:00 +02:00
|
|
|
auto anonToDynView(const MultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
2020-07-08 17:55:51 +02:00
|
|
|
-> ConstSlice<T,Range1,RangeTypes...,DynamicRange>
|
2018-11-03 22:03:35 +01:00
|
|
|
{
|
|
|
|
constexpr size_t LAST = sizeof...(RangeTypes)+1;
|
2020-07-08 17:55:51 +02:00
|
|
|
DynamicRangeFactory drf(rptr<LAST>(ma)->orig());
|
2018-11-03 22:03:35 +01:00
|
|
|
std::tuple<std::shared_ptr<Range1>,std::shared_ptr<RangeTypes>...,
|
2020-07-08 17:55:51 +02:00
|
|
|
std::shared_ptr<DynamicRange>> mNSpace;
|
2018-11-03 22:03:35 +01:00
|
|
|
CopyRanges<LAST-1>::exec(ma.range()->space(),mNSpace);
|
|
|
|
std::get<LAST>(mNSpace) = createExplicit( drf );
|
2020-07-08 17:55:51 +02:00
|
|
|
return ConstSlice<T,Range1,RangeTypes...,DynamicRange>(mNSpace, ma.data());
|
2018-11-03 22:03:35 +01:00
|
|
|
}
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <typename T, class Range1, class... RangeTypes>
|
2019-09-13 18:08:23 +02:00
|
|
|
auto anonToDynView(MutableMultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
2020-07-08 17:55:51 +02:00
|
|
|
-> Slice<T,Range1,RangeTypes...,DynamicRange>
|
2019-09-13 18:08:23 +02:00
|
|
|
{
|
|
|
|
constexpr size_t LAST = sizeof...(RangeTypes)+1;
|
2020-07-08 17:55:51 +02:00
|
|
|
DynamicRangeFactory drf(rptr<LAST>(ma)->orig());
|
2019-09-13 18:08:23 +02:00
|
|
|
std::tuple<std::shared_ptr<Range1>,std::shared_ptr<RangeTypes>...,
|
2020-07-08 17:55:51 +02:00
|
|
|
std::shared_ptr<DynamicRange>> mNSpace;
|
2019-09-13 18:08:23 +02:00
|
|
|
CopyRanges<LAST-1>::exec(ma.range()->space(),mNSpace);
|
|
|
|
std::get<LAST>(mNSpace) = createExplicit( drf );
|
2020-07-08 17:55:51 +02:00
|
|
|
return Slice<T,Range1,RangeTypes...,DynamicRange>(mNSpace, ma.data());
|
2019-09-13 18:08:23 +02:00
|
|
|
}
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <typename T, class Range1, class... RangeTypes>
|
|
|
|
auto dynToAnonMove(MultiArray<T,Range1,RangeTypes...,DynamicRange>&& ma)
|
2018-11-03 22:03:35 +01:00
|
|
|
-> MultiArray<T,Range1,RangeTypes...,AnonymousRange>
|
|
|
|
{
|
|
|
|
constexpr size_t LAST = sizeof...(RangeTypes)+1;
|
|
|
|
AnonymousRangeFactory arf(rptr<LAST>(ma)->orig());
|
|
|
|
std::tuple<std::shared_ptr<Range1>,std::shared_ptr<RangeTypes>...,
|
|
|
|
std::shared_ptr<AnonymousRange>> mNSpace;
|
|
|
|
CopyRanges<LAST-1>::exec(ma.range()->space(),mNSpace);
|
|
|
|
std::get<LAST>(mNSpace) = createExplicit( arf );
|
|
|
|
return ma.format(mNSpace);
|
|
|
|
}
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <typename T>
|
2019-05-15 20:37:00 +02:00
|
|
|
auto anonToDynView(const MultiArrayBase<T,AnonymousRange>& ma)
|
2020-07-08 17:55:51 +02:00
|
|
|
-> ConstSlice<T,DynamicRange>
|
2018-11-03 22:03:35 +01:00
|
|
|
{
|
2020-07-08 17:55:51 +02:00
|
|
|
DynamicRangeFactory drf(rptr<0>(ma)->orig());
|
2018-11-03 22:03:35 +01:00
|
|
|
auto mNSpace = std::make_tuple( createExplicit( drf ) );
|
2020-07-08 17:55:51 +02:00
|
|
|
return ConstSlice<T,DynamicRange>(mNSpace, ma.data());
|
2018-11-03 22:03:35 +01:00
|
|
|
}
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <typename T>
|
2019-09-13 18:08:23 +02:00
|
|
|
auto anonToDynView(MutableMultiArrayBase<T,AnonymousRange>& ma)
|
2020-07-08 17:55:51 +02:00
|
|
|
-> Slice<T,DynamicRange>
|
2019-09-13 18:08:23 +02:00
|
|
|
{
|
2020-07-08 17:55:51 +02:00
|
|
|
DynamicRangeFactory drf(rptr<0>(ma)->orig());
|
2019-09-13 18:08:23 +02:00
|
|
|
auto mNSpace = std::make_tuple( createExplicit( drf ) );
|
2020-07-08 17:55:51 +02:00
|
|
|
return Slice<T,DynamicRange>(mNSpace, ma.data());
|
2019-09-13 18:08:23 +02:00
|
|
|
}
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <typename T>
|
|
|
|
auto dynToAnonMove(MultiArray<T,DynamicRange>&& ma)
|
2018-11-03 22:03:35 +01:00
|
|
|
-> MultiArray<T,AnonymousRange>
|
|
|
|
{
|
|
|
|
AnonymousRangeFactory arf(rptr<0>(ma)->orig());
|
|
|
|
auto mNSpace = std::make_tuple( createExplicit( arf ) );
|
|
|
|
return ma.format(mNSpace);
|
|
|
|
}
|
|
|
|
|
2019-03-08 13:09:10 +01:00
|
|
|
template <class Range>
|
|
|
|
auto metaSlice(const std::shared_ptr<Range>& r)
|
2019-03-11 19:24:34 +01:00
|
|
|
-> ConstSlice<typename Range::MetaType,ClassicRange>
|
2019-03-08 13:09:10 +01:00
|
|
|
{
|
|
|
|
ClassicRF crf(r->size());
|
2019-03-11 19:24:34 +01:00
|
|
|
return ConstSlice<typename Range::MetaType,ClassicRange>( createExplicit(crf), &r->get(0) );
|
2019-03-08 13:09:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Range, class ORange>
|
|
|
|
auto metaSlice(const std::shared_ptr<Range>& r, const std::shared_ptr<ORange>& ro)
|
2019-03-11 19:24:34 +01:00
|
|
|
-> ConstSlice<typename Range::MetaType,ORange>
|
2019-03-08 13:09:10 +01:00
|
|
|
{
|
2019-03-11 19:24:34 +01:00
|
|
|
return ConstSlice<typename Range::MetaType,ORange>( ro, &r->get(0) );
|
2019-03-08 13:09:10 +01:00
|
|
|
}
|
|
|
|
|
2019-03-13 19:17:22 +01:00
|
|
|
template <typename T, class... Ranges>
|
|
|
|
auto mkArray(const std::shared_ptr<Ranges>&... rs)
|
|
|
|
-> MultiArray<T,Ranges...>
|
|
|
|
{
|
|
|
|
return MultiArray<T,Ranges...>(rs...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, class... Ranges>
|
|
|
|
auto mkArray(const std::shared_ptr<Ranges>&... rs, const T& val)
|
|
|
|
-> MultiArray<T,Ranges...>
|
|
|
|
{
|
|
|
|
return MultiArray<T,Ranges...>(rs..., val);
|
|
|
|
}
|
|
|
|
|
2020-09-02 18:35:20 +02:00
|
|
|
template <typename T, class... Ranges>
|
|
|
|
auto mkArrayPtr(const std::shared_ptr<Ranges>&... rs)
|
|
|
|
-> std::shared_ptr<MultiArray<T,Ranges...>>
|
|
|
|
{
|
|
|
|
return std::make_shared<MultiArray<T,Ranges...>>(rs...);
|
|
|
|
}
|
2018-11-03 22:03:35 +01:00
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
}
|