1 #ifndef STAN_MATH_REV_MAT_FUNCTOR_MAP_RECT_REDUCE_HPP 2 #define STAN_MATH_REV_MAT_FUNCTOR_MAP_RECT_REDUCE_HPP 21 const std::vector<double>& x_r,
22 const std::vector<int>& x_i,
23 std::ostream* msgs =
nullptr)
const {
24 const size_type num_shared_params = shared_params.rows();
25 const size_type num_job_specific_params = job_specific_params.rows();
26 matrix_d out(1 + num_shared_params + num_job_specific_params, 0);
34 = F()(shared_params_v, job_specific_params_v, x_r, x_i, msgs);
38 out.resize(Eigen::NoChange, size_f);
41 out(0, i) = fx_v(i).val();
44 for (
size_type j = 0; j < num_shared_params; ++j)
45 out(1 + j, i) = shared_params_v(j).vi_->adj_;
46 for (
size_type j = 0; j < num_job_specific_params; ++j)
47 out(1 + num_shared_params + j, i)
48 = job_specific_params_v(j).vi_->adj_;
51 }
catch (
const std::exception&
e) {
63 const std::vector<double>& x_r,
64 const std::vector<int>& x_i,
65 std::ostream* msgs =
nullptr)
const {
66 const size_type num_job_specific_params = job_specific_params.rows();
67 matrix_d out(1 + num_job_specific_params, 0);
73 vector_v fx_v = F()(shared_params, job_specific_params_v, x_r, x_i, msgs);
77 out.resize(Eigen::NoChange, size_f);
80 out(0, i) = fx_v(i).val();
83 for (
size_type j = 0; j < num_job_specific_params; ++j)
84 out(1 + j, i) = job_specific_params_v(j).vi_->adj_;
87 }
catch (
const std::exception&
e) {
99 const std::vector<double>& x_r,
100 const std::vector<int>& x_i,
101 std::ostream* msgs =
nullptr)
const {
102 const size_type num_shared_params = shared_params.rows();
103 matrix_d out(1 + num_shared_params, 0);
109 vector_v fx_v = F()(shared_params_v, job_specific_params, x_r, x_i, msgs);
113 out.resize(Eigen::NoChange, size_f);
116 out(0, i) = fx_v(i).val();
119 for (
size_type j = 0; j < num_shared_params; ++j)
120 out(1 + j, i) = shared_params_v(j).vi_->adj_;
123 }
catch (
const std::exception&
e) {
135 #ifdef STAN_REGISTER_MPI_MAP_RECT_ALL 137 #undef STAN_REGISTER_MPI_MAP_RECT_ALL 139 #define STAN_REGISTER_MPI_MAP_RECT_ALL(CALLID, FUNCTOR) \ 140 STAN_REGISTER_MPI_MAP_RECT(CALLID, FUNCTOR, double, double) \ 141 STAN_REGISTER_MPI_MAP_RECT(CALLID, FUNCTOR, double, var) \ 142 STAN_REGISTER_MPI_MAP_RECT(CALLID, FUNCTOR, var, double) \ 143 STAN_REGISTER_MPI_MAP_RECT(CALLID, FUNCTOR, var, var)
Eigen::Matrix< var, Eigen::Dynamic, 1 > vector_v
The type of a (column) vector holding var values.
Eigen::Matrix< double, Eigen::Dynamic, 1 > vector_d
Type for (column) vector of double values.
static void set_zero_all_adjoints_nested()
Reset all adjoint values in the top nested portion of the stack to zero.
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
Independent (input) and dependent (output) variables for gradients.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double e.
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
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
double e()
Return the base of the natural logarithm.
static void recover_memory_nested()
Recover only the memory used for the top nested call.
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
std::vector< var > to_var(const std::vector< double > &v)
Converts argument to an automatic differentiation variable.
static void start_nested()
Record the current position so that recover_memory_nested() can find it.