add some utilities
This commit is contained in:
parent
861adac36a
commit
a1a6b02bb5
2 changed files with 34 additions and 0 deletions
|
@ -120,6 +120,14 @@ namespace MultiArrayTools
|
||||||
return std::dynamic_pointer_cast<Range>( rbptr );
|
return std::dynamic_pointer_cast<Range>( rbptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Range, typename... Args>
|
||||||
|
auto createRangeE(const Args&... args)
|
||||||
|
-> std::shared_ptr<Range>
|
||||||
|
{
|
||||||
|
typename Range::Factory f(args...);
|
||||||
|
return createExplicit(f);
|
||||||
|
}
|
||||||
|
|
||||||
template <size_t N, class MArray>
|
template <size_t N, class MArray>
|
||||||
auto rptr(const MArray& ma)
|
auto rptr(const MArray& ma)
|
||||||
-> decltype(ma.template getRangePtr<N>())
|
-> decltype(ma.template getRangePtr<N>())
|
||||||
|
@ -228,5 +236,19 @@ namespace MultiArrayTools
|
||||||
return ConstSlice<typename Range::MetaType,ORange>( ro, &r->get(0) );
|
return ConstSlice<typename Range::MetaType,ORange>( ro, &r->get(0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,10 @@ namespace MultiArrayTools
|
||||||
auto createRange(const vector<char>& cvec)
|
auto createRange(const vector<char>& cvec)
|
||||||
-> std::shared_ptr<Range>;
|
-> std::shared_ptr<Range>;
|
||||||
|
|
||||||
|
template <class Range, typename... Args>
|
||||||
|
auto createRangeE(const Args&... args)
|
||||||
|
-> std::shared_ptr<Range>;
|
||||||
|
|
||||||
template <size_t N, class MArray>
|
template <size_t N, class MArray>
|
||||||
auto rptr(const MArray& ma)
|
auto rptr(const MArray& ma)
|
||||||
-> decltype(ma.template getRangePtr<N>());
|
-> decltype(ma.template getRangePtr<N>());
|
||||||
|
@ -103,6 +107,14 @@ namespace MultiArrayTools
|
||||||
auto metaSlice(const std::shared_ptr<Range>& r, const std::shared_ptr<ORange>& ro)
|
auto metaSlice(const std::shared_ptr<Range>& r, const std::shared_ptr<ORange>& ro)
|
||||||
-> ConstSlice<typename Range::MetaType,ORange>;
|
-> ConstSlice<typename Range::MetaType,ORange>;
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
auto mkArray(const std::shared_ptr<Ranges>&... rs)
|
||||||
|
-> MultiArray<T,Ranges...>;
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
auto mkArray(const std::shared_ptr<Ranges>&... rs, const T& val)
|
||||||
|
-> MultiArray<T,Ranges...>;
|
||||||
|
|
||||||
template <class IndexType>
|
template <class IndexType>
|
||||||
inline void For(const std::shared_ptr<IndexType>& ind, const std::function<void(void)>& ll)
|
inline void For(const std::shared_ptr<IndexType>& ind, const std::function<void(void)>& ll)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue