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

The coupled ode system for unknown intial values and unknown parameters. More...

#include <coupled_ode_system.hpp>

Public Member Functions

 coupled_ode_system (const F &f, const std::vector< var > &y0, const std::vector< var > &theta, const std::vector< double > &x, const std::vector< int > &x_int, std::ostream *msgs)
 Construct a coupled ODE system with unknown initial value and known parameters, given the base ODE system functor, the initial state of the base ODE, the parameters, data, and an output stream to which to write messages. More...
 
void operator() (const std::vector< double > &z, std::vector< double > &dz_dt, double t)
 Populates the derivative vector with derivatives of the coupled ODE system state with respect to time evaluated at the specified state and specified time. More...
 
size_t size () const
 Returns the size of the coupled system. More...
 
std::vector< double > initial_state ()
 Returns the initial state of the coupled system. More...
 
std::vector< std::vector< var > > decouple_states (const std::vector< std::vector< double > > &y)
 Return the basic ODE solutions given the specified coupled system solutions, including the partials versus the parameters encoded in the autodiff results. More...
 

Public Attributes

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

Detailed Description

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

The coupled ode system for unknown intial values and unknown parameters.

The coupled system has N + N * (N + M) states, where N is size of the base ODE state vector and M is the number of parameters.

The first N states correspond to the base system's N states: $ \frac{d x_n}{dt} $

The next N+M states correspond to the sensitivities of the initial conditions, then to the parameters with respect to the to the first base system equation:

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

\[ \frac{d x_{N+N+m}}{dt} = \frac{d}{dt} \frac{\partial x_1}{\partial \theta_m} \]

The next N+M states correspond to the sensitivities with respect to the second base system equation, etc.

If the original ode has a state vector of size N states and a parameter vector of size M, the coupled system has N + N * (N

Template Parameters
Fthe functor for the base ode system

Definition at line 468 of file coupled_ode_system.hpp.

Constructor & Destructor Documentation

§ coupled_ode_system()

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

Construct a coupled ODE system with unknown initial value and known parameters, given the base ODE system functor, the initial state of the base ODE, the parameters, data, and an output stream to which to write 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]msgsoutput stream to which to print messages.

Definition at line 494 of file coupled_ode_system.hpp.

Member Function Documentation

§ decouple_states()

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

Return the basic ODE solutions given the specified coupled system solutions, including the partials versus the parameters encoded in the autodiff results.

Parameters
ythe vector of the coupled states after solving the ode

Definition at line 620 of file coupled_ode_system.hpp.

§ initial_state()

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

Returns the initial state of the coupled system.

Because the initial state is unknown, the coupled system incorporates the initial condition offset from zero as a parameter, and hence the return of this function is a vector of zeros.

Returns
the initial condition of the coupled system. This is a vector of length size() where all elements are 0.

Definition at line 608 of file coupled_ode_system.hpp.

§ operator()()

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

Populates the derivative vector with derivatives of the coupled ODE system state with respect to time evaluated at the specified state and specified time.

Parameters
[in]zthe current state of the coupled, shifted ode system, of size size().
[in,out]dz_dtpopulate with the derivatives of the coupled system evaluated at the specified state and time.
[in]ttime.
Exceptions
exceptionif the base system does not return a derivative vector of the same size as the state vector.

y is the base ODE system state

Definition at line 534 of file coupled_ode_system.hpp.

§ size()

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

Returns the size of the coupled system.

Returns
size of the coupled system.

Definition at line 593 of file coupled_ode_system.hpp.

Member Data Documentation

§ f_

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

Definition at line 469 of file coupled_ode_system.hpp.

§ M_

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

Definition at line 477 of file coupled_ode_system.hpp.

§ msgs_

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

Definition at line 479 of file coupled_ode_system.hpp.

§ N_

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

Definition at line 476 of file coupled_ode_system.hpp.

§ size_

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

Definition at line 478 of file coupled_ode_system.hpp.

§ theta_

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

Definition at line 472 of file coupled_ode_system.hpp.

§ theta_dbl_

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

Definition at line 473 of file coupled_ode_system.hpp.

§ x_

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

Definition at line 474 of file coupled_ode_system.hpp.

§ x_int_

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

Definition at line 475 of file coupled_ode_system.hpp.

§ y0_

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

Definition at line 470 of file coupled_ode_system.hpp.

§ y0_dbl_

template<typename F >
std::vector<double> stan::math::coupled_ode_system< F, var, stan::math::var >::y0_dbl_

Definition at line 471 of file coupled_ode_system.hpp.


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

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