6 #include <tao/seq/make_integer_range.hpp>
13 template <
size_t N,
size_t NA,
size_t D,
class TArities>
15 template <
class TRV,
class TP,
class TA,
size_t... Is>
16 static void apply(std::index_sequence<Is...>, TRV &rvs, TP &prc,
19 std::get<N>(prc).random(std::get<N - 1>(rvs), std::get<Is>(args)...);
20 constexpr
size_t arity =
21 std::tuple_element<N + 1, TArities>::type::value - 1;
22 GetRandom<N + 1, NA + arity, D, TArities>::apply(
23 tao::seq::make_index_range<NA, NA + arity>(), rvs, prc, args);
27 template <
size_t NA,
size_t D,
class TArities>
28 struct GetRandom<0, NA, D, TArities> {
29 template <
class TRV,
class TP,
class TA,
size_t... Is>
30 static void apply(std::index_sequence<Is...>, TRV &rvs, TP &prc,
32 std::get<0>(rvs) = std::get<0>(prc).random(std::get<Is>(args)...);
33 constexpr
size_t arity = std::tuple_element<1, TArities>::type::value - 1;
34 GetRandom<1, NA + arity, D, TArities>::apply(
35 tao::seq::make_index_range<NA, NA + arity>(), rvs, prc, args);
39 template <
size_t NA,
size_t D,
class TArities>
40 struct GetRandom<D, NA, D, TArities> {
41 template <
class TRV,
class TP,
class TA,
size_t... Is>
42 static void apply(std::index_sequence<Is...>, TRV &rvs, TP &prc,
45 std::get<D>(prc).random(std::get<D - 1>(rvs), std::get<Is>(args)...);
50 struct GetInitialized {
51 template <
class TRV,
class TP>
52 static void apply(TRV &rvs, TP &prc) {
53 std::get<N>(rvs) = std::get<N>(prc).initialize();
55 GetInitialized<N - 1>::apply(rvs, prc);
60 struct GetInitialized<0> {
61 template <
class TRV,
class TP>
62 static void apply(TRV &rvs, TP &prc) {
63 std::get<0>(rvs) = std::get<0>(prc).initialize();
68 template <
size_t N,
size_t NA,
size_t D,
class TArities>
69 struct GetLikelihood {
70 template <
class TRV,
class TP,
class TA,
size_t... Is>
71 static void apply(std::index_sequence<Is...>,
double &lik,
const TRV &rvs,
72 TP &prc,
const TA &args) {
74 lik *= std::get<N>(prc).likelihood(std::get<N>(rvs), std::get<N - 1>(rvs),
75 std::get<Is>(args)...);
77 constexpr
size_t arity =
78 std::tuple_element<N + 1, TArities>::type::value - 1;
79 GetLikelihood<N + 1, NA + arity, D, TArities>::apply(
80 tao::seq::make_index_range<NA, NA + arity>(), lik, rvs, prc, args);
84 template <
size_t NA,
size_t D,
class TArities>
85 struct GetLikelihood<0, NA, D, TArities> {
86 template <
class TRV,
class TP,
class TA,
size_t... Is>
87 static void apply(std::index_sequence<Is...>,
double &lik,
const TRV &rvs,
88 TP &prc,
const TA &args) {
90 lik *= std::get<0>(prc).likelihood(std::get<0>(rvs), std::get<Is>(args)...);
92 constexpr
size_t arity = std::tuple_element<1, TArities>::type::value - 1;
93 GetLikelihood<1, NA + arity, D, TArities>::apply(
94 tao::seq::make_index_range<NA, NA + arity>(), lik, rvs, prc, args);
98 template <
size_t NA,
size_t D,
class TArities>
99 struct GetLikelihood<D, NA, D, TArities> {
100 template <
class TRV,
class TP,
class TA,
size_t... Is>
101 static void apply(std::index_sequence<Is...>,
double &lik,
const TRV &rvs,
102 TP &prc,
const TA &args) {
104 lik *= std::get<D>(prc).likelihood(std::get<D>(rvs), std::get<D - 1>(rvs),
105 std::get<Is>(args)...);