1#ifndef STAN_MATH_REV_FUNCTOR_MAP_RECT_REDUCE_HPP
2#define STAN_MATH_REV_FUNCTOR_MAP_RECT_REDUCE_HPP
19 const std::vector<double>& x_r,
20 const std::vector<int>& x_i,
21 std::ostream* msgs =
nullptr)
const {
22 const size_type num_shared_params = shared_params.rows();
23 const size_type num_job_specific_params = job_specific_params.rows();
24 matrix_d out(1 + num_shared_params + num_job_specific_params, 0);
32 vector_v fx_v = F()(shared_params_v, job_specific_params_v, x_r, x_i, msgs);
36 out.resize(Eigen::NoChange, size_f);
39 out(0, i) = fx_v(i).val();
42 for (
size_type j = 0; j < num_shared_params; ++j) {
43 out(1 + j, i) = shared_params_v(j).vi_->adj_;
45 for (
size_type j = 0; j < num_job_specific_params; ++j) {
46 out(1 + num_shared_params + j, i) = job_specific_params_v(j).vi_->adj_;
57 const std::vector<double>& x_r,
58 const std::vector<int>& x_i,
59 std::ostream* msgs =
nullptr)
const {
60 const size_type num_job_specific_params = job_specific_params.rows();
61 matrix_d out(1 + num_job_specific_params, 0);
68 vector_v fx_v = F()(shared_params, job_specific_params_v, x_r, x_i, msgs);
72 out.resize(Eigen::NoChange, size_f);
75 out(0, i) = fx_v(i).val();
78 for (
size_type j = 0; j < num_job_specific_params; ++j) {
79 out(1 + j, i) = job_specific_params_v(j).vi_->adj_;
90 const std::vector<double>& x_r,
91 const std::vector<int>& x_i,
92 std::ostream* msgs =
nullptr)
const {
93 const size_type num_shared_params = shared_params.rows();
94 matrix_d out(1 + num_shared_params, 0);
101 vector_v fx_v = F()(shared_params_v, job_specific_params, x_r, x_i, msgs);
105 out.resize(Eigen::NoChange, size_f);
108 out(0, i) = fx_v(i).val();
111 for (
size_type j = 0; j < num_shared_params; ++j) {
112 out(1 + j, i) = shared_params_v(j).vi_->adj_;
124#ifdef STAN_REGISTER_MPI_MAP_RECT_ALL
126#undef STAN_REGISTER_MPI_MAP_RECT_ALL
128#define STAN_REGISTER_MPI_MAP_RECT_ALL(CALLID, FUNCTOR) \
129 STAN_REGISTER_MPI_MAP_RECT(CALLID, FUNCTOR, double, double) \
130 STAN_REGISTER_MPI_MAP_RECT(CALLID, FUNCTOR, double, var) \
131 STAN_REGISTER_MPI_MAP_RECT(CALLID, FUNCTOR, var, double) \
132 STAN_REGISTER_MPI_MAP_RECT(CALLID, FUNCTOR, var, var)
void set_zero_all_adjoints()
Reset all adjoint values in this nested stack to zero.
A class following the RAII idiom to start and recover nested autodiff scopes.
var to_var(double x)
Converts argument to an automatic differentiation variable.
Eigen::Matrix< double, Eigen::Dynamic, 1 > vector_d
Type for (column) vector of double values.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double elements.
Eigen::Matrix< var, Eigen::Dynamic, 1 > vector_v
The type of a (column) vector holding var values.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
matrix_d operator()(const vector_d &shared_params, const vector_d &job_specific_params, const std::vector< double > &x_r, const std::vector< int > &x_i, std::ostream *msgs=nullptr) const
matrix_d operator()(const vector_d &shared_params, const vector_d &job_specific_params, const std::vector< double > &x_r, const std::vector< int > &x_i, std::ostream *msgs=nullptr) const
matrix_d operator()(const vector_d &shared_params, const vector_d &job_specific_params, const std::vector< double > &x_r, const std::vector< int > &x_i, std::ostream *msgs=nullptr) const