1 #ifndef STAN_MATH_PRIM_ARR_FUNCTOR_COUPLED_ODE_OBSERVER_HPP 2 #define STAN_MATH_PRIM_ARR_FUNCTOR_COUPLED_ODE_OBSERVER_HPP 29 template <
typename F,
typename T1,
typename T2,
typename T_t0,
typename T_ts>
37 const std::vector<T1>&
y0_;
39 const std::vector<T_ts>&
ts_;
41 const std::vector<double>&
x_;
44 std::vector<std::vector<return_t>>&
y_;
71 const std::vector<T2>& theta,
const T_t0& t0,
72 const std::vector<T_ts>& ts,
73 const std::vector<double>& x,
74 const std::vector<int>& x_int, std::ostream* msgs,
75 std::vector<std::vector<return_t>>& y)
103 void operator()(
const std::vector<double>& coupled_state,
double t) {
104 check_less(
"coupled_ode_observer",
"time-state number", next_ts_index_,
107 std::vector<return_t> yt;
110 ops_partials_t ops_partials(y0_, theta_, t0_, ts_[next_ts_index_]);
112 std::vector<double> dy_dt;
114 std::vector<double> y_dbl(coupled_state.begin(),
115 coupled_state.begin() +
N_);
122 for (
size_t j = 0; j <
N_; j++) {
125 for (std::size_t k = 0; k <
N_; k++)
130 for (std::size_t k = 0; k <
M_; k++)
132 = coupled_state[N_ + index_offset_theta_ + N_ * k + j];
139 yt.emplace_back(ops_partials.
build(coupled_state[j]));
stan::return_type< T1, T2, T_t0, T_ts >::type return_t
const std::vector< T1 > & y0_
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Extends std::true_type when instantiated with zero or more template parameters, all of which extend t...
internal::ops_partials_edge< double, Op4 > edge4_
This template builds partial derivatives with respect to a set of operands.
coupled_ode_observer(const F &f, const std::vector< T1 > &y0, const std::vector< T2 > &theta, const T_t0 &t0, const std::vector< T_ts > &ts, const std::vector< double > &x, const std::vector< int > &x_int, std::ostream *msgs, std::vector< std::vector< return_t >> &y)
Construct a coupled ODE observer for the specified coupled vector.
void operator()(const std::vector< double > &coupled_state, double t)
Callback function for ODE solvers to record values.
operands_and_partials< std::vector< T1 >, std::vector< T2 >, T_t0, T_ts > ops_partials_t
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
Observer for the coupled states.
const std::vector< T_ts > & ts_
boost::math::tools::promote_args< double, typename scalar_type< T >::type, typename return_type< Types_pack... >::type >::type type
const std::vector< double > & x_
const std::vector< T2 > & theta_
empty_broadcast_array< ViewElt, Op > partials_
T_return_type build(double value)
Build the node to be stored on the autodiff graph.
std::vector< std::vector< return_t > > & y_
internal::ops_partials_edge< double, Op2 > edge2_
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
const std::size_t index_offset_theta_
void check_less(const char *function, const char *name, const T_y &y, const T_high &high)
Check if y is strictly less than high.
internal::ops_partials_edge< double, Op1 > edge1_
const std::vector< int > & x_int_