blob: c4054fd15ea919f1e001589a9be3d12de90da62a [file] [log] [blame]
Brian Silverman7c33ab22018-08-04 17:14:51 -07001/*
2 [auto_generated]
3 libs/numeric/odeint/test_external/eigen/runge_kutta4.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_kutta4.hpp>
28#include <boost/numeric/odeint/external/eigen/eigen_resize.hpp>
29
30using namespace boost::unit_test;
31using namespace boost::numeric::odeint;
32
33struct sys
34{
35 template< class State , class Deriv >
36 void operator()( const State &x , Deriv &dxdt , double t ) const
37 {
38 dxdt[0] = 1.0;
39 }
40};
41
42
43BOOST_AUTO_TEST_SUITE( eigen_runge_kutta4 )
44
45BOOST_AUTO_TEST_CASE( compile_time_matrix )
46{
47 typedef Eigen::Matrix< double , 1 , 1 > state_type;
48 state_type x;
49 x[0] = 10.0;
50 runge_kutta4< state_type , double , state_type , double , vector_space_algebra > rk4;
51 rk4.do_step( sys() , x , 0.0 , 0.1 );
52 BOOST_CHECK_CLOSE( x[0] , 10.1 , 1.0e-13 );
53
54}
55
56BOOST_AUTO_TEST_CASE( runtime_matrix )
57{
58 typedef Eigen::Matrix< double , Eigen::Dynamic , 1 > state_type;
59 state_type x( 1 );
60 x[0] = 10.0;
61 runge_kutta4< state_type , double , state_type , double , vector_space_algebra > rk4;
62 rk4.do_step( sys() , x , 0.0 , 0.1 );
63 BOOST_CHECK_CLOSE( x[0] , 10.1 , 1.0e-13 );
64}
65
66
67
68
69
70
71BOOST_AUTO_TEST_CASE( compile_time_array )
72{
73 typedef Eigen::Array< double , 1 , 1 > state_type;
74 state_type x;
75 x[0] = 10.0;
76 runge_kutta4< state_type , double , state_type , double , vector_space_algebra > rk4;
77 rk4.do_step( sys() , x , 0.0 , 0.1 );
78 BOOST_CHECK_CLOSE( x[0] , 10.1 , 1.0e-13 );
79
80}
81
82BOOST_AUTO_TEST_CASE( runtime_array )
83{
84 typedef Eigen::Array< double , Eigen::Dynamic , 1 > state_type;
85 state_type x( 1 );
86 x[0] = 10.0;
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
93
94BOOST_AUTO_TEST_SUITE_END()