mirror of
https://github.com/boostorg/odeint.git
synced 2026-01-25 06:22:11 +00:00
added std::ref & std::bind support
This commit is contained in:
@@ -23,9 +23,9 @@
|
||||
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
|
||||
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
|
||||
#include <boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/copy.hpp>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -58,7 +58,7 @@ size_t integrate_adaptive(
|
||||
{ //make a last step to end exactly at end_time
|
||||
stepper.do_step( system , start_state , end , end_time - end );
|
||||
steps++;
|
||||
typename boost::unwrap_reference< Observer >::type &obs = observer;
|
||||
typename detail::unwrap_reference< Observer >::type &obs = observer;
|
||||
obs( start_state , end_time );
|
||||
}
|
||||
return steps;
|
||||
@@ -75,7 +75,7 @@ size_t integrate_adaptive(
|
||||
Observer observer , controlled_stepper_tag
|
||||
)
|
||||
{
|
||||
typename boost::unwrap_reference< Observer >::type &obs = observer;
|
||||
typename detail::unwrap_reference< Observer >::type &obs = observer;
|
||||
|
||||
const size_t max_attempts = 1000;
|
||||
const char *error_string = "Integrate adaptive : Maximal number of iterations reached. A step size could not be found.";
|
||||
@@ -116,7 +116,7 @@ size_t integrate_adaptive(
|
||||
Time start_time , Time end_time , Time dt ,
|
||||
Observer observer , dense_output_stepper_tag )
|
||||
{
|
||||
typename boost::unwrap_reference< Observer >::type &obs = observer;
|
||||
typename detail::unwrap_reference< Observer >::type &obs = observer;
|
||||
|
||||
size_t count = 0;
|
||||
stepper.initialize( start_state , start_time , dt );
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
|
||||
#include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp>
|
||||
#include <boost/numeric/odeint/integrate/detail/units_helper.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
@@ -43,7 +42,7 @@ Time integrate_n_steps(
|
||||
Time start_time , Time dt , size_t num_of_steps ,
|
||||
Observer observer , stepper_tag )
|
||||
{
|
||||
typename boost::unwrap_reference< Observer >::type &obs = observer;
|
||||
typename detail::unwrap_reference< Observer >::type &obs = observer;
|
||||
|
||||
Time time = start_time;
|
||||
|
||||
@@ -68,7 +67,7 @@ Time integrate_n_steps(
|
||||
Time start_time , Time dt , size_t num_of_steps ,
|
||||
Observer observer , controlled_stepper_tag )
|
||||
{
|
||||
typename boost::unwrap_reference< Observer >::type &obs = observer;
|
||||
typename detail::unwrap_reference< Observer >::type &obs = observer;
|
||||
|
||||
Time time = start_time;
|
||||
Time time_step = dt;
|
||||
@@ -95,7 +94,7 @@ Time integrate_n_steps(
|
||||
Time start_time , Time dt , size_t num_of_steps ,
|
||||
Observer observer , dense_output_stepper_tag )
|
||||
{
|
||||
typename boost::unwrap_reference< Observer >::type &obs = observer;
|
||||
typename detail::unwrap_reference< Observer >::type &obs = observer;
|
||||
|
||||
Time time = start_time;
|
||||
const Time end_time = start_time + static_cast< typename detail::unit_value_type<Time>::type >(num_of_steps) * dt;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
@@ -41,7 +40,7 @@ size_t integrate_times(
|
||||
Observer observer , stepper_tag
|
||||
)
|
||||
{
|
||||
typename boost::unwrap_reference< Observer >::type &obs = observer;
|
||||
typename detail::unwrap_reference< Observer >::type &obs = observer;
|
||||
|
||||
size_t steps = 0;
|
||||
Time current_dt = dt;
|
||||
@@ -72,7 +71,7 @@ size_t integrate_times(
|
||||
Observer observer , controlled_stepper_tag
|
||||
)
|
||||
{
|
||||
typename boost::unwrap_reference< Observer >::type &obs = observer;
|
||||
typename detail::unwrap_reference< Observer >::type &obs = observer;
|
||||
|
||||
const size_t max_attempts = 1000;
|
||||
const char *error_string = "Integrate adaptive : Maximal number of iterations reached. A step size could not be found.";
|
||||
@@ -111,7 +110,7 @@ size_t integrate_times(
|
||||
Observer observer , dense_output_stepper_tag
|
||||
)
|
||||
{
|
||||
typename boost::unwrap_reference< Observer >::type &obs = observer;
|
||||
typename detail::unwrap_reference< Observer >::type &obs = observer;
|
||||
|
||||
Time last_time_point = *(end_time-1);
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_BASHFORTH_HPP_INCLUDED
|
||||
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
|
||||
#include <boost/numeric/odeint/algebra/default_operations.hpp>
|
||||
@@ -223,10 +222,10 @@ public :
|
||||
template< class ExplicitStepper , class System , class StateIn >
|
||||
void initialize( ExplicitStepper explicit_stepper , System system , StateIn &x , time_type &t , const time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< ExplicitStepper >::type &stepper = explicit_stepper;
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< ExplicitStepper >::type &stepper = explicit_stepper;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
|
||||
m_resizer.adjust_size( x , boost::bind( &stepper_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
for( size_t i=0 ; i<steps-1 ; ++i )
|
||||
{
|
||||
@@ -241,7 +240,7 @@ public :
|
||||
template< class System , class StateIn >
|
||||
void initialize( System system , StateIn &x , time_type &t , const time_type &dt )
|
||||
{
|
||||
initialize( boost::ref( m_initializing_stepper ) , system , x , t , dt );
|
||||
initialize( detail::ref( m_initializing_stepper ) , system , x , t , dt );
|
||||
}
|
||||
|
||||
void reset( void )
|
||||
@@ -263,8 +262,8 @@ private:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
void do_step_impl( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
if( m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) ) )
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
if( m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) ) )
|
||||
{
|
||||
m_steps_initialized = 0;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_BASHFORTH_MOULTON_HPP_INCLUDED
|
||||
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
|
||||
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED
|
||||
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
|
||||
#include <boost/numeric/odeint/algebra/default_operations.hpp>
|
||||
@@ -135,8 +134,8 @@ public :
|
||||
template< class System , class StateIn , class StateOut , class ABBuf >
|
||||
void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt , const ABBuf &buf )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( in , m_dxdt.m_v , t );
|
||||
detail::adams_moulton_call_algebra< steps , algebra_type , operations_type >()( m_algebra , in , out , m_dxdt.m_v , buf , m_coefficients , dt );
|
||||
}
|
||||
@@ -144,8 +143,8 @@ public :
|
||||
template< class System , class StateIn , class StateOut , class ABBuf >
|
||||
void do_step( System system , const StateIn &in , const time_type &t , const StateOut &out , const time_type &dt , const ABBuf &buf )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( in , m_dxdt.m_v , t );
|
||||
detail::adams_moulton_call_algebra< steps , algebra_type , operations_type >()( m_algebra , in , out , m_dxdt.m_v , buf , m_coefficients , dt );
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_BASE_EXPLICIT_ERROR_STEPPER_BASE_HPP_INCLUDED
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_BASE_EXPLICIT_ERROR_STEPPER_BASE_HPP_INCLUDED
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/util/state_wrapper.hpp>
|
||||
#include <boost/numeric/odeint/util/resizer.hpp>
|
||||
@@ -124,8 +123,8 @@ public:
|
||||
template< class System , class StateIn , class StateOut , class Err >
|
||||
void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt , Err &xerr )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , boost::bind( &internal_stepper_base_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( in , m_dxdt.m_v ,t );
|
||||
this->stepper().do_step_impl( system , in , m_dxdt.m_v , t , out , dt , xerr );
|
||||
}
|
||||
@@ -163,8 +162,8 @@ private:
|
||||
template< class System , class StateInOut , class Err >
|
||||
void do_step_v1( System system , StateInOut &x , const time_type &t , const time_type &dt , Err &xerr )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , boost::bind( &internal_stepper_base_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( x , m_dxdt.m_v ,t );
|
||||
this->stepper().do_step_impl( system , x , m_dxdt.m_v , t , x , dt , xerr );
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_BASE_EXPLICIT_STEPPER_AND_ERROR_STEPPER_BASE_HPP_INCLUDED
|
||||
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/util/state_wrapper.hpp>
|
||||
#include <boost/numeric/odeint/util/is_resizeable.hpp>
|
||||
@@ -137,8 +136,8 @@ public:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , boost::bind( &internal_stepper_base_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( in , m_dxdt.m_v ,t );
|
||||
this->stepper().do_step_impl( system , in , m_dxdt.m_v , t , out , dt );
|
||||
}
|
||||
@@ -196,8 +195,8 @@ public:
|
||||
template< class System , class StateIn , class StateOut , class Err >
|
||||
void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt , Err &xerr )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , boost::bind( &internal_stepper_base_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( in , m_dxdt.m_v ,t );
|
||||
this->stepper().do_step_impl( system , in , m_dxdt.m_v , t , out , dt , xerr );
|
||||
}
|
||||
@@ -227,8 +226,8 @@ private:
|
||||
template< class System , class StateInOut >
|
||||
void do_step_v1( System system , StateInOut &x , const time_type &t , const time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( x , boost::bind( &internal_stepper_base_type::template resize_impl<StateInOut> , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( x , detail::bind( &internal_stepper_base_type::template resize_impl<StateInOut> , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( x , m_dxdt.m_v ,t );
|
||||
this->stepper().do_step_impl( system , x , m_dxdt.m_v , t , x , dt );
|
||||
}
|
||||
@@ -236,8 +235,8 @@ private:
|
||||
template< class System , class StateInOut , class Err >
|
||||
void do_step_v5( System system , StateInOut &x , const time_type &t , const time_type &dt , Err &xerr )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( x , boost::bind( &internal_stepper_base_type::template resize_impl<StateInOut> , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( x , detail::bind( &internal_stepper_base_type::template resize_impl<StateInOut> , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( x , m_dxdt.m_v ,t );
|
||||
this->stepper().do_step_impl( system , x , m_dxdt.m_v , t , x , dt , xerr );
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_BASE_EXPLICIT_STEPPER_AND_ERROR_STEPPER_FSAL_BASE_HPP_INCLUDED
|
||||
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/util/state_wrapper.hpp>
|
||||
#include <boost/numeric/odeint/util/is_resizeable.hpp>
|
||||
@@ -139,7 +138,7 @@ public:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt )
|
||||
{
|
||||
if( m_resizer.adjust_size( in , boost::bind( &internal_stepper_base_type::template resize_impl< StateIn > , boost::ref( *this ) , _1 ) ) || m_first_call )
|
||||
if( m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
|
||||
{
|
||||
initialize( system , in , t );
|
||||
}
|
||||
@@ -203,7 +202,7 @@ public:
|
||||
template< class System , class StateIn , class StateOut , class Err >
|
||||
void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt , Err &xerr )
|
||||
{
|
||||
if( m_resizer.adjust_size( in , boost::bind( &internal_stepper_base_type::template resize_impl< StateIn > , boost::ref( *this ) , _1 ) ) || m_first_call )
|
||||
if( m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
|
||||
{
|
||||
initialize( system , in , t );
|
||||
}
|
||||
@@ -247,7 +246,7 @@ public:
|
||||
template< class System , class StateIn >
|
||||
void initialize( System system , const StateIn &x , const time_type &t )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
sys( x , m_dxdt.m_v , t );
|
||||
m_first_call = false;
|
||||
}
|
||||
@@ -264,7 +263,7 @@ private:
|
||||
template< class System , class StateInOut >
|
||||
void do_step_v1( System system , StateInOut &x , const time_type &t , const time_type &dt )
|
||||
{
|
||||
if( m_resizer.adjust_size( x , boost::bind( &internal_stepper_base_type::template resize_impl< StateInOut > , boost::ref( *this ) , _1 ) ) || m_first_call )
|
||||
if( m_resizer.adjust_size( x , detail::bind( &internal_stepper_base_type::template resize_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
|
||||
{
|
||||
initialize( system , x , t );
|
||||
}
|
||||
@@ -274,7 +273,7 @@ private:
|
||||
template< class System , class StateInOut , class Err >
|
||||
void do_step_v5( System system , StateInOut &x , const time_type &t , const time_type &dt , Err &xerr )
|
||||
{
|
||||
if( m_resizer.adjust_size( x , boost::bind( &internal_stepper_base_type::template resize_impl< StateInOut > , boost::ref( *this ) , _1 ) ) || m_first_call )
|
||||
if( m_resizer.adjust_size( x , detail::bind( &internal_stepper_base_type::template resize_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
|
||||
{
|
||||
initialize( system , x , t );
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
|
||||
#include <boost/numeric/odeint/util/state_wrapper.hpp>
|
||||
@@ -123,8 +122,8 @@ public:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , boost::bind( &internal_stepper_base_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( in , m_dxdt.m_v ,t );
|
||||
this->stepper().do_step_impl( system , in , m_dxdt.m_v , t , out , dt );
|
||||
}
|
||||
@@ -166,8 +165,8 @@ private:
|
||||
template< class System , class StateInOut >
|
||||
void do_step_v1( System system , StateInOut &x , const time_type &t , const time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( x , boost::bind( &internal_stepper_base_type::template resize_impl< StateInOut > , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_resizer.adjust_size( x , detail::bind( &internal_stepper_base_type::template resize_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( x , m_dxdt.m_v ,t );
|
||||
this->stepper().do_step_impl( system , x , m_dxdt.m_v , t , x , dt );
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_BASE_SYMPLECTIC_RKN_STEPPER_BASE_HPP_INCLUDED
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_BASE_SYMPLECTIC_RKN_STEPPER_BASE_HPP_INCLUDED
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/util/copy.hpp>
|
||||
@@ -110,14 +109,14 @@ public:
|
||||
template< class System , class StateInOut >
|
||||
void do_step( System system , const StateInOut &state , const time_type &t , const time_type &dt )
|
||||
{
|
||||
typedef typename boost::unwrap_reference< System >::type system_type;
|
||||
typedef typename detail::unwrap_reference< System >::type system_type;
|
||||
do_step_impl( system , state , t , state , dt , typename is_pair< system_type >::type() );
|
||||
}
|
||||
|
||||
template< class System , class StateInOut >
|
||||
void do_step( System system , StateInOut &state , const time_type &t , const time_type &dt )
|
||||
{
|
||||
typedef typename boost::unwrap_reference< System >::type system_type;
|
||||
typedef typename detail::unwrap_reference< System >::type system_type;
|
||||
do_step_impl( system , state , t , state , dt , typename is_pair< system_type >::type() );
|
||||
}
|
||||
|
||||
@@ -132,13 +131,13 @@ public:
|
||||
template< class System , class CoorInOut , class MomentumInOut >
|
||||
void do_step( System system , CoorInOut &q , MomentumInOut &p , const time_type &t , const time_type &dt )
|
||||
{
|
||||
do_step( system , std::make_pair( boost::ref( q ) , boost::ref( p ) ) , t , dt );
|
||||
do_step( system , std::make_pair( detail::ref( q ) , detail::ref( p ) ) , t , dt );
|
||||
}
|
||||
|
||||
template< class System , class CoorInOut , class MomentumInOut >
|
||||
void do_step( System system , const CoorInOut &q , const MomentumInOut &p , const time_type &t , const time_type &dt )
|
||||
{
|
||||
do_step( system , std::make_pair( boost::ref( q ) , boost::ref( p ) ) , t , dt );
|
||||
do_step( system , std::make_pair( detail::ref( q ) , detail::ref( p ) ) , t , dt );
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +152,7 @@ public:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt )
|
||||
{
|
||||
typedef typename boost::unwrap_reference< System >::type system_type;
|
||||
typedef typename detail::unwrap_reference< System >::type system_type;
|
||||
do_step_impl( system , in , t , out , dt , typename is_pair< system_type >::type() );
|
||||
}
|
||||
|
||||
@@ -174,29 +173,29 @@ private:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
void do_step_impl( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt , boost::mpl::true_ )
|
||||
{
|
||||
typedef typename boost::unwrap_reference< System >::type system_type;
|
||||
typedef typename boost::unwrap_reference< typename system_type::first_type >::type coor_deriv_func_type;
|
||||
typedef typename boost::unwrap_reference< typename system_type::second_type >::type momentum_deriv_func_type;
|
||||
typedef typename detail::unwrap_reference< System >::type system_type;
|
||||
typedef typename detail::unwrap_reference< typename system_type::first_type >::type coor_deriv_func_type;
|
||||
typedef typename detail::unwrap_reference< typename system_type::second_type >::type momentum_deriv_func_type;
|
||||
system_type &sys = system;
|
||||
coor_deriv_func_type &coor_func = sys.first;
|
||||
momentum_deriv_func_type &momentum_func = sys.second;
|
||||
|
||||
typedef typename boost::unwrap_reference< StateIn >::type state_in_type;
|
||||
typedef typename boost::unwrap_reference< typename state_in_type::first_type >::type coor_in_type;
|
||||
typedef typename boost::unwrap_reference< typename state_in_type::second_type >::type momentum_in_type;
|
||||
typedef typename detail::unwrap_reference< StateIn >::type state_in_type;
|
||||
typedef typename detail::unwrap_reference< typename state_in_type::first_type >::type coor_in_type;
|
||||
typedef typename detail::unwrap_reference< typename state_in_type::second_type >::type momentum_in_type;
|
||||
const state_in_type &state_in = in;
|
||||
const coor_in_type &coor_in = state_in.first;
|
||||
const momentum_in_type &momentum_in = state_in.second;
|
||||
|
||||
typedef typename boost::unwrap_reference< StateOut >::type state_out_type;
|
||||
typedef typename boost::unwrap_reference< typename state_out_type::first_type >::type coor_out_type;
|
||||
typedef typename boost::unwrap_reference< typename state_out_type::second_type >::type momentum_out_type;
|
||||
typedef typename detail::unwrap_reference< StateOut >::type state_out_type;
|
||||
typedef typename detail::unwrap_reference< typename state_out_type::first_type >::type coor_out_type;
|
||||
typedef typename detail::unwrap_reference< typename state_out_type::second_type >::type momentum_out_type;
|
||||
state_out_type &state_out = out;
|
||||
coor_out_type &coor_out = state_out.first;
|
||||
momentum_out_type &momentum_out = state_out.second;
|
||||
|
||||
m_dqdt_resizer.adjust_size( coor_in , boost::bind( &internal_stepper_base_type::template resize_dqdt< coor_in_type > , boost::ref( *this ) , _1 ) );
|
||||
m_dpdt_resizer.adjust_size( momentum_in , boost::bind( &internal_stepper_base_type::template resize_dpdt< momentum_in_type > , boost::ref( *this ) , _1 ) );
|
||||
m_dqdt_resizer.adjust_size( coor_in , detail::bind( &internal_stepper_base_type::template resize_dqdt< coor_in_type > , detail::ref( *this ) , detail::_1 ) );
|
||||
m_dpdt_resizer.adjust_size( momentum_in , detail::bind( &internal_stepper_base_type::template resize_dpdt< momentum_in_type > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
// ToDo: check sizes?
|
||||
|
||||
@@ -228,26 +227,26 @@ private:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
void do_step_impl( System system , const StateIn &in , const time_type & /* t */ , StateOut &out , const time_type &dt , boost::mpl::false_ )
|
||||
{
|
||||
typedef typename boost::unwrap_reference< System >::type momentum_deriv_func_type;
|
||||
typedef typename detail::unwrap_reference< System >::type momentum_deriv_func_type;
|
||||
momentum_deriv_func_type &momentum_func = system;
|
||||
|
||||
typedef typename boost::unwrap_reference< StateIn >::type state_in_type;
|
||||
typedef typename boost::unwrap_reference< typename state_in_type::first_type >::type coor_in_type;
|
||||
typedef typename boost::unwrap_reference< typename state_in_type::second_type >::type momentum_in_type;
|
||||
typedef typename detail::unwrap_reference< StateIn >::type state_in_type;
|
||||
typedef typename detail::unwrap_reference< typename state_in_type::first_type >::type coor_in_type;
|
||||
typedef typename detail::unwrap_reference< typename state_in_type::second_type >::type momentum_in_type;
|
||||
const state_in_type &state_in = in;
|
||||
const coor_in_type &coor_in = state_in.first;
|
||||
const momentum_in_type &momentum_in = state_in.second;
|
||||
|
||||
typedef typename boost::unwrap_reference< StateOut >::type state_out_type;
|
||||
typedef typename boost::unwrap_reference< typename state_out_type::first_type >::type coor_out_type;
|
||||
typedef typename boost::unwrap_reference< typename state_out_type::second_type >::type momentum_out_type;
|
||||
typedef typename detail::unwrap_reference< StateOut >::type state_out_type;
|
||||
typedef typename detail::unwrap_reference< typename state_out_type::first_type >::type coor_out_type;
|
||||
typedef typename detail::unwrap_reference< typename state_out_type::second_type >::type momentum_out_type;
|
||||
state_out_type &state_out = out;
|
||||
coor_out_type &coor_out = state_out.first;
|
||||
momentum_out_type &momentum_out = state_out.second;
|
||||
|
||||
|
||||
m_dqdt_resizer.adjust_size( coor_in , boost::bind( &internal_stepper_base_type::template resize_dqdt< coor_in_type > , boost::ref( *this ) , _1 ) );
|
||||
m_dpdt_resizer.adjust_size( momentum_in , boost::bind( &internal_stepper_base_type::template resize_dpdt< momentum_in_type > , boost::ref( *this ) , _1 ) );
|
||||
m_dqdt_resizer.adjust_size( coor_in , detail::bind( &internal_stepper_base_type::template resize_dqdt< coor_in_type > , detail::ref( *this ) , detail::_1 ) );
|
||||
m_dpdt_resizer.adjust_size( momentum_in , detail::bind( &internal_stepper_base_type::template resize_dpdt< momentum_in_type > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
|
||||
// ToDo: check sizes?
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/controlled_runge_kutta.hpp>
|
||||
#include <boost/numeric/odeint/stepper/modified_midpoint.hpp>
|
||||
@@ -153,7 +152,7 @@ public:
|
||||
template< class System , class StateInOut , class DerivIn >
|
||||
controlled_step_result try_step( System system , StateInOut &x , const DerivIn &dxdt , time_type &t , time_type &dt )
|
||||
{
|
||||
m_xnew_resizer.adjust_size( x , boost::bind( &controlled_error_bs_type::template resize_m_xnew< StateInOut > , boost::ref( *this ) , _1 ) );
|
||||
m_xnew_resizer.adjust_size( x , detail::bind( &controlled_error_bs_type::template resize_m_xnew< StateInOut > , detail::ref( *this ) , detail::_1 ) );
|
||||
controlled_step_result res = try_step( system , x , dxdt , t , m_xnew.m_v , dt );
|
||||
if( res == success )
|
||||
{
|
||||
@@ -170,8 +169,8 @@ public:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
controlled_step_result try_step( System system , const StateIn &in , time_type &t , StateOut &out , time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_dxdt_resizer.adjust_size( in , boost::bind( &controlled_error_bs_type::template resize_m_dxdt< StateIn > , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_dxdt_resizer.adjust_size( in , detail::bind( &controlled_error_bs_type::template resize_m_dxdt< StateIn > , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( in , m_dxdt.m_v , t );
|
||||
return try_step( system , in , m_dxdt.m_v , t , out , dt );
|
||||
}
|
||||
@@ -182,8 +181,8 @@ public:
|
||||
{
|
||||
static const time_type val1( static_cast< time_type >( 1.0 ) );
|
||||
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
if( m_resizer.adjust_size( in , boost::bind( &controlled_error_bs_type::template resize_impl< StateIn > , boost::ref( *this ) , _1 ) ) )
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
if( m_resizer.adjust_size( in , detail::bind( &controlled_error_bs_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) )
|
||||
{
|
||||
reset(); // system resized -> reset
|
||||
}
|
||||
@@ -365,8 +364,8 @@ private:
|
||||
template< class System , class StateInOut >
|
||||
controlled_step_result try_step_v1( System system , StateInOut &x , time_type &t , time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_dxdt_resizer.adjust_size( x , boost::bind( &controlled_error_bs_type::template resize_m_dxdt< StateInOut > , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_dxdt_resizer.adjust_size( x , detail::bind( &controlled_error_bs_type::template resize_m_dxdt< StateInOut > , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( x , m_dxdt.m_v ,t );
|
||||
return try_step( system , x , m_dxdt.m_v , t , dt );
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/math/special_functions/binomial.hpp>
|
||||
|
||||
@@ -226,7 +225,7 @@ public:
|
||||
template< class System , class StateInOut >
|
||||
controlled_step_result try_step( System system , StateInOut &x , time_type &t , time_type &dt )
|
||||
{
|
||||
m_xnew_resizer.adjust_size( x , boost::bind( &controlled_error_bs_type::template resize_m_xnew< StateInOut > , boost::ref( *this ) , _1 ) );
|
||||
m_xnew_resizer.adjust_size( x , detail::bind( &controlled_error_bs_type::template resize_m_xnew< StateInOut > , detail::ref( *this ) , detail::_1 ) );
|
||||
controlled_step_result res = try_step( system , x , t , m_xnew.m_v , dt );
|
||||
if( ( res == success_step_size_increased ) || ( res == success_step_size_unchanged ) )
|
||||
{
|
||||
@@ -241,8 +240,8 @@ public:
|
||||
{
|
||||
static const time_type val1( static_cast< time_type >( 1.0 ) );
|
||||
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
// if( m_resizer.adjust_size( in , boost::bind( &controlled_error_bs_type::template resize_impl< StateIn > , boost::ref( *this ) , _1 ) ) )
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
// if( m_resizer.adjust_size( in , detail::bind( &controlled_error_bs_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) )
|
||||
// reset(); // system resized -> reset
|
||||
// if( dt != m_dt_last )
|
||||
// reset(); // step size changed from outside -> reset
|
||||
@@ -385,7 +384,7 @@ public:
|
||||
template< class StateType >
|
||||
void initialize( const StateType &x0 , const time_type &t0 , const time_type &dt0 )
|
||||
{
|
||||
m_resizer.adjust_size( x0 , boost::bind( &controlled_error_bs_type::template resize_impl< StateType > , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( x0 , detail::bind( &controlled_error_bs_type::template resize_impl< StateType > , detail::ref( *this ) , detail::_1 ) );
|
||||
boost::numeric::odeint::copy( x0 , *m_current_state );
|
||||
m_t = t0;
|
||||
m_dt = dt0;
|
||||
@@ -403,7 +402,7 @@ public:
|
||||
|
||||
if( m_first )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
sys( *m_current_state , *m_current_deriv , m_t );
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/util/copy.hpp>
|
||||
|
||||
@@ -189,7 +188,7 @@ public:
|
||||
template< class System , class StateInOut , class DerivIn >
|
||||
controlled_step_result try_step( System system , StateInOut &x , const DerivIn &dxdt , time_type &t , time_type &dt )
|
||||
{
|
||||
m_xnew_resizer.adjust_size( x , boost::bind( &controlled_runge_kutta::template resize_m_xnew_impl< StateInOut > , boost::ref( *this ) , _1 ) );
|
||||
m_xnew_resizer.adjust_size( x , detail::bind( &controlled_runge_kutta::template resize_m_xnew_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) );
|
||||
controlled_step_result res = try_step( system , x , dxdt , t , m_xnew.m_v , dt );
|
||||
if( res == success )
|
||||
{
|
||||
@@ -206,8 +205,8 @@ public:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
controlled_step_result try_step( System system , const StateIn &in , time_type &t , StateOut &out , time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_dxdt_resizer.adjust_size( in , boost::bind( &controlled_runge_kutta::template resize_m_dxdt_impl< StateIn > , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_dxdt_resizer.adjust_size( in , detail::bind( &controlled_runge_kutta::template resize_m_dxdt_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( in , m_dxdt.m_v , t );
|
||||
return try_step( system , in , m_dxdt.m_v , t , out , dt );
|
||||
}
|
||||
@@ -225,7 +224,7 @@ public:
|
||||
using std::min;
|
||||
using std::pow;
|
||||
|
||||
m_xerr_resizer.adjust_size( in , boost::bind( &controlled_runge_kutta::template resize_m_xerr_impl< StateIn > , boost::ref( *this ) , _1 ) );
|
||||
m_xerr_resizer.adjust_size( in , detail::bind( &controlled_runge_kutta::template resize_m_xerr_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
// do one step with error calculation
|
||||
m_stepper.do_step( system , in , dxdt , t , out , dt , m_xerr.m_v );
|
||||
@@ -287,8 +286,8 @@ private:
|
||||
template< class System , class StateInOut >
|
||||
controlled_step_result try_step_v1( System system , StateInOut &x , time_type &t , time_type &dt )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
m_dxdt_resizer.adjust_size( x , boost::bind( &controlled_runge_kutta::template resize_m_dxdt_impl< StateInOut > , boost::ref( *this ) , _1 ) );
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
m_dxdt_resizer.adjust_size( x , detail::bind( &controlled_runge_kutta::template resize_m_dxdt_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) );
|
||||
sys( x , m_dxdt.m_v ,t );
|
||||
return try_step( system , x , m_dxdt.m_v , t , dt );
|
||||
}
|
||||
@@ -401,9 +400,9 @@ public:
|
||||
template< class System , class StateIn , class StateOut >
|
||||
controlled_step_result try_step( System system , const StateIn &in , time_type &t , StateOut &out , time_type &dt )
|
||||
{
|
||||
if( m_dxdt_resizer.adjust_size( in , boost::bind( &controlled_runge_kutta::template resize_m_dxdt_impl< StateIn > , boost::ref( *this ) , _1 ) ) || m_first_call )
|
||||
if( m_dxdt_resizer.adjust_size( in , detail::bind( &controlled_runge_kutta::template resize_m_dxdt_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
sys( in , m_dxdt.m_v ,t );
|
||||
m_first_call = false;
|
||||
}
|
||||
@@ -419,8 +418,8 @@ public:
|
||||
template< class System , class StateInOut , class DerivInOut >
|
||||
controlled_step_result try_step( System system , StateInOut &x , DerivInOut &dxdt , time_type &t , time_type &dt )
|
||||
{
|
||||
m_xnew_resizer.adjust_size( x , boost::bind( &controlled_runge_kutta::template resize_m_xnew_impl< StateInOut > , boost::ref( *this ) , _1 ) );
|
||||
m_dxdt_new_resizer.adjust_size( x , boost::bind( &controlled_runge_kutta::template resize_m_dxdt_new_impl< StateInOut > , boost::ref( *this ) , _1 ) );
|
||||
m_xnew_resizer.adjust_size( x , detail::bind( &controlled_runge_kutta::template resize_m_xnew_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) );
|
||||
m_dxdt_new_resizer.adjust_size( x , detail::bind( &controlled_runge_kutta::template resize_m_dxdt_new_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) );
|
||||
controlled_step_result res = try_step( system , x , dxdt , t , m_xnew.m_v , m_dxdtnew.m_v , dt );
|
||||
if( res == success )
|
||||
{
|
||||
@@ -444,7 +443,7 @@ public:
|
||||
using std::min;
|
||||
using std::pow;
|
||||
|
||||
m_xerr_resizer.adjust_size( in , boost::bind( &controlled_runge_kutta::template resize_m_xerr_impl< StateIn > , boost::ref( *this ) , _1 ) );
|
||||
m_xerr_resizer.adjust_size( in , detail::bind( &controlled_runge_kutta::template resize_m_xerr_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
//fsal: m_stepper.get_dxdt( dxdt );
|
||||
//fsal: m_stepper.do_step( sys , x , dxdt , t , dt , m_x_err );
|
||||
@@ -532,9 +531,9 @@ private:
|
||||
template< class System , class StateInOut >
|
||||
controlled_step_result try_step_v1( System system , StateInOut &x , time_type &t , time_type &dt )
|
||||
{
|
||||
if( m_dxdt_resizer.adjust_size( x , boost::bind( &controlled_runge_kutta::template resize_m_dxdt_impl< StateInOut > , boost::ref( *this ) , _1 ) ) || m_first_call )
|
||||
if( m_dxdt_resizer.adjust_size( x , detail::bind( &controlled_runge_kutta::template resize_m_dxdt_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
sys( x , m_dxdt.m_v , t );
|
||||
m_first_call = false;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/util/copy.hpp>
|
||||
|
||||
@@ -114,7 +113,7 @@ public:
|
||||
template< class StateType >
|
||||
void initialize( const StateType &x0 , const time_type &t0 , const time_type &dt0 )
|
||||
{
|
||||
m_resizer.adjust_size( x0 , boost::bind( &dense_output_stepper_type::template resize_impl< StateType > , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( x0 , detail::bind( &dense_output_stepper_type::template resize_impl< StateType > , detail::ref( *this ) , detail::_1 ) );
|
||||
boost::numeric::odeint::copy( x0 , *m_current_state );
|
||||
m_t = t0;
|
||||
m_dt = dt0;
|
||||
@@ -284,7 +283,7 @@ public:
|
||||
template< class StateType >
|
||||
void initialize( const StateType &x0 , const time_type &t0 , const time_type &dt0 )
|
||||
{
|
||||
m_resizer.adjust_size( x0 , boost::bind( &dense_output_stepper_type::template resize< StateType > , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( x0 , detail::bind( &dense_output_stepper_type::template resize< StateType > , detail::ref( *this ) , detail::_1 ) );
|
||||
boost::numeric::odeint::copy( x0 , *m_current_state );
|
||||
m_t = t0;
|
||||
m_dt = dt0;
|
||||
@@ -298,7 +297,7 @@ public:
|
||||
|
||||
if( !m_is_deriv_initialized )
|
||||
{
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
sys( *m_current_state , *m_current_deriv , m_t );
|
||||
m_is_deriv_initialized = true;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <boost/numeric/odeint/algebra/default_operations.hpp>
|
||||
#include <boost/numeric/odeint/stepper/detail/generic_rk_call_algebra.hpp>
|
||||
#include <boost/numeric/odeint/stepper/detail/generic_rk_operations.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
namespace fusion = boost::fusion;
|
||||
@@ -229,7 +230,7 @@ public:
|
||||
const Time &t , StateOut &out , const Time &dt ,
|
||||
StateTemp &x_tmp , Deriv F[StageCount-1] ) const
|
||||
{
|
||||
typedef typename boost::unwrap_reference< System >::type unwrapped_system_type;
|
||||
typedef typename detail::unwrap_reference< System >::type unwrapped_system_type;
|
||||
unwrapped_system_type &sys = system;
|
||||
fusion::for_each( m_stages , calculate_stage<
|
||||
unwrapped_system_type , StateIn , StateTemp , DerivIn , Deriv , StateOut , Time >
|
||||
|
||||
@@ -121,10 +121,10 @@ public:
|
||||
void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt ,
|
||||
const time_type &t , StateOut &out , const time_type &dt )
|
||||
{
|
||||
//typedef typename boost::unwrap_reference< System >::type unwrapped_system_type;
|
||||
//typedef typename detail::unwrap_reference< System >::type unwrapped_system_type;
|
||||
//unwrapped_system_type &sys = system;
|
||||
|
||||
m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize_impl< StateIn > , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
// actual calculation done in generic_rk.hpp
|
||||
m_rk_algorithm.do_step( stepper_base_type::m_algebra , system , in , dxdt , t , out , dt , m_x_tmp.m_v , m_F );
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp>
|
||||
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
|
||||
@@ -157,10 +156,10 @@ public:
|
||||
void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt ,
|
||||
const time_type &t , StateOut &out , const time_type &dt )
|
||||
{
|
||||
//typedef typename boost::unwrap_reference< System >::type unwrapped_system_type;
|
||||
//typedef typename detail::unwrap_reference< System >::type unwrapped_system_type;
|
||||
//unwrapped_system_type &sys = system;
|
||||
|
||||
m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize_impl< StateIn > , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
// actual calculation done in generic_rk.hpp
|
||||
m_rk_algorithm.do_step( stepper_base_type::m_algebra , system , in , dxdt , t , out , dt , m_x_tmp.m_v , m_F );
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
|
||||
|
||||
@@ -73,14 +72,14 @@ public:
|
||||
template< class System >
|
||||
void do_step( System system , state_type &x , value_type t , value_type dt )
|
||||
{
|
||||
typedef typename boost::unwrap_reference< System >::type system_type;
|
||||
typedef typename boost::unwrap_reference< typename system_type::first_type >::type deriv_func_type;
|
||||
typedef typename boost::unwrap_reference< typename system_type::second_type >::type jacobi_func_type;
|
||||
typedef typename detail::unwrap_reference< System >::type system_type;
|
||||
typedef typename detail::unwrap_reference< typename system_type::first_type >::type deriv_func_type;
|
||||
typedef typename detail::unwrap_reference< typename system_type::second_type >::type jacobi_func_type;
|
||||
system_type &sys = system;
|
||||
deriv_func_type &deriv_func = sys.first;
|
||||
jacobi_func_type &jacobi_func = sys.second;
|
||||
|
||||
m_resizer.adjust_size( x , boost::bind( &stepper_type::template resize_impl<state_type> , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_impl<state_type> , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
for( size_t i=0 ; i<x.size() ; ++i )
|
||||
m_pm.m_v[i] = i;
|
||||
|
||||
@@ -63,12 +63,12 @@ public :
|
||||
static const value_type val1 = static_cast< value_type >( 1.0 );
|
||||
static const value_type val05 = static_cast< value_type >( 0.5 );
|
||||
|
||||
m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize_impl< StateIn > , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
const time_type h = dt / static_cast<time_type>( m_steps );
|
||||
const time_type h2 = static_cast<time_type>( 2.0 ) * h;
|
||||
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
|
||||
time_type th = t + h;
|
||||
|
||||
@@ -187,12 +187,12 @@ public :
|
||||
static const value_type val1 = static_cast< value_type >( 1.0 );
|
||||
static const value_type val05 = static_cast< value_type >( 0.5 );
|
||||
|
||||
m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize< StateIn > , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize< StateIn > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
const time_type h = dt / static_cast<time_type>( m_steps );
|
||||
const time_type h2 = static_cast<time_type>( 2.0 ) * h;
|
||||
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
|
||||
time_type th = t + h;
|
||||
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_ROSENBROCK4_HPP_INCLUDED
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_ROSENBROCK4_HPP_INCLUDED
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/ublas/vector.hpp>
|
||||
#include <boost/numeric/ublas/matrix.hpp>
|
||||
@@ -139,16 +138,16 @@ public:
|
||||
void do_step( System system , const state_type &x , time_type t , state_type &xout , time_type dt , state_type &xerr )
|
||||
{
|
||||
// get the systen and jacobi function
|
||||
typedef typename boost::unwrap_reference< System >::type system_type;
|
||||
typedef typename boost::unwrap_reference< typename system_type::first_type >::type deriv_func_type;
|
||||
typedef typename boost::unwrap_reference< typename system_type::second_type >::type jacobi_func_type;
|
||||
typedef typename detail::unwrap_reference< System >::type system_type;
|
||||
typedef typename detail::unwrap_reference< typename system_type::first_type >::type deriv_func_type;
|
||||
typedef typename detail::unwrap_reference< typename system_type::second_type >::type jacobi_func_type;
|
||||
system_type &sys = system;
|
||||
deriv_func_type &deriv_func = sys.first;
|
||||
jacobi_func_type &jacobi_func = sys.second;
|
||||
|
||||
const size_t n = x.size();
|
||||
|
||||
m_resizer.adjust_size( x , boost::bind( &stepper_type::template resize_impl<state_type> , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_impl<state_type> , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
for( size_t i=0 ; i<n ; ++i )
|
||||
m_pm.m_v( i ) = i;
|
||||
@@ -219,14 +218,14 @@ public:
|
||||
template< class System >
|
||||
void do_step( System system , const state_type &x , time_type t , state_type &xout , time_type dt )
|
||||
{
|
||||
m_x_err_resizer.adjust_size( x , boost::bind( &stepper_type::template resize_x_err<state_type> , boost::ref( *this ) , _1 ) );
|
||||
m_x_err_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_x_err<state_type> , detail::ref( *this ) , detail::_1 ) );
|
||||
do_step( system , x , t , xout , dt , m_x_err.m_v );
|
||||
}
|
||||
|
||||
template< class System >
|
||||
void do_step( System system , state_type &x , time_type t , time_type dt )
|
||||
{
|
||||
m_x_err_resizer.adjust_size( x , boost::bind( &stepper_type::template resize_x_err<state_type> , boost::ref( *this ) , _1 ) );
|
||||
m_x_err_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_x_err<state_type> , detail::ref( *this ) , detail::_1 ) );
|
||||
do_step( system , x , t , dt , m_x_err.m_v );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_ROSENBROCK4_CONTROLLER_HPP_INCLUDED
|
||||
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
|
||||
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
|
||||
@@ -90,7 +89,7 @@ public:
|
||||
boost::numeric::odeint::controlled_step_result
|
||||
try_step( System sys , state_type &x , value_type &t , value_type &dt )
|
||||
{
|
||||
m_xnew_resizer.adjust_size( x , boost::bind( &controller_type::template resize_m_xnew< state_type > , boost::ref( *this ) , _1 ) );
|
||||
m_xnew_resizer.adjust_size( x , detail::bind( &controller_type::template resize_m_xnew< state_type > , detail::ref( *this ) , detail::_1 ) );
|
||||
boost::numeric::odeint::controlled_step_result res = try_step( sys , x , t , m_xnew.m_v , dt );
|
||||
if( res == success )
|
||||
{
|
||||
@@ -109,7 +108,7 @@ public:
|
||||
{
|
||||
static const value_type safe = 0.9 , fac1 = 5.0 , fac2 = 1.0 / 6.0;
|
||||
|
||||
m_xerr_resizer.adjust_size( x , boost::bind( &controller_type::template resize_m_xerr< state_type > , boost::ref( *this ) , _1 ) );
|
||||
m_xerr_resizer.adjust_size( x , detail::bind( &controller_type::template resize_m_xerr< state_type > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
m_stepper.do_step( sys , x , t , xout , dt , m_xerr.m_v );
|
||||
value_type err = error( xout , x , m_xerr.m_v );
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/rosenbrock4_controller.hpp>
|
||||
#include <boost/numeric/odeint/util/is_resizeable.hpp>
|
||||
@@ -91,7 +90,7 @@ public:
|
||||
template< class StateType >
|
||||
void initialize( const StateType &x0 , const time_type &t0 , const time_type &dt0 )
|
||||
{
|
||||
m_resizer.adjust_size( x0 , boost::bind( &dense_output_stepper_type::template resize_impl< StateType > , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( x0 , detail::bind( &dense_output_stepper_type::template resize_impl< StateType > , detail::ref( *this ) , detail::_1 ) );
|
||||
*m_current_state = x0;
|
||||
m_t = t0;
|
||||
m_dt = dt0;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA4_CLASSIC_HPP_INCLUDED
|
||||
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp>
|
||||
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
|
||||
@@ -68,9 +67,9 @@ public :
|
||||
|
||||
static const value_type val1 = static_cast< value_type >( 1.0 );
|
||||
|
||||
m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize_impl< StateIn > , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
|
||||
const time_type dh = static_cast< value_type >( 0.5 ) * dt;
|
||||
const time_type th = t + dh;
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_CASH_KARP54_CLASSIC_HPP_INCLUDED
|
||||
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp>
|
||||
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
|
||||
@@ -122,9 +121,9 @@ public :
|
||||
const value_type c4 = static_cast<value_type> ( 125.0 ) / static_cast<value_type>( 594.0 );
|
||||
const value_type c6 = static_cast<value_type> ( 512.0 ) / static_cast<value_type>( 1771.0 );
|
||||
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
|
||||
m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
//m_x1 = x + dt*b21*dxdt
|
||||
stepper_base_type::m_algebra.for_each3( m_x_tmp.m_v , in , dxdt ,
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_DOPRI5_HPP_INCLUDED
|
||||
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/numeric/odeint/util/bind.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp>
|
||||
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
|
||||
@@ -97,9 +96,9 @@ public :
|
||||
const value_type c5 = static_cast<value_type> ( -2187.0 ) / static_cast<value_type>( 6784.0 );
|
||||
const value_type c6 = static_cast<value_type> ( 11.0 ) / static_cast<value_type>( 84.0 );
|
||||
|
||||
typename boost::unwrap_reference< System >::type &sys = system;
|
||||
typename detail::unwrap_reference< System >::type &sys = system;
|
||||
|
||||
m_resizer.adjust_size( in , boost::bind( &stepper_type::template resize_impl<StateIn> , boost::ref( *this ) , _1 ) );
|
||||
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
|
||||
|
||||
//m_x_tmp = x + dt*b21*dxdt
|
||||
stepper_base_type::m_algebra.for_each3( m_x_tmp.m_v , in , dxdt_in ,
|
||||
|
||||
80
boost/numeric/odeint/util/bind.hpp
Normal file
80
boost/numeric/odeint/util/bind.hpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* [begin_description]
|
||||
* Boost bind pull the placeholders, _1, _2, ... into global
|
||||
* namespace. This can conflict with the C++03 TR1 and C++11
|
||||
* std::placeholders. This header provides a workaround for
|
||||
* this problem.
|
||||
* [end_description]
|
||||
*
|
||||
* Copyright 2012 Christoph Koke
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or
|
||||
* copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
* */
|
||||
|
||||
#ifndef BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED
|
||||
#define BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#define BOOST_NUMERIC_ODEINT_CXX11 1
|
||||
#endif
|
||||
|
||||
#if BOOST_NUMERIC_ODEINT_CXX11
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#else
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if BOOST_NUMERIC_ODEINT_CXX11
|
||||
template<typename T> class reference_wrapper;
|
||||
|
||||
template<typename T> class unwrap_reference;
|
||||
#endif
|
||||
|
||||
namespace numeric {
|
||||
namespace odeint {
|
||||
namespace detail {
|
||||
|
||||
#if BOOST_NUMERIC_ODEINT_CXX11
|
||||
using ::std::bind;
|
||||
using ::std::ref;
|
||||
using namespace ::std::placeholders;
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct unwrap_reference
|
||||
{
|
||||
typedef typename std::remove_reference<T>::type type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct unwrap_reference< std::reference_wrapper<T> >
|
||||
{
|
||||
typedef typename std::remove_reference<T>::type type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct unwrap_reference< boost::reference_wrapper<T> >
|
||||
{
|
||||
typedef typename boost::unwrap_reference<T>::type type;
|
||||
};
|
||||
|
||||
#else
|
||||
using ::boost::bind;
|
||||
using ::boost::ref;
|
||||
using ::boost::unwrap_reference;
|
||||
using ::_1;
|
||||
using ::_2;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED
|
||||
Reference in New Issue
Block a user