File indexing completed on 2025-01-18 09:42:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_CALL_ALGEBRA_HPP_INCLUDED
0019 #define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_CALL_ALGEBRA_HPP_INCLUDED
0020
0021 #include <boost/assert.hpp>
0022
0023
0024 namespace boost {
0025 namespace numeric {
0026 namespace odeint {
0027 namespace detail {
0028
0029 template< size_t Step , class Algebra , class Operations >
0030 struct adams_bashforth_call_algebra;
0031
0032 template< class Algebra , class Operations >
0033 struct adams_bashforth_call_algebra< 1 , Algebra , Operations >
0034 {
0035 template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
0036 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
0037 {
0038 typedef typename Coefficients::value_type value_type;
0039 algebra.for_each3( out , in , steps[0].m_v , typename Operations::template scale_sum2< value_type , Time >( 1.0 , dt * coef[0] ) );
0040 }
0041 };
0042
0043
0044 template< class Algebra , class Operations >
0045 struct adams_bashforth_call_algebra< 2 , Algebra , Operations >
0046 {
0047 template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
0048 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
0049 {
0050 typedef typename Coefficients::value_type value_type;
0051 algebra.for_each4( out , in , steps[0].m_v , steps[1].m_v ,
0052 typename Operations::template scale_sum3< value_type , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] ) );
0053 }
0054 };
0055
0056
0057 template< class Algebra , class Operations >
0058 struct adams_bashforth_call_algebra< 3 , Algebra , Operations >
0059 {
0060 template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
0061 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
0062 {
0063 typedef typename Coefficients::value_type value_type;
0064 algebra.for_each5( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v ,
0065 typename Operations::template scale_sum4< value_type , Time , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] ) );
0066 }
0067 };
0068
0069
0070 template< class Algebra , class Operations >
0071 struct adams_bashforth_call_algebra< 4 , Algebra , Operations >
0072 {
0073 template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
0074 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
0075 {
0076 typedef typename Coefficients::value_type value_type;
0077 algebra.for_each6( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v ,
0078 typename Operations::template scale_sum5< value_type , Time , Time , Time >(
0079 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] ) );
0080 }
0081 };
0082
0083
0084 template< class Algebra , class Operations >
0085 struct adams_bashforth_call_algebra< 5 , Algebra , Operations >
0086 {
0087 template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
0088 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
0089 {
0090 typedef typename Coefficients::value_type value_type;
0091 algebra.for_each7( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v ,
0092 typename Operations::template scale_sum6< value_type , Time , Time , Time , Time >(
0093 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] ) );
0094 }
0095 };
0096
0097
0098 template< class Algebra , class Operations >
0099 struct adams_bashforth_call_algebra< 6 , Algebra , Operations >
0100 {
0101 template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
0102 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
0103 {
0104 typedef typename Coefficients::value_type value_type;
0105 algebra.for_each8( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v , steps[5].m_v ,
0106 typename Operations::template scale_sum7< value_type , Time , Time , Time , Time , Time >(
0107 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] ) );
0108 }
0109 };
0110
0111
0112 template< class Algebra , class Operations >
0113 struct adams_bashforth_call_algebra< 7 , Algebra , Operations >
0114 {
0115 template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
0116 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
0117 {
0118
0119 typedef typename Coefficients::value_type value_type;
0120 algebra.for_each9( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v , steps[5].m_v , steps[6].m_v ,
0121 typename Operations::template scale_sum8< value_type , Time , Time , Time , Time , Time , Time >(
0122 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] , dt * coef[6] ) );
0123 }
0124 };
0125
0126
0127 template< class Algebra , class Operations >
0128 struct adams_bashforth_call_algebra< 8 , Algebra , Operations >
0129 {
0130 template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
0131 void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
0132 {
0133
0134 typedef typename Coefficients::value_type value_type;
0135 algebra.for_each10( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v , steps[5].m_v , steps[6].m_v , steps[7].m_v ,
0136 typename Operations::template scale_sum9< value_type , Time , Time , Time , Time , Time , Time , Time >(
0137 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] , dt * coef[6] , dt * coef[7] ) );
0138 }
0139 };
0140
0141
0142
0143
0144 }
0145 }
0146 }
0147 }
0148
0149
0150
0151 #endif