Brian Silverman | 7c33ab2 | 2018-08-04 17:14:51 -0700 | [diff] [blame^] | 1 | /* |
| 2 | |
| 3 | [begin_description] |
| 4 | Test case for issue 149: |
| 5 | Error C2582 with msvc-10 when using iterator-based integration |
| 6 | [end_description] |
| 7 | |
| 8 | Copyright 2011-2015 Karsten Ahnert |
| 9 | Copyright 2011-2015 Mario Mulansky |
| 10 | |
| 11 | Distributed under the Boost Software License, Version 1.0. |
| 12 | (See accompanying file LICENSE_1_0.txt or |
| 13 | copy at http://www.boost.org/LICENSE_1_0.txt) |
| 14 | */ |
| 15 | |
| 16 | |
| 17 | // disable checked iterator warning for msvc |
| 18 | |
| 19 | #include <boost/config.hpp> |
| 20 | #ifdef BOOST_MSVC |
| 21 | #pragma warning(disable:4996) |
| 22 | #endif |
| 23 | |
| 24 | #define BOOST_TEST_MODULE odeint_regression_147 |
| 25 | |
| 26 | #include <utility> |
| 27 | #include <iostream> |
| 28 | |
| 29 | #include <boost/test/unit_test.hpp> |
| 30 | |
| 31 | #include <boost/mpl/vector.hpp> |
| 32 | #include <boost/range/algorithm/find_if.hpp> |
| 33 | |
| 34 | #include <boost/numeric/odeint.hpp> |
| 35 | |
| 36 | using namespace boost::unit_test; |
| 37 | using namespace boost::numeric::odeint; |
| 38 | namespace mpl = boost::mpl; |
| 39 | |
| 40 | typedef std::vector<double> state_type; |
| 41 | |
| 42 | void rhs( const state_type &x , state_type &dxdt , const double t ) |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | |
| 47 | template<class Stepper> |
| 48 | struct perform_test |
| 49 | { |
| 50 | void operator()( void ) |
| 51 | { |
| 52 | bulirsch_stoer< state_type > stepper( 1e-9, 0.0, 0.0, 0.0 ); |
| 53 | state_type x( 3, 10.0 ); |
| 54 | |
| 55 | print( boost::find_if( |
| 56 | make_adaptive_time_range( stepper, rhs, x, 0.0, 1.0, 0.01 ), |
| 57 | pred ) ); |
| 58 | |
| 59 | } |
| 60 | |
| 61 | static bool pred( const std::pair< const state_type &, double > &x ) |
| 62 | { |
| 63 | return ( x.first[0] < 0.0 ); |
| 64 | } |
| 65 | |
| 66 | template<class Iterator> |
| 67 | void print( Iterator iter ) |
| 68 | { |
| 69 | std::cout << iter->second << "\t" << iter->first[0] << "\t" |
| 70 | << iter->first[1] << "\t" << iter->first[2] << "\n"; |
| 71 | } |
| 72 | }; |
| 73 | |
| 74 | typedef mpl::vector< |
| 75 | euler< state_type > , |
| 76 | runge_kutta4< state_type > , |
| 77 | runge_kutta_cash_karp54< state_type > , |
| 78 | runge_kutta_dopri5< state_type > , |
| 79 | runge_kutta_fehlberg78< state_type > , |
| 80 | bulirsch_stoer< state_type > |
| 81 | > steppers; |
| 82 | |
| 83 | |
| 84 | BOOST_AUTO_TEST_SUITE( regression_147_test ) |
| 85 | |
| 86 | BOOST_AUTO_TEST_CASE_TEMPLATE( regression_147_test , Stepper, |
| 87 | steppers ) |
| 88 | { |
| 89 | perform_test< Stepper > tester; |
| 90 | tester(); |
| 91 | } |
| 92 | |
| 93 | BOOST_AUTO_TEST_SUITE_END() |