1 /*
2 [auto_generated]
3 libs/numeric/odeint/test_external/eigen/runge_kutta_dopri5.cpp
4
5 [begin_description]
6 tba.
7 [end_description]
8
9 Copyright 2013 Karsten Ahnert
10 Copyright 2013 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 #include <boost/config.hpp>
18 #ifdef BOOST_MSVC
19 #pragma warning(disable:4996)
20 #endif
21
22 #define BOOST_TEST_MODULE odeint_eigen_runge_kutta4
23
24 #include <boost/test/unit_test.hpp>
25
26 #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
27 #include <boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp>
28 #include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
29 #include <boost/numeric/odeint/stepper/controlled_runge_kutta.hpp>
30 #include <boost/numeric/odeint/stepper/dense_output_runge_kutta.hpp>
31
32 // #include <boost/numeric/odeint/external/eigen/eigen_resize.hpp>
33 #include <boost/numeric/odeint/external/eigen/eigen_algebra.hpp>
34
35
36 using namespace boost::unit_test;
37 using namespace boost::numeric::odeint;
38
39 struct sys
40 {
41 template< class State , class Deriv >
operator ()sys42 void operator()( const State &x , Deriv &dxdt , double t ) const
43 {
44 dxdt[0] = 1.0;
45 }
46 };
47
48 template< class State >
49 struct stepper
50 {
51 typedef runge_kutta_dopri5< State , double , State , double , vector_space_algebra > type;
52 };
53
54 template< class State >
55 struct controlled_stepper
56 {
57 typedef controlled_runge_kutta< typename stepper< State >::type > type;
58 };
59
60 template< class State >
61 struct dense_output_stepper
62 {
63 typedef dense_output_runge_kutta< typename controlled_stepper< State >::type > type;
64 };
65
66
67
68
69 BOOST_AUTO_TEST_SUITE( eigen_runge_kutta_dopri5 )
70
BOOST_AUTO_TEST_CASE(compile_time_matrix)71 BOOST_AUTO_TEST_CASE( compile_time_matrix )
72 {
73 typedef Eigen::Matrix< double , 1 , 1 > state_type;
74 state_type x;
75 x[0] = 10.0;
76 double t = 0.0 , dt = 0.1 ;
77
78 // dense_output_stepper< state_type >::type s;
79 // s.initialize( x , t , dt );
80
81 // controlled_stepper< state_type >::type s;
82 // s.try_step( sys() , x , t , dt );
83
84 stepper< state_type >::type s;
85 s.do_step( sys() , x , t , dt );
86
87 // runge_kutta4< state_type , double , state_type , double , vector_space_algebra > rk4;
88 // rk4.do_step( sys() , x , 0.0 , 0.1 );
89 // BOOST_CHECK_CLOSE( x[0] , 10.1 , 1.0e-13 );
90
91 }
92
BOOST_AUTO_TEST_CASE(runtime_matrix)93 BOOST_AUTO_TEST_CASE( runtime_matrix )
94 {
95 typedef Eigen::Matrix< double , Eigen::Dynamic , 1 > state_type;
96 state_type x( 1 );
97 x[0] = 10.0;
98
99 // runge_kutta4< state_type , double , state_type , double , vector_space_algebra > rk4;
100 // rk4.do_step( sys() , x , 0.0 , 0.1 );
101 // BOOST_CHECK_CLOSE( x[0] , 10.1 , 1.0e-13 );
102 }
103
104
105
106
107
108
BOOST_AUTO_TEST_CASE(compile_time_array)109 BOOST_AUTO_TEST_CASE( compile_time_array )
110 {
111 typedef Eigen::Array< double , 1 , 1 > state_type;
112 state_type x;
113 x[0] = 10.0;
114 // runge_kutta4< state_type , double , state_type , double , vector_space_algebra > rk4;
115 // rk4.do_step( sys() , x , 0.0 , 0.1 );
116 // BOOST_CHECK_CLOSE( x[0] , 10.1 , 1.0e-13 );
117
118 }
119
BOOST_AUTO_TEST_CASE(runtime_array)120 BOOST_AUTO_TEST_CASE( runtime_array )
121 {
122 typedef Eigen::Array< double , Eigen::Dynamic , 1 > state_type;
123 state_type x( 1 );
124 x[0] = 10.0;
125 // runge_kutta4< state_type , double , state_type , double , vector_space_algebra > rk4;
126 // rk4.do_step( sys() , x , 0.0 , 0.1 );
127 // BOOST_CHECK_CLOSE( x[0] , 10.1 , 1.0e-13 );
128 }
129
130
131
132 BOOST_AUTO_TEST_SUITE_END()
133