1 | /* |
2 | [auto_generated] |
3 | libs/numeric/odeint/test/dummy_steppers.hpp |
4 | |
5 | [begin_description] |
6 | Dummy steppers for several tests. |
7 | [end_description] |
8 | |
9 | Copyright 2012 Karsten Ahnert |
10 | Copyright 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 | |
18 | #ifndef BOOST_LIBS_NUMERIC_ODEINT_TEST_DUMMY_STEPPER_HPP_INCLUDED |
19 | #define BOOST_LIBS_NUMERIC_ODEINT_TEST_DUMMY_STEPPER_HPP_INCLUDED |
20 | |
21 | #include <array> |
22 | #include <boost/numeric/odeint/stepper/stepper_categories.hpp> |
23 | #include <boost/numeric/odeint/stepper/controlled_step_result.hpp> |
24 | |
25 | namespace boost { |
26 | namespace numeric { |
27 | namespace odeint { |
28 | |
29 | struct dummy_stepper |
30 | { |
31 | typedef double value_type; |
32 | typedef value_type time_type; |
33 | typedef std::array< value_type , 1 > state_type; |
34 | typedef state_type deriv_type; |
35 | typedef unsigned short order_type; |
36 | typedef stepper_tag stepper_category; |
37 | |
38 | order_type order( void ) const { return 1; } |
39 | |
40 | template< class System > |
41 | void do_step( System sys , state_type &x , time_type t , time_type dt ) const |
42 | { |
43 | x[0] += 0.25; |
44 | } |
45 | }; |
46 | |
47 | struct dummy_dense_output_stepper |
48 | { |
49 | typedef double value_type; |
50 | typedef value_type time_type; |
51 | typedef std::array< value_type , 1 > state_type; |
52 | typedef state_type deriv_type; |
53 | typedef dense_output_stepper_tag stepper_category; |
54 | |
55 | void initialize( const state_type &x0 , time_type t0 , time_type dt0 ) |
56 | { |
57 | m_x = x0; |
58 | m_t = t0; |
59 | m_dt = dt0; |
60 | } |
61 | |
62 | template< class System > |
63 | std::pair< time_type , time_type > do_step( System sys ) |
64 | { |
65 | m_x[0] += 0.25; |
66 | m_t += m_dt; |
67 | return std::make_pair( x: m_t - m_dt , y&: m_t ); |
68 | } |
69 | |
70 | void calc_state( time_type t_inter , state_type &x ) const |
71 | { |
72 | value_type theta = ( m_t - t_inter ) / m_dt; |
73 | x[0] = m_x[0] - 0.25 * theta; |
74 | |
75 | } |
76 | |
77 | const time_type& current_time( void ) const |
78 | { |
79 | return m_t; |
80 | } |
81 | |
82 | const state_type& current_state( void ) const |
83 | { |
84 | return m_x; |
85 | } |
86 | |
87 | const time_type& current_time_step( void ) const |
88 | { |
89 | return m_dt; |
90 | } |
91 | |
92 | state_type m_x; |
93 | time_type m_t; |
94 | time_type m_dt; |
95 | }; |
96 | |
97 | |
98 | |
99 | struct dummy_controlled_stepper |
100 | { |
101 | typedef double value_type; |
102 | typedef value_type time_type; |
103 | typedef std::array< value_type , 1 > state_type; |
104 | typedef state_type deriv_type; |
105 | typedef controlled_stepper_tag stepper_category; |
106 | |
107 | template< class Sys > |
108 | controlled_step_result try_step( Sys sys , state_type &x , time_type &t , time_type &dt ) const |
109 | { |
110 | x[0] += 0.25; |
111 | t += dt; |
112 | return success; |
113 | } |
114 | }; |
115 | |
116 | |
117 | } // odeint |
118 | } // numeric |
119 | } // boost |
120 | |
121 | |
122 | #endif // BOOST_LIBS_NUMERIC_ODEINT_TEST_DUMMY_STEPPER_HPP_INCLUDED |
123 | |