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

finalized redesign iterators

This commit is contained in:
Karsten Ahnert
2013-02-01 14:55:41 +01:00
parent a64b3f65f2
commit 94de59c54a
19 changed files with 640 additions and 394 deletions

View File

@@ -33,8 +33,8 @@ exe simple1d : simple1d.cpp ;
exe stochastic_euler : stochastic_euler.cpp ;
exe generation_functions : generation_functions.cpp ;
exe heun : heun.cpp ;
# exe const_step_iterator : const_step_iterator.cpp : <cxxflags>-std=c++0x ;
# exe adaptive_iterator : adaptive_iterator.cpp : <cxxflags>-std=c++0x ;
exe const_step_iterator : const_step_iterator.cpp : <cxxflags>-std=c++0x ;
exe adaptive_iterator : adaptive_iterator.cpp : <cxxflags>-std=c++0x ;
exe bind_member_functions : bind_member_functions.cpp ;
exe bind_member_functions_cpp11 : bind_member_functions_cpp11.cpp : <cxxflags>-std=c++0x ;

View File

@@ -67,7 +67,7 @@ int main( int argc , char **argv )
state_type x = {{ 10.0 , 10.0 , 10.0 }};
std::for_each( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
[]( const std::pair< state_type&, double > &x ) {
[]( const std::pair< const state_type&, double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}
@@ -79,7 +79,7 @@ int main( int argc , char **argv )
std::copy_if( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
std::back_inserter( res ) ,
[]( const pair< state_type& , double > &x ) {
[]( const pair< const state_type& , double > &x ) {
return ( x.first[0] > 0.0 ) ? true : false; } );
for( size_t i=0 ; i<res.size() ; ++i )
cout << res[i].first[0] << tab << res[i].first[1] << tab << res[i].first[2] << "\n";
@@ -92,7 +92,7 @@ int main( int argc , char **argv )
double res = std::accumulate( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
0.0 ,
[]( double sum , const pair< state_type& , double > &x ) {
[]( double sum , const pair< const state_type& , double > &x ) {
return sum + x.first[0]; } );
cout << res << endl;
}
@@ -106,7 +106,7 @@ int main( int argc , char **argv )
std::transform( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
back_inserter( weights ) ,
[]( const pair< state_type& , double > &x ) {
[]( const pair< const state_type& , double > &x ) {
return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } );
for( size_t i=0 ; i<weights.size() ; ++i )
cout << weights[i] << "\n";
@@ -134,7 +134,7 @@ int main( int argc , char **argv )
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
state_type x = {{ 10.0 , 10.0 , 10.0 }};
boost::range::for_each( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
[]( const std::pair< state_type& , double > &x ) {
[]( const std::pair< const state_type& , double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}
@@ -145,7 +145,7 @@ int main( int argc , char **argv )
std::vector< std::pair< state_type , double > > res;
state_type x = {{ 10.0 , 10.0 , 10.0 }};
boost::range::copy( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) |
boost::adaptors::filtered( [] ( const pair< state_type& , double > &x ) { return ( x.first[0] > 0.0 ); } ) ,
boost::adaptors::filtered( [] ( const pair< const state_type& , double > &x ) { return ( x.first[0] > 0.0 ); } ) ,
std::back_inserter( res ) );
for( size_t i=0 ; i<res.size() ; ++i )
cout << res[i].first[0] << tab << res[i].first[1] << tab << res[i].first[2] << "\n";
@@ -157,7 +157,7 @@ int main( int argc , char **argv )
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
state_type x = {{ 10.0 , 10.0 , 10.0 }};
double res = boost::accumulate( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 ,
[]( double sum , const pair< state_type& , double > &x ) {
[]( double sum , const pair< const state_type& , double > &x ) {
return sum + x.first[0]; } );
cout << res << endl;
//]
@@ -170,7 +170,7 @@ int main( int argc , char **argv )
state_type x = {{ 10.0 , 10.0 , 10.0 }};
vector< double > weights;
boost::transform( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , back_inserter( weights ) ,
[]( const pair< state_type& , double > &x ) {
[]( const pair< const state_type& , double > &x ) {
return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } );
for( size_t i=0 ; i<weights.size() ; ++i )
cout << weights[i] << "\n";
@@ -182,7 +182,7 @@ int main( int argc , char **argv )
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
state_type x = {{ 10.0 , 10.0 , 10.0 }};
auto iter = boost::find_if( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
[]( const std::pair< state_type & , double > &x ) {
[]( const std::pair< const state_type & , double > &x ) {
return ( x.first[0] < 0.0 ); } );
cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n";
}

View File

@@ -59,7 +59,7 @@ int main( int argc , char **argv )
state_type x = {{ 10.0 , 10.0 , 10.0 }};
std::for_each( make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_const_step_time_iterator_end( stepper , lorenz() , x ) ,
[]( const std::pair< state_type&, double > &x ) {
[]( const std::pair< const state_type&, double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}
@@ -116,7 +116,7 @@ int main( int argc , char **argv )
std::transform( make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_const_step_time_iterator_end( stepper , lorenz() , x ) ,
back_inserter( weights ) ,
[]( const std::pair< state_type &, double > &x ) {
[]( const std::pair< const state_type &, double > &x ) {
return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } );
for( size_t i=0 ; i<weights.size() ; ++i )
cout << weights[i] << "\n";
@@ -150,7 +150,7 @@ int main( int argc , char **argv )
runge_kutta4< state_type > stepper;
state_type x = {{ 10.0 , 10.0 , 10.0 }};
boost::range::for_each( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
[]( const std::pair< state_type& , double > &x ) {
[]( const std::pair< const state_type& , double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}
@@ -185,7 +185,7 @@ int main( int argc , char **argv )
runge_kutta4< state_type > stepper;
state_type x = {{ 10.0 , 10.0 , 10.0 }};
double res = boost::accumulate( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 ,
[]( double sum , const std::pair< state_type &, double > &x ) {
[]( double sum , const std::pair< const state_type &, double > &x ) {
return sum + x.first[0]; } );
cout << res << endl;
//]
@@ -210,7 +210,7 @@ int main( int argc , char **argv )
runge_kutta4< state_type > stepper;
state_type x = {{ 10.0 , 10.0 , 10.0 }};
auto iter = boost::find_if( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
[]( const std::pair< state_type & , double > &x ) {
[]( const std::pair< const state_type & , double > &x ) {
return ( x.first[0] < 0.0 ); } );
cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n";
@@ -246,7 +246,7 @@ int main( int argc , char **argv )
runge_kutta_dopri5< state_type > stepper;
state_type x = {{ 10.0 , 10.0 , 10.0 }};
boost::range::for_each( make_const_step_time_range( make_dense_output( 1.0e-6 , 1.0e-6 , stepper ) , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
[]( const std::pair< state_type& , double > &x ) {
[]( const std::pair< const state_type& , double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}

View File

@@ -45,7 +45,7 @@ BOOST_AUTO_TEST_SUITE( adaptive_iterator_test )
typedef mpl::vector<
dummy_controlled_stepper
// , dummy_dense_output_stepper
, dummy_dense_output_stepper
> dummy_steppers;
@@ -72,6 +72,45 @@ BOOST_AUTO_TEST_CASE( copy_controlled_stepper_iterator )
}
BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator )
{
typedef adaptive_iterator< dummy_dense_output_stepper , empty_system > iterator_type;
state_type x = {{ 1.0 }};
iterator_type iter1( dummy_dense_output_stepper() , empty_system() , x );
iterator_type iter2( iter1 );
BOOST_CHECK_NE( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
++iter1;
++iter2;
BOOST_CHECK_NE( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator_with_reference_wrapper )
{
typedef adaptive_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type;
state_type x = {{ 1.0 }};
dummy_dense_output_stepper stepper;
iterator_type iter1( boost::ref( stepper ) , empty_system() , x );
iterator_type iter2( iter1 );
BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
++iter1;
++iter2;
BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_controlled_stepper_iterator )
{
typedef adaptive_iterator< dummy_controlled_stepper , empty_system > iterator_type;
@@ -87,6 +126,44 @@ BOOST_AUTO_TEST_CASE( assignment_controlled_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator )
{
typedef adaptive_iterator< dummy_dense_output_stepper , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( dummy_dense_output_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_NE( & (*iter1) , & (*iter2) );
BOOST_CHECK( !iter1.same( iter2 ) );
iter2 = iter1;
BOOST_CHECK_NE( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator_with_reference_wrapper )
{
typedef adaptive_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
dummy_dense_output_stepper stepper;
iterator_type iter1 = iterator_type( boost::ref( stepper ) , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( boost::ref( stepper ) , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );
BOOST_CHECK( !iter1.same( iter2 ) );
iter2 = iter1;
BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_factory )
{
dummy_controlled_stepper stepper;
@@ -101,6 +178,21 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_factory )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
std::for_each(
make_adaptive_iterator_begin( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
make_adaptive_iterator_end( stepper , boost::ref( system ) , x ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( controlled_stepper_range )
{
dummy_controlled_stepper stepper;
@@ -113,6 +205,18 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_range )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_range )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
boost::for_each( make_adaptive_range( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_with_reference_wrapper_factory )
{
dummy_controlled_stepper stepper;
@@ -127,6 +231,19 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_with_reference_wrapper_factory
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_with_reference_wrapper_factory )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
std::for_each(
make_adaptive_iterator_begin( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
make_adaptive_iterator_end( boost::ref( stepper ) , boost::ref( system ) , x ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( controlled_stepper_range_with_reference_wrapper )
{
dummy_controlled_stepper stepper;
@@ -139,6 +256,18 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_range_with_reference_wrapper )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_range_with_reference_wrapper )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
boost::for_each( make_adaptive_range( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers )
{
@@ -203,32 +332,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dum
}
// BOOST_AUTO_TEST_CASE( copy_constructor_iterator_dense_output_stepper )
// {
// state_type x = {{ 1.0 }};
// dummy_dense_output_stepper stepper;
// adaptive_iterator< dummy_dense_output_stepper , empty_system > iter1( stepper , empty_system() , x , 0.0 , 10.0 , 0.01 );
// adaptive_iterator< dummy_dense_output_stepper , empty_system > iter2( iter1 );
// const state_type &p1 = *iter1;
// const state_type &p2 = *iter2;
// BOOST_CHECK_EQUAL( p1[0] , p2[0] );
// BOOST_CHECK_EQUAL( p1[0] , x[0] );
// ++iter1;
// ++iter2;
// BOOST_CHECK_EQUAL( p1[0] , p2[0] );
// const state_type &p3 = *iter1;
// const state_type &p4 = *iter2;
// BOOST_CHECK_EQUAL( p3[0] , p4[0] );
// BOOST_CHECK_EQUAL( p3[0] , p1[0] );
// }
BOOST_AUTO_TEST_SUITE_END()

View File

@@ -49,7 +49,7 @@ BOOST_AUTO_TEST_SUITE( adaptive_time_iterator_test )
typedef mpl::vector<
dummy_controlled_stepper
// , dummy_dense_output_stepper
, dummy_dense_output_stepper
> dummy_steppers;
@@ -64,6 +64,30 @@ BOOST_AUTO_TEST_CASE( copy_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator )
{
typedef adaptive_time_iterator< dummy_dense_output_stepper , empty_system > iterator_type;
state_type x = {{ 1.0 }};
iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iter1;
BOOST_CHECK_NE( &( iter1->first ) , &( iter2->first ) );
BOOST_CHECK_NE( &( iter1->first ) , &x );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator_with_reference_wrapper )
{
typedef adaptive_time_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type;
state_type x = {{ 1.0 }};
dummy_dense_output_stepper stepper;
iterator_type iter1 = iterator_type( boost::ref( stepper ) , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iter1;
BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) );
BOOST_CHECK_NE( &( iter1->first ) , &x );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
{
typedef adaptive_time_iterator< dummy_controlled_stepper , empty_system > iterator_type;
@@ -79,6 +103,42 @@ BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator )
{
typedef adaptive_time_iterator< dummy_dense_output_stepper , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( dummy_dense_output_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_NE( &( iter1->first ) , &x1 );
BOOST_CHECK_NE( &( iter2->first ) , &x2 );
BOOST_CHECK( !iter1.same( iter2 ) );
iter2 = iter1;
BOOST_CHECK_NE( &( iter1->first ) , &x1 );
BOOST_CHECK_NE( &( iter2->first ) , &x1 );
BOOST_CHECK( iter1.same( iter2 ) );
BOOST_CHECK_EQUAL( (iter1->first)[0] , (iter1->first)[0] );
}
BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator_with_reference_wrapper )
{
typedef adaptive_time_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
dummy_dense_output_stepper stepper;
iterator_type iter1 = iterator_type( boost::ref( stepper ) , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( boost::ref( stepper ) , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_NE( &( iter1->first ) , &x1 );
BOOST_CHECK_NE( &( iter2->first ) , &x2 );
BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) );
BOOST_CHECK( !iter1.same( iter2 ) );
iter2 = iter1;
BOOST_CHECK_NE( &( iter1->first ) , &x1 );
BOOST_CHECK_NE( &( iter2->first ) , &x1 );
BOOST_CHECK( iter1.same( iter2 ) );
BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
{
dummy_controlled_stepper stepper;
@@ -93,6 +153,20 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_factory )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
std::for_each(
make_adaptive_time_iterator_begin( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
make_adaptive_time_iterator_end( stepper , boost::ref( system ) , x ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( stepper_range )
{
dummy_controlled_stepper stepper;
@@ -105,6 +179,18 @@ BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_range )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
boost::for_each( make_adaptive_time_range( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
{
dummy_controlled_stepper stepper;
@@ -119,6 +205,21 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_with_reference_wrapper_factory )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
std::for_each(
make_adaptive_time_iterator_begin( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
make_adaptive_time_iterator_end( boost::ref( stepper ) , boost::ref( system ) , x ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper )
{
dummy_controlled_stepper stepper;
@@ -131,6 +232,17 @@ BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_range_with_reference_wrapper )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
boost::for_each( make_adaptive_time_range( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
dummy_observer() );
}
@@ -170,8 +282,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers )
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers )
@@ -191,8 +301,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_ste
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers )
@@ -211,8 +319,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dum
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
}

View File

@@ -46,27 +46,28 @@ BOOST_AUTO_TEST_SUITE( const_step_iterator_test )
typedef mpl::vector<
dummy_stepper
// , dummy_dense_output_stepper
, dummy_dense_output_stepper
> dummy_steppers;
BOOST_AUTO_TEST_CASE( copy_stepper_iterator )
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_stepper_iterator , Stepper , dummy_steppers )
{
typedef const_step_iterator< dummy_stepper , empty_system > iterator_type;
typedef const_step_iterator< Stepper , empty_system > iterator_type;
state_type x = {{ 1.0 }};
iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter1 = iterator_type( Stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iter1;
BOOST_CHECK_EQUAL( &(*iter1) , &(*iter2) );
BOOST_CHECK_EQUAL( &(*iter1) , &x );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_AUTO_TEST_CASE_TEMPLATE( assignment_stepper_iterator , Stepper , dummy_steppers )
{
typedef const_step_iterator< dummy_stepper , empty_system > iterator_type;
typedef const_step_iterator< Stepper , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( dummy_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
iterator_type iter1 = iterator_type( Stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( Stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_EQUAL( &(*iter1) , &x1 );
BOOST_CHECK_EQUAL( &(*iter2) , &x2 );
BOOST_CHECK( !iter1.same( iter2 ) );
@@ -76,9 +77,11 @@ BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_factory , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -90,9 +93,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -102,9 +105,9 @@ BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_with_reference_wrapper_factory , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -116,9 +119,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range_with_reference_wrapper , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};

View File

@@ -47,28 +47,28 @@ BOOST_AUTO_TEST_SUITE( const_step_time_iterator_test )
typedef mpl::vector<
dummy_stepper
// , dummy_dense_output_stepper
, dummy_dense_output_stepper
> dummy_steppers;
BOOST_AUTO_TEST_CASE( copy_stepper_iterator )
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_stepper_iterator , Stepper , dummy_steppers )
{
typedef const_step_time_iterator< dummy_stepper , empty_system > iterator_type;
typedef const_step_time_iterator< Stepper , empty_system > iterator_type;
state_type x = {{ 1.0 }};
iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter1 = iterator_type( Stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iter1;
BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) );
BOOST_CHECK_EQUAL( &( iter1->first ) , &x );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_AUTO_TEST_CASE_TEMPLATE( assignment_stepper_iterator , Stepper , dummy_steppers )
{
typedef const_step_time_iterator< dummy_stepper , empty_system > iterator_type;
typedef const_step_time_iterator< Stepper , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( dummy_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
iterator_type iter1 = iterator_type( Stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( Stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_EQUAL( &( iter1->first ) , &x1 );
BOOST_CHECK_EQUAL( &( iter2->first ) , &x2 );
BOOST_CHECK( !iter1.same( iter2 ) );
@@ -78,9 +78,9 @@ BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_factory , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -92,9 +92,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -104,9 +104,9 @@ BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_with_reference_wrapper_factory , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -118,9 +118,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range_with_reference_wrapper , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};