Automatic Differentiation
 
Loading...
Searching...
No Matches
ode_adams.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUNCTOR_ODE_ADAMS_HPP
2#define STAN_MATH_REV_FUNCTOR_ODE_ADAMS_HPP
3
8#include <ostream>
9#include <vector>
10
11namespace stan {
12namespace math {
13
48template <typename F, typename T_y0, typename T_t0, typename T_ts,
49 typename... T_Args, require_eigen_col_vector_t<T_y0>* = nullptr>
50std::vector<Eigen::Matrix<stan::return_type_t<T_y0, T_t0, T_ts, T_Args...>,
51 Eigen::Dynamic, 1>>
52ode_adams_tol_impl(const char* function_name, const F& f, const T_y0& y0,
53 const T_t0& t0, const std::vector<T_ts>& ts,
54 double relative_tolerance, double absolute_tolerance,
55 long int max_num_steps, // NOLINT(runtime/int)
56 std::ostream* msgs, const T_Args&... args) {
57 const auto& args_ref_tuple = std::make_tuple(to_ref(args)...);
58 return math::apply(
59 [&](const auto&... args_refs) {
61 integrator(function_name, f, y0, t0, ts, relative_tolerance,
62 absolute_tolerance, max_num_steps, msgs, args_refs...);
63
64 return integrator();
65 },
66 args_ref_tuple);
67}
68
102template <typename F, typename T_y0, typename T_t0, typename T_ts,
103 typename... T_Args, require_eigen_col_vector_t<T_y0>* = nullptr>
104std::vector<Eigen::Matrix<stan::return_type_t<T_y0, T_t0, T_ts, T_Args...>,
105 Eigen::Dynamic, 1>>
106ode_adams_tol(const F& f, const T_y0& y0, const T_t0& t0,
107 const std::vector<T_ts>& ts, double relative_tolerance,
108 double absolute_tolerance,
109 long int max_num_steps, // NOLINT(runtime/int)
110 std::ostream* msgs, const T_Args&... args) {
111 return ode_adams_tol_impl("ode_adams_tol", f, y0, t0, ts, relative_tolerance,
112 absolute_tolerance, max_num_steps, msgs, args...);
113}
114
145template <typename F, typename T_y0, typename T_t0, typename T_ts,
146 typename... T_Args, require_eigen_col_vector_t<T_y0>* = nullptr>
147std::vector<Eigen::Matrix<stan::return_type_t<T_y0, T_t0, T_ts, T_Args...>,
148 Eigen::Dynamic, 1>>
149ode_adams(const F& f, const T_y0& y0, const T_t0& t0,
150 const std::vector<T_ts>& ts, std::ostream* msgs,
151 const T_Args&... args) {
152 double relative_tolerance = 1e-10;
153 double absolute_tolerance = 1e-10;
154 long int max_num_steps = 1e8; // NOLINT(runtime/int)
155
156 return ode_adams_tol_impl("ode_adams", f, y0, t0, ts, relative_tolerance,
157 absolute_tolerance, max_num_steps, msgs, args...);
158}
159
160} // namespace math
161} // namespace stan
162#endif
Integrator interface for CVODES' ODE solvers (Adams & BDF methods).
require_t< is_eigen_col_vector< std::decay_t< T > > > require_eigen_col_vector_t
Require type satisfies is_eigen_col_vector.
Definition is_vector.hpp:98
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, T_Args... >, Eigen::Dynamic, 1 > > ode_adams_tol_impl(const char *function_name, const F &f, const T_y0 &y0, const T_t0 &t0, const std::vector< T_ts > &ts, double relative_tolerance, double absolute_tolerance, long int max_num_steps, std::ostream *msgs, const T_Args &... args)
Solve the ODE initial value problem y' = f(t, y), y(t0) = y0 at a set of times, { t1,...
Definition ode_adams.hpp:52
static constexpr double e()
Return the base of the natural logarithm.
Definition constants.hpp:20
std::vector< Eigen::Matrix< stan::return_type_t< T_y0, T_t0, T_ts, T_Args... >, Eigen::Dynamic, 1 > > ode_adams_tol(const F &f, const T_y0 &y0, const T_t0 &t0, const std::vector< T_ts > &ts, double relative_tolerance, double absolute_tolerance, long int max_num_steps, std::ostream *msgs, const T_Args &... args)
Solve the ODE initial value problem y' = f(t, y), y(t0) = y0 at a set of times, { t1,...
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
constexpr decltype(auto) apply(F &&f, Tuple &&t, PreArgs &&... pre_args)
Definition apply.hpp:52
std::vector< Eigen::Matrix< stan::return_type_t< T_y0, T_t0, T_ts, T_Args... >, Eigen::Dynamic, 1 > > ode_adams(const F &f, const T_y0 &y0, const T_t0 &t0, const std::vector< T_ts > &ts, std::ostream *msgs, const T_Args &... args)
Solve the ODE initial value problem y' = f(t, y), y(t0) = y0 at a set of times, { t1,...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...