]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/numeric/odeint/include/boost/numeric/odeint/stepper/adams_moulton.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / numeric / odeint / include / boost / numeric / odeint / stepper / adams_moulton.hpp
CommitLineData
7c673cae
FG
1/*
2 [auto_generated]
3 boost/numeric/odeint/stepper/adams_moulton.hpp
4
5 [begin_description]
6 Implementation of the Adams-Moulton method. This is method is not a real stepper, it is more a helper class
7 which computes the corrector step in the Adams-Bashforth-Moulton method.
8 [end_description]
9
10 Copyright 2011-2012 Karsten Ahnert
11 Copyright 2011-2013 Mario Mulansky
12 Copyright 2012 Christoph Koke
13
14 Distributed under the Boost Software License, Version 1.0.
15 (See accompanying file LICENSE_1_0.txt or
16 copy at http://www.boost.org/LICENSE_1_0.txt)
17 */
18
19
20#ifndef BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED
21#define BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED
22
23
24#include <boost/numeric/odeint/util/bind.hpp>
25
26#include <boost/numeric/odeint/algebra/range_algebra.hpp>
27#include <boost/numeric/odeint/algebra/default_operations.hpp>
28#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
29#include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
30
31#include <boost/numeric/odeint/util/state_wrapper.hpp>
32#include <boost/numeric/odeint/util/is_resizeable.hpp>
33#include <boost/numeric/odeint/util/resizer.hpp>
34
35#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
36#include <boost/numeric/odeint/stepper/runge_kutta4_classic.hpp>
37
38#include <boost/numeric/odeint/stepper/detail/adams_moulton_call_algebra.hpp>
39#include <boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp>
40#include <boost/numeric/odeint/stepper/detail/rotating_buffer.hpp>
41
42
43
44
45namespace boost {
46namespace numeric {
47namespace odeint {
48
49
50/*
51 * Static implicit Adams-Moulton multistep-solver without step size control and without dense output.
52 */
53template<
54size_t Steps ,
55class State ,
56class Value = double ,
57class Deriv = State ,
58class Time = Value ,
59class Algebra = typename algebra_dispatcher< State >::algebra_type ,
60class Operations = typename operations_dispatcher< State >::operations_type ,
61class Resizer = initially_resizer
62>
63class adams_moulton
64{
65private:
66
67
68public :
69
70 typedef State state_type;
71 typedef state_wrapper< state_type > wrapped_state_type;
72 typedef Value value_type;
73 typedef Deriv deriv_type;
74 typedef state_wrapper< deriv_type > wrapped_deriv_type;
75 typedef Time time_type;
76 typedef Algebra algebra_type;
77 typedef Operations operations_type;
78 typedef Resizer resizer_type;
79 typedef stepper_tag stepper_category;
80
81 typedef adams_moulton< Steps , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_type;
82
83 static const size_t steps = Steps;
84
85 typedef unsigned short order_type;
86 static const order_type order_value = steps + 1;
87
88 typedef detail::rotating_buffer< wrapped_deriv_type , steps > step_storage_type;
89
90 adams_moulton( )
91 : m_coefficients() , m_dxdt() , m_resizer() ,
92 m_algebra_instance() , m_algebra( m_algebra_instance )
93 { }
94
95 adams_moulton( algebra_type &algebra )
96 : m_coefficients() , m_dxdt() , m_resizer() ,
97 m_algebra_instance() , m_algebra( algebra )
98 { }
99
100 adams_moulton& operator=( const adams_moulton &stepper )
101 {
102 m_dxdt = stepper.m_dxdt;
103 m_resizer = stepper.m_resizer;
104 m_algebra = stepper.m_algebra;
105 return *this;
106 }
107
108 order_type order( void ) const { return order_value; }
109
110
111 /*
112 * Version 1 : do_step( system , x , t , dt , buf );
113 *
114 * solves the forwarding problem
115 */
116 template< class System , class StateInOut , class StateIn , class ABBuf >
117 void do_step( System system , StateInOut &x , StateIn const & pred , time_type t , time_type dt , const ABBuf &buf )
118 {
119 do_step( system , x , pred , t , x , dt , buf );
120 }
121
122 template< class System , class StateInOut , class StateIn , class ABBuf >
123 void do_step( System system , const StateInOut &x , StateIn const & pred , time_type t , time_type dt , const ABBuf &buf )
124 {
125 do_step( system , x , pred , t , x , dt , buf );
126 }
127
128
129
130 /*
131 * Version 2 : do_step( system , in , t , out , dt , buf );
132 *
133 * solves the forwarding problem
134 */
135 template< class System , class StateIn , class PredIn , class StateOut , class ABBuf >
136 void do_step( System system , const StateIn &in , const PredIn &pred , time_type t , StateOut &out , time_type dt , const ABBuf &buf )
137 {
138 do_step_impl( system , in , pred , t , out , dt , buf );
139 }
140
141 template< class System , class StateIn , class PredIn , class StateOut , class ABBuf >
142 void do_step( System system , const StateIn &in , const PredIn &pred , time_type t , const StateOut &out , time_type dt , const ABBuf &buf )
143 {
144 do_step_impl( system , in , pred , t , out , dt , buf );
145 }
146
147
148
149 template< class StateType >
150 void adjust_size( const StateType &x )
151 {
152 resize_impl( x );
153 }
154
155 algebra_type& algebra()
156 { return m_algebra; }
157
158 const algebra_type& algebra() const
159 { return m_algebra; }
160
161
162private:
163
164
165 template< class System , class StateIn , class PredIn , class StateOut , class ABBuf >
166 void do_step_impl( System system , const StateIn &in , const PredIn &pred , time_type t , StateOut &out , time_type dt , const ABBuf &buf )
167 {
168 typename odeint::unwrap_reference< System >::type &sys = system;
169 m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl<StateIn> , detail::ref( *this ) , detail::_1 ) );
170 sys( pred , m_dxdt.m_v , t );
171 detail::adams_moulton_call_algebra< steps , algebra_type , operations_type >()( m_algebra , in , out , m_dxdt.m_v , buf , m_coefficients , dt );
172 }
173
174
175 template< class StateIn >
176 bool resize_impl( const StateIn &x )
177 {
178 return adjust_size_by_resizeability( m_dxdt , x , typename is_resizeable<deriv_type>::type() );
179 }
180
181
182 const detail::adams_moulton_coefficients< value_type , steps > m_coefficients;
183 wrapped_deriv_type m_dxdt;
184 resizer_type m_resizer;
185
186protected:
187
188 algebra_type m_algebra_instance;
189 algebra_type &m_algebra;
190};
191
192
193
194
195} // odeint
196} // numeric
197} // boost
198
199
200
201#endif // BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED