blob: 75179519522286f1d4bfa9c03e3b75d7237c4bb8 [file] [log] [blame]
Brian Silverman7c33ab22018-08-04 17:14:51 -07001/*
2 [auto_generated]
3 libs/numeric/odeint/test/resizing.cpp
4
5 [begin_description]
6 This file tests the resizing mechanism of odeint.
7 [end_description]
8
9 Copyright 2010-2012 Karsten Ahnert
10 Copyright 2010-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// disable checked iterator warning for msvc
18#include <boost/config.hpp>
19#ifdef BOOST_MSVC
20 #pragma warning(disable:4996)
21#endif
22
23#define BOOST_TEST_MODULE odeint_resize
24
25#include <vector>
26#include <cmath>
27
28#include <boost/array.hpp>
29#include <boost/bind.hpp>
30#include <boost/utility.hpp>
31#include <boost/type_traits/integral_constant.hpp>
32
33#include <boost/test/unit_test.hpp>
34
35#include <boost/mpl/vector.hpp>
36#include <boost/mpl/int.hpp>
37#include <boost/mpl/at.hpp>
38
39#include <boost/numeric/odeint/stepper/euler.hpp>
40#include <boost/numeric/odeint/stepper/runge_kutta4_classic.hpp>
41#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
42#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
43
44#include <boost/numeric/odeint/util/resizer.hpp>
45#include <boost/numeric/odeint/util/is_resizeable.hpp>
46
47#include "resizing_test_state_type.hpp"
48
49using namespace boost::unit_test;
50using namespace boost::numeric::odeint;
51
52namespace mpl = boost::mpl;
53
54
55
56
57
58
59void constant_system( const test_array_type &x , test_array_type &dxdt , double t ) { dxdt[0] = 1.0; }
60
61
62BOOST_AUTO_TEST_SUITE( check_resize_test )
63
64
65typedef euler< test_array_type , double , test_array_type , double , range_algebra , default_operations , never_resizer > euler_manual_type;
66typedef euler< test_array_type , double , test_array_type , double , range_algebra , default_operations , initially_resizer > euler_initially_type;
67typedef euler< test_array_type , double , test_array_type , double , range_algebra , default_operations , always_resizer > euler_always_type;
68
69typedef runge_kutta4_classic< test_array_type , double , test_array_type , double , range_algebra , default_operations , never_resizer > rk4_manual_type;
70typedef runge_kutta4_classic< test_array_type , double , test_array_type , double , range_algebra , default_operations , initially_resizer > rk4_initially_type;
71typedef runge_kutta4_classic< test_array_type , double , test_array_type , double , range_algebra , default_operations , always_resizer > rk4_always_type;
72
73
74typedef runge_kutta4< test_array_type , double , test_array_type , double , range_algebra , default_operations , never_resizer > rk4_gen_manual_type;
75typedef runge_kutta4< test_array_type , double , test_array_type , double , range_algebra , default_operations , initially_resizer > rk4_gen_initially_type;
76typedef runge_kutta4< test_array_type , double , test_array_type , double , range_algebra , default_operations , always_resizer > rk4_gen_always_type;
77
78
79typedef mpl::vector<
80 mpl::vector< euler_manual_type , mpl::int_<1> , mpl::int_<0> > ,
81 mpl::vector< euler_initially_type , mpl::int_<1> , mpl::int_<1> > ,
82 mpl::vector< euler_always_type , mpl::int_<1> , mpl::int_<3> > ,
83 mpl::vector< rk4_manual_type , mpl::int_<5> , mpl::int_<0> > ,
84 mpl::vector< rk4_initially_type , mpl::int_<5> , mpl::int_<1> > ,
85 mpl::vector< rk4_always_type , mpl::int_<5> , mpl::int_<3> > ,
86 mpl::vector< rk4_gen_manual_type , mpl::int_<5> , mpl::int_<0> > ,
87 mpl::vector< rk4_gen_initially_type , mpl::int_<5> , mpl::int_<1> > ,
88 mpl::vector< rk4_gen_always_type , mpl::int_<5> , mpl::int_<3> >
89 >::type resize_check_types;
90
91
92BOOST_AUTO_TEST_CASE_TEMPLATE( test_resize , T, resize_check_types )
93{
94 typedef typename mpl::at< T , mpl::int_< 0 > >::type stepper_type;
95 const size_t resize_calls = mpl::at< T , mpl::int_< 1 > >::type::value;
96 const size_t multiplicity = mpl::at< T , mpl::int_< 2 > >::type::value;
97 adjust_size_count = 0;
98
99 stepper_type stepper;
100 test_array_type x;
101 stepper.do_step( constant_system , x , 0.0 , 0.1 );
102 stepper.do_step( constant_system , x , 0.0 , 0.1 );
103 stepper.do_step( constant_system , x , 0.0 , 0.1 );
104
105 BOOST_TEST_MESSAGE( "adjust_size_count : " << adjust_size_count );
106 BOOST_CHECK_MESSAGE( adjust_size_count == resize_calls * multiplicity , "adjust_size_count : " << adjust_size_count << " expected: " << resize_calls * multiplicity );
107}
108
109
110BOOST_AUTO_TEST_SUITE_END()