1 #ifndef STAN_MATH_REV_ARR_FUN_DECOUPLE_ODE_STATES_HPP
2 #define STAN_MATH_REV_ARR_FUN_DECOUPLE_ODE_STATES_HPP
33 template <
typename T_initial,
typename T_param>
38 const std::vector<T_initial>& y0,
39 const std::vector<T_param>& theta) {
42 vector<typename stan::return_type<T_initial, T_param>::type> vars;
46 const size_t N = y0.size();
47 const size_t M = theta.size();
48 const size_t S = (initial_var::value ? N : 0)
49 + (param_var::value ? M : 0);
52 if (initial_var::value)
53 vars.insert(vars.end(), y0.begin(), y0.end());
55 vars.insert(vars.end(), theta.begin(), theta.end());
57 vector<var> temp_vars(N);
58 vector<double> temp_gradients(S);
59 vector<vector<var> > y_return(y.size());
61 for (
size_t i = 0; i < y.size(); ++i) {
62 for (
size_t j = 0; j < N; ++j) {
63 for (
size_t k = 0; k < S; ++k) {
64 temp_gradients[k] = y[i][N + N * k + j];
67 vars, temp_gradients);
69 y_return[i] = temp_vars;
85 std::vector<std::vector<double> >
87 const std::vector<double>& y0,
88 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...
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...