2
0
mirror of https://github.com/boostorg/odeint.git synced 2026-01-19 04:22:12 +00:00

Merge pull request #69 from boostorg/bind

Remove use of Boost.Bind
This commit is contained in:
Matt Borland
2024-01-11 06:28:25 +01:00
committed by GitHub
37 changed files with 78 additions and 190 deletions

View File

@@ -15,7 +15,6 @@ target_include_directories(boost_numeric_odeint INTERFACE include)
target_link_libraries(boost_numeric_odeint
INTERFACE
Boost::assert
Boost::bind
Boost::compute
Boost::config
Boost::core

View File

@@ -15,7 +15,6 @@
#include <iostream>
#include <array>
#include <boost/bind.hpp>
#include <boost/numeric/odeint.hpp>
using namespace std;
@@ -130,7 +129,7 @@ int main( int argc , char **argv )
//[ symplectic_stepper_detail_system_class_example
harm_osc h;
rkn.do_step( make_pair( boost::bind( &harm_osc::f1 , h , _1 , _2 ) , boost::bind( &harm_osc::f2 , h , _1 , _2 ) ) ,
rkn.do_step( make_pair( detail::bind( &harm_osc::f1 , h , _1 , _2 ) , detail::bind( &harm_osc::f2 , h , _1 , _2 ) ) ,
x , t , dt );
//]
}

View File

@@ -43,7 +43,7 @@
#include <boost/config.hpp>
#if __cplusplus >= 201103L
#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
#define BOOST_NUMERIC_ODEINT_CXX11 1
#endif

View File

@@ -75,8 +75,7 @@ public:
deriv_func_type &deriv_func = sys.first;
jacobi_func_type &jacobi_func = sys.second;
m_resizer.adjust_size( x , detail::bind(
&stepper_type::template resize_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
m_identity.m_v = 1;

View File

@@ -23,7 +23,6 @@
#include <boost/static_assert.hpp>
#include <boost/numeric/odeint/util/bind.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
@@ -194,7 +193,7 @@ public :
typename odeint::unwrap_reference< ExplicitStepper >::type &stepper = explicit_stepper;
typename odeint::unwrap_reference< System >::type &sys = system;
m_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
for( size_t i=0 ; i+1<steps ; ++i )
{
@@ -210,7 +209,7 @@ public :
template< class System , class StateIn >
void initialize( System system , StateIn &x , time_type &t , time_type dt )
{
initialize( detail::ref( m_initializing_stepper ) , system , x , t , dt );
initialize( std::ref( m_initializing_stepper ) , system , x , t , dt );
}
void reset( void )
@@ -233,7 +232,7 @@ private:
void do_step_impl( System system , const StateIn &in , time_type t , StateOut &out , time_type dt )
{
typename odeint::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 ) ) )
if( m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); } ) )
{
m_steps_initialized = 0;
}

View File

