extra operation to function

This commit is contained in:
Christian Zimmermann 2019-02-19 16:20:38 +01:00
parent 5fdf6970c9
commit 709e30a4a1
3 changed files with 21 additions and 0 deletions

View file

@ -86,6 +86,11 @@ namespace MultiArrayTools
{ {
return a1 + a2; return a1 + a2;
} }
static inline T& selfApply(T& a1, const T& a2)
{
return a1 += a2;
}
}; };
template <typename T> template <typename T>

View file

@ -97,6 +97,18 @@ namespace MultiArrayTools
return out; return out;
} }
template <typename T, class OperationClass>
template <class AOp, class... Indices>
auto OperationBase<T,OperationClass>::oto(const AOp& aop,
const std::shared_ptr<Indices>&... inds) const
-> MultiArray<T,typename Indices::RangeType...>
{
MultiArray<T,typename Indices::RangeType...> out(inds->range()...,
static_cast<T>(0));
AOp::selfApply(out(inds...), THIS());
return out;
}
template <typename T, class OperationClass> template <typename T, class OperationClass>
template <typename R, class... Args> template <typename R, class... Args>
auto OperationBase<T,OperationClass>::a(const std::shared_ptr<function<R,T,typename Args::value_type...>>& ll, auto OperationBase<T,OperationClass>::a(const std::shared_ptr<function<R,T,typename Args::value_type...>>& ll,

View file

@ -69,6 +69,10 @@ namespace MultiArrayTools
auto to(const std::shared_ptr<Indices>&... inds) const auto to(const std::shared_ptr<Indices>&... inds) const
-> MultiArray<T,typename Indices::RangeType...>; -> MultiArray<T,typename Indices::RangeType...>;
template <class AOp, class... Indices>
auto oto(const AOp& aop, const std::shared_ptr<Indices>&... inds) const
-> MultiArray<T,typename Indices::RangeType...>;
template <typename R, class... Args> // Args = Operation Classes 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 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...>; -> Operation<R,function<R,T,typename Args::value_type...>,OperationClass, Args...>;