| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
coupled_ode_system.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_ARR_FUNCTOR_COUPLED_ODE_SYSTEM_HPP
2 #define STAN_MATH_PRIM_ARR_FUNCTOR_COUPLED_ODE_SYSTEM_HPP
3
4 #include <stan/math/prim/mat/err/check_matching_sizes.hpp>
5 #include <ostream>
6 #include <vector>
7
8 namespace stan {
9
10 namespace math {
11
25 template <typename F, typename T1, typename T2>
26 struct coupled_ode_system {
27 };
28
29
40 template <typename F>
41 struct coupled_ode_system<F, double, double> {
42 const F& f_;
43 const std::vector<double>& y0_dbl_;
44 const std::vector<double>& theta_dbl_;
45 const std::vector<double>& x_;
46 const std::vector<int>& x_int_;
47 const int N_;
48 const int M_;
49 const int size_;
50 std::ostream* msgs_;
51
64 coupled_ode_system(const F& f,
65 const std::vector<double>& y0,
66 const std::vector<double>& theta,
67 const std::vector<double>& x,
68 const std::vector<int>& x_int,
69 std::ostream* msgs)
70 : f_(f),
71 y0_dbl_(y0),
72 theta_dbl_(theta),
73 x_(x),
74 x_int_(x_int),
75 N_(y0.size()),
76 M_(theta.size()),
77 size_(N_),
78 msgs_(msgs) {
79 }
80
96 void operator()(const std::vector<double>& y,
97 std::vector<double>& dy_dt,
98 double t) {
99 dy_dt = f_(t, y, theta_dbl_, x_, x_int_, msgs_);
100 stan::math::check_matching_sizes("coupled_ode_system",
101 "y", y,
102 "dy_dt", dy_dt);
103 }
104
110 int size() const {
111 return size_;
112 }
113
126 std::vector<double> initial_state() {
127 std::vector<double> state(size_, 0.0);
128 for (int n = 0; n < N_; n++)
129 state[n] = y0_dbl_[n];
130 return state;
131 }
132
143 std::vector<std::vector<double> >
144 decouple_states(const std::vector<std::vector<double> >& y) {
145 return y;
146 }
147 };
148
149 }
150
151 }
152
153 #endif
stan::math::coupled_ode_system< F, double, double >::operator()
void operator()(const std::vector< double > &y, std::vector< double > &dy_dt, double t)
Calculates the derivative of the coupled ode system with respect to the specified state at the specif...
Definition: coupled_ode_system.hpp:96
stan::math::coupled_ode_system< F, double, double >::x_
const std::vector< double > & x_
Definition: coupled_ode_system.hpp:45
stan::math::coupled_ode_system< F, double, double >::msgs_
std::ostream * msgs_
Definition: coupled_ode_system.hpp:50
stan::math::coupled_ode_system< F, double, double >::x_int_
const std::vector< int > & x_int_
Definition: coupled_ode_system.hpp:46
stan::math::coupled_ode_system< F, double, double >::N_
const int N_
Definition: coupled_ode_system.hpp:47
stan::math::coupled_ode_system< F, double, double >::y0_dbl_
const std::vector< double > & y0_dbl_
Definition: coupled_ode_system.hpp:43
stan::math::coupled_ode_system< F, double, double >::theta_dbl_
const std::vector< double > & theta_dbl_
Definition: coupled_ode_system.hpp:44
check_matching_sizes.hpp
stan::math::coupled_ode_system< F, double, double >::M_
const int M_
Definition: coupled_ode_system.hpp:48
M_
int M_
Definition: mdivide_left.hpp:19
stan::math::coupled_ode_system< F, double, double >::initial_state
std::vector< double > initial_state()
Returns the initial state of the coupled system, which is identical to the base ODE original state in...
Definition: coupled_ode_system.hpp:126
size_
size_t size_
Definition: dot_self.hpp:18
stan::math::coupled_ode_system< F, double, double >::size
int size() const
Returns the size of the coupled system.
Definition: coupled_ode_system.hpp:110
stan::math::check_matching_sizes
bool check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Return true if two structures at the same size.
Definition: check_matching_sizes.hpp:29
stan::math::coupled_ode_system< F, double, double >::coupled_ode_system
coupled_ode_system(const F &f, const std::vector< double > &y0, const std::vector< double > &theta, const std::vector< double > &x, const std::vector< int > &x_int, std::ostream *msgs)
Construct the coupled ODE system from the base system function, initial state, parameters, data and a stream for messages.
Definition: coupled_ode_system.hpp:64
stan::math::coupled_ode_system< F, double, double >::size_
const int size_
Definition: coupled_ode_system.hpp:49
stan::math::coupled_ode_system< F, double, double >::decouple_states
std::vector< std::vector< double > > decouple_states(const std::vector< std::vector< double > > &y)
Returns the base portion of the coupled state.
Definition: coupled_ode_system.hpp:144
stan::math::coupled_ode_system< F, double, double >::f_
const F & f_
Definition: coupled_ode_system.hpp:42
stan::math::size
int size(const std::vector< T > &x)
Definition: size.hpp:11
stan::math::coupled_ode_system
Base template class for a coupled ordinary differential equation system, which adds sensitivities to ...
Definition: coupled_ode_system.hpp:26
N_
int N_
Definition: mdivide_left.hpp:20

[ Stan Home Page ] © 2011–2015, Stan Development Team.