From 1eefa78c96a0f103407e956d513cf2387f5899fa Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 9 Dec 2015 12:09:39 +0100 Subject: [PATCH 01/25] Bugfix for #144 also in const version Issue #144 has been fixed some time ago, but only for the non-const ref do_step interface. This fixes also the const ref interface implementation. --- include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp b/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp index 2f7cc4c6..c41f572a 100644 --- a/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp +++ b/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp @@ -175,7 +175,7 @@ public : { m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) ); 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 , out , dt , m_adams_bashforth.step_storage() ); + m_adams_moulton.do_step( system , in , m_x.m_v , t+dt , out , dt , m_adams_bashforth.step_storage() ); } else { From 9d02efbff2ecbe658db6a6d3375e0e7ab80685f7 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 9 Dec 2015 12:51:50 +0100 Subject: [PATCH 02/25] added reset to adams bashforth moulton The ABM stepper was missing reset functionality, see #182 --- .../boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp | 11 +++++++++++ test/adams_bashforth.cpp | 7 ++++++- test/adams_bashforth_moulton.cpp | 4 ++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp b/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp index c41f572a..f3edce19 100644 --- a/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp +++ b/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp @@ -150,6 +150,12 @@ public : } + void reset(void) + { + m_adams_bashforth.reset(); + } + + private: @@ -293,6 +299,11 @@ public : * \param dt The step size. */ + /** + * \fn adams_bashforth_moulton::reset( void ) + * \brief Resets the internal buffers of the stepper. + */ + } // odeint } // numeric diff --git a/test/adams_bashforth.cpp b/test/adams_bashforth.cpp index f7e5e2bf..7574346c 100644 --- a/test/adams_bashforth.cpp +++ b/test/adams_bashforth.cpp @@ -208,8 +208,13 @@ BOOST_AUTO_TEST_CASE( test_auto_initialization ) adams.do_step( lorenz() , x , 0.0 , x , 0.1 ); BOOST_CHECK_EQUAL( adams.initializing_stepper().do_count , size_t( 2 ) ); + adams.reset(); + adams.do_step( lorenz() , x , 0.0 , x , 0.1 ); - BOOST_CHECK_EQUAL( adams.initializing_stepper().do_count , size_t( 2 ) ); + BOOST_CHECK_EQUAL( adams.initializing_stepper().do_count , size_t( 3 ) ); + + adams.do_step( lorenz() , x , 0.0 , x , 0.1 ); + BOOST_CHECK_EQUAL( adams.initializing_stepper().do_count , size_t( 4 ) ); } BOOST_AUTO_TEST_CASE( test_manual_initialization ) diff --git a/test/adams_bashforth_moulton.cpp b/test/adams_bashforth_moulton.cpp index c821ac79..8e7688bb 100644 --- a/test/adams_bashforth_moulton.cpp +++ b/test/adams_bashforth_moulton.cpp @@ -104,8 +104,8 @@ BOOST_AUTO_TEST_CASE( test_instantiation ) s4.do_step( lorenz() , x , t , dt ); s5.do_step( lorenz() , x , t , dt ); s6.do_step( lorenz() , x , t , dt ); -// s7.do_step( lorenz() , x , t , dt ); -// s8.do_step( lorenz() , x , t , dt ); +// s7.do_step( lorenz() , x , t , dt ); +// s8.do_step( lorenz() , x , t , dt ); } From a569bdc0c5afc07b3dd4ed55fa31e185b4c49008 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Thu, 10 Dec 2015 17:18:09 +0100 Subject: [PATCH 03/25] fixing #183 --- include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp index 4b908333..2c612799 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp @@ -282,7 +282,7 @@ class bulirsch_stoer { { m_current_k_opt = min BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast(m_k_max-1) , static_cast(m_current_k_opt)+1 ); new_h = h_opt[k]; - new_h *= m_cost[m_current_k_opt]/m_cost[k]; + new_h *= static_cast(m_cost[m_current_k_opt])/static_cast(m_cost[k]); } else new_h = h_opt[m_current_k_opt]; break; From eb2804b2819a1dbb569b83efe03d4db529984a1f Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Thu, 10 Dec 2015 17:22:44 +0100 Subject: [PATCH 04/25] resetting optimal order when resetting BS stepper addressing #184, simple fix is to also reset m_current_k_opt and therefore make sure the loop doesnt overshoot. --- include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp index 2c612799..4f5bcda7 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp @@ -117,16 +117,8 @@ class bulirsch_stoer { const value_type r = static_cast< value_type >( m_interval_sequence[i] ) / static_cast< value_type >( m_interval_sequence[k] ); m_coeff[i][k] = 1.0 / ( r*r - static_cast< value_type >( 1.0 ) ); // coefficients for extrapolation } - - // crude estimate of optimal order - - m_current_k_opt = 4; - /* no calculation because log10 might not exist for value_type! - const value_type logfact( -log10( max BOOST_PREVENT_MACRO_SUBSTITUTION( eps_rel , static_cast< value_type >(1.0E-12) ) ) * 0.6 + 0.5 ); - m_current_k_opt = max BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast( 1 ) , min BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast( m_k_max-1 ) , logfact )); - */ } - + reset(); } @@ -344,6 +336,12 @@ class bulirsch_stoer { { m_first = true; m_last_step_rejected = false; + // crude estimate of optimal order + m_current_k_opt = 4; + /* no calculation because log10 might not exist for value_type! + const value_type logfact( -log10( max BOOST_PREVENT_MACRO_SUBSTITUTION( eps_rel , static_cast< value_type >(1.0E-12) ) ) * 0.6 + 0.5 ); + m_current_k_opt = max BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast( 1 ) , min BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast( m_k_max-1 ) , logfact )); + */ } From cc8c9772ac7894f5170ca69bf3e748a9f22885d5 Mon Sep 17 00:00:00 2001 From: Martin Langer Date: Fri, 18 Dec 2015 15:32:48 +0100 Subject: [PATCH 05/25] table for precomputed facmin in bulirsch_stoer --- include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp index 4f5bcda7..7a97960d 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp @@ -98,6 +98,7 @@ class bulirsch_stoer { m_interval_sequence( m_k_max+1 ) , m_coeff( m_k_max+1 ) , m_cost( m_k_max+1 ) , + m_facmin_table( m_k_max+1 ) , m_table( m_k_max ) , STEPFAC1( 0.65 ) , STEPFAC2( 0.94 ) , STEPFAC3( 0.02 ) , STEPFAC4( 4.0 ) , KFAC1( 0.8 ) , KFAC2( 0.9 ) { @@ -112,6 +113,7 @@ class bulirsch_stoer { else m_cost[i] = m_cost[i-1] + m_interval_sequence[i]; m_coeff[i].resize(i); + m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , 1.0 / static_cast< value_type > ( 2*i+1 ) ); for( size_t k = 0 ; k < i ; ++k ) { const value_type r = static_cast< value_type >( m_interval_sequence[i] ) / static_cast< value_type >( m_interval_sequence[k] ); @@ -415,7 +417,7 @@ class bulirsch_stoer { BOOST_USING_STD_MAX(); using std::pow; value_type expo( 1.0/(2*k+1) ); - value_type facmin = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , expo ); + value_type facmin = m_facmin_table[k]; value_type fac; if (error == 0.0) fac=1.0/facmin; @@ -504,6 +506,7 @@ class bulirsch_stoer { int_vector m_interval_sequence; // stores the successive interval counts value_matrix m_coeff; int_vector m_cost; // costs for interval count + value_vector m_facmin_table // for precomputed facmin to save pow calls state_table_type m_table; // sequence of states for extrapolation From 607bb768ba8b0c2a019990a092a42544a9ee57ba Mon Sep 17 00:00:00 2001 From: Martin Langer Date: Fri, 18 Dec 2015 15:40:53 +0100 Subject: [PATCH 06/25] table for precomputed facmin in bulirsch_stoer_dense_out --- include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp index d876ca3d..ff448cc2 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp @@ -110,6 +110,7 @@ class bulirsch_stoer_dense_out { m_interval_sequence( m_k_max+1 ) , m_coeff( m_k_max+1 ) , m_cost( m_k_max+1 ) , + m_facmin_table( m_k_max+1 ) , m_table( m_k_max ) , m_mp_states( m_k_max+1 ) , m_derivs( m_k_max+1 ) , @@ -129,6 +130,7 @@ class bulirsch_stoer_dense_out { else m_cost[i] = m_cost[i-1] + m_interval_sequence[i]; m_coeff[i].resize(i); + m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , 1.0 / static_cast< value_type > ( 2*i+1 ) ); for( size_t k = 0 ; k < i ; ++k ) { const value_type r = static_cast< value_type >( m_interval_sequence[i] ) / static_cast< value_type >( m_interval_sequence[k] ); @@ -429,7 +431,7 @@ class bulirsch_stoer_dense_out { using std::pow; value_type expo = static_cast(1)/(m_interval_sequence[k-1]); - value_type facmin = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , expo ); + value_type facmin = m_facmin_table[k]; value_type fac; if (error == 0.0) fac = static_cast(1)/facmin; @@ -692,6 +694,7 @@ class bulirsch_stoer_dense_out { int_vector m_interval_sequence; // stores the successive interval counts value_matrix m_coeff; int_vector m_cost; // costs for interval count + value_vector m_facmin_table // for precomputed facmin to save pow calls state_vector_type m_table; // sequence of states for extrapolation From 61a74d2bfc915ed76bd6cdb5b188e9d2967c70e1 Mon Sep 17 00:00:00 2001 From: Martin Langer Date: Fri, 18 Dec 2015 16:14:48 +0100 Subject: [PATCH 07/25] fixed missing semicolon --- include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp | 2 +- include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp index 7a97960d..aad52e0c 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp @@ -506,7 +506,7 @@ class bulirsch_stoer { int_vector m_interval_sequence; // stores the successive interval counts value_matrix m_coeff; int_vector m_cost; // costs for interval count - value_vector m_facmin_table // for precomputed facmin to save pow calls + value_vector m_facmin_table; // for precomputed facmin to save pow calls state_table_type m_table; // sequence of states for extrapolation diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp index ff448cc2..44d4c06c 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp @@ -694,7 +694,7 @@ class bulirsch_stoer_dense_out { int_vector m_interval_sequence; // stores the successive interval counts value_matrix m_coeff; int_vector m_cost; // costs for interval count - value_vector m_facmin_table // for precomputed facmin to save pow calls + value_vector m_facmin_table; // for precomputed facmin to save pow calls state_vector_type m_table; // sequence of states for extrapolation From 0f943fbf8b303a8083876bb1fba677d4c4677417 Mon Sep 17 00:00:00 2001 From: Martin Langer Date: Sun, 27 Dec 2015 22:42:33 +0100 Subject: [PATCH 08/25] fixed wrong precomputation in BS dense stepper --- include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp index 44d4c06c..5f5d5e3d 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp @@ -130,7 +130,7 @@ class bulirsch_stoer_dense_out { else m_cost[i] = m_cost[i-1] + m_interval_sequence[i]; m_coeff[i].resize(i); - m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , 1.0 / static_cast< value_type > ( 2*i+1 ) ); + m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , static_cast(1)/(m_interval_sequence[i-1]) ); for( size_t k = 0 ; k < i ; ++k ) { const value_type r = static_cast< value_type >( m_interval_sequence[i] ) / static_cast< value_type >( m_interval_sequence[k] ); From a625f532b158fc4aa853467c9b6d2d0c9d0dd3b2 Mon Sep 17 00:00:00 2001 From: Martin Langer Date: Mon, 28 Dec 2015 12:04:39 +0100 Subject: [PATCH 09/25] corrected rushed fix --- include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp index 5f5d5e3d..6b26a8c4 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp @@ -126,11 +126,16 @@ class bulirsch_stoer_dense_out { m_interval_sequence[i] = 2 + 4*i; // 2 6 10 14 ... m_derivs[i].resize( m_interval_sequence[i] ); if( i == 0 ) + { m_cost[i] = m_interval_sequence[i]; + m_facmin_table[0] = 1; // never to be used + } else + { + m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , static_cast(1)/(m_interval_sequence[i-1]) ); m_cost[i] = m_cost[i-1] + m_interval_sequence[i]; + } m_coeff[i].resize(i); - m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , static_cast(1)/(m_interval_sequence[i-1]) ); for( size_t k = 0 ; k < i ; ++k ) { const value_type r = static_cast< value_type >( m_interval_sequence[i] ) / static_cast< value_type >( m_interval_sequence[k] ); From cc9b1963e734b017930d6740732f0fa4216a5b16 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Mon, 28 Dec 2015 15:26:00 +0100 Subject: [PATCH 10/25] BS stepper: correct exponents for optimal h Becoming suspicious by the difference of the exponents used for computing the new step size in the BS and BS denseout stepper (see 0f943fbf8b303a8083876bb1fba677d4c4677417) I checked again the Hairer book and I'm now convinced there was a mistake in our implementation and both steppers should use 1/(2*k+1) as exponent. The background is the this exponent represents the order of the error of the k-th iteration, and this order is always 2k+1, independent of the interval_sequence. This error is computed from the difference of the k-th and k-1 - th iteration, which have the orders 2k+2 2k respectively, which means the computed error has order 2k+1. --- include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp | 2 +- include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp index aad52e0c..02c37492 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp @@ -113,7 +113,7 @@ class bulirsch_stoer { else m_cost[i] = m_cost[i-1] + m_interval_sequence[i]; m_coeff[i].resize(i); - m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , 1.0 / static_cast< value_type > ( 2*i+1 ) ); + m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , static_cast< value_type >(1) / static_cast< value_type >( 2*i+1 ) ); for( size_t k = 0 ; k < i ; ++k ) { const value_type r = static_cast< value_type >( m_interval_sequence[i] ) / static_cast< value_type >( m_interval_sequence[k] ); diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp index 6b26a8c4..6a1eed15 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp @@ -128,13 +128,11 @@ class bulirsch_stoer_dense_out { if( i == 0 ) { m_cost[i] = m_interval_sequence[i]; - m_facmin_table[0] = 1; // never to be used - } - else + } else { - m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , static_cast(1)/(m_interval_sequence[i-1]) ); m_cost[i] = m_cost[i-1] + m_interval_sequence[i]; } + m_facmin_table[i] = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , static_cast< value_type >(1) / static_cast< value_type >( 2*i+1 ) ); m_coeff[i].resize(i); for( size_t k = 0 ; k < i ; ++k ) { From 31c29dd9486c78d1ec4c0eac7b95e7d34a21362e Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 19 Jan 2016 15:37:50 +0100 Subject: [PATCH 11/25] fixes #189 A bug introduced with the recent max_dt facility prevented the rosenbrock controller to increase step size in most cases (if max_dt=0). This is fixed now, and a regression test case has been added. --- .../odeint/stepper/rosenbrock4_controller.hpp | 2 + test/regression/Jamfile.v2 | 1 + test/regression/regression_189.cpp | 71 ++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 test/regression/regression_189.cpp diff --git a/include/boost/numeric/odeint/stepper/rosenbrock4_controller.hpp b/include/boost/numeric/odeint/stepper/rosenbrock4_controller.hpp index 0e5edd32..61d6e511 100644 --- a/include/boost/numeric/odeint/stepper/rosenbrock4_controller.hpp +++ b/include/boost/numeric/odeint/stepper/rosenbrock4_controller.hpp @@ -163,6 +163,8 @@ class rosenbrock4_controller if( m_max_dt != static_cast(0) ) { dt = detail::min_abs(m_max_dt, dt_new); + } else { + dt = dt_new; } m_last_rejected = false; return success; diff --git a/test/regression/Jamfile.v2 b/test/regression/Jamfile.v2 index 25bbf0c1..4f64698b 100644 --- a/test/regression/Jamfile.v2 +++ b/test/regression/Jamfile.v2 @@ -26,5 +26,6 @@ test-suite "odeint" [ run regression_147.cpp ] [ compile regression_149.cpp : -std=c++0x ] [ run regression_168.cpp ] + [ run regression_189.cpp ] : valgrind ; diff --git a/test/regression/regression_189.cpp b/test/regression/regression_189.cpp new file mode 100644 index 00000000..dbd88ac8 --- /dev/null +++ b/test/regression/regression_189.cpp @@ -0,0 +1,71 @@ +/* + + [begin_description] + Test case for issue 189: + Controlled Rosenbrock stepper fails to increase step size + [end_description] + + Copyright 2016 Karsten Ahnert + Copyright 2016 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#define BOOST_TEST_MODULE odeint_regression_189 + +#include + +#include +#include +#include + +using namespace boost::numeric::odeint; +namespace phoenix = boost::phoenix; + +typedef boost::numeric::ublas::vector< double > vector_type; +typedef boost::numeric::ublas::matrix< double > matrix_type; + +struct stiff_system +{ + void operator()( const vector_type &x , vector_type &dxdt , double /* t */ ) + { + dxdt[ 0 ] = -101.0 * x[ 0 ] - 100.0 * x[ 1 ]; + dxdt[ 1 ] = x[ 0 ]; + } +}; + +struct stiff_system_jacobi +{ + void operator()( const vector_type & /* x */ , matrix_type &J , const double & /* t */ , vector_type &dfdt ) + { + J( 0 , 0 ) = -101.0; + J( 0 , 1 ) = -100.0; + J( 1 , 0 ) = 1.0; + J( 1 , 1 ) = 0.0; + dfdt[0] = 0.0; + dfdt[1] = 0.0; + } +}; + + +BOOST_AUTO_TEST_CASE( regression_189 ) +{ + vector_type x( 2 , 1.0 ); + + size_t num_of_steps = integrate_const( make_dense_output< rosenbrock4< double > >( 1.0e-6 , 1.0e-6 ) , + std::make_pair( stiff_system() , stiff_system_jacobi() ) , + x , 0.0 , 50.0 , 0.01 , + std::cout << phoenix::arg_names::arg2 << " " << phoenix::arg_names::arg1[0] << "\n" ); + // regression: number of steps should be 74 + BOOST_CHECK_EQUAL( num_of_steps , 74 ); + + vector_type x2( 2 , 1.0 ); + + size_t num_of_steps2 = integrate_const( make_dense_output< runge_kutta_dopri5< vector_type > >( 1.0e-6 , 1.0e-6 ) , + stiff_system() , x2 , 0.0 , 50.0 , 0.01 , + std::cout << phoenix::arg_names::arg2 << " " << phoenix::arg_names::arg1[0] << "\n" ); + + BOOST_CHECK_EQUAL( num_of_steps2 , 1531 ); +} From c2add5c93f2d20dac2c9b0e622aae70c00a305b9 Mon Sep 17 00:00:00 2001 From: OGAWA KenIchi Date: Sun, 21 Feb 2016 01:45:55 +0900 Subject: [PATCH 12/25] Remove .gitmodules --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 9ecf20af..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "doc"] - path = doc - url = git@github.com:headmyshoulder/odeint-v2.git From 9c4a5d8f42efd701d0b79003b88ad6b8c128e863 Mon Sep 17 00:00:00 2001 From: akumta Date: Mon, 29 Feb 2016 19:50:21 -0800 Subject: [PATCH 13/25] update for ticket #12034 --- include/boost/numeric/odeint/integrate/max_step_checker.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/numeric/odeint/integrate/max_step_checker.hpp b/include/boost/numeric/odeint/integrate/max_step_checker.hpp index 6808a57b..654c95bc 100644 --- a/include/boost/numeric/odeint/integrate/max_step_checker.hpp +++ b/include/boost/numeric/odeint/integrate/max_step_checker.hpp @@ -69,7 +69,7 @@ class max_step_checker if( m_steps++ >= m_max_steps ) { char error_msg[200]; - sprintf(error_msg, "Max number of iterations exceeded (%d).", m_max_steps); + std::sprintf(error_msg, "Max number of iterations exceeded (%d).", m_max_steps); BOOST_THROW_EXCEPTION( no_progress_error(error_msg) ); } } @@ -101,7 +101,7 @@ class failed_step_checker : public max_step_checker if( m_steps++ >= m_max_steps ) { char error_msg[200]; - sprintf(error_msg, "Max number of iterations exceeded (%d). A new step size was not found.", m_max_steps); + std::sprintf(error_msg, "Max number of iterations exceeded (%d). A new step size was not found.", m_max_steps); BOOST_THROW_EXCEPTION( step_adjustment_error(error_msg) ); } } @@ -111,4 +111,4 @@ class failed_step_checker : public max_step_checker } // namespace numeric } // namespace boost -#endif \ No newline at end of file +#endif From b816e93fcfd099fdd33e9f3caa6dc5d57b83f8d7 Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Fri, 1 Apr 2016 21:39:42 +0200 Subject: [PATCH 14/25] fixing #12107 --- include/boost/numeric/odeint/integrate/integrate_n_steps.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/numeric/odeint/integrate/integrate_n_steps.hpp b/include/boost/numeric/odeint/integrate/integrate_n_steps.hpp index 7f3a49bd..5cc8aa0e 100644 --- a/include/boost/numeric/odeint/integrate/integrate_n_steps.hpp +++ b/include/boost/numeric/odeint/integrate/integrate_n_steps.hpp @@ -23,6 +23,7 @@ #include #include #include +#include namespace boost { namespace numeric { From 5c8c4fb1b1759eafbfcbdab4ef0112bef5f3ae89 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 30 Jul 2016 16:57:53 +0900 Subject: [PATCH 15/25] Relaxing test requirements. --- test/regression/Jamfile.v2 | 2 +- test/regression/regression_149.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/test/regression/Jamfile.v2 b/test/regression/Jamfile.v2 index 25bbf0c1..87195225 100644 --- a/test/regression/Jamfile.v2 +++ b/test/regression/Jamfile.v2 @@ -24,7 +24,7 @@ project test-suite "odeint" : [ run regression_147.cpp ] - [ compile regression_149.cpp : -std=c++0x ] + [ compile regression_149.cpp ] [ run regression_168.cpp ] : valgrind ; diff --git a/test/regression/regression_149.cpp b/test/regression/regression_149.cpp index a61082b3..2790d683 100644 --- a/test/regression/regression_149.cpp +++ b/test/regression/regression_149.cpp @@ -52,11 +52,20 @@ struct perform_test bulirsch_stoer< state_type > stepper( 1e-9, 0.0, 0.0, 0.0 ); state_type x( 3, 10.0 ); - auto iter = boost::find_if( + print( boost::find_if( make_adaptive_time_range( stepper, rhs, x, 0.0, 1.0, 0.01 ), - []( const std::pair< const state_type &, double > &x ) - { return ( x.first[0] < 0.0 ); } ); + pred ) ); + } + + static bool pred( const std::pair< const state_type &, double > &x ) + { + return ( x.first[0] < 0.0 ); + } + + template + void print( Iterator iter ) + { std::cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n"; } From 357e5b36e76db72d751e4e6e9ff90dae1a567f68 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 30 Jul 2016 16:59:51 +0900 Subject: [PATCH 16/25] Fix missing include. --- test/numeric/order_quadrature_formula.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/numeric/order_quadrature_formula.cpp b/test/numeric/order_quadrature_formula.cpp index bdf2ae46..722dfa18 100644 --- a/test/numeric/order_quadrature_formula.cpp +++ b/test/numeric/order_quadrature_formula.cpp @@ -28,6 +28,8 @@ #include +#include + using namespace boost::unit_test; using namespace boost::numeric::odeint; namespace mpl = boost::mpl; From f1255a83196d1b69b1b81d7eec9b77d9281682cd Mon Sep 17 00:00:00 2001 From: Tim Keitt Date: Thu, 26 Jan 2017 12:05:53 -0600 Subject: [PATCH 17/25] Fix unused variable warning --- include/boost/numeric/odeint/stepper/controlled_runge_kutta.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/numeric/odeint/stepper/controlled_runge_kutta.hpp b/include/boost/numeric/odeint/stepper/controlled_runge_kutta.hpp index 8ae627fe..aac2b02d 100644 --- a/include/boost/numeric/odeint/stepper/controlled_runge_kutta.hpp +++ b/include/boost/numeric/odeint/stepper/controlled_runge_kutta.hpp @@ -143,7 +143,7 @@ class default_step_adjuster error = max BOOST_PREVENT_MACRO_SUBSTITUTION ( static_cast( pow( static_cast(5.0) , -static_cast(stepper_order) ) ) , error); - time_type dt_old = dt; + // time_type dt_old = dt; unused variable warning //error too small - increase dt and keep the evolution and limit scaling factor to 5.0 dt *= static_cast(9)/static_cast(10) * pow(error, static_cast(-1) / stepper_order); From 850fa824ebff9e94a2c1420768cc31ad003ecc32 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Thu, 26 Jan 2017 21:48:39 -0800 Subject: [PATCH 18/25] Add no-unused-local-typedef to Jenkins build This adds the flag -Wno-unused-local-typedef to the global build options on Jenkins to shorten the log file for the clang build when building Boost. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8d97c457..0dc65c01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ addons: env: - CXXSTD="" - - CXXSTD="cxxflags='-std=c++0x'" + - CXXSTD="-std=c++0x" # For now disable gcc on osx as g++4.8 is not yet available matrix: @@ -45,4 +45,4 @@ before_install: - $CC --version script: - - $BOOST_ROOT/b2 toolset=$CC $CXXSTD \ No newline at end of file + - $BOOST_ROOT/b2 toolset=$CC cxxflags='-Wno-unused-local-typedef $CXXSTD' \ No newline at end of file From 5d3b01395546ea55068007a60373eadb88cba69d Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Sun, 7 May 2017 12:40:31 -0700 Subject: [PATCH 19/25] Update Boost on Travis, fix bug with boost 1.63 --- .travis.yml | 11 ++++------- test/numeric/order_quadrature_formula.cpp | 2 ++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0dc65c01..85f94940 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,14 +28,11 @@ matrix: compiler: gcc before_install: -# 1.55: http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download -# 1.57: http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.bz2/download # 1.58: http://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.tar.bz2\?r\=\&ts\=1435589970\&use_mirror\=garr - - wget http://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.tar.bz2\?r\=\&ts\=1435589970\&use_mirror\=garr -O /tmp/boost.tar.bz2 +# 1.63: https://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.tar.bz2/download?use_mirror=superb-dca2 + - wget https://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.tar.bz2/download?use_mirror=superb-dca2 -O /tmp/boost.tar.bz2 - tar jxf /tmp/boost.tar.bz2 - - mv boost_1_58_0 $PWD/boost-trunk -# patch the boost build system - not neccessary with 1.58 anymore -# - patch $PWD/boost-trunk/tools/build/v2/build/toolset.jam toolset.jam.patch + - mv boost_1_63_0 $PWD/boost-trunk - export BOOST_ROOT="$PWD/boost-trunk" - cd $BOOST_ROOT @@ -45,4 +42,4 @@ before_install: - $CC --version script: - - $BOOST_ROOT/b2 toolset=$CC cxxflags='-Wno-unused-local-typedef $CXXSTD' \ No newline at end of file + - $BOOST_ROOT/b2 toolset=$CC cxxflags='$CXXSTD' \ No newline at end of file diff --git a/test/numeric/order_quadrature_formula.cpp b/test/numeric/order_quadrature_formula.cpp index bdf2ae46..923183ff 100644 --- a/test/numeric/order_quadrature_formula.cpp +++ b/test/numeric/order_quadrature_formula.cpp @@ -20,6 +20,8 @@ #include #include +#include "boost/format.hpp" + #include #include From dd54cbf031c9b52a88be4602ea7e632eff68bf82 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Sun, 7 May 2017 12:51:53 -0700 Subject: [PATCH 20/25] Fix Badge in Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 735afd52..23e4f88b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/headmyshoulder/odeint-v2/trend.png)](https://bitdeli.com/free "Bitdeli Badge") +[![Build Status](https://travis-ci.org/headmyshoulder/odeint-v2.svg?branch=master)](https://travis-ci.org/headmyshoulder/odeint-v2) odeint is a highly flexible library for solving ordinary differential equations. From a452f6e8167379528b25880a1029cfcdeb458bbb Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Sun, 7 May 2017 13:07:10 -0700 Subject: [PATCH 21/25] Fix `abs` warnings and clang compiler warning flag --- Jamroot | 2 +- test/runge_kutta_concepts.cpp | 1 + test/runge_kutta_controlled_concepts.cpp | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Jamroot b/Jamroot index 6476f9a9..03ad4f0a 100644 --- a/Jamroot +++ b/Jamroot @@ -15,7 +15,7 @@ project : requirements include&&$(BOOST_ROOT) gcc:"-Wall -Wno-unused-parameter -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-local-typedefs" - clang:"-Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-local-typedefs" + clang:"-Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-local-typedef" intel:"-ipo" ; diff --git a/test/runge_kutta_concepts.cpp b/test/runge_kutta_concepts.cpp index a16b04fd..42235dea 100644 --- a/test/runge_kutta_concepts.cpp +++ b/test/runge_kutta_concepts.cpp @@ -88,6 +88,7 @@ struct perform_stepper_test typedef T vector_space_type; void operator()( void ) const { + using std::abs; vector_space_type x; x = 2.0; Stepper stepper; diff --git a/test/runge_kutta_controlled_concepts.cpp b/test/runge_kutta_controlled_concepts.cpp index 2132b092..7f70cc53 100644 --- a/test/runge_kutta_controlled_concepts.cpp +++ b/test/runge_kutta_controlled_concepts.cpp @@ -87,6 +87,7 @@ struct perform_controlled_stepper_test typedef T vector_space_type; void operator()( void ) const { + using std::abs; vector_space_type x; x = 2.0; ControlledStepper controlled_stepper; @@ -134,6 +135,7 @@ struct perform_controlled_stepper_test< ControlledStepper , vector_space_type > { void operator()( void ) const { + using std::abs; vector_space_type x; x = 2.0; ControlledStepper controlled_stepper; From ff3fd556cba6153fcca28759db5237b65020fa25 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Sun, 7 May 2017 13:27:57 -0700 Subject: [PATCH 22/25] Fix compiler warnings, activate parallel CI build --- .travis.yml | 2 +- Jamroot | 2 +- test/regression/regression_189.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 85f94940..598074c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,4 +42,4 @@ before_install: - $CC --version script: - - $BOOST_ROOT/b2 toolset=$CC cxxflags='$CXXSTD' \ No newline at end of file + - $BOOST_ROOT/b2 toolset=$CC cxxflags='$CXXSTD' -j4 \ No newline at end of file diff --git a/Jamroot b/Jamroot index 03ad4f0a..9b22377b 100644 --- a/Jamroot +++ b/Jamroot @@ -15,7 +15,7 @@ project : requirements include&&$(BOOST_ROOT) gcc:"-Wall -Wno-unused-parameter -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-local-typedefs" - clang:"-Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-local-typedef" + clang:"-Wall -Wextra -Wno-unknown-warning-option -Wno-unused-function -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-local-typedef" intel:"-ipo" ; diff --git a/test/regression/regression_189.cpp b/test/regression/regression_189.cpp index dbd88ac8..54530072 100644 --- a/test/regression/regression_189.cpp +++ b/test/regression/regression_189.cpp @@ -59,13 +59,14 @@ BOOST_AUTO_TEST_CASE( regression_189 ) x , 0.0 , 50.0 , 0.01 , std::cout << phoenix::arg_names::arg2 << " " << phoenix::arg_names::arg1[0] << "\n" ); // regression: number of steps should be 74 - BOOST_CHECK_EQUAL( num_of_steps , 74 ); + size_t num_of_steps_expected = 74; + BOOST_CHECK_EQUAL( num_of_steps , num_of_steps_expected ); vector_type x2( 2 , 1.0 ); size_t num_of_steps2 = integrate_const( make_dense_output< runge_kutta_dopri5< vector_type > >( 1.0e-6 , 1.0e-6 ) , stiff_system() , x2 , 0.0 , 50.0 , 0.01 , std::cout << phoenix::arg_names::arg2 << " " << phoenix::arg_names::arg1[0] << "\n" ); - - BOOST_CHECK_EQUAL( num_of_steps2 , 1531 ); + num_of_steps_expected = 1531; + BOOST_CHECK_EQUAL( num_of_steps2 , num_of_steps_expected ); } From 53d15cc83a09e2ba57ea3420b1c637c4e8b1c611 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Sun, 7 May 2017 13:46:30 -0700 Subject: [PATCH 23/25] Use 2 cores on Travis, not 4 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 598074c8..7d723fb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,8 @@ before_install: - ./bootstrap.sh - cd $TRAVIS_BUILD_DIR - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$CC" = "gcc" ]; then export CC=gcc-4.8; fi + - echo "Toolset: ${CC}" - $CC --version script: - - $BOOST_ROOT/b2 toolset=$CC cxxflags='$CXXSTD' -j4 \ No newline at end of file + - $BOOST_ROOT/b2 toolset=$CC cxxflags='$CXXSTD' -j2 \ No newline at end of file From 3a83fdbd8f312ba62e0097fc762e9492904bbfd3 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Sun, 7 May 2017 13:51:50 -0700 Subject: [PATCH 24/25] Fix travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7d723fb6..df24254b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ before_install: - ./bootstrap.sh - cd $TRAVIS_BUILD_DIR - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$CC" = "gcc" ]; then export CC=gcc-4.8; fi - - echo "Toolset: ${CC}" + - echo "Toolset: $CC" - $CC --version script: From f0469a2fb6d707d184fb07cc072aa179d0b31579 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Sun, 7 May 2017 13:57:31 -0700 Subject: [PATCH 25/25] Fix travis config 2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index df24254b..118d3c0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ before_install: - ./bootstrap.sh - cd $TRAVIS_BUILD_DIR - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$CC" = "gcc" ]; then export CC=gcc-4.8; fi - - echo "Toolset: $CC" + - echo $CC - $CC --version script: