remove statics/ utils/

This commit is contained in:
Christian Zimmermann 2022-11-26 17:03:39 +01:00
parent 3418ec9ee1
commit 42a8acbc6e
5 changed files with 0 additions and 836 deletions

View file

@ -3,7 +3,6 @@
#define __cxz_aindex_cc_h__ #define __cxz_aindex_cc_h__
#include "aindex.h" #include "aindex.h"
#include "statics/static_for.h"
namespace CNORXZ namespace CNORXZ
{ {

View file

@ -1,173 +0,0 @@
#ifndef __cxz_static_for_h__
#define __cxz_static_for_h__
#include <cstdlib>
namespace CNORXZ
{
template <size_t BEG, size_t END, int OFF, typename Incr, typename F>
inline auto sfor(Incr incr, F f)
{
constexpr auto idx = std::integral_constant<size_t, BEG>{};
constexpr auto idxm = std::integral_constant<size_t, BEG+OFF>{};
const bool cond = f(idxm);
if constexpr(incr(idx) != END){
if(cond){
sfor<incr(idx),END,OFF>(incr,f);
}
}
return cond;
}
template <size_t BEG, size_t END, int OFF, typename Incr, typename F, typename Cond>
inline auto sforx(Incr incr, F f, Cond cond)
{
constexpr auto idx = std::integral_constant<size_t, BEG>{};
constexpr auto idxm = std::integral_constant<size_t, BEG+OFF>{};
if constexpr(incr(idx) != END){
if(cond(idx)){
return sforx<incr(idx),END,OFF>(incr,f,cond);
}
else {
return f(idxm);
}
}
else {
return f(idxm);
}
}
template <size_t BEG, size_t END, int OFF, typename Incr, typename F, typename Conc>
inline auto sfor(Incr incr, F f, Conc conc)
{
constexpr auto idx = std::integral_constant<size_t, BEG>{};
constexpr auto idxm = std::integral_constant<size_t, BEG+OFF>{};
//static_assert(abs(idx.value - END) >= abs(incr(idx) - END),
// "this turns out to be a static endless loop");
auto tmp = f(idxm);
if constexpr(incr(idx) == END){
return tmp;
}
else {
return conc(tmp, sfor<incr(idx),END,OFF>(incr,f,conc));
}
}
template <size_t BEG, size_t END, int OFF, typename Incr, typename F, typename Conc, typename Arg>
inline auto sfor(Incr incr, F f, Conc conc, const Arg& arg)
{
constexpr auto idx = std::integral_constant<size_t, BEG>{};
constexpr auto idxm = std::integral_constant<size_t, BEG+OFF>{};
//static_assert(abs(idx.value - END) >= abs(incr(idx) - END),
// "this turns out to be a static endless loop");
auto tmp = f(idxm);
if constexpr(incr(idx) == END){
return conc(tmp, arg);
}
else {
return conc(tmp, sfor<incr(idx),END,OFF>(incr,f,conc,arg));
}
}
template <size_t BEG, size_t END, int OFF, typename Incr, typename F, typename Create, typename... Args>
inline auto unpack(Incr incr, F f, Create create, const Args&... args)
{
constexpr auto idx = std::integral_constant<size_t, BEG>{};
constexpr auto idxm = std::integral_constant<size_t, BEG+OFF>{};
//static_assert(abs(idx.value - END) >= abs(incr(idx) - END),
// "this turns out to be a static endless loop");
if constexpr(BEG == END){
return create(args...);
}
else {
auto tmp = f(idxm);
return unpack<incr(idx),END,OFF>(incr, f, create, args..., tmp);
}
}
}
#define MA_INC [&](auto i) constexpr { return i+1; }
#define MA_DEC [&](auto i) constexpr { return i-1; }
#define MA_ZCONC [&](auto a, auto b) { return 0; }
namespace CNORXZ
{
template <size_t BEG, size_t END, typename F>
inline auto sfor_p(F f)
{
return sfor<BEG,END,0>(MA_INC,f);
}
template <size_t BEG, size_t END, typename F>
inline auto sfor_m(F f)
{
return sfor<BEG,END,-1>(MA_DEC,f);
}
template <size_t BEG, size_t END, typename F, typename Cond>
inline auto sforx_p(F f, Cond cond)
{
return sforx<BEG,END,0>(MA_INC,f,cond);
}
template <size_t BEG, size_t END, typename F, typename Cond>
inline auto sforx_m(F f, Cond cond)
{
return sforx<BEG,END,-1>(MA_DEC,f,cond);
}
template <size_t BEG, size_t END, typename F, typename Conc>
inline auto sfor_p(F f, Conc conc)
{
return sfor<BEG,END,0>(MA_INC,f,conc);
}
template <size_t BEG, size_t END, typename F>
inline auto sfor_pn(F f)
{
return sfor_p<BEG,END>(f,MA_ZCONC);
}
template <size_t BEG, size_t END, typename F, typename Conc>
inline auto sfor_m(F f, Conc conc)
{
return sfor<BEG,END,-1>(MA_DEC,f,conc);
}
template <size_t BEG, size_t END, typename F>
inline auto sfor_mn(F f)
{
return sfor_m<BEG,END>(f,MA_ZCONC);
}
template <size_t BEG, size_t END, typename F, typename Conc, typename Arg>
inline auto sfor_p(F f, Conc conc, const Arg& arg)
{
return sfor<BEG,END,0>(MA_INC,f,conc,arg);
}
template <size_t BEG, size_t END, typename F, typename Arg>
inline auto sfor_pn(F f, const Arg& arg)
{
return sfor_p<BEG,END>(f,MA_ZCONC,arg);
}
template <size_t BEG, size_t END, typename F, typename Conc, typename Arg>
inline auto sfor_m(F f, Conc conc, const Arg& arg)
{
return sfor<BEG,END,-1>(MA_DEC,f,conc,arg);
}
template <size_t BEG, size_t END, typename F, typename Arg>
inline auto sfor_mn(F f, const Arg& arg)
{
return sfor_m<BEG,END>(f,MA_ZCONC,arg);
}
}
#endif

View file

@ -1,26 +0,0 @@
#include "base_def.h"
namespace CNORXZ
{
template <typename T>
struct IsArray
{
static constexpr bool VALUE = false;
};
#define add_array_trait(name) template <typename... X> struct IsArray<##name<X...>> { \
static constexpr bool VALUE = true; \
}
add_array_trait(DArrayBase);
add_array_trait(MDArrayBase);
add_array_trait(DArray);
//add_array_trait(FunctionalArray);
//add_array_trait(Slice);
//add_array_trait(ConstSlice);
#undef add_array_trait
}

View file

@ -1,398 +0,0 @@
#include "helper_tools.h"
namespace CNORXZ
{
template <typename... T>
std::ostream& operator<<(std::ostream& out, const std::tuple<T...>& tp)
{
sfor_pn<0,sizeof...(T)-1>( [&](auto i){ out << std::get<i>(tp) << ", "; return 0; } );
out << std::get<sizeof...(T)-1>(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, "Range 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() );
}
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;
}
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;
}
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;
}
template <class Index>
auto mkIndexW(const std::shared_ptr<Index>& ind)
-> std::shared_ptr<IndexW>
{
return std::make_shared<IndexWrapper<Index>>(ind);
}
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<MapORType<Op,STYPE>,Op,STYPE,RangeTypes...> >
{
GenMapRangeFactory<MapORType<Op,STYPE>,Op,STYPE,RangeTypes...> mrf(f, ranges... );
return createExplicit( mrf );
}
template <SpaceType STYPE, class ORType, class Op, class MA, class... RangeTypes>
auto mkGenMapRwith(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& f,
std::shared_ptr<RangeTypes>... ranges)
-> std::shared_ptr<GenMapRange<ORType,Op,STYPE,RangeTypes...> >
{
GenMapRangeFactory<ORType,Op,STYPE,RangeTypes...> mrf(outr, f, ranges... );
return createExplicit( mrf );
}
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()... ) );
(*mi)(indices...);
return mi;
}
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 ORType, class Op, class MA, class... RangeTypes>
auto mkMapRwith(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& f,
std::shared_ptr<RangeTypes>... ranges)
-> decltype( mkGenMapRwith<SpaceType::ANY>(outr, f, ranges... ) )
{
return mkGenMapRwith<SpaceType::ANY>(outr, f, ranges... );
}
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 ORType, class Func, class... Indices>
auto mkMapRwith(const std::shared_ptr<ORType>& outr, const std::shared_ptr<Func>& func, const std::shared_ptr<Indices>&... is)
-> decltype( mkMapRwith(outr, mkMapOp( func, is... ), is->range()... ) )
{
return mkMapRwith(outr, mkMapOp( func, is... ), is->range()... );
}
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... );
}
template <class... RangeTypes>
auto mkMulti(std::tuple<std::shared_ptr<RangeTypes>...> rangesTuple)
-> std::shared_ptr<MultiRange<RangeTypes...>>
{
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>
auto createRange(const vector<char>& cvec)
-> 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 );
}
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());
}
template <class Range, typename... Args>
auto createRangeE(Args&&... args)
-> std::shared_ptr<Range>
{
typename Range::FType f(args...);
return createExplicit(f);
}
template <size_t N, class MArray>
auto rptr(const MArray& ma)
-> decltype(ma.template getRangePtr<N>())
{
return ma.template getRangePtr<N>();
}
template <class MArray>
auto dynamic(const MArray& ma, bool slice)
-> std::shared_ptr<ArrayBase<typename MArray::value_type,DynamicRange>>
{
DynamicRangeFactory drf(ma.range()->space());
if(slice){
return std::make_shared<ConstSlice<typename MArray::value_type,DynamicRange>>
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
ma.data() );
}
else {
return std::make_shared<Array<typename MArray::value_type,DynamicRange>>
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
ma.vdata() );
}
}
template <class MArray>
auto mdynamic(MArray& ma, bool slice)
-> std::shared_ptr<MutableArrayBase<typename MArray::value_type,DynamicRange>>
{
DynamicRangeFactory drf(ma.range()->space());
if(slice){
return std::make_shared<Slice<typename MArray::value_type,DynamicRange>>
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
ma.data() );
}
else {
return std::make_shared<Array<typename MArray::value_type,DynamicRange>>
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
ma.vdata() );
}
}
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);
}
};
}
template <typename T, class Range1, class... RangeTypes>
auto anonToDynView(const ArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
-> ConstSlice<T,Range1,RangeTypes...,DynamicRange>
{
constexpr size_t LAST = sizeof...(RangeTypes)+1;
DynamicRangeFactory drf(rptr<LAST>(ma)->orig());
std::tuple<std::shared_ptr<Range1>,std::shared_ptr<RangeTypes>...,
std::shared_ptr<DynamicRange>> mNSpace;
CopyRanges<LAST-1>::exec(ma.range()->space(),mNSpace);
std::get<LAST>(mNSpace) = createExplicit( drf );
return ConstSlice<T,Range1,RangeTypes...,DynamicRange>(mNSpace, ma.data());
}
template <typename T, class Range1, class... RangeTypes>
auto anonToDynView(MutableArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
-> Slice<T,Range1,RangeTypes...,DynamicRange>
{
constexpr size_t LAST = sizeof...(RangeTypes)+1;
DynamicRangeFactory drf(rptr<LAST>(ma)->orig());
std::tuple<std::shared_ptr<Range1>,std::shared_ptr<RangeTypes>...,
std::shared_ptr<DynamicRange>> mNSpace;
CopyRanges<LAST-1>::exec(ma.range()->space(),mNSpace);
std::get<LAST>(mNSpace) = createExplicit( drf );
return Slice<T,Range1,RangeTypes...,DynamicRange>(mNSpace, ma.data());
}
template <typename T, class Range1, class... RangeTypes>
auto dynToAnonMove(Array<T,Range1,RangeTypes...,DynamicRange>&& ma)
-> Array<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);
}
template <typename T>
auto anonToDynView(const ArrayBase<T,AnonymousRange>& ma)
-> ConstSlice<T,DynamicRange>
{
DynamicRangeFactory drf(rptr<0>(ma)->orig());
auto mNSpace = std::make_tuple( createExplicit( drf ) );
return ConstSlice<T,DynamicRange>(mNSpace, ma.data());
}
template <typename T>
auto anonToDynView(MutableArrayBase<T,AnonymousRange>& ma)
-> Slice<T,DynamicRange>
{
DynamicRangeFactory drf(rptr<0>(ma)->orig());
auto mNSpace = std::make_tuple( createExplicit( drf ) );
return Slice<T,DynamicRange>(mNSpace, ma.data());
}
template <typename T>
auto dynToAnonMove(Array<T,DynamicRange>&& ma)
-> Array<T,AnonymousRange>
{
AnonymousRangeFactory arf(rptr<0>(ma)->orig());
auto mNSpace = std::make_tuple( createExplicit( arf ) );
return ma.format(mNSpace);
}
template <class Range>
auto metaSlice(const std::shared_ptr<Range>& r)
-> ConstSlice<typename Range::MetaType,ClassicRange>
{
ClassicRF crf(r->size());
return ConstSlice<typename Range::MetaType,ClassicRange>( createExplicit(crf), &r->get(0) );
}
template <class Range, class ORange>
auto metaSlice(const std::shared_ptr<Range>& r, const std::shared_ptr<ORange>& ro)
-> ConstSlice<typename Range::MetaType,ORange>
{
return ConstSlice<typename Range::MetaType,ORange>( ro, &r->get(0) );
}
template <typename T, class... Ranges>
auto mkArray(const std::shared_ptr<Ranges>&... rs)
-> Array<T,Ranges...>
{
return Array<T,Ranges...>(rs...);
}
template <typename T, class... Ranges>
auto mkArray(const std::shared_ptr<Ranges>&... rs, const T& val)
-> Array<T,Ranges...>
{
return Array<T,Ranges...>(rs..., val);
}
template <typename T, class... Ranges>
auto mkArrayPtr(const std::shared_ptr<Ranges>&... rs)
-> std::shared_ptr<Array<T,Ranges...>>
{
return std::make_shared<Array<T,Ranges...>>(rs...);
}
}

View file

@ -1,238 +0,0 @@
#ifndef __cxz_helper_tools_h__
#define __cxz_helper_tools_h__
#include "base_def.h"
#include "slice.h"
#include <ostream>
#include "map_range.h"
#include <functional>
#include "xpr/iloop.h"
namespace CNORXZ
{
template <typename... T>
std::ostream& operator<<(std::ostream& out, const std::tuple<T...>& tp);
template <class RangeType>
auto getIndex(std::shared_ptr<RangeType> range)
-> std::shared_ptr<typename RangeType::IndexType>;
// only if 'RangeType' is defaultable and unique (Singleton)
template <class RangeType>
auto getIndex() -> std::shared_ptr<typename RangeType::IndexType>;
template <class... RangeTypes>
auto mkMulti(std::shared_ptr<RangeTypes>... ranges)
-> std::shared_ptr<MultiRange<RangeTypes...> >;
template <class Op, SpaceType XSTYPE>
using MapORType = SingleRange<typename Op::value_type,XSTYPE>;
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<MapORType<Op,STYPE>,Op,STYPE,RangeTypes...> >;
template <SpaceType STYPE, class ORType, class Op, class MA, class... RangeTypes>
auto mkGenMapRwith(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& f,
std::shared_ptr<RangeTypes>... ranges)
-> std::shared_ptr<GenMapRange<ORType,Op,STYPE,RangeTypes...> >;
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 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 ORType, class Op, class MA, class... RangeTypes>
auto mkMapRwith(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& f, std::shared_ptr<RangeTypes>... ranges)
-> decltype( mkGenMapRwith<SpaceType::ANY>(outr, f, ranges... ) );
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()... ) );
template <class ORType, class Func, class... Indices>
auto mkMapRwith(const std::shared_ptr<ORType>& outr, const std::shared_ptr<Func>& func, const std::shared_ptr<Indices>&... is)
-> decltype( mkMapRwith(outr, mkMapOp( func, is... ), is->range()... ) );
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 indexToRangeTuple(const std::tuple<std::shared_ptr<IndexTypes>...>& indices)
-> std::tuple<std::shared_ptr<typename IndexTypes::RangeType>...>;
template <class... RangeTypes>
auto mkMulti(std::tuple<std::shared_ptr<RangeTypes>...> rangesTuple)
-> std::shared_ptr<MultiRange<RangeTypes...>>;
template <class... IndexTypes>
auto mkMIndex(std::shared_ptr<IndexTypes>... indices)
-> decltype( getIndex( mkMulti( indices.range()... ) ) );
template <class... IndexTypes>
auto mkMIndex(const std::tuple<std::shared_ptr<IndexTypes>...>& indices)
-> decltype( getIndex( mkMulti( indexToRangeTuple(indices) ) ) );
template <class Index>
auto mkIndexW(const std::shared_ptr<Index>& ind)
-> std::shared_ptr<IndexW>;
template <class RangeFactory>
auto createExplicit(RangeFactory& rf)
-> std::shared_ptr<typename RangeFactory::oType>;
template <class RangeFactory>
auto createExplicit(std::shared_ptr<RangeFactory> rfp)
-> std::shared_ptr<typename RangeFactory::oType>;
template <class Range>
auto createRange(const vector<char>& cvec)
-> std::shared_ptr<Range>;
inline auto createRange(const vector<char>* cvec, int metaType, size_t size)
-> std::shared_ptr<RangeBase>;
inline auto createRangeA(const vector<char>* cvec, int metaType, size_t size)
-> std::shared_ptr<AnonymousRange>;
template <class Range, typename... Args>
auto createRangeE(Args&&... args)
-> std::shared_ptr<Range>;
template <size_t N, class MArray>
auto rptr(const MArray& ma)
-> decltype(ma.template getRangePtr<N>());
template <size_t I, class MIndex>
auto get(const std::shared_ptr<MIndex>& i)
-> decltype(i->template getPtr<I>())
{
return i->template getPtr<I>();
}
template <class MArray>
auto dynamic(const MArray& ma, bool slice = false)
-> std::shared_ptr<ArrayBase<typename MArray::value_type,DynamicRange>>;
template <class MArray>
auto mdynamic(MArray& ma, bool slice)
-> std::shared_ptr<MutableArrayBase<typename MArray::value_type,DynamicRange>>;
template <typename T, class Range1, class... RangeTypes>
auto anonToDynView(const ArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
-> ConstSlice<T,Range1,RangeTypes...,DynamicRange>;
template <typename T, class Range1, class... RangeTypes>
auto anonToDynView(MutableArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
-> Slice<T,Range1,RangeTypes...,DynamicRange>;
template <typename T, class Range1, class... RangeTypes>
auto dynToAnonMove(Array<T,Range1,RangeTypes...,DynamicRange>&& ma)
-> Array<T,Range1,RangeTypes...,AnonymousRange>;
template <typename T>
auto anonToDynView(const ArrayBase<T,AnonymousRange>& ma)
-> ConstSlice<T,DynamicRange>;
template <typename T>
auto anonToDynView(MutableArrayBase<T,AnonymousRange>& ma)
-> Slice<T,DynamicRange>;
template <typename T>
auto dynToAnonMove(Array<T,DynamicRange>&& ma)
-> Array<T,AnonymousRange>;
template <class Range>
auto metaSlice(const std::shared_ptr<Range>& r)
-> ConstSlice<typename Range::MetaType,ClassicRange>;
template <class Range, class ORange>
auto metaSlice(const std::shared_ptr<Range>& r, const std::shared_ptr<ORange>& ro)
-> ConstSlice<typename Range::MetaType,ORange>;
template <typename T, class... Ranges>
auto mkArray(const std::shared_ptr<Ranges>&... rs)
-> Array<T,Ranges...>;
template <typename T, class... Ranges>
auto mkArrayPtr(const std::shared_ptr<Ranges>&... rs)
-> std::shared_ptr<Array<T,Ranges...>>;
template <typename T, class... Ranges>
auto mkArray(const std::shared_ptr<Ranges>&... rs, const T& val)
-> Array<T,Ranges...>;
template <class OpTp, class IndTp, class VarTp, class LTp>
auto mkILoop(const OpTp& opTp, const IndTp& indTp, const VarTp& varTp, const LTp& lTp,
const std::array<size_t,std::tuple_size<LTp>::value>& umpos,
const std::array<size_t,std::tuple_size<VarTp>::value>& setzero)
-> CNORXZInternal::ILoop<OpTp,IndTp,VarTp,LTp>
{
return CNORXZInternal::ILoop<OpTp,IndTp,VarTp,LTp>(opTp, indTp, varTp, lTp, umpos, setzero);
}
template <class CF>
auto mkPILoop(const CF& cf)
-> CNORXZInternal::PILoop<CF>
{
return CNORXZInternal::PILoop<CF>(cf);
}
template <class IndexType>
inline void For(const std::shared_ptr<IndexType>& ind, const std::function<void(void)>& ll)
{
for((*ind) = 0; ind->pos() != ind->max(); ++(*ind)){
ll();
}
}
// parallel:
template <class IndexType>
inline void PFor(const std::shared_ptr<IndexType>& ind,
const std::function<void(const std::shared_ptr<IndexType>&)>& ll)
{
const int max = static_cast<int>(ind->max());
int i = 0;
#pragma omp parallel shared(ind,ll) private(i)
{
#pragma omp for nowait
for(i = 0; i < max; i++) {
auto ii = getIndex( ind->range() );
((*ii) = i)();
ll(ii);
}
}
}
template <class Index>
inline auto mkOp(const std::shared_ptr<Index>& i)
-> decltype(std::declval<FunctionalArray<typename Index::MetaType,
identity<typename Index::MetaType>,typename Index::RangeType> >
().exec(i))
{
FunctionalArray<typename Index::MetaType,
identity<typename Index::MetaType>,
typename Index::RangeType> fma(i->range());
return fma.exec(i);
}
template <typename R, typename... Ts>
struct Func
{
static inline std::shared_ptr<function<R,Ts...>> mk(const std::function<R(Ts...)>& ll)
{
return std::make_shared<function<R,Ts...>>(ll);
}
};
}
#endif