Public Member Functions | List of all members
stan::math::internal::map_rect_reduce< F, var, var > Struct Template Reference

#include "stan/math/rev/mat/functor/map_rect_reduce.hpp"

Public Member Functions

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
 

Detailed Description

template<typename F>
struct stan::math::internal::map_rect_reduce< F, var, var >

Definition at line 17 of file map_rect_reduce.hpp.

Member Function Documentation

template<typename F >
matrix_d stan::math::internal::map_rect_reduce< F, var, var >::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
inline

Definition at line 18 of file map_rect_reduce.hpp.

References stan::math::e(), F, MECModelEnuComparisons::i, calib::j, lem_server::msgs, confusionMatrixTree::out, stan::math::recover_memory_nested(), stan::math::set_zero_all_adjoints_nested(), stan::math::start_nested(), and stan::math::to_var().

22  {
23  const size_type num_shared_params = shared_params.rows();
24  const size_type num_job_specific_params = job_specific_params.rows();
25  matrix_d out(1 + num_shared_params + num_job_specific_params, 0);
26 
27  try {
28  start_nested();
29  vector_v shared_params_v = to_var(shared_params);
30  vector_v job_specific_params_v = to_var(job_specific_params);
31 
32  vector_v fx_v
33  = F()(shared_params_v, job_specific_params_v, x_r, x_i, msgs);
34 
35  const size_type size_f = fx_v.rows();
36 
37  out.resize(Eigen::NoChange, size_f);
38 
39  for (size_type i = 0; i < size_f; ++i) {
40  out(0, i) = fx_v(i).val();
42  fx_v(i).grad();
43  for (size_type j = 0; j < num_shared_params; ++j)
44  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)
47  = job_specific_params_v(j).vi_->adj_;
48  }
50  } catch (const std::exception& e) {
52  throw;
53  }
54  return out;
55  }
#define F(x, y, z)
Eigen::Matrix< var, Eigen::Dynamic, 1 > vector_v
Definition: typedefs.hpp:22
static void set_zero_all_adjoints_nested()
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Definition: typedefs.hpp:11
const double j
Definition: BetheBloch.cxx:29
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Definition: typedefs.hpp:19
double e()
Definition: constants.hpp:89
static void recover_memory_nested()
std::vector< var > to_var(const std::vector< double > &v)
Definition: to_var.hpp:19
static void start_nested()

The documentation for this struct was generated from the following file: