1#ifndef STAN_MATH_PRIM_FUNCTOR_COUPLED_ODE_SYSTEM_HPP
2#define STAN_MATH_PRIM_FUNCTOR_COUPLED_ODE_SYSTEM_HPP
15template <
bool ArithmeticArguments,
typename F,
typename T_y0,
typename... Args>
28template <
typename F,
typename T_y0,
typename... Args>
31 const Eigen::VectorXd&
y0_;
47 std::ostream* msgs,
const Args&... args)
48 : f_(f), y0_(y0), args_tuple_(args...), N_(y0.
size()), msgs_(msgs) {}
63 void operator()(
const std::vector<double>& z, std::vector<double>& dz_dt,
65 Eigen::VectorXd y(z.size());
66 for (
size_t n = 0; n < z.size(); ++n)
69 dz_dt.resize(y.size());
72 [&](
const Args&... args) {
return f_(t, y, msgs_, args...); },
78 Eigen::Map<Eigen::VectorXd>(dz_dt.data(), dz_dt.size()) = f_y_t;
86 size_t size()
const {
return N_; }
95 std::vector<double> initial(
size(), 0.0);
97 for (
size_t i = 0; i < N_; i++) {
105template <
typename F,
typename T_y0,
typename... Args>
108 std::is_arithmetic<return_type_t<T_y0, Args...>>::value, F, T_y0,
111 const Eigen::Matrix<T_y0, Eigen::Dynamic, 1>& y0,
112 std::ostream* msgs,
const Args&... args)
115 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)
std::is_arithmetic< scalar_type_t< T > > is_arithmetic
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)