@@ -28,7 +28,7 @@ struct neg_binomial_2_log_likelihood {
2828 require_all_eigen_vector_t <ThetaVec>* = nullptr >
2929 inline auto operator ()(const ThetaVec& theta, const Eta& eta,
3030 const std::vector<int >& y,
31- const std::vector<int >& y_index, const Mean& mean,
31+ const std::vector<int >& y_index, Mean& & mean,
3232 std::ostream* pstream) const {
3333 Eigen::VectorXi n_per_group = Eigen::VectorXi::Zero (theta.size ());
3434 Eigen::VectorXi counts_per_group = Eigen::VectorXi::Zero (theta.size ());
@@ -76,18 +76,18 @@ template <bool propto = false, typename Eta, typename ThetaVec, typename Mean,
7676 require_eigen_vector_t <ThetaVec>* = nullptr >
7777inline auto laplace_marginal_tol_neg_binomial_2_log_lpmf (
7878 const std::vector<int >& y, const std::vector<int >& y_index, const Eta& eta,
79- const Mean& mean, CovarFun&& covariance_function, CovarArgs&& covar_args,
79+ Mean& & mean, CovarFun&& covariance_function, CovarArgs&& covar_args,
8080 const ThetaVec& theta_0, double tolerance, int max_num_steps,
8181 const int hessian_block_size, const int solver,
8282 const int max_steps_line_search, std::ostream* msgs) {
8383 laplace_options_user_supplied ops{hessian_block_size, solver,
8484 max_steps_line_search, tolerance,
8585 max_num_steps, value_of (theta_0)};
86- return laplace_marginal_density (neg_binomial_2_log_likelihood{},
87- std::forward_as_tuple (eta, y, y_index, mean) ,
88- std::forward<CovarFun>(covariance_function ),
89- std::forward<CovarArgs>(covar_args), ops ,
90- msgs);
86+ return laplace_marginal_density (
87+ neg_binomial_2_log_likelihood{} ,
88+ std::forward_as_tuple (eta, y, y_index, std::forward<Mean>(mean) ),
89+ std::forward<CovarFun>(covariance_function) ,
90+ std::forward<CovarArgs>(covar_args), ops, msgs);
9191}
9292
9393/* *
@@ -112,13 +112,13 @@ template <bool propto = false, typename Eta, typename Mean, typename CovarFun,
112112 typename CovarArgs>
113113inline auto laplace_marginal_neg_binomial_2_log_lpmf (
114114 const std::vector<int >& y, const std::vector<int >& y_index, const Eta& eta,
115- const Mean& mean, CovarFun&& covariance_function, CovarArgs&& covar_args,
115+ Mean& & mean, CovarFun&& covariance_function, CovarArgs&& covar_args,
116116 std::ostream* msgs) {
117- return laplace_marginal_density (neg_binomial_2_log_likelihood{},
118- std::forward_as_tuple (eta, y, y_index, mean) ,
119- std::forward<CovarFun>(covariance_function ),
120- std::forward<CovarArgs>(covar_args ),
121- laplace_options_default{}, msgs);
117+ return laplace_marginal_density (
118+ neg_binomial_2_log_likelihood{} ,
119+ std::forward_as_tuple (eta, y, y_index, std::forward<Mean>(mean) ),
120+ std::forward<CovarFun>(covariance_function ),
121+ std::forward<CovarArgs>(covar_args), laplace_options_default{}, msgs);
122122}
123123
124124struct neg_binomial_2_log_likelihood_summary {
@@ -127,8 +127,8 @@ struct neg_binomial_2_log_likelihood_summary {
127127 inline auto operator ()(const ThetaVec& theta, const Eta& eta,
128128 const std::vector<int >& y,
129129 const std::vector<int >& n_per_group,
130- const std::vector<int >& counts_per_group,
131- const Mean& mean, std::ostream* pstream) const {
130+ const std::vector<int >& counts_per_group, Mean&& mean,
131+ std::ostream* pstream) const {
132132 Eigen::Map<const Eigen::VectorXi> y_map (y.data (), y.size ());
133133 Eigen::Map<const Eigen::VectorXi> n_per_group_map (n_per_group.data (),
134134 n_per_group.size ());
@@ -173,7 +173,7 @@ template <bool propto = false, typename Eta, typename ThetaVec, typename Mean,
173173 require_eigen_vector_t <ThetaVec>* = nullptr >
174174inline auto laplace_marginal_tol_neg_binomial_2_log_summary_lpmf (
175175 const std::vector<int >& y, const std::vector<int >& n_per_group,
176- const std::vector<int >& counts_per_group, const Eta& eta, const Mean& mean,
176+ const std::vector<int >& counts_per_group, const Eta& eta, Mean& & mean,
177177 CovarFun&& covariance_function, CovarArgs&& covar_args,
178178 const ThetaVec& theta_0, double tolerance, int max_num_steps,
179179 const int hessian_block_size, const int solver,
@@ -183,7 +183,8 @@ inline auto laplace_marginal_tol_neg_binomial_2_log_summary_lpmf(
183183 max_num_steps, value_of (theta_0)};
184184 return laplace_marginal_density (
185185 neg_binomial_2_log_likelihood_summary{},
186- std::forward_as_tuple (eta, y, n_per_group, counts_per_group, mean),
186+ std::forward_as_tuple (eta, y, n_per_group, counts_per_group,
187+ std::forward<Mean>(mean)),
187188 std::forward<CovarFun>(covariance_function),
188189 std::forward<CovarArgs>(covar_args), ops, msgs);
189190}
@@ -210,12 +211,13 @@ template <bool propto = false, typename Eta, typename Mean, typename CovarFun,
210211 typename CovarArgs>
211212inline auto laplace_marginal_neg_binomial_2_log_summary_lpmf (
212213 const std::vector<int >& y, const std::vector<int >& n_per_group,
213- const std::vector<int >& counts_per_group, const Eta& eta, const Mean& mean,
214+ const std::vector<int >& counts_per_group, const Eta& eta, Mean& & mean,
214215 CovarFun&& covariance_function, CovarArgs&& covar_args,
215216 std::ostream* msgs) {
216217 return laplace_marginal_density (
217218 neg_binomial_2_log_likelihood_summary{},
218- std::forward_as_tuple (eta, y, n_per_group, counts_per_group, mean),
219+ std::forward_as_tuple (eta, y, n_per_group, counts_per_group,
220+ std::forward<Mean>(mean)),
219221 std::forward<CovarFun>(covariance_function),
220222 std::forward<CovarArgs>(covar_args), laplace_options_default{}, msgs);
221223}
0 commit comments