1 #ifndef STAN_MATH_REV_ARR_FUN_DECOUPLE_ODE_STATES_HPP
2 #define STAN_MATH_REV_ARR_FUN_DECOUPLE_ODE_STATES_HPP
34 template <
typename T_initial,
typename T_param>
39 const std::vector<T_initial>& y0,
40 const std::vector<T_param>& theta) {
45 vector<typename stan::return_type<T_initial, T_param>::type> vars;
49 const size_t N = y0.size();
50 const size_t M = theta.size();
51 const size_t S = (initial_var::value ? N : 0)
52 + (param_var::value ? M : 0);
55 if (initial_var::value)
56 vars.insert(vars.end(), y0.begin(), y0.end());
58 vars.insert(vars.end(), theta.begin(), theta.end());
60 vector<var> temp_vars(N);
61 vector<double> temp_gradients(S);
62 vector<vector<var> > y_return(y.size());
64 for (
size_t i = 0; i < y.size(); ++i) {
65 for (
size_t j = 0; j < N; ++j) {
66 for (
size_t k = 0; k < S; ++k) {
67 temp_gradients[k] = y[i][N + N * k + j];
70 vars, temp_gradients);
72 y_return[i] = temp_vars;
88 std::vector<std::vector<double> >
90 const std::vector<double>& y0,
91 const std::vector<double>& theta) {
var precomputed_gradients(const double value, const std::vector< var > &operands, const std::vector< double > &gradients)
This function returns a var for an expression that has the specified value, vector of operands...
Metaprogram to calculate the base scalar return type resulting from promoting all the scalar types of...
Independent (input) and dependent (output) variables for gradients.
std::vector< std::vector< typename stan::return_type< T_initial, T_param >::type > > decouple_ode_states(const std::vector< std::vector< double > > &y, const std::vector< T_initial > &y0, const std::vector< T_param > &theta)
Takes sensitivity output from integrators and returns results in precomputed_gradients format...