@@ -163,7 +163,7 @@ private:
{
if( m_adams_bashforth.is_initialized() )
{
m_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateInOut>(std::forward<decltype(arg)>(arg)); });
m_adams_bashforth.do_step( system , x , t , m_x.m_v , dt );
m_adams_moulton.do_step( system , x , m_x.m_v , t+dt , x , dt , m_adams_bashforth.step_storage() );
}
@@ -178,7 +178,7 @@ private:
{
if( m_adams_bashforth.is_initialized() )
{
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
m_adams_bashforth.do_step( system , in , t , m_x.m_v , dt );
m_adams_moulton.do_step( system , in , m_x.m_v , t+dt , out , dt , m_adams_bashforth.step_storage() );
}

View File

@@ -166,7 +166,7 @@ private:
void do_step_impl( System system , const StateIn &in , const PredIn &pred , time_type t , StateOut &out , time_type dt , const ABBuf &buf )
{
typename odeint::unwrap_reference< System >::type &sys = system;
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
sys( pred , 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 );
}

View File

@@ -86,7 +86,7 @@ public:
template< class System >
void do_step(System system, state_type &inOut, time_type t, time_type dt )
{
m_xnew_resizer.adjust_size( inOut , detail::bind( &stepper_type::template resize_xnew_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_xnew_resizer.adjust_size(inOut, [this](auto&& arg) { return this->resize_xnew_impl<state_type>(std::forward<decltype(arg)>(arg)); });
do_step(system, inOut, t, m_xnew.m_v, dt, m_xerr.m_v);
boost::numeric::odeint::copy( m_xnew.m_v , inOut);
@@ -101,7 +101,7 @@ public:
template< class System >
void do_step(System system, state_type &inOut, time_type t, time_type dt, state_type &xerr)
{
m_xnew_resizer.adjust_size( inOut , detail::bind( &stepper_type::template resize_xnew_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_xnew_resizer.adjust_size(inOut, [this](auto&& arg) { return this->resize_xnew_impl<state_type>(std::forward<decltype(arg)>(arg)); });
do_step(system, inOut, t, m_xnew.m_v, dt, xerr);
boost::numeric::odeint::copy( m_xnew.m_v , inOut);
@@ -128,7 +128,7 @@ public:
reset();
dt = dt/static_cast< time_type >(order_value);
m_dxdt_resizer.adjust_size( inOut , detail::bind( &stepper_type::template resize_dxdt_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_dxdt_resizer.adjust_size(inOut, [this](auto&& arg) { return this->resize_dxdt_impl<state_type>(std::forward<decltype(arg)>(arg)); });
system( inOut , m_dxdt.m_v , t );
for( size_t i=0 ; i<order_value; ++i )
@@ -168,8 +168,8 @@ public:
{
size_t eO = m_coeff.m_eo;
m_xerr_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_xerr_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_dxdt_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_dxdt_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_xerr_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_xerr_impl<state_type>(std::forward<decltype(arg)>(arg)); });
m_dxdt_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_dxdt_impl<state_type>(std::forward<decltype(arg)>(arg)); });
m_coeff.predict(t, dt);
if (m_coeff.m_steps_init == 1)

View File

@@ -179,7 +179,7 @@ public:
do_step( System system , const StateIn &in , time_type t , StateOut &out , time_type dt )
{
typename odeint::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 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
sys( in , m_dxdt.m_v ,t );
this->stepper().do_step_impl( system , in , m_dxdt.m_v , t , out , dt );
}
@@ -258,7 +258,7 @@ public:
void do_step( System system , const StateIn &in , time_type t , StateOut &out , time_type dt , Err &xerr )
{
typename odeint::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 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
sys( in , m_dxdt.m_v ,t );
this->stepper().do_step_impl( system , in , m_dxdt.m_v , t , out , dt , xerr );
}
@@ -289,7 +289,7 @@ private:
void do_step_v1( System system , StateInOut &x , time_type t , time_type dt )
{
typename odeint::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 ) );
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateInOut>(std::forward<decltype(arg)>(arg)); });
sys( x , m_dxdt.m_v , t );
this->stepper().do_step_impl( system , x , m_dxdt.m_v , t , x , dt );
}
@@ -298,7 +298,7 @@ private:
void do_step_v5( System system , StateInOut &x , time_type t , time_type dt , Err &xerr )
{
typename odeint::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 ) );
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateInOut>(std::forward<decltype(arg)>(arg)); });
sys( x , m_dxdt.m_v ,t );
this->stepper().do_step_impl( system , x , m_dxdt.m_v , t , x , dt , xerr );
}

View File

@@ -177,7 +177,7 @@ public:
typename boost::disable_if< boost::is_same< StateIn , time_type > , void >::type
do_step( System system , const StateIn &in , time_type t , StateOut &out , time_type dt )
{
if( m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
if( m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); }) || m_first_call )
{
initialize( system , in , t );
}
@@ -251,7 +251,7 @@ public:
template< class System , class StateIn , class StateOut , class Err >
void do_step( System system , const StateIn &in , time_type t , StateOut &out , time_type dt , Err &xerr )
{
if( m_resizer.adjust_size( in , detail::bind( &internal_stepper_base_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
if( m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); }) || m_first_call )
{
initialize( system , in , t );
}
@@ -310,7 +310,7 @@ private:
template< class System , class StateInOut >
void do_step_v1( System system , StateInOut &x , time_type t , time_type dt )
{
if( m_resizer.adjust_size( x , detail::bind( &internal_stepper_base_type::template resize_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
if( m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateInOut>(std::forward<decltype(arg)>(arg)); }) || m_first_call )
{
initialize( system , x , t );
}
@@ -320,7 +320,7 @@ private:
template< class System , class StateInOut , class Err >
void do_step_v5( System system , StateInOut &x , time_type t , time_type dt , Err &xerr )
{
if( m_resizer.adjust_size( x , detail::bind( &internal_stepper_base_type::template resize_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
if( m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateInOut>(std::forward<decltype(arg)>(arg)); }) || m_first_call )
{
initialize( system , x , t );
}

View File

@@ -162,7 +162,7 @@ public:
void do_step( System system , const StateIn &in , time_type t , StateOut &out , time_type dt )
{
typename odeint::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 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
sys( in , m_dxdt.m_v ,t );
this->stepper().do_step_impl( system , in , m_dxdt.m_v , t , out , dt );
}
@@ -225,7 +225,7 @@ private:
void do_step_v1( System system , StateInOut &x , time_type t , time_type dt )
{
typename odeint::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 ) );
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateInOut>(std::forward<decltype(arg)>(arg)); });
sys( x , m_dxdt.m_v ,t );
this->stepper().do_step_impl( system , x , m_dxdt.m_v , t , x , dt );
}

View File

@@ -136,7 +136,7 @@ public:
template< class System , class CoorInOut , class MomentumInOut >
void do_step( System system , CoorInOut &q , MomentumInOut &p , time_type t , time_type dt )
{
do_step( system , std::make_pair( detail::ref( q ) , detail::ref( p ) ) , t , dt );
do_step( system , std::make_pair( std::ref( q ) , std::ref( p ) ) , t , dt );
}
/**
@@ -146,7 +146,7 @@ public:
template< class System , class CoorInOut , class MomentumInOut >
void do_step( System system , const CoorInOut &q , const MomentumInOut &p , time_type t , time_type dt )
{
do_step( system , std::make_pair( detail::ref( q ) , detail::ref( p ) ) , t , dt );
do_step( system , std::make_pair( std::ref( q ) , std::ref( p ) ) , t , dt );
}
@@ -206,8 +206,8 @@ private:
coor_out_type &coor_out = state_out.first;
momentum_out_type &momentum_out = state_out.second;
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 ) );
m_dqdt_resizer.adjust_size(coor_in, [this](auto&& arg) { return this->resize_dqdt<coor_in_type>(std::forward<decltype(arg)>(arg)); });
m_dpdt_resizer.adjust_size(momentum_in, [this](auto&& arg) { return this->resize_dpdt<momentum_in_type>(std::forward<decltype(arg)>(arg)); });
// ToDo: check sizes?
@@ -258,8 +258,7 @@ private:
// m_dqdt not required when called with momentum_func only - don't resize
// 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 ) );
m_dpdt_resizer.adjust_size(momentum_in, [this](auto&& arg) { return this->resize_dpdt<momentum_in_type>(std::forward<decltype(arg)>(arg)); });
// ToDo: check sizes?

View File

@@ -152,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 , detail::bind( &controlled_error_bs_type::template resize_m_xnew< StateInOut > , detail::ref( *this ) , detail::_1 ) );
m_xnew_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_m_xnew<StateInOut>(std::forward<decltype(arg)>(arg)); });
controlled_step_result res = try_step( system , x , dxdt , t , m_xnew.m_v , dt );
if( res == success )
{
@@ -171,7 +171,7 @@ public:
try_step( System system , const StateIn &in , time_type &t , StateOut &out , time_type &dt )
{
typename odeint::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 ) );
m_dxdt_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_m_dxdt<StateIn>(std::forward<decltype(arg)>(arg)); });
sys( in , m_dxdt.m_v , t );
return try_step( system , in , m_dxdt.m_v , t , out , dt );
}
@@ -198,7 +198,7 @@ public:
static const value_type val1( 1.0 );
if( m_resizer.adjust_size( in , detail::bind( &controlled_error_bs_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) )
if( m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); }) )
{
reset(); // system resized -> reset
}
@@ -388,7 +388,7 @@ private:
controlled_step_result try_step_v1( System system , StateInOut &x , time_type &t , time_type &dt )
{
typename odeint::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 ) );
m_dxdt_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_m_dxdt<StateInOut>(std::forward<decltype(arg)>(arg)); });
sys( x , m_dxdt.m_v ,t );
return try_step( system , x , m_dxdt.m_v , t , dt );
}

View File

@@ -308,7 +308,7 @@ public:
template< class StateType >
void initialize( const StateType &x0 , const time_type &t0 , const time_type &dt0 )
{
m_resizer.adjust_size( x0 , detail::bind( &controlled_error_bs_type::template resize_impl< StateType > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(x0, [this](auto&& arg) { return this->resize_impl<StateType>(std::forward<decltype(arg)>(arg)); });
boost::numeric::odeint::copy( x0 , get_current_state() );
m_t = t0;
m_dt = dt0;

View File

@@ -178,7 +178,7 @@ public:
reset();
coeff_type &coeff = m_stepper.coeff();
m_dxdt_resizer.adjust_size( inOut , detail::bind( &controlled_stepper_type::template resize_dxdt_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_dxdt_resizer.adjust_size(inOut, [this](auto&& arg) { return this->resize_dxdt_impl<state_type>(std::forward<decltype(arg)>(arg)); });
controlled_step_result res = fail;
@@ -206,7 +206,7 @@ public:
template< class System >
controlled_step_result try_step(System system, state_type & inOut, time_type &t, time_type &dt)
{
m_xnew_resizer.adjust_size( inOut , detail::bind( &controlled_stepper_type::template resize_xnew_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_xnew_resizer.adjust_size(inOut, [this](auto&& arg) { return this->resize_xnew_impl<state_type>(std::forward<decltype(arg)>(arg)); });
controlled_step_result res = try_step(system, inOut, t, m_xnew.m_v, dt);
@@ -221,8 +221,8 @@ public:
template< class System >
controlled_step_result try_step(System system, const state_type & in, time_type &t, state_type & out, time_type &dt)
{
m_xerr_resizer.adjust_size( in , detail::bind( &controlled_stepper_type::template resize_xerr_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_dxdt_resizer.adjust_size( in , detail::bind( &controlled_stepper_type::template resize_dxdt_impl< state_type > , detail::ref( *this ) , detail::_1 ) );
m_xerr_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_xerr_impl<state_type>(std::forward<decltype(arg)>(arg)); });
m_dxdt_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_dxdt_impl<state_type>(std::forward<decltype(arg)>(arg)); });
m_stepper.do_step_impl(system, in, t, out, dt, m_xerr[2].m_v);

View File

@@ -337,7 +337,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 , detail::bind( &controlled_runge_kutta::template resize_m_xnew_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) );
m_xnew_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_m_xnew_impl<StateInOut>(std::forward<decltype(arg)>(arg)); });
controlled_step_result res = try_step( system , x , dxdt , t , m_xnew.m_v , dt );
if( res == success )
{
@@ -378,7 +378,7 @@ public:
try_step( System system , const StateIn &in , time_type &t , StateOut &out , time_type &dt )
{
typename odeint::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 ) );
m_dxdt_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_m_dxdt_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
sys( in , m_dxdt.m_v , t );
return try_step( system , in , m_dxdt.m_v , t , out , dt );
}
@@ -419,7 +419,7 @@ public:
return fail;
}
m_xerr_resizer.adjust_size( in , detail::bind( &controlled_runge_kutta::template resize_m_xerr_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
m_xerr_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_m_xerr_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
// do one step with error calculation
m_stepper.do_step( system , in , dxdt , t , out , dt , m_xerr.m_v );
@@ -478,7 +478,7 @@ private:
controlled_step_result try_step_v1( System system , StateInOut &x , time_type &t , time_type &dt )
{
typename odeint::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 ) );
m_dxdt_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_m_dxdt_impl<StateInOut>(std::forward<decltype(arg)>(arg)); });
sys( x , m_dxdt.m_v ,t );
return try_step( system , x , m_dxdt.m_v , t , dt );
}
@@ -678,7 +678,7 @@ public:
typename boost::disable_if< boost::is_same< StateIn , time_type > , controlled_step_result >::type
try_step( System system , const StateIn &in , time_type &t , StateOut &out , time_type &dt )
{
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 )
if( m_dxdt_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_m_dxdt_impl<StateIn>(std::forward<decltype(arg)>(arg)); }) || m_first_call )
{
initialize( system , in , t );
}
@@ -713,8 +713,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 , 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 ) );
m_xnew_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_m_xnew_impl<StateInOut>(std::forward<decltype(arg)>(arg)); });
m_dxdt_new_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_m_dxdt_new_impl<StateInOut>(std::forward<decltype(arg)>(arg)); });
controlled_step_result res = try_step( system , x , dxdt , t , m_xnew.m_v , m_dxdtnew.m_v , dt );
if( res == success )
{
@@ -761,7 +761,7 @@ public:
return fail;
}
m_xerr_resizer.adjust_size( in , detail::bind( &controlled_runge_kutta::template resize_m_xerr_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
m_xerr_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_m_xerr_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
//fsal: m_stepper.get_dxdt( dxdt );
//fsal: m_stepper.do_step( sys , x , dxdt , t , dt , m_x_err );
@@ -895,7 +895,7 @@ 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 , detail::bind( &controlled_runge_kutta::template resize_m_dxdt_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) ) || m_first_call )
if( m_dxdt_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_m_dxdt_impl<StateInOut>(std::forward<decltype(arg)>(arg)); }) || m_first_call )
{
initialize( system , x , t );
}

View File

@@ -105,7 +105,7 @@ public:
template< class StateType >
void initialize( const StateType &x0 , time_type t0 , time_type dt0 )
{
m_resizer.adjust_size( x0 , detail::bind( &dense_output_stepper_type::template resize_impl< StateType > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(x0, [this](auto&& arg) { return this->resize_impl<StateType>(std::forward<decltype(arg)>(arg)); });
boost::numeric::odeint::copy( x0 , get_current_state() );
m_t = t0;
m_dt = dt0;
@@ -313,7 +313,7 @@ public:
template< class StateType >
void initialize( const StateType &x0 , time_type t0 , time_type dt0 )
{
m_resizer.adjust_size( x0 , detail::bind( &dense_output_stepper_type::template resize< StateType > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(x0, [this](auto&& arg) { return this->resize<StateType>(std::forward<decltype(arg)>(arg)); });
boost::numeric::odeint::copy( x0 , get_current_state() );
m_t = t0;
m_dt = dt0;

View File

@@ -132,7 +132,7 @@ public:
void do_step(const deriv_type &dxdt, const int o = 0)
{
m_phi_resizer.adjust_size( dxdt , detail::bind( &aac_type::template resize_phi_impl< deriv_type > , detail::ref( *this ) , detail::_1 ) );
m_phi_resizer.adjust_size(dxdt, [this](auto&& arg) { return this->resize_phi_impl<deriv_type>(std::forward<decltype(arg)>(arg)); });
phi[o][0].m_v = dxdt;

View File

@@ -129,7 +129,7 @@ public:
void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt ,
time_type t , StateOut &out , time_type dt )
{
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
// 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 );

View File

@@ -146,7 +146,7 @@ public:
void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt ,
time_type t , StateOut &out , time_type dt )
{
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
// 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 );

View File

@@ -172,9 +172,7 @@ class extrapolation_stepper : public explicit_error_stepper_base
void do_step_impl( System system, const StateIn &in, const DerivIn &dxdt,
time_type t, StateOut &out, time_type dt )
{
m_resizer.adjust_size(
in, detail::bind( &stepper_type::template resize_impl< StateIn >,
detail::ref( *this ), detail::_1 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
size_t k = 0;
m_midpoint.set_steps( m_interval_sequence[k] );
m_midpoint.do_step( system, in, dxdt, t, out, dt );
@@ -191,10 +189,7 @@ class extrapolation_stepper : public explicit_error_stepper_base
time_type t, time_type dt )
{
// special care for inout
m_xout_resizer.adjust_size(
inout,
detail::bind( &stepper_type::template resize_m_xout< StateInOut >,
detail::ref( *this ), detail::_1 ) );
m_xout_resizer.adjust_size(inout, [this](auto&& arg) { return this->resize_m_xout<StateInOut>(std::forward<decltype(arg)>(arg)); });
do_step_impl( system, inout, dxdt, t, m_xout.m_v, dt );
boost::numeric::odeint::copy( m_xout.m_v, inout );
}

View File

@@ -80,7 +80,7 @@ public:
deriv_func_type &deriv_func = sys.first;
jacobi_func_type &jacobi_func = sys.second;
m_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_impl<state_type> , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<state_type>(std::forward<decltype(arg)>(arg)); });
for( size_t i=0 ; i<x.size() ; ++i )
m_pm.m_v[i] = i;

View File

@@ -81,7 +81,7 @@ public :
static const value_type val1 = static_cast< value_type >( 1 );
static const value_type val05 = static_cast< value_type >( 1 ) / static_cast< value_type >( 2 );
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
const time_type h = dt / static_cast<value_type>( m_steps );
const time_type h2 = static_cast<value_type>(2) * h;
@@ -204,7 +204,7 @@ public :
static const value_type val1 = static_cast< value_type >( 1 );
static const value_type val05 = static_cast< value_type >( 1 ) / static_cast< value_type >( 2 );
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize< StateIn > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize<StateIn>(std::forward<decltype(arg)>(arg)); });
const time_type h = dt / static_cast<value_type>( m_steps );
const time_type h2 = static_cast<value_type>( 2 ) * h;

View File

@@ -178,7 +178,7 @@ public:
const size_t n = x.size();
m_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_impl<state_type> , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<state_type>(std::forward<decltype(arg)>(arg)); });
for( size_t i=0 ; i<n ; ++i )
m_pm.m_v( i ) = i;
@@ -249,14 +249,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 , detail::bind( &stepper_type::template resize_x_err<state_type> , detail::ref( *this ) , detail::_1 ) );
m_x_err_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_x_err<state_type>(std::forward<decltype(arg)>(arg)); });
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 , detail::bind( &stepper_type::template resize_x_err<state_type> , detail::ref( *this ) , detail::_1 ) );
m_x_err_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_x_err<state_type>(std::forward<decltype(arg)>(arg)); });
do_step( system , x , t , dt , m_x_err.m_v );
}

View File

@@ -99,7 +99,7 @@ public:
boost::numeric::odeint::controlled_step_result
try_step( System sys , state_type &x , time_type &t , time_type &dt )
{
m_xnew_resizer.adjust_size( x , detail::bind( &controller_type::template resize_m_xnew< state_type > , detail::ref( *this ) , detail::_1 ) );
m_xnew_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_m_xnew<state_type>(std::forward<decltype(arg)>(arg)); });
boost::numeric::odeint::controlled_step_result res = try_step( sys , x , t , m_xnew.m_v , dt );
if( res == success )
{
@@ -127,7 +127,7 @@ public:
static const value_type safe = 0.9 , fac1 = 5.0 , fac2 = 1.0 / 6.0;
m_xerr_resizer.adjust_size( x , detail::bind( &controller_type::template resize_m_xerr< state_type > , detail::ref( *this ) , detail::_1 ) );
m_xerr_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_m_xerr<state_type>(std::forward<decltype(arg)>(arg)); });
m_stepper.do_step( sys , x , t , xout , dt , m_xerr.m_v );
value_type err = error( xout , x , m_xerr.m_v );

View File

@@ -67,7 +67,7 @@ public:
template< class StateType >
void initialize( const StateType &x0 , time_type t0 , time_type dt0 )
{
m_resizer.adjust_size( x0 , detail::bind( &dense_output_stepper_type::template resize_impl< StateType > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(x0, [this](auto&& arg) { return this->resize_impl<StateType>(std::forward<decltype(arg)>(arg)); });
get_current_state() = x0;
m_t = t0;
m_dt = dt0;

View File

@@ -91,7 +91,7 @@ public :
static const value_type val1 = static_cast< value_type >( 1 );
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
typename odeint::unwrap_reference< System >::type &sys = system;

View File

@@ -145,7 +145,7 @@ public :
typename odeint::unwrap_reference< System >::type &sys = system;
m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
//m_x1 = x + dt*b21*dxdt
stepper_base_type::m_algebra.for_each3( m_x_tmp.m_v , in , dxdt ,

View File

@@ -125,7 +125,7 @@ public :
typename odeint::unwrap_reference< System >::type &sys = system;
m_k_x_tmp_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_k_x_tmp_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
m_k_x_tmp_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_k_x_tmp_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
//m_x_tmp = x + dt*b21*dxdt
stepper_base_type::m_algebra.for_each3( m_x_tmp.m_v , in , dxdt_in ,
@@ -179,7 +179,7 @@ public :
/* ToDo: copy only if &dxdt_in == &dxdt_out ? */
if( same_instance( dxdt_in , dxdt_out ) )
{
m_dxdt_tmp_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_dxdt_tmp_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
m_dxdt_tmp_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_dxdt_tmp_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
boost::numeric::odeint::copy( dxdt_in , m_dxdt_tmp.m_v );
do_step_impl( system , in , dxdt_in , t , out , dxdt_out , dt );
//error estimate

View File

@@ -149,9 +149,7 @@ public:
void initialize( const AccelerationIn & ain )
{
// alloc a
m_resizer.adjust_size( ain ,
detail::bind( &velocity_verlet::template resize_impl< AccelerationIn > ,
detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(ain, [this](auto&& arg) { return this->resize_impl<AccelerationIn>(std::forward<decltype(arg)>(arg)); });
boost::numeric::odeint::copy( ain , get_current_acc() );
m_first_call = false;
}
@@ -160,9 +158,7 @@ public:
template< class System , class CoorIn , class VelocityIn >
void initialize( System system , const CoorIn & qin , const VelocityIn & pin , time_type t )
{
m_resizer.adjust_size( qin ,
detail::bind( &velocity_verlet::template resize_impl< CoorIn > ,
detail::ref( *this ) , detail::_1 ) );
m_resizer.adjust_size(qin, [this](auto&& arg) { return this->resize_impl<CoorIn>(std::forward<decltype(arg)>(arg)); });
initialize_acc( system , qin , pin , t );
}
@@ -195,10 +191,8 @@ private:
momentum_in_type & pinout = statein.second;
// alloc a
if( m_resizer.adjust_size( qinout ,
detail::bind( &velocity_verlet::template resize_impl< xyz_type > ,
detail::ref( *this ) , detail::_1 ) )
|| m_first_call )
if( m_resizer.adjust_size(qinout, [this](auto&& arg) { return this->resize_impl<xyz_type>(std::forward<decltype(arg)>(arg)); })
|| m_first_call )
{
initialize_acc( system , qinout , pinout , t );
}

View File

@@ -17,85 +17,19 @@
#ifndef BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED
#include <boost/numeric/odeint/config.hpp>
#if BOOST_NUMERIC_ODEINT_CXX11
#include <functional>
#else
#define BOOST_BIND_NO_PLACEHOLDERS
#include <boost/bind.hpp>
#endif
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
#if BOOST_NUMERIC_ODEINT_CXX11
using ::std::bind;
using namespace ::std::placeholders;
#else
// unnamed namespace to avoid multiple declarations (#138)
namespace {
using ::boost::bind;
boost::arg<1> _1;
boost::arg<2> _2;
}
// using ::boost::bind;
// using ::_1;
// using ::_2;
#endif
}
}
}
}
/*
// the following is the suggested way. Unfortunately it does not work with all compilers.
#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
#include <boost/bind.hpp>
#else
#include <functional>
#endif
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
using std::bind;
using namespace std::placeholders;
using ::boost::bind;
using ::_1;
using ::_2;
#else
using ::std::bind;
using namespace ::std::placeholders;
#endif
}
}
}
}*/
} //namespace detail
} //namespace odeint
} //namespace numeric
} //namespace boost
#endif // BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED

View File

@@ -20,28 +20,16 @@
#include <boost/numeric/odeint/config.hpp>
#if BOOST_NUMERIC_ODEINT_CXX11
#include <functional>
#else
#include <boost/ref.hpp>
#endif
namespace boost {
#if BOOST_NUMERIC_ODEINT_CXX11
template<typename T> class reference_wrapper;
template<typename T> struct unwrap_reference;
#endif
namespace numeric {
namespace odeint {
#if BOOST_NUMERIC_ODEINT_CXX11
template<typename T>
struct unwrap_reference
{
@@ -60,24 +48,11 @@ struct unwrap_reference< boost::reference_wrapper<T> >
typedef typename boost::unwrap_reference<T>::type type;
};
#else
using ::boost::unwrap_reference;
#endif
namespace detail
{
#if BOOST_NUMERIC_ODEINT_CXX11
using ::std::ref;
#else
using ::boost::ref;
#endif
}
}

View File

@@ -27,8 +27,7 @@ project
<link>static
<toolset>clang:<cxxflags>-Wno-unused-variable
# <cxxflags>-D_SCL_SECURE_NO_WARNINGS
[ requires cxx11_noexcept cxx11_rvalue_references sfinae_expr cxx11_auto_declarations cxx11_lambdas cxx11_unified_initialization_syntax cxx11_hdr_tuple cxx11_hdr_initializer_list cxx11_hdr_chrono cxx11_thread_local cxx11_constexpr cxx11_nullptr cxx11_numeric_limits cxx11_decltype cxx11_hdr_array cxx11_hdr_atomic cxx11_hdr_type_traits cxx11_allocator cxx11_explicit_conversion_operators ]
;
[ requires cxx14_decltype_auto cxx14_generic_lambdas cxx14_return_type_deduction cxx14_variable_templates cxx14_decltype_auto cxx14_generic_lambdas cxx14_return_type_deduction ] ;
test-suite "odeint"
:

View File

@@ -26,7 +26,6 @@
#include <cmath>
#include <array>
#include <boost/bind.hpp>
#include <boost/utility.hpp>
#include <boost/type_traits/integral_constant.hpp>

View File

@@ -34,7 +34,6 @@
#include <boost/test/unit_test.hpp>
#include <boost/ref.hpp>
#include <boost/bind.hpp>
#include <boost/utility.hpp>
#include <boost/type_traits/add_reference.hpp>

View File

@@ -34,7 +34,6 @@
#include <boost/test/unit_test.hpp>
#include <boost/ref.hpp>
#include <boost/bind.hpp>
#include <boost/utility.hpp>
#include <boost/type_traits/add_reference.hpp>

View File

@@ -34,7 +34,6 @@
#include <boost/test/unit_test.hpp>
#include <boost/ref.hpp>
#include <boost/bind.hpp>
#include <boost/utility.hpp>
#include <boost/type_traits/add_reference.hpp>