1/*
2
3 [begin_description]
4 Test case for issue 147
5 [end_description]
6
7 Copyright 2011-2015 Karsten Ahnert
8 Copyright 2011-2015 Mario Mulansky
9
10 Distributed under the Boost Software License, Version 1.0.
11 (See accompanying file LICENSE_1_0.txt or
12 copy at http://www.boost.org/LICENSE_1_0.txt)
13 */
14
15
16// disable checked iterator warning for msvc
17
18#include <boost/config.hpp>
19#ifdef BOOST_MSVC
20 #pragma warning(disable:4996)
21#endif
22
23#define BOOST_TEST_MODULE odeint_regression_147
24
25#include <utility>
26
27#include <boost/array.hpp>
28
29#include <boost/test/unit_test.hpp>
30
31#include <boost/mpl/vector.hpp>
32
33#include <boost/numeric/odeint.hpp>
34
35using namespace boost::unit_test;
36using namespace boost::numeric::odeint;
37namespace mpl = boost::mpl;
38
39typedef double state_type;
40
41void rhs( const state_type &x , state_type &dxdt , const double t )
42{
43 dxdt = 1;
44}
45
46
47template<class Stepper, class InitStepper>
48struct perform_init_test
49{
50 void operator()( void )
51 {
52 double t = 0;
53 const double dt = 0.1;
54
55 state_type x = 0;
56
57 Stepper stepper;
58 InitStepper init_stepper;
59 stepper.initialize( init_stepper, rhs, x, t, dt );
60
61 // ab-stepper needs order-1 init steps: t and x should be (order-1)*dt
62 BOOST_CHECK_CLOSE( t , (stepper.order()-1)*dt , 1E-16 );
63 BOOST_CHECK_CLOSE( x, ( stepper.order() - 1 ) * dt, 2E-14 );
64 }
65};
66
67typedef mpl::vector<
68 euler< state_type > ,
69 modified_midpoint< state_type > ,
70 runge_kutta4< state_type > ,
71 runge_kutta4_classic< state_type > ,
72 runge_kutta_cash_karp54_classic< state_type > ,
73 runge_kutta_cash_karp54< state_type > ,
74 runge_kutta_dopri5< state_type > ,
75 runge_kutta_fehlberg78< state_type >
76 > runge_kutta_steppers;
77
78
79BOOST_AUTO_TEST_SUITE( regression_147_test )
80
81BOOST_AUTO_TEST_CASE_TEMPLATE( init_test , InitStepper,
82 runge_kutta_steppers )
83{
84 perform_init_test< adams_bashforth<4, state_type>, InitStepper > tester;
85 tester();
86}
87
88BOOST_AUTO_TEST_SUITE_END()
89

source code of boost/libs/numeric/odeint/test/regression/regression_147.cpp