Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / numeric / odeint / performance / odeint_rk4_lorenz_array.cpp
1 /*
2  * odeint_rk4_lorenz.cpp
3  *
4  * Copyright 2011-2012 Mario Mulansky
5  * Copyright 2012 Karsten Ahnert
6  *
7  * Distributed under the Boost Software License, Version 1.0.
8  * (See accompanying file LICENSE_1_0.txt or
9  * copy at http://www.boost.org/LICENSE_1_0.txt)
10  */
11
12
13 #include <boost/array.hpp>
14
15 #include <boost/numeric/odeint/stepper/runge_kutta4_classic.hpp>
16 #include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
17 #include <boost/numeric/odeint/algebra/array_algebra.hpp>
18
19 #include "rk_performance_test_case.hpp"
20
21 #include "lorenz.hpp"
22
23 typedef boost::array< double , 3 > state_type;
24 typedef boost::numeric::odeint::runge_kutta4< state_type , double , state_type , double ,
25                                               boost::numeric::odeint::array_algebra > rk4_odeint_type;
26
27
28 class odeint_wrapper
29 {
30 public:
31     void reset_init_cond()
32     {
33         /* random */
34         /*
35         m_x[0] = 10.0 * rand() / RAND_MAX;
36         m_x[1] = 10.0 * rand() / RAND_MAX;
37         m_x[2] = 10.0 * rand() / RAND_MAX;
38         */
39         /* hand chosen random (cf fortran) */
40         m_x[0] = 8.5;
41         m_x[1] = 3.1;
42         m_x[2] = 1.2;
43
44         m_t = 0.0;
45     }
46
47     inline void do_step( const double dt )
48     {
49         m_stepper.do_step( lorenz() , m_x , m_t , dt );
50         //m_t += dt;
51     }
52
53     double state( const size_t i ) const
54     { return m_x[i]; }
55
56 private:
57     state_type m_x;
58     double m_t;
59     rk4_odeint_type m_stepper;
60 };
61
62
63
64 int main()
65 {
66     srand( 12312354 );
67
68     odeint_wrapper stepper;
69
70     run( stepper );
71 }