AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
Composer.impl.hpp
1#pragma once
2
3#include <tuple>
4#include <utility>
5
6#include <amdis/operations/Arithmetic.hpp>
7#include <amdis/operations/Composer.hpp>
8
9namespace AMDiS { namespace Operation {
10
13 template <int J, class F, class... Gs>
14 auto partial(Composer<F,Gs...> const& c, index_t<J> _j)
15 {
16 auto index_seq = std::make_index_sequence<sizeof...(Gs)>{};
17
18 // d_i(f)[g...] * d_j(g_i)
19 auto term_i = [&](auto const _i)
20 {
21 auto di_f = std::apply([&](auto const&... gs) {
22 return compose(partial(c.f_, _i), gs...);
23 }, c.gs_);
24
25 auto const& g_i = std::get<_i>(c.gs_);
26 return compose(Multiplies{}, di_f, partial(g_i, _j));
27 };
28
29 // sum_i [ d_i(f)[g...] * d_j(g_i) ]
30 return std::apply([&](auto const... _i)
31 {
32 return compose(Plus{}, term_i(_i)...);
33 }, index_seq);
34 }
35
36}} // end namespace AMDiS::Operation