Automatic Differentiation
 
Loading...
Searching...
No Matches
ode_ckrk.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUNCTOR_ODE_CKRK_HPP
2#define STAN_MATH_PRIM_FUNCTOR_ODE_CKRK_HPP
3
8#include <ostream>
9#include <tuple>
10#include <vector>
11
12namespace stan {
13namespace math {
14
53template <typename F, typename T_y0, typename T_t0, typename T_ts,
54 typename... Args, require_eigen_vector_t<T_y0>* = nullptr>
55inline std::vector<Eigen::Matrix<stan::return_type_t<T_y0, T_t0, T_ts, Args...>,
56 Eigen::Dynamic, 1>>
57ode_ckrk_tol_impl(const char* function_name, const F& f, const T_y0& y0_arg,
58 T_t0 t0, const std::vector<T_ts>& ts,
59 double relative_tolerance, double absolute_tolerance,
60 long int max_num_steps, // NOLINT(runtime/int)
61 std::ostream* msgs, const Args&... args) {
62 const auto& args_ref_tuple = std::make_tuple(to_ref(args)...);
63 return math::apply(
64 [&](const auto&... args_refs) {
65 arkode_integrator<ARKODE_CASH_KARP_6_4_5, false, F, T_y0, T_t0, T_ts,
67 integrator(function_name, f, y0_arg, t0, ts, relative_tolerance,
68 absolute_tolerance, max_num_steps, msgs, args_refs...);
69
70 return integrator();
71 },
72 args_ref_tuple);
73}
74
111template <typename F, typename T_y0, typename T_t0, typename T_ts,
112 typename... Args, require_eigen_vector_t<T_y0>* = nullptr>
113inline std::vector<Eigen::Matrix<stan::return_type_t<T_y0, T_t0, T_ts, Args...>,
114 Eigen::Dynamic, 1>>
115ode_ckrk_tol(const F& f, const T_y0& y0_arg, T_t0 t0,
116 const std::vector<T_ts>& ts, double relative_tolerance,
117 double absolute_tolerance,
118 long int max_num_steps, // NOLINT(runtime/int)
119 std::ostream* msgs, const Args&... args) {
120 return ode_ckrk_tol_impl("ode_ckrk_tol", f, y0_arg, t0, ts,
121 relative_tolerance, absolute_tolerance,
122 max_num_steps, msgs, args...);
123}
124
158template <typename F, typename T_y0, typename T_t0, typename T_ts,
159 typename... Args, require_eigen_vector_t<T_y0>* = nullptr>
160inline std::vector<Eigen::Matrix<stan::return_type_t<T_y0, T_t0, T_ts, Args...>,
161 Eigen::Dynamic, 1>>
162ode_ckrk(const F& f, const T_y0& y0, T_t0 t0, const std::vector<T_ts>& ts,
163 std::ostream* msgs, const Args&... args) {
164 double relative_tolerance = 1e-6;
165 double absolute_tolerance = 1e-6;
166 long int max_num_steps = 1e6; // NOLINT(runtime/int)
167
168 return ode_ckrk_tol_impl("ode_ckrk", f, y0, t0, ts, relative_tolerance,
169 absolute_tolerance, max_num_steps, msgs, args...);
170}
171
172} // namespace math
173} // namespace stan
174#endif
Integrator interface for ARKODE's ERKStep explicit adaptive Runge-Kutta solver, using one of ERKStep'...
require_t< is_eigen_vector< std::decay_t< T > > > require_eigen_vector_t
Require type satisfies is_eigen_vector.
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
std::vector< Eigen::Matrix< stan::return_type_t< T_y0, T_t0, T_ts, Args... >, Eigen::Dynamic, 1 > > ode_ckrk_tol(const F &f, const T_y0 &y0_arg, T_t0 t0, const std::vector< T_ts > &ts, double relative_tolerance, double absolute_tolerance, long int max_num_steps, std::ostream *msgs, const Args &... args)
Solve the ODE initial value problem y' = f(t, y), y(t0) = y0 at a set of times, { t1,...
Definition ode_ckrk.hpp:115
std::vector< Eigen::Matrix< stan::return_type_t< T_y0, T_t0, T_ts, Args... >, Eigen::Dynamic, 1 > > ode_ckrk(const F &f, const T_y0 &y0, T_t0 t0, const std::vector< T_ts > &ts, std::ostream *msgs, const Args &... args)
Solve the ODE initial value problem y' = f(t, y), y(t0) = y0 at a set of times, { t1,...
Definition ode_ckrk.hpp:162
static constexpr double e()
Return the base of the natural logarithm.
Definition constants.hpp:18
std::vector< Eigen::Matrix< stan::return_type_t< T_y0, T_t0, T_ts, Args... >, Eigen::Dynamic, 1 > > ode_ckrk_tol_impl(const char *function_name, const F &f, const T_y0 &y0_arg, T_t0 t0, const std::vector< T_ts > &ts, double relative_tolerance, double absolute_tolerance, long int max_num_steps, std::ostream *msgs, const Args &... args)
Solve the ODE initial value problem y' = f(t, y), y(t0) = y0 at a set of times, { t1,...
Definition ode_ckrk.hpp:57
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:18
constexpr decltype(auto) apply(F &&f, Tuple &&t, PreArgs &&... pre_args)
Definition apply.hpp:51
typename ref_type_if< true, T >::type ref_type_t
Definition ref_type.hpp:56
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...