ma operation: parallel version of .to and .addto

This commit is contained in:
Christian Zimmermann 2019-05-24 13:55:07 +02:00
parent a8efbd083a
commit 472abec3fd
2 changed files with 29 additions and 0 deletions

View file

@ -108,6 +108,27 @@ namespace MultiArrayTools
return out;
}
template <typename T, class OperationClass>
template <class... Indices>
auto OperationBase<T,OperationClass>::pto(const std::shared_ptr<Indices>&... inds) const
-> MultiArray<T,typename Indices::RangeType...>
{
MultiArray<T,typename Indices::RangeType...> out(inds->range()...);
out(inds...).par() = THIS();
return out;
}
template <typename T, class OperationClass>
template <class... Indices>
auto OperationBase<T,OperationClass>::paddto(const std::shared_ptr<Indices>&... inds) const
-> MultiArray<T,typename Indices::RangeType...>
{
MultiArray<T,typename Indices::RangeType...> out(inds->range()...,
static_cast<T>(0));
out(inds...).par() += THIS();
return out;
}
template <typename T, class OperationClass>
template <typename R, class... Args>
auto OperationBase<T,OperationClass>::a(const std::shared_ptr<function<R,T,typename Args::value_type...>>& ll,

View file

@ -73,6 +73,14 @@ namespace MultiArrayTools
auto addto(const std::shared_ptr<Indices>&... inds) const
-> MultiArray<T,typename Indices::RangeType...>;
template <class... Indices>
auto pto(const std::shared_ptr<Indices>&... inds) const
-> MultiArray<T,typename Indices::RangeType...>;
template <class... Indices>
auto paddto(const std::shared_ptr<Indices>&... inds) const
-> MultiArray<T,typename Indices::RangeType...>;
template <typename R, class... Args> // Args = Operation Classes
auto a(const std::shared_ptr<function<R,T,typename Args::value_type...>>& ll, const Args&... args) const
-> Operation<R,function<R,T,typename Args::value_type...>,OperationClass, Args...>;