Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / numeric / odeint / test / adams_moulton.cpp
1 /*
2  [auto_generated]
3  libs/numeric/odeint/test/adams_moulton.cpp
4
5  [begin_description]
6  This file tests the use of the Adams-Moulton stepper.
7  [end_description]
8
9  Copyright 2011-2012 Karsten Ahnert
10  Copyright 2011-2012 Mario Mulansky
11
12  Distributed under the Boost Software License, Version 1.0.
13  (See accompanying file LICENSE_1_0.txt or
14  copy at http://www.boost.org/LICENSE_1_0.txt)
15  */
16
17
18 #define BOOST_TEST_MODULE odeint_adams_moulton
19
20 #include <utility>
21
22 #include <boost/array.hpp>
23
24 #include <boost/test/unit_test.hpp>
25
26 #include <boost/mpl/list.hpp>
27 #include <boost/mpl/size_t.hpp>
28 #include <boost/mpl/range_c.hpp>
29
30
31 #include <boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp>
32 #include <boost/numeric/odeint/stepper/detail/rotating_buffer.hpp>
33 #include <boost/numeric/odeint/stepper/adams_moulton.hpp>
34
35 using namespace boost::unit_test;
36 using namespace boost::numeric::odeint;
37
38 typedef double value_type;
39
40 struct lorenz
41 {
42     template< class State , class Deriv , class Value >
43     void operator()( const State &_x , Deriv &_dxdt , const Value &dt ) const
44     {
45         const value_type sigma = 10.0;
46         const value_type R = 28.0;
47         const value_type b = 8.0 / 3.0;
48
49         typename boost::range_iterator< const State >::type x = boost::begin( _x );
50         typename boost::range_iterator< Deriv >::type dxdt = boost::begin( _dxdt );
51
52         dxdt[0] = sigma * ( x[1] - x[0] );
53         dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
54         dxdt[2] = x[0]*x[1] - b * x[2];
55     }
56 };
57
58 BOOST_AUTO_TEST_SUITE( adams_moulton_test )
59
60 BOOST_AUTO_TEST_CASE( test_adams_moulton_coefficients )
61 {
62     detail::adams_moulton_coefficients< value_type , 1 > c1;
63     detail::adams_moulton_coefficients< value_type , 2 > c2;
64     detail::adams_moulton_coefficients< value_type , 3 > c3;
65     detail::adams_moulton_coefficients< value_type , 4 > c4;
66     detail::adams_moulton_coefficients< value_type , 5 > c5;
67     detail::adams_moulton_coefficients< value_type , 6 > c6;
68     detail::adams_moulton_coefficients< value_type , 7 > c7;
69     detail::adams_moulton_coefficients< value_type , 8 > c8;
70 }
71
72 typedef boost::mpl::range_c< size_t , 1 , 6 > vector_of_steps;
73
74 BOOST_AUTO_TEST_CASE_TEMPLATE( test_init_and_steps , step_type , vector_of_steps )
75 {
76     const static size_t steps = step_type::value;
77     typedef boost::array< value_type , 3 > state_type;
78
79     adams_moulton< steps , state_type > stepper;
80 //    state_type x = {{ 10.0 , 10.0 , 10.0 }};
81 //    const value_type dt = 0.01;
82 //    value_type t = 0.0;
83
84 //    stepper.do_step( lorenz() , x , t , dt );
85 }
86
87 BOOST_AUTO_TEST_CASE( test_instantiation )
88 {
89     typedef boost::array< double , 3 > state_type;
90     adams_moulton< 1 , state_type > s1;
91     adams_moulton< 2 , state_type > s2;
92     adams_moulton< 3 , state_type > s3;
93     adams_moulton< 4 , state_type > s4;
94     adams_moulton< 5 , state_type > s5;
95     adams_moulton< 6 , state_type > s6;
96     adams_moulton< 7 , state_type > s7;
97     adams_moulton< 8 , state_type > s8;
98
99 //    state_type x = {{ 10.0 , 10.0 , 10.0 }};
100 //    value_type t = 0.0 , dt = 0.01;
101 }
102
103
104 BOOST_AUTO_TEST_SUITE_END()