@@ -41,35 +41,35 @@ struct poisson_log_likelihood_tuple_expanded {
41
41
};
42
42
43
43
struct 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
+ }
60
60
};
61
61
62
62
struct 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__>;
70
70
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
+ }
73
73
};
74
74
75
75
TEST (laplace, theta_0_as_expression_issue_3196) {
@@ -80,26 +80,25 @@ TEST(laplace, theta_0_as_expression_issue_3196) {
80
80
double sigmaz = 1.0 ;
81
81
double alpha = 1.0 ;
82
82
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 }}};
84
88
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 ));
92
95
auto arena_init = stan::math::to_arena (stan::math::rep_vector (0.0 , N));
93
96
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 ));
103
102
}
104
103
105
104
TEST (laplace, poisson_log_phi_dim_2_tuple_extended) {
@@ -295,4 +294,4 @@ TEST(laplace, poisson_log_phi_dim_2_array_tuple) {
295
294
theta_0);
296
295
}
297
296
298
- }
297
+ } // namespace
0 commit comments