1#ifndef STAN_MATH_PRIM_FUNCTOR_COUPLED_ODE_SYSTEM_HPP
2#define STAN_MATH_PRIM_FUNCTOR_COUPLED_ODE_SYSTEM_HPP
14template <
bool ArithmeticArguments,
typename F,
typename T_y0,
typename... Args>
27template <
typename F,
typename T_y0,
typename... Args>
30 const Eigen::VectorXd&
y0_;
46 std::ostream* msgs,
const Args&... args)
47 : f_(f), y0_(y0), args_tuple_(args...), N_(y0.
size()), msgs_(msgs) {}
62 void operator()(
const std::vector<double>& z, std::vector<double>& dz_dt,
64 Eigen::VectorXd y(z.size());
65 for (
size_t n = 0; n < z.size(); ++n)
68 dz_dt.resize(y.size());
71 [&](
const Args&... args) {
return f_(t, y, msgs_, args...); },
77 Eigen::Map<Eigen::VectorXd>(dz_dt.data(), dz_dt.size()) = f_y_t;
85 size_t size()
const {
return N_; }
94 std::vector<double> initial(
size(), 0.0);
96 for (
size_t i = 0; i < N_; i++) {
104template <
typename F,
typename T_y0,
typename... Args>
107 std::is_arithmetic<return_type_t<T_y0, Args...>>::value, F, T_y0,
110 const Eigen::Matrix<T_y0, Eigen::Dynamic, 1>& y0,
111 std::ostream* msgs,
const Args&... args)
114 Args...>(f, y0, msgs, args...) {}
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
T value_of(const fvar< T > &v)
Return the value of the specified variable.
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.
constexpr decltype(auto) apply(F &&f, Tuple &&t, PreArgs &&... pre_args)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
coupled_ode_system_impl(const F &f, const Eigen::VectorXd &y0, std::ostream *msgs, const Args &... args)
Construct a coupled ode system from the base system function, initial state of the base system,...
std::vector< double > initial_state() const
Returns the initial state of the coupled system.
const Eigen::VectorXd & y0_
size_t size() const
Returns the size of the coupled system.
std::tuple< const Args &... > args_tuple_
void operator()(const std::vector< double > &z, std::vector< double > &dz_dt, double t) const
Evaluate the right hand side of the coupled system at state z and time t, and store the sensitivities...
coupled_ode_system(const F &f, const Eigen::Matrix< T_y0, Eigen::Dynamic, 1 > &y0, std::ostream *msgs, const Args &... args)