annotate DEPENDENCIES/generic/include/boost/numeric/odeint/stepper/adams_moulton.hpp @ 16:2665513ce2d3

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