@@ -94,6 +94,9 @@ namespace math {
94
94
* const std::vector<double>& x_r, const std::vector<int>& x_i,
95
95
* std::ostream* msgs = 0) const { ... }
96
96
*
97
+ * If an expression is passed as `shared_params`, the functor needs to accept
98
+ * expression.
99
+ *
97
100
* WARNING: For the MPI case, the data arguments are NOT checked if
98
101
* they are unchanged between repeated evaluations for a given
99
102
* call_id/functor F pair. This is silently assumed to be immutable
@@ -118,9 +121,10 @@ namespace math {
118
121
*/
119
122
120
123
template <int call_id, typename F, typename T_shared_param,
121
- typename T_job_param>
124
+ typename T_job_param,
125
+ require_eigen_col_vector_t <T_shared_param>* = nullptr >
122
126
Eigen::Matrix<return_type_t <T_shared_param, T_job_param>, Eigen::Dynamic, 1 >
123
- map_rect (const Eigen::Matrix< T_shared_param, Eigen::Dynamic, 1 > & shared_params,
127
+ map_rect (const T_shared_param& shared_params,
124
128
const std::vector<Eigen::Matrix<T_job_param, Eigen::Dynamic, 1 >>&
125
129
job_params,
126
130
const std::vector<std::vector<double >>& x_r,
@@ -169,11 +173,16 @@ map_rect(const Eigen::Matrix<T_shared_param, Eigen::Dynamic, 1>& shared_params,
169
173
}
170
174
171
175
#ifdef STAN_MPI
172
- return internal::map_rect_mpi<call_id, F, T_shared_param, T_job_param>(
173
- shared_params, job_params, x_r, x_i, msgs);
176
+ using T_plain_shared_param = plain_type_t <T_shared_param>;
177
+ T_plain_shared_param shared_params_eval = shared_params;
178
+ return internal::map_rect_mpi<call_id, F, T_plain_shared_param, T_job_param>(
179
+ shared_params_eval, job_params, x_r, x_i, msgs);
174
180
#else
175
- return internal::map_rect_concurrent<call_id, F, T_shared_param, T_job_param>(
176
- shared_params, job_params, x_r, x_i, msgs);
181
+ using T_shared_param_ref = ref_type_t <T_shared_param>;
182
+ T_shared_param_ref shared_params_ref = shared_params;
183
+ return internal::map_rect_concurrent<call_id, F, T_shared_param_ref,
184
+ T_job_param>(shared_params_ref,
185
+ job_params, x_r, x_i, msgs);
177
186
#endif
178
187
}
179
188
0 commit comments