1 #ifndef STAN_MATH_PRIM_MAT_FUNCTOR_MAP_RECT_COMBINE_HPP 2 #define STAN_MATH_PRIM_MAT_FUNCTOR_MAP_RECT_COMBINE_HPP 36 template <
typename F,
typename T_shared_param,
typename T_job_param>
39 Eigen::Matrix<T_shared_param, Eigen::Dynamic, 1>,
40 Eigen::Matrix<T_job_param, Eigen::Dynamic, 1>>
42 std::vector<ops_partials_t> ops_partials_;
44 const std::size_t num_shared_operands_;
45 const std::size_t num_job_operands_;
48 typedef Eigen::Matrix<
54 : ops_partials_(), num_shared_operands_(0), num_job_operands_(0) {}
56 const Eigen::Matrix<T_shared_param, Eigen::Dynamic, 1>& shared_params,
57 const std::vector<Eigen::Matrix<T_job_param, Eigen::Dynamic, 1>>&
60 num_shared_operands_(shared_params.
rows()),
61 num_job_operands_(
dims(job_params)[1]) {
62 ops_partials_.reserve(job_params.size());
63 for (
const auto& job_param : job_params)
64 ops_partials_.emplace_back(shared_params, job_param);
68 const std::vector<int>& world_f_out) {
69 const std::size_t num_jobs = world_f_out.size();
70 const std::size_t offset_job_params
72 const std::size_t size_world_f_out =
sum(world_f_out);
76 for (std::size_t i = 0, ij = 0; i != num_jobs; ++i) {
77 for (
int j = 0; j != world_f_out[i]; ++j, ++ij) {
79 ops_partials_[i].edge1_.partials_
80 = world_result.block(1, ij, num_shared_operands_, 1);
83 ops_partials_[i].edge2_.partials_
84 = world_result.block(offset_job_params, ij, num_job_operands_, 1);
86 out(ij) = ops_partials_[i].build(world_result(0, ij));
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
int rows(const Eigen::Matrix< T, R, C > &m)
Return the number of rows in the specified matrix, vector, or row vector.
Extends std::true_type when instantiated with zero or more template parameters, all of which extend t...
This template builds partial derivatives with respect to a set of operands.
void dims(const T &x, std::vector< int > &result)
result_t operator()(const matrix_d &world_result, const std::vector< int > &world_f_out)
boost::math::tools::promote_args< double, typename scalar_type< T >::type, typename return_type< Types_pack... >::type >::type type
map_rect_combine(const Eigen::Matrix< T_shared_param, Eigen::Dynamic, 1 > &shared_params, const std::vector< Eigen::Matrix< T_job_param, Eigen::Dynamic, 1 >> &job_params)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
Eigen::Matrix< typename stan::return_type< T_shared_param, T_job_param >::type, Eigen::Dynamic, 1 > result_t