@@ -41,35 +41,35 @@ struct poisson_log_likelihood_tuple_expanded {
4141};
4242
4343struct poisson_re_log_ll {
44- template < typename T0__, typename T2__,
45- stan:: require_all_t <stan::is_col_vector<T0__> ,
46- stan::is_vt_not_complex<T0__>,
47- stan::is_col_vector<T2__ >,
48- stan::is_vt_not_complex<T2__>>* = nullptr >
49- stan::return_type_t <stan::base_type_t <T0__>, stan::base_type_t <T2__>>
50- operator ()(const T0__& theta_arg__, const std::vector<int >& y,
51- const T2__& mu_arg__, std::ostream* pstream__) const {
52- using local_scalar_t__ = stan:: return_type_t <stan:: base_type_t <T0__>,
53- stan::base_type_t <T2__>>;
54- // suppress unused var warning
55- const auto & theta = stan::math::to_ref (theta_arg__);
56- const auto & mu = stan::math::to_ref (mu_arg__);
57- static constexpr bool propto__ = true ;
58- return stan::math::poisson_log_lpmf<false >(y, stan::math::add (mu, theta));
59- }
44+ template <
45+ typename T0__, typename T2__ ,
46+ stan::require_all_t <
47+ stan::is_col_vector<T0__>, stan::is_vt_not_complex<T0__ >,
48+ stan::is_col_vector<T2__>, stan::is_vt_not_complex<T2__>>* = nullptr >
49+ stan::return_type_t <stan::base_type_t <T0__>, stan::base_type_t <T2__>>
50+ operator ()(const T0__& theta_arg__, const std::vector<int >& y,
51+ const T2__& mu_arg__, std::ostream* pstream__) const {
52+ using local_scalar_t__
53+ = stan:: return_type_t <stan:: base_type_t <T0__>, stan::base_type_t <T2__>>;
54+ // suppress unused var warning
55+ const auto & theta = stan::math::to_ref (theta_arg__);
56+ const auto & mu = stan::math::to_ref (mu_arg__);
57+ static constexpr bool propto__ = true ;
58+ return stan::math::poisson_log_lpmf<false >(y, stan::math::add (mu, theta));
59+ }
6060};
6161
6262struct cov_fun {
63- template <typename T0__,
64- stan::require_all_t <stan::math::disjunction<stan::is_autodiff<T0__>,
65- std::is_floating_point<
66- std::decay_t <T0__>>>>* = nullptr >
67- Eigen::Matrix<stan::return_type_t <T0__>,-1 ,-1 >
68- operator ()( const T0__& sigma, const int & N, std::ostream* pstream__) const {
69- using local_scalar_t__ = stan::return_type_t <T0__>;
63+ template <typename T0__,
64+ stan::require_all_t <stan::math::disjunction<
65+ stan::is_autodiff<T0__>,
66+ std::is_floating_point< std::decay_t <T0__>>>>* = nullptr >
67+ Eigen::Matrix<stan::return_type_t <T0__>, -1 , -1 > operator ()(
68+ const T0__& sigma, const int & N, std::ostream* pstream__) const {
69+ using local_scalar_t__ = stan::return_type_t <T0__>;
7070 return stan::math::diag_matrix (
71- stan::math::rep_vector (stan::math::pow (sigma, 2 ), N));
72- }
71+ stan::math::rep_vector (stan::math::pow (sigma, 2 ), N));
72+ }
7373};
7474
7575TEST (laplace, theta_0_as_expression_issue_3196) {
@@ -80,26 +80,25 @@ TEST(laplace, theta_0_as_expression_issue_3196) {
8080 double sigmaz = 1.0 ;
8181 double alpha = 1.0 ;
8282 int N = 5 ;
83- Eigen::MatrixXd X{{{1 ,1 ,1 ,1 ,1 }, {1 , 1 , 1 , 1 , 1 }, {1 , 1 , 1 , 1 , 1 }, {1 , 1 , 1 , 1 , 1 }, {1 , 1 , 1 , 1 , 1 }}};
83+ Eigen::MatrixXd X{{{1 , 1 , 1 , 1 , 1 },
84+ {1 , 1 , 1 , 1 , 1 },
85+ {1 , 1 , 1 , 1 , 1 },
86+ {1 , 1 , 1 , 1 , 1 },
87+ {1 , 1 , 1 , 1 , 1 }}};
8488 EXPECT_NO_THROW (stan::math::laplace_marginal<false >(
85- poisson_re_log_ll (),
86- std::tuple<const std::vector<int >&,
87- Eigen::Matrix<double ,-1 ,1 >>(y,
88- stan::math::add (stan::math::add (offset, alpha),
89- stan::math::multiply (X, beta))),
90- stan::math::rep_vector (0.0 , N), cov_fun (),
91- std::tuple<double , int >(sigmaz, N), nullptr ));
89+ poisson_re_log_ll (),
90+ std::tuple<const std::vector<int >&, Eigen::Matrix<double , -1 , 1 >>(
91+ y, stan::math::add (stan::math::add (offset, alpha),
92+ stan::math::multiply (X, beta))),
93+ stan::math::rep_vector (0.0 , N), cov_fun (),
94+ std::tuple<double , int >(sigmaz, N), nullptr ));
9295 auto arena_init = stan::math::to_arena (stan::math::rep_vector (0.0 , N));
9396 EXPECT_NO_THROW (stan::math::laplace_marginal<false >(
94- poisson_re_log_ll (),
95- std::tuple<const std::vector<int >&,
96- Eigen::Matrix<double ,-1 ,1 >>(y,
97- stan::math::add (stan::math::add (offset, alpha),
98- stan::math::multiply (X, beta))),
99- arena_init, cov_fun (),
100- std::tuple<double , int >(sigmaz, N), nullptr ));
101-
102-
97+ poisson_re_log_ll (),
98+ std::tuple<const std::vector<int >&, Eigen::Matrix<double , -1 , 1 >>(
99+ y, stan::math::add (stan::math::add (offset, alpha),
100+ stan::math::multiply (X, beta))),
101+ arena_init, cov_fun (), std::tuple<double , int >(sigmaz, N), nullptr ));
103102}
104103
105104TEST (laplace, poisson_log_phi_dim_2_tuple_extended) {
@@ -295,4 +294,4 @@ TEST(laplace, poisson_log_phi_dim_2_array_tuple) {
295294 theta_0);
296295}
297296
298- }
297+ } // namespace
0 commit comments