10 template <
class ExprType
14 const ConfigType& config,
18 program_t program = expr;
20 auto pack = program.activate();
21 size_t n_cont = std::get<0>(pack).uc_offset;
22 size_t n_disc = std::get<1>(pack).uc_offset;
25 f(program, config, pack, res);
33 auto n_cont_c__ = [&](
auto& eq_node) {
34 auto& var = eq_node.get_variable();
35 using var_t = std::decay_t<decltype(var)>;
36 if constexpr (util::is_param_v<var_t> &&
38 n_cont_c += var.size();
41 program.get_model().traverse(n_cont_c__);
52 MCMCResult<> t_res(config.samples, n_cont_c + 1, n_disc);
59 auto& cont_pack = std::get<0>(pack);
60 auto& disc_pack = std::get<1>(pack);
61 Eigen::Matrix<util::disc_param_t, Eigen::Dynamic, 1> disc_uc_val(disc_pack.uc_offset);
62 Eigen::VectorXd cont_uc_val(cont_pack.uc_offset);
63 Eigen::VectorXd cont_tp_val(cont_pack.tp_offset);
64 Eigen::VectorXd cont_c_val(cont_pack.c_offset);
65 Eigen::Matrix<size_t, Eigen::Dynamic, 1> cont_v_val(cont_pack.v_offset);
70 cont_ptr_pack.
uc_val = cont_uc_val.data();
71 cont_ptr_pack.
tp_val = cont_tp_val.data();
72 cont_ptr_pack.
c_val = cont_c_val.data();
73 cont_ptr_pack.
v_val = cont_v_val.data();
74 program.bind(cont_ptr_pack);
77 disc_ptr_pack.
uc_val = disc_uc_val.data();
78 program.bind(disc_ptr_pack);
83 auto lpdf = program.log_pdf();
85 auto copy__ = [&](
auto& eq_node) {
86 auto& var = eq_node.get_variable();
87 using var_t = std::decay_t<decltype(var)>;
88 if constexpr (util::is_param_v<var_t> &&
90 Eigen::Map<Eigen::MatrixXd> mp(
nullptr, 0, 0);
91 if constexpr (util::is_scl_v<var_t>) {
94 util::bind(mp, var.get().data(), 1, var.size());
100 program.get_model().traverse(copy__);