File: resizing.cpp

package info (click to toggle)
boost1.83 1.83.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 545,632 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (110 lines) | stat: -rw-r--r-- 4,356 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 [auto_generated]
 libs/numeric/odeint/test/resizing.cpp

 [begin_description]
 This file tests the resizing mechanism of odeint.
 [end_description]

 Copyright 2010-2012 Karsten Ahnert
 Copyright 2010-2012 Mario Mulansky

 Distributed under the Boost Software License, Version 1.0.
 (See accompanying file LICENSE_1_0.txt or
 copy at http://www.boost.org/LICENSE_1_0.txt)
 */

// disable checked iterator warning for msvc
#include <boost/config.hpp>
#ifdef BOOST_MSVC
    #pragma warning(disable:4996)
#endif

#define BOOST_TEST_MODULE odeint_resize

#include <vector>
#include <cmath>

#include <boost/array.hpp>
#include <boost/bind.hpp>
#include <boost/utility.hpp>
#include <boost/type_traits/integral_constant.hpp>

#include <boost/test/unit_test.hpp>

#include <boost/mpl/vector.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/at.hpp>

#include <boost/numeric/odeint/stepper/euler.hpp>
#include <boost/numeric/odeint/stepper/runge_kutta4_classic.hpp>
#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>

#include <boost/numeric/odeint/util/resizer.hpp>
#include <boost/numeric/odeint/util/is_resizeable.hpp>

#include "resizing_test_state_type.hpp"

using namespace boost::unit_test;
using namespace boost::numeric::odeint;

namespace mpl = boost::mpl;






void constant_system( const test_array_type &x , test_array_type &dxdt , double t ) { dxdt[0] = 1.0; }


BOOST_AUTO_TEST_SUITE( check_resize_test )


typedef euler< test_array_type , double , test_array_type , double , range_algebra , default_operations , never_resizer > euler_manual_type;
typedef euler< test_array_type , double , test_array_type , double , range_algebra , default_operations , initially_resizer > euler_initially_type;
typedef euler< test_array_type , double , test_array_type , double , range_algebra , default_operations , always_resizer > euler_always_type;

typedef runge_kutta4_classic< test_array_type , double , test_array_type , double , range_algebra , default_operations , never_resizer > rk4_manual_type;
typedef runge_kutta4_classic< test_array_type , double , test_array_type , double , range_algebra , default_operations , initially_resizer > rk4_initially_type;
typedef runge_kutta4_classic< test_array_type , double , test_array_type , double , range_algebra , default_operations , always_resizer > rk4_always_type;


typedef runge_kutta4< test_array_type , double , test_array_type , double , range_algebra , default_operations , never_resizer > rk4_gen_manual_type;
typedef runge_kutta4< test_array_type , double , test_array_type , double , range_algebra , default_operations , initially_resizer > rk4_gen_initially_type;
typedef runge_kutta4< test_array_type , double , test_array_type , double , range_algebra , default_operations , always_resizer > rk4_gen_always_type;


typedef mpl::vector<
    mpl::vector< euler_manual_type , mpl::int_<1> , mpl::int_<0> > ,
    mpl::vector< euler_initially_type , mpl::int_<1> , mpl::int_<1> > ,
    mpl::vector< euler_always_type , mpl::int_<1> , mpl::int_<3> > ,
    mpl::vector< rk4_manual_type , mpl::int_<5> , mpl::int_<0> > ,
    mpl::vector< rk4_initially_type , mpl::int_<5> , mpl::int_<1> > ,
    mpl::vector< rk4_always_type , mpl::int_<5> , mpl::int_<3> > ,
    mpl::vector< rk4_gen_manual_type , mpl::int_<5> , mpl::int_<0> > ,
    mpl::vector< rk4_gen_initially_type , mpl::int_<5> , mpl::int_<1> > ,
    mpl::vector< rk4_gen_always_type , mpl::int_<5> , mpl::int_<3> >
    >::type resize_check_types;


BOOST_AUTO_TEST_CASE_TEMPLATE( test_resize , T, resize_check_types )
{
    typedef typename mpl::at< T , mpl::int_< 0 > >::type stepper_type;
    const size_t resize_calls = mpl::at< T , mpl::int_< 1 > >::type::value;
    const size_t multiplicity = mpl::at< T , mpl::int_< 2 > >::type::value;
    adjust_size_count = 0;

    stepper_type stepper;
    test_array_type x;
    stepper.do_step( constant_system , x , 0.0 , 0.1 );
    stepper.do_step( constant_system , x , 0.0 , 0.1 );
    stepper.do_step( constant_system , x , 0.0 , 0.1 );

    BOOST_TEST_MESSAGE( "adjust_size_count : " << adjust_size_count );
    BOOST_CHECK_MESSAGE( adjust_size_count == resize_calls * multiplicity , "adjust_size_count : " << adjust_size_count << " expected: " << resize_calls * multiplicity );
}


BOOST_AUTO_TEST_SUITE_END()