I'm going to understand the library odeintfrom c++ boost, and I need to know which part does what. In boost/numeric/odeint/integrate/integrate_adaptive.hppthere is a function called integrate_adaptive. This function has several overloads. A simplified file with my little manipulations is as follows:
integrate_adaptive_minimal.hpp
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#include <boost/type_traits/is_same.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/integrate/null_observer.hpp>
#include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp>
using namespace std;
namespace boost {
namespace numeric {
namespace odeint {
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer )
{
cout<<"type one"<<endl;
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer )
{
cout<<"type two"<<endl;
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
}
}
}
The difference between the two functions is related to the parameter start_state. In the second function, it contains a keyword const. I want to know what overload is called. So, I added cout to each function. Then I call them from this test file:
minimal.cpp
#include "integrate_adaptive_minimal.hpp"
#include <boost/numeric/odeint.hpp>
#include <armadillo>
using namespace arma;
using namespace boost::numeric::odeint;
typedef vec::fixed<2> state_type;
void sys( const state_type &x , state_type &dxdt , const double t)
{
mat A;
A<<-1<<0<<endr<<0<<-1;
mat B;
B<<1<<endr<<1;
dxdt=A*x+B*(t>0?1:0);
}
void observer( const state_type &x , const double t )
{
}
typedef runge_kutta_dopri5<state_type> stepper_type;
int main()
{
state_type x;
x(0) = 0.0;
x(1) = 0.0;
integrate_adaptive(make_controlled(1E-10,1E-10,stepper_type()),
sys,x,0.0,11.0,0.1,observer);
return 0;
}
When I compile and run:
g++ -std=c++11 minimal.cpp -larmadillo -lboost_thread -lboost_filesystem -lboost_system -Wfatal-errors
./a.out
, integrate_adaptive, const. , , ? x const!
- boost, , .
Update:
: github, doc