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

Replace detail::bind with lambda functions

This commit is contained in:
Matt Borland
2024-01-10 10:55:55 +01:00
parent f37a81a712
commit 8eb09b94a2
27 changed files with 66 additions and 80 deletions

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 > , std::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> , std::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 )
{
@@ -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> , std::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 > , std::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 > , std::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> , std::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 > , std::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 > , std::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 > , std::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 > , std::ref( *this ) , detail::_1 ) );
m_dxdt_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_dxdt_impl< state_type > , std::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> , std::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> , std::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> , std::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> , std::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 > , std::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 > , std::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 > , std::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 > , std::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> , std::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 > , std::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

@@ -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 > , std::ref( *this ) , detail::_1 ) );
m_dpdt_resizer.adjust_size( momentum_in , detail::bind( &internal_stepper_base_type::template resize_dpdt< momentum_in_type > , std::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 > , std::ref( *this ) , detail::_1 ) );
m_dpdt_resizer.adjust_size( momentum_in , detail::bind( &internal_stepper_base_type::template resize_dpdt< momentum_in_type > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 > , std::ref( *this ) , detail::_1 ) );
m_dxdt_resizer.adjust_size( in , detail::bind( &controlled_stepper_type::template resize_dxdt_impl< state_type > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 > , std::ref( *this ) , detail::_1 ) );
m_dxdt_new_resizer.adjust_size( x , detail::bind( &controlled_runge_kutta::template resize_m_dxdt_new_impl< StateInOut > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 > , std::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 >,
std::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 >,
std::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> , std::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 > , std::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 > , std::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> , std::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> , std::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> , std::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 > , std::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 > , std::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 > , std::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 > , std::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> , std::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> , std::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> , std::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 > ,
std::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 > ,
std::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 > ,
std::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 );
}