regression_168.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. [begin_description]
  3. Test case for issue 149:
  4. Error C2582 with msvc-10 when using iterator-based integration
  5. [end_description]
  6. Copyright 2011-2015 Karsten Ahnert
  7. Copyright 2011-2015 Mario Mulansky
  8. Distributed under the Boost Software License, Version 1.0.
  9. (See accompanying file LICENSE_1_0.txt or
  10. copy at http://www.boost.org/LICENSE_1_0.txt)
  11. */
  12. // disable checked iterator warning for msvc
  13. #include <boost/config.hpp>
  14. #ifdef BOOST_MSVC
  15. #pragma warning(disable:4996)
  16. #endif
  17. #define BOOST_TEST_MODULE odeint_regression_147
  18. #include <utility>
  19. #include <iostream>
  20. #include <boost/array.hpp>
  21. #include <boost/test/unit_test.hpp>
  22. #include <boost/mpl/vector.hpp>
  23. #include <boost/range/algorithm/find_if.hpp>
  24. #include <boost/numeric/odeint.hpp>
  25. #include <boost/numeric/odeint/algebra/fusion_algebra.hpp>
  26. #include <boost/numeric/odeint/algebra/fusion_algebra_dispatcher.hpp>
  27. #include <boost/units/systems/si/length.hpp>
  28. #include <boost/units/systems/si/time.hpp>
  29. #include <boost/units/systems/si/velocity.hpp>
  30. #include <boost/units/systems/si/acceleration.hpp>
  31. #include <boost/units/systems/si/io.hpp>
  32. #include <boost/fusion/container.hpp>
  33. using namespace boost::unit_test;
  34. using namespace boost::numeric::odeint;
  35. namespace mpl = boost::mpl;
  36. namespace fusion = boost::fusion;
  37. namespace units = boost::units;
  38. namespace si = boost::units::si;
  39. typedef units::quantity< si::time , double > time_type;
  40. typedef units::quantity< si::length , double > length_type;
  41. typedef units::quantity< si::velocity , double > velocity_type;
  42. typedef units::quantity< si::acceleration , double > acceleration_type;
  43. typedef units::quantity< si::frequency , double > frequency_type;
  44. typedef fusion::vector< length_type , velocity_type > state_type;
  45. typedef fusion::vector< velocity_type , acceleration_type > deriv_type;
  46. struct oscillator
  47. {
  48. frequency_type m_omega;
  49. oscillator( const frequency_type &omega = 1.0 * si::hertz ) : m_omega( omega ) { }
  50. void operator()( const state_type &x , deriv_type &dxdt , time_type t ) const
  51. {
  52. fusion::at_c< 0 >( dxdt ) = fusion::at_c< 1 >( x );
  53. fusion::at_c< 1 >( dxdt ) = - m_omega * m_omega * fusion::at_c< 0 >( x );
  54. }
  55. };
  56. BOOST_AUTO_TEST_CASE( regression_168 )
  57. {
  58. typedef runge_kutta_dopri5< state_type , double , deriv_type , time_type > stepper_type;
  59. state_type x( 1.0 * si::meter , 0.0 * si::meter_per_second );
  60. integrate_const( make_dense_output( 1.0e-6 , 1.0e-6 , stepper_type() ) , oscillator( 2.0 * si::hertz ) ,
  61. x , 0.0 * si::second , 100.0 * si::second , 0.1 * si::second);
  62. }