diff --git a/.travis.yml b/.travis.yml index 59e5470f..8d97c457 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,25 @@ +sudo: false language: cpp os: - - linux - - osx + - linux + - osx compiler: - - gcc - - clang + - gcc + - clang +install: + - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 + - clang env: - - CXXSTD='' - - CXXSTD='cxxflags="-std=c++0x"' + - CXXSTD="" + - CXXSTD="cxxflags='-std=c++0x'" # For now disable gcc on osx as g++4.8 is not yet available matrix: @@ -17,11 +28,14 @@ matrix: compiler: gcc before_install: - - wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download -O /tmp/boost.tar.bz2 +# 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 - tar jxf /tmp/boost.tar.bz2 - - mv boost_1_55_0 $PWD/boost-trunk -# patch the boost build system - - patch $PWD/boost-trunk/tools/build/v2/build/toolset.jam toolset.jam.patch + - 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 - export BOOST_ROOT="$PWD/boost-trunk" - cd $BOOST_ROOT @@ -31,7 +45,4 @@ before_install: - $CC --version script: - - $BOOST_ROOT/b2 toolset=$CC $CXXSTD -# build in c++11 mode only with gcc -# - if [ "$CXX" = "g++" ]; then $BOOST_ROOT/b2 -a toolset=$CC$GCCVER cxxflags="-std=c++0x"; fi - + - $BOOST_ROOT/b2 toolset=$CC $CXXSTD \ No newline at end of file diff --git a/README b/README deleted file mode 100644 index f34601f5..00000000 --- a/README +++ /dev/null @@ -1 +0,0 @@ -odeint is a highly flexible library for solving ordinary differential equations. diff --git a/README.md b/README.md new file mode 100644 index 00000000..735afd52 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/headmyshoulder/odeint-v2/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + +odeint is a highly flexible library for solving ordinary differential equations. diff --git a/doc/stepper_table.qbk b/doc/stepper_table.qbk index a50cdd8e..86e10180 100644 --- a/doc/stepper_table.qbk +++ b/doc/stepper_table.qbk @@ -1,8 +1,8 @@ [/============================================================================ Boost.odeint - Copyright 2011-2012 Karsten Ahnert - Copyright 2011-2012 Mario Mulansky + Copyright 2011-2015 Karsten Ahnert + Copyright 2011-2015 Mario Mulansky Copyright 2012 Sylwester Arabas Use, modification and distribution is subject to the Boost Software License, @@ -21,7 +21,8 @@ [[Fehlberg 78] [`runge_kutta_fehlberg78`] [__error_stepper] [__system] [8] [Yes (7)] [No] [No] [Good high order method with error estimation, to be used in controlled_error_stepper.]] [[Adams Bashforth] [`adams_bashforth`] [__stepper] [__system] [configurable] [No] [No] [Yes] [Multistep method]] - [[Adams Moulton] [`adams_moulton`] [__stepper] [__system] [configurable] [No] [No] [Yes] [Multistep method]] +[/ # removed as it is not an independent algorithm. + [[Adams Moulton] [`adams_moulton`] [__stepper] [__system] [configurable] [No] [No] [Yes] [Multistep method]] \] [[Adams Bashforth Moulton] [`adams_bashforth_moulton`] [__stepper] [__system] [configurable] [No] [No] [Yes] [Combined multistep method]] [[Controlled Runge-Kutta] [`controlled_runge_kutta`] [__controlled_stepper] [__system] [depends] [Yes] [No] [depends] [Error control for __error_stepper. Requires an __error_stepper from above. Order depends on the given ErrorStepper]] diff --git a/doc/tutorial_parallel.qbk b/doc/tutorial_parallel.qbk index 38376f9b..92f401c5 100644 --- a/doc/tutorial_parallel.qbk +++ b/doc/tutorial_parallel.qbk @@ -134,7 +134,7 @@ Depending on the MPI implementation the code might need to be compiled with i.e. Instead of reading another thread's data, we asynchronously send and receive the relevant data from neighbouring nodes, performing some computation in the interim to hide the latency. -[phase_chain_rhs] +[phase_chain_mpi_rhs] Analogous to `openmp_state` we use `mpi_state< InnerState >`, which automatically selects `mpi_nested_algebra` and the appropriate MPI-oblivious diff --git a/examples/gmpxx/Makefile b/examples/gmpxx/Makefile new file mode 100644 index 00000000..0a9f7cb0 --- /dev/null +++ b/examples/gmpxx/Makefile @@ -0,0 +1,5 @@ +CXXFLAGS = -I${BOOST_ROOT} -O2 -static +LDFLAGS = -lgmpxx -lgmp + +lorenz_gmpxx: lorenz_gmpxx.cpp + ${CXX} ${CXXFLAGS} lorenz_gmpxx.cpp ${LDFLAGS} -o lorenz_gmpxx diff --git a/examples/openmp/lorenz_ensemble_simple.cpp b/examples/openmp/lorenz_ensemble_simple.cpp index a145c815..fbaf2499 100644 --- a/examples/openmp/lorenz_ensemble_simple.cpp +++ b/examples/openmp/lorenz_ensemble_simple.cpp @@ -57,19 +57,21 @@ int main() { state_type X(n, point_type(10, 10, 10)); - typedef runge_kutta4< - state_type, double, - state_type, double, - openmp_range_algebra - > stepper; - const double t_max = 10.0, dt = 0.01; - integrate_const( - stepper(), - sys_func(R), X, - 0.0, t_max, dt - ); + // Simple stepper with constant step size + // typedef runge_kutta4 stepper; + + // integrate_const(stepper(), sys_func(R), X, 0.0, t_max, dt); + + // Controlled stepper with variable step size + typedef runge_kutta_fehlberg78 error_stepper_type; + typedef controlled_runge_kutta controlled_stepper_type; + controlled_stepper_type controlled_stepper; + + integrate_adaptive(controlled_stepper, sys_func(R), X, 0.0, t_max, dt); copy( X.begin(), X.end(), ostream_iterator(cout, "\n") ); diff --git a/openmp.jam b/examples/openmp/openmp.jam similarity index 100% rename from openmp.jam rename to examples/openmp/openmp.jam diff --git a/include/boost/numeric/odeint/external/openmp/openmp_range_algebra.hpp b/include/boost/numeric/odeint/external/openmp/openmp_range_algebra.hpp index f5668e4d..295db647 100644 --- a/include/boost/numeric/odeint/external/openmp/openmp_range_algebra.hpp +++ b/include/boost/numeric/odeint/external/openmp/openmp_range_algebra.hpp @@ -259,7 +259,7 @@ BOOST_ODEINT_GEN_FOR_EACH(BOOST_ODEINT_GEN_BODY) typedef typename norm_result_type< S >::type result_type; result_type init = static_cast< result_type >( 0 ); const size_t len = boost::size(s); - typename boost::range_iterator::type beg = boost::begin(s); + typename boost::range_iterator::type beg = boost::begin(s); # pragma omp parallel for reduction(max: init) schedule(dynamic) for( size_t i = 0 ; i < len ; ++i ) init = max( init , abs( beg[i] ) ); diff --git a/include/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp b/include/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp index 15338ecd..743e5770 100644 --- a/include/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp +++ b/include/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp @@ -98,7 +98,7 @@ size_t integrate_adaptive( } size_t trials = 0; - controlled_step_result res = success; + controlled_step_result res; do { res = st.try_step( system , start_state , start_time , dt ); diff --git a/include/boost/numeric/odeint/integrate/detail/integrate_times.hpp b/include/boost/numeric/odeint/integrate/detail/integrate_times.hpp index ac9b75d8..d5446ba5 100644 --- a/include/boost/numeric/odeint/integrate/detail/integrate_times.hpp +++ b/include/boost/numeric/odeint/integrate/detail/integrate_times.hpp @@ -130,7 +130,9 @@ size_t integrate_times( if( start_time == end_time ) return 0; - Time last_time_point = static_cast(*(end_time-1)); + TimeIterator last_time_iterator = end_time; + --last_time_iterator; + Time last_time_point = static_cast(*last_time_iterator); st.initialize( start_state , *start_time , dt ); obs( start_state , *start_time++ ); 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 0036d1d2..3018524e 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp @@ -109,7 +109,7 @@ public: m_table( m_k_max ) , m_mp_states( m_k_max+1 ) , m_derivs( m_k_max+1 ) , - m_diffs( 2*m_k_max+1 ) , + m_diffs( 2*m_k_max+2 ) , STEPFAC1( 0.65 ) , STEPFAC2( 0.94 ) , STEPFAC3( 0.02 ) , STEPFAC4( 4.0 ) , KFAC1( 0.8 ) , KFAC2( 0.9 ) { BOOST_USING_STD_MIN(); @@ -139,7 +139,7 @@ public: */ } int num = 1; - for( int i = 2*(m_k_max) ; i >=0 ; i-- ) + for( int i = 2*(m_k_max)+1 ; i >=0 ; i-- ) { m_diffs[i].resize( num ); num += (i+1)%2; @@ -587,7 +587,7 @@ private: for( size_t i = 0 ; i < m_k_max+1 ; ++i ) for( size_t j = 0 ; j < m_derivs[i].size() ; ++j ) resized |= adjust_size_by_resizeability( m_derivs[i][j] , x , typename is_resizeable::type() ); - for( size_t i = 0 ; i < 2*m_k_max+1 ; ++i ) + for( size_t i = 0 ; i < 2*m_k_max+2 ; ++i ) for( size_t j = 0 ; j < m_diffs[i].size() ; ++j ) resized |= adjust_size_by_resizeability( m_diffs[i][j] , x , typename is_resizeable::type() ); diff --git a/include/boost/numeric/odeint/util/detail/less_with_sign.hpp b/include/boost/numeric/odeint/util/detail/less_with_sign.hpp index 8a7fda27..d90e12f7 100644 --- a/include/boost/numeric/odeint/util/detail/less_with_sign.hpp +++ b/include/boost/numeric/odeint/util/detail/less_with_sign.hpp @@ -47,9 +47,9 @@ template< typename T > bool less_eq_with_sign( T t1 , T t2 , T dt ) { if( get_unit_value(dt) > 0 ) - return t1-t2 < std::numeric_limits::epsilon(); + return t1-t2 <= std::numeric_limits::epsilon(); else - return t2-t1 < std::numeric_limits::epsilon(); + return t2-t1 <= std::numeric_limits::epsilon(); } template< typename T > diff --git a/test/regression/Jamfile.v2 b/test/regression/Jamfile.v2 index e44b5354..25bbf0c1 100644 --- a/test/regression/Jamfile.v2 +++ b/test/regression/Jamfile.v2 @@ -25,5 +25,6 @@ test-suite "odeint" : [ run regression_147.cpp ] [ compile regression_149.cpp : -std=c++0x ] + [ run regression_168.cpp ] : valgrind ; diff --git a/test/regression/regression_168.cpp b/test/regression/regression_168.cpp new file mode 100644 index 00000000..8349261a --- /dev/null +++ b/test/regression/regression_168.cpp @@ -0,0 +1,90 @@ +/* + + [begin_description] + Test case for issue 149: + Error C2582 with msvc-10 when using iterator-based integration + [end_description] + + Copyright 2011-2015 Karsten Ahnert + Copyright 2011-2015 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) + */ + + +// disable checked iterator warning for msvc + +#include +#ifdef BOOST_MSVC + #pragma warning(disable:4996) +#endif + +#define BOOST_TEST_MODULE odeint_regression_147 + +#include +#include + +#include + +#include + +#include +#include + +#include +#include +#include + + +#include +#include +#include +#include +#include + +#include + + +using namespace boost::unit_test; +using namespace boost::numeric::odeint; +namespace mpl = boost::mpl; + +namespace fusion = boost::fusion; +namespace units = boost::units; +namespace si = boost::units::si; + +typedef units::quantity< si::time , double > time_type; +typedef units::quantity< si::length , double > length_type; +typedef units::quantity< si::velocity , double > velocity_type; +typedef units::quantity< si::acceleration , double > acceleration_type; +typedef units::quantity< si::frequency , double > frequency_type; + +typedef fusion::vector< length_type , velocity_type > state_type; +typedef fusion::vector< velocity_type , acceleration_type > deriv_type; + + +struct oscillator +{ + frequency_type m_omega; + + oscillator( const frequency_type &omega = 1.0 * si::hertz ) : m_omega( omega ) { } + + void operator()( const state_type &x , deriv_type &dxdt , time_type t ) const + { + fusion::at_c< 0 >( dxdt ) = fusion::at_c< 1 >( x ); + fusion::at_c< 1 >( dxdt ) = - m_omega * m_omega * fusion::at_c< 0 >( x ); + } +}; + + +BOOST_AUTO_TEST_CASE( regression_168 ) +{ + typedef runge_kutta_dopri5< state_type , double , deriv_type , time_type > stepper_type; + + state_type x( 1.0 * si::meter , 0.0 * si::meter_per_second ); + + integrate_const( make_dense_output( 1.0e-6 , 1.0e-6 , stepper_type() ) , oscillator( 2.0 * si::hertz ) , + x , 0.0 * si::second , 100.0 * si::second , 0.1 * si::second); +} \ No newline at end of file diff --git a/test_external/mtl4/Jamfile.v2 b/test_external/mtl4/Jamfile.v2 index 3a8481ab..de9d87f2 100644 --- a/test_external/mtl4/Jamfile.v2 +++ b/test_external/mtl4/Jamfile.v2 @@ -7,10 +7,11 @@ import testing ; import boost ; -boost.use-project ; +# boost.use-project ; +use-project boost : $(BOOST_ROOT) ; # set your MTL4 directory here -MTL4_INCLUDE = /home/mario/MTL4 ; +MTL4_INCLUDE = /home/mario/MTL4/usr/include ; project : requirements @@ -25,6 +26,5 @@ project test-suite "odeint-mtl4" : [ run mtl4_resize.cpp ] - [ run lorenz.cpp ] : valgrind ;