Stan Math Library  2.20.0
reverse mode automatic differentiation
Public Member Functions | Public Attributes | List of all members
stan::math::coupled_ode_system< F, var, double > Struct Template Reference

The coupled_ode_system template specialization for unknown initial values and known parameters. More...

#include <coupled_ode_system.hpp>

Public Member Functions

 coupled_ode_system (const F &f, const std::vector< var > &y0, const std::vector< double > &theta, const std::vector< double > &x, const std::vector< int > &x_int, std::ostream *msgs)
 Construct a coupled ode system from the base system function, initial state of the base system, parameters, and a stream for messages. More...
 
void operator() (const std::vector< double > &z, std::vector< double > &dz_dt, double t) const
 Calculates the derivative of the coupled ode system with respect to time. More...
 
size_t size () const
 Returns the size of the coupled system. More...
 
std::vector< double > initial_state () const
 Returns the initial state of the coupled system. More...
 

Public Attributes

const F & f_
 
const std::vector< var > & y0_
 
const std::vector< double > & theta_dbl_
 
const std::vector< double > & x_
 
const std::vector< int > & x_int_
 
std::ostream * msgs_
 
const size_t N_
 
const size_t M_
 
const size_t size_
 

Detailed Description

template<typename F>
struct stan::math::coupled_ode_system< F, var, double >

The coupled_ode_system template specialization for unknown initial values and known parameters.

This coupled ode system has N + N * N states where N is the size of the base ode system.

For the coupled ode system, the first N states are the base system's states: $ \frac{d x_n}{dt} $.

The next N states correspond to the sensitivities of the initial conditions with respect to the first base system equation:

\[ \frac{d x_{N + n}}{dt} = \frac{d}{dt} \frac{\partial x_1}{\partial y0_m} \]

for $ n \in {1, \ldots, N} $].

The next N states correspond to the sensitivites with respect to the second base system equation, and so on through the last base system equation.

Template Parameters
Fbase ode system functor. Must provide operator()(double t, std::vector<var> y, std::vector<double> theta, std::vector<double> x, std::vector<int>x_int, std::ostream* msgs)

Definition at line 217 of file coupled_ode_system.hpp.

Constructor & Destructor Documentation

◆ coupled_ode_system()

template<typename F >
stan::math::coupled_ode_system< F, var, double >::coupled_ode_system ( const F &  f,
const std::vector< var > &  y0,
const std::vector< double > &  theta,
const std::vector< double > &  x,
const std::vector< int > &  x_int,
std::ostream *  msgs 
)
inline

Construct a coupled ode system from the base system function, initial state of the base system, parameters, and a stream for messages.

Parameters
[in]fthe base ODE system functor
[in]y0the initial state of the base ode
[in]thetaparameters of the base ode
[in]xreal data
[in]x_intinteger data
[in,out]msgsstream for messages

Definition at line 240 of file coupled_ode_system.hpp.

Member Function Documentation

◆ initial_state()

template<typename F >
std::vector<double> stan::math::coupled_ode_system< F, var, double >::initial_state ( ) const
inline

Returns the initial state of the coupled system.

Because the starting state is unknown, the coupled system incorporates the initial conditions as parameters. At the initial time the Jacobian of the integrated function is the identity matrix.

Returns
the initial condition of the coupled system. This is a vector of length size() where the first N values are the initial condition of the base ODE and the remainder correspond to the identity matrix which is the Jacobian of the integrated function at the initial time-point.

Definition at line 328 of file coupled_ode_system.hpp.

◆ operator()()

template<typename F >
void stan::math::coupled_ode_system< F, var, double >::operator() ( const std::vector< double > &  z,
std::vector< double > &  dz_dt,
double  t 
) const
inline

Calculates the derivative of the coupled ode system with respect to time.

This method uses nested autodiff and is not thread safe.

Parameters
[in]zstate of the coupled ode syste; this must be size size()
[out]dz_dta vector of length size() with the derivatives of the coupled system with respect to time
[in]ttime
Exceptions
exceptionif the base ode function does not return the expected number of derivatives, N.

Definition at line 268 of file coupled_ode_system.hpp.

◆ size()

template<typename F >
size_t stan::math::coupled_ode_system< F, var, double >::size ( ) const
inline

Returns the size of the coupled system.

Returns
size of the coupled system.

Definition at line 313 of file coupled_ode_system.hpp.

Member Data Documentation

◆ f_

template<typename F >
const F& stan::math::coupled_ode_system< F, var, double >::f_

Definition at line 218 of file coupled_ode_system.hpp.

◆ M_

template<typename F >
const size_t stan::math::coupled_ode_system< F, var, double >::M_

Definition at line 225 of file coupled_ode_system.hpp.

◆ msgs_

template<typename F >
std::ostream* stan::math::coupled_ode_system< F, var, double >::msgs_

Definition at line 223 of file coupled_ode_system.hpp.

◆ N_

template<typename F >
const size_t stan::math::coupled_ode_system< F, var, double >::N_

Definition at line 224 of file coupled_ode_system.hpp.

◆ size_

template<typename F >
const size_t stan::math::coupled_ode_system< F, var, double >::size_

Definition at line 226 of file coupled_ode_system.hpp.

◆ theta_dbl_

template<typename F >
const std::vector<double>& stan::math::coupled_ode_system< F, var, double >::theta_dbl_

Definition at line 220 of file coupled_ode_system.hpp.

◆ x_

template<typename F >
const std::vector<double>& stan::math::coupled_ode_system< F, var, double >::x_

Definition at line 221 of file coupled_ode_system.hpp.

◆ x_int_

template<typename F >
const std::vector<int>& stan::math::coupled_ode_system< F, var, double >::x_int_

Definition at line 222 of file coupled_ode_system.hpp.

◆ y0_

template<typename F >
const std::vector<var>& stan::math::coupled_ode_system< F, var, double >::y0_

Definition at line 219 of file coupled_ode_system.hpp.


The documentation for this struct was generated from the following file:

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