Automatic Differentiation
 
Loading...
Searching...
No Matches
ode_bdf.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUNCTOR_ODE_BDF_HPP
2#define STAN_MATH_REV_FUNCTOR_ODE_BDF_HPP
3
8#include <ostream>
9#include <vector>
10
11namespace stan {
12namespace math {
13
49template <typename F, typename T_y0, typename T_t0, typename T_ts,
50 typename... T_Args, require_eigen_col_vector_t<T_y0>* = nullptr>
51std::vector<Eigen::Matrix<stan::return_type_t<T_y0, T_t0, T_ts, T_Args...>,
52 Eigen::Dynamic, 1>>
53ode_bdf_tol_impl(const char* function_name, const F& f, const T_y0& y0,
54 const T_t0& t0, const std::vector<T_ts>& ts,
55 double relative_tolerance, double absolute_tolerance,
56 long int max_num_steps, // NOLINT(runtime/int)
57 std::ostream* msgs, const T_Args&... args) {
58 const auto& args_ref_tuple = std::make_tuple(to_ref(args)...);
59 return math::apply(
60 [&](const auto&... args_refs) {
62 integrator(function_name, f, y0, t0, ts, relative_tolerance,
63 absolute_tolerance, max_num_steps, msgs, args_refs...);
64
65 return integrator();
66 },
67 args_ref_tuple);
68}
69
103template <typename F, typename T_y0, typename T_t0, typename T_ts,
104 typename... T_Args, require_eigen_col_vector_t<T_y0>* = nullptr>
105std::vector<Eigen::Matrix<stan::return_type_t<T_y0, T_t0, T_ts, T_Args...>,
106 Eigen::Dynamic, 1>>
107ode_bdf_tol(const F& f, const T_y0& y0, const T_t0& t0,
108 const std::vector<T_ts>& ts, double relative_tolerance,
109 double absolute_tolerance,
110 long int max_num_steps, // NOLINT(runtime/int)
111 std::ostream* msgs, const T_Args&... args) {
112 return ode_bdf_tol_impl("ode_bdf_tol", f, y0, t0, ts, relative_tolerance,
113 absolute_tolerance, max_num_steps, msgs, args...);
114}
115
146template <typename F, typename T_y0, typename T_t0, typename T_ts,
147 typename... T_Args, require_eigen_col_vector_t<T_y0>* = nullptr>
148std::vector<Eigen::Matrix<stan::return_type_t<T_y0, T_t0, T_ts, T_Args...>,
149 Eigen::Dynamic, 1>>
150ode_bdf(const F& f, const T_y0& y0, const T_t0& t0, const std::vector<T_ts>& ts,
151 std::ostream* msgs, 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_bdf_tol_impl("ode_bdf", 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.
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_bdf_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_bdf.hpp:53
std::vector< Eigen::Matrix< stan::return_type_t< T_y0, T_t0, T_ts, T_Args... >, Eigen::Dynamic, 1 > > ode_bdf(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,...
Definition ode_bdf.hpp:150
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
std::vector< Eigen::Matrix< stan::return_type_t< T_y0, T_t0, T_ts, T_Args... >, Eigen::Dynamic, 1 > > ode_bdf_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,...
Definition ode_bdf.hpp:107
constexpr decltype(auto) apply(F &&f, Tuple &&t, PreArgs &&... pre_args)
Definition apply.hpp:52
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...