This commit is contained in:
2026-03-23 20:54:41 +08:00
commit e13b3650e9
4596 changed files with 1015768 additions and 0 deletions

View File

@@ -0,0 +1,148 @@
/*
[auto_generated]
boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp
[begin_description]
Algebra caller for the Adams Bashforth stepper.
[end_description]
Copyright 2011-2012 Karsten Ahnert
Copyright 2011 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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_CALL_ALGEBRA_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_CALL_ALGEBRA_HPP_INCLUDED
#include <cstddef>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< size_t Step , class Algebra , class Operations >
struct adams_bashforth_call_algebra;
template< class Algebra , class Operations >
struct adams_bashforth_call_algebra< 1 , Algebra , Operations >
{
template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each3( out , in , steps[0].m_v , typename Operations::template scale_sum2< value_type , Time >( 1.0 , dt * coef[0] ) );
}
};
template< class Algebra , class Operations >
struct adams_bashforth_call_algebra< 2 , Algebra , Operations >
{
template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each4( out , in , steps[0].m_v , steps[1].m_v ,
typename Operations::template scale_sum3< value_type , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] ) );
}
};
template< class Algebra , class Operations >
struct adams_bashforth_call_algebra< 3 , Algebra , Operations >
{
template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each5( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v ,
typename Operations::template scale_sum4< value_type , Time , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] ) );
}
};
template< class Algebra , class Operations >
struct adams_bashforth_call_algebra< 4 , Algebra , Operations >
{
template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each6( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v ,
typename Operations::template scale_sum5< value_type , Time , Time , Time >(
1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] ) );
}
};
template< class Algebra , class Operations >
struct adams_bashforth_call_algebra< 5 , Algebra , Operations >
{
template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
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 ,
typename Operations::template scale_sum6< value_type , Time , Time , Time , Time >(
1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] ) );
}
};
template< class Algebra , class Operations >
struct adams_bashforth_call_algebra< 6 , Algebra , Operations >
{
template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
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 ,
typename Operations::template scale_sum7< value_type , Time , Time , Time , Time , Time >(
1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] ) );
}
};
template< class Algebra , class Operations >
struct adams_bashforth_call_algebra< 7 , Algebra , Operations >
{
template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
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 ,
typename Operations::template scale_sum8< value_type , Time , Time , Time , Time , Time , Time >(
1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] , dt * coef[6] ) );
}
};
template< class Algebra , class Operations >
struct adams_bashforth_call_algebra< 8 , Algebra , Operations >
{
template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
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 ,
typename Operations::template scale_sum9< value_type , Time , Time , Time , Time , Time , Time , Time >(
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] ) );
}
};
} // detail
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_CALL_ALGEBRA_HPP_INCLUDED

View File

@@ -0,0 +1,168 @@
/*
[auto_generated]
boost/numeric/odeint/stepper/detail/adams_bashforth_coefficients.hpp
[begin_description]
Definition of the coefficients for the Adams-Bashforth method.
[end_description]
Copyright 2011-2012 Karsten Ahnert
Copyright 2011-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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_COEFFICIENTS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_COEFFICIENTS_HPP_INCLUDED
#include <array>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< class Value , size_t Steps >
class adams_bashforth_coefficients ;
template< class Value >
class adams_bashforth_coefficients< Value , 1 > : public std::array< Value , 1 >
{
public:
adams_bashforth_coefficients( void )
: std::array< Value , 1 >()
{
(*this)[0] = static_cast< Value >( 1 );
}
};
template< class Value >
class adams_bashforth_coefficients< Value , 2 > : public std::array< Value , 2 >
{
public:
adams_bashforth_coefficients( void )
: std::array< Value , 2 >()
{
(*this)[0] = static_cast< Value >( 3 ) / static_cast< Value >( 2 );
(*this)[1] = -static_cast< Value >( 1 ) / static_cast< Value >( 2 );
}
};
template< class Value >
class adams_bashforth_coefficients< Value , 3 > : public std::array< Value , 3 >
{
public:
adams_bashforth_coefficients( void )
: std::array< Value , 3 >()
{
(*this)[0] = static_cast< Value >( 23 ) / static_cast< Value >( 12 );
(*this)[1] = -static_cast< Value >( 4 ) / static_cast< Value >( 3 );
(*this)[2] = static_cast< Value >( 5 ) / static_cast< Value >( 12 );
}
};
template< class Value >
class adams_bashforth_coefficients< Value , 4 > : public std::array< Value , 4 >
{
public:
adams_bashforth_coefficients( void )
: std::array< Value , 4 >()
{
(*this)[0] = static_cast< Value >( 55 ) / static_cast< Value >( 24 );
(*this)[1] = -static_cast< Value >( 59 ) / static_cast< Value >( 24 );
(*this)[2] = static_cast< Value >( 37 ) / static_cast< Value >( 24 );
(*this)[3] = -static_cast< Value >( 3 ) / static_cast< Value >( 8 );
}
};
template< class Value >
class adams_bashforth_coefficients< Value , 5 > : public std::array< Value , 5 >
{
public:
adams_bashforth_coefficients( void )
: std::array< Value , 5 >()
{
(*this)[0] = static_cast< Value >( 1901 ) / static_cast< Value >( 720 );
(*this)[1] = -static_cast< Value >( 1387 ) / static_cast< Value >( 360 );
(*this)[2] = static_cast< Value >( 109 ) / static_cast< Value >( 30 );
(*this)[3] = -static_cast< Value >( 637 ) / static_cast< Value >( 360 );
(*this)[4] = static_cast< Value >( 251 ) / static_cast< Value >( 720 );
}
};
template< class Value >
class adams_bashforth_coefficients< Value , 6 > : public std::array< Value , 6 >
{
public:
adams_bashforth_coefficients( void )
: std::array< Value , 6 >()
{
(*this)[0] = static_cast< Value >( 4277 ) / static_cast< Value >( 1440 );
(*this)[1] = -static_cast< Value >( 2641 ) / static_cast< Value >( 480 );
(*this)[2] = static_cast< Value >( 4991 ) / static_cast< Value >( 720 );
(*this)[3] = -static_cast< Value >( 3649 ) / static_cast< Value >( 720 );
(*this)[4] = static_cast< Value >( 959 ) / static_cast< Value >( 480 );
(*this)[5] = -static_cast< Value >( 95 ) / static_cast< Value >( 288 );
}
};
template< class Value >
class adams_bashforth_coefficients< Value , 7 > : public std::array< Value , 7 >
{
public:
adams_bashforth_coefficients( void )
: std::array< Value , 7 >()
{
(*this)[0] = static_cast< Value >( 198721 ) / static_cast< Value >( 60480 );
(*this)[1] = -static_cast< Value >( 18637 ) / static_cast< Value >( 2520 );
(*this)[2] = static_cast< Value >( 235183 ) / static_cast< Value >( 20160 );
(*this)[3] = -static_cast< Value >( 10754 ) / static_cast< Value >( 945 );
(*this)[4] = static_cast< Value >( 135713 ) / static_cast< Value >( 20160 );
(*this)[5] = -static_cast< Value >( 5603 ) / static_cast< Value >( 2520 );
(*this)[6] = static_cast< Value >( 19087 ) / static_cast< Value >( 60480 );
}
};
template< class Value >
class adams_bashforth_coefficients< Value , 8 > : public std::array< Value , 8 >
{
public:
adams_bashforth_coefficients( void )
: std::array< Value , 8 >()
{
(*this)[0] = static_cast< Value >( 16083 ) / static_cast< Value >( 4480 );
(*this)[1] = -static_cast< Value >( 1152169 ) / static_cast< Value >( 120960 );
(*this)[2] = static_cast< Value >( 242653 ) / static_cast< Value >( 13440 );
(*this)[3] = -static_cast< Value >( 296053 ) / static_cast< Value >( 13440 );
(*this)[4] = static_cast< Value >( 2102243 ) / static_cast< Value >( 120960 );
(*this)[5] = -static_cast< Value >( 115747 ) / static_cast< Value >( 13440 );
(*this)[6] = static_cast< Value >( 32863 ) / static_cast< Value >( 13440 );
(*this)[7] = -static_cast< Value >( 5257 ) / static_cast< Value >( 17280 );
}
};
} // detail
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_COEFFICIENTS_HPP_INCLUDED

View File

@@ -0,0 +1,148 @@
/*
[auto_generated]
boost/numeric/odeint/stepper/detail/adams_moulton_call_algebra.hpp
[begin_description]
Algebra caller for the Adams Moulton method.
[end_description]
Copyright 2011-2012 Karsten Ahnert
Copyright 2011 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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_MOULTON_CALL_ALGEBRA_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_MOULTON_CALL_ALGEBRA_HPP_INCLUDED
#include <cstddef>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< size_t Step , class Algebra , class Operations >
struct adams_moulton_call_algebra;
template< class Algebra , class Operations >
struct adams_moulton_call_algebra< 1 , Algebra , Operations >
{
template< class StateIn , class StateOut , class DerivIn , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage& /* steps */ , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each3( out , in , dxdt , typename Operations::template scale_sum2< value_type , Time >( 1.0 , dt * coef[0] ) );
}
};
template< class Algebra , class Operations >
struct adams_moulton_call_algebra< 2 , Algebra , Operations >
{
template< class StateIn , class StateOut , class DerivIn , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each4( out , in , dxdt , steps[0].m_v ,
typename Operations::template scale_sum3< value_type , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] ) );
}
};
template< class Algebra , class Operations >
struct adams_moulton_call_algebra< 3 , Algebra , Operations >
{
template< class StateIn , class StateOut , class DerivIn , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each5( out , in , dxdt , steps[0].m_v , steps[1].m_v ,
typename Operations::template scale_sum4< value_type , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] ) );
}
};
template< class Algebra , class Operations >
struct adams_moulton_call_algebra< 4 , Algebra , Operations >
{
template< class StateIn , class StateOut , class DerivIn , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each6( out , in , dxdt , steps[0].m_v , steps[1].m_v , steps[2].m_v ,
typename Operations::template scale_sum5< value_type , Time , Time , Time >(
1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] ) );
}
};
template< class Algebra , class Operations >
struct adams_moulton_call_algebra< 5 , Algebra , Operations >
{
template< class StateIn , class StateOut , class DerivIn , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each7( out , in , dxdt , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v ,
typename Operations::template scale_sum6< value_type , Time , Time , Time , Time >(
1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] ) );
}
};
template< class Algebra , class Operations >
struct adams_moulton_call_algebra< 6 , Algebra , Operations >
{
template< class StateIn , class StateOut , class DerivIn , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each8( out , in , dxdt , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v ,
typename Operations::template scale_sum7< value_type , Time , Time , Time , Time , Time >(
1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] ) );
}
};
template< class Algebra , class Operations >
struct adams_moulton_call_algebra< 7 , Algebra , Operations >
{
template< class StateIn , class StateOut , class DerivIn , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each9( out , in , dxdt , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v , steps[5].m_v ,
typename Operations::template scale_sum8< value_type , Time , Time , Time , Time , Time , Time >(
1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] , dt * coef[6] ) );
}
};
template< class Algebra , class Operations >
struct adams_moulton_call_algebra< 8 , Algebra , Operations >
{
template< class StateIn , class StateOut , class DerivIn , class StepStorage , class Coefficients , class Time >
void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage &steps , const Coefficients &coef , Time dt ) const
{
typedef typename Coefficients::value_type value_type;
algebra.for_each10( out , in , dxdt , 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 ,
typename Operations::template scale_sum9< value_type , Time , Time , Time , Time , Time , Time , Time >(
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] ) );
}
};
} // detail
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_MOULTON_CALL_ALGEBRA_HPP_INCLUDED

View File

@@ -0,0 +1,168 @@
/*
[auto_generated]
boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp
[begin_description]
Coefficients for the Adams Moulton method.
[end_description]
Copyright 2011-2012 Karsten Ahnert
Copyright 2011-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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_MOULTON_COEFFICIENTS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_MOULTON_COEFFICIENTS_HPP_INCLUDED
#include <array>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< class Value , size_t Steps >
class adams_moulton_coefficients ;
template< class Value >
class adams_moulton_coefficients< Value , 1 > : public std::array< Value , 1 >
{
public:
adams_moulton_coefficients( void )
: std::array< Value , 1 >()
{
(*this)[0] = static_cast< Value >( 1 );
}
};
template< class Value >
class adams_moulton_coefficients< Value , 2 > : public std::array< Value , 2 >
{
public:
adams_moulton_coefficients( void )
: std::array< Value , 2 >()
{
(*this)[0] = static_cast< Value >( 1 ) / static_cast< Value >( 2 );
(*this)[1] = static_cast< Value >( 1 ) / static_cast< Value >( 2 );
}
};
template< class Value >
class adams_moulton_coefficients< Value , 3 > : public std::array< Value , 3 >
{
public:
adams_moulton_coefficients( void )
: std::array< Value , 3 >()
{
(*this)[0] = static_cast< Value >( 5 ) / static_cast< Value >( 12 );
(*this)[1] = static_cast< Value >( 2 ) / static_cast< Value >( 3 );
(*this)[2] = -static_cast< Value >( 1 ) / static_cast< Value >( 12 );
}
};
template< class Value >
class adams_moulton_coefficients< Value , 4 > : public std::array< Value , 4 >
{
public:
adams_moulton_coefficients( void )
: std::array< Value , 4 >()
{
(*this)[0] = static_cast< Value >( 3 ) / static_cast< Value >( 8 );
(*this)[1] = static_cast< Value >( 19 ) / static_cast< Value >( 24 );
(*this)[2] = -static_cast< Value >( 5 ) / static_cast< Value >( 24 );
(*this)[3] = static_cast< Value >( 1 ) / static_cast< Value >( 24 );
}
};
template< class Value >
class adams_moulton_coefficients< Value , 5 > : public std::array< Value , 5 >
{
public:
adams_moulton_coefficients( void )
: std::array< Value , 5 >()
{
(*this)[0] = static_cast< Value >( 251 ) / static_cast< Value >( 720 );
(*this)[1] = static_cast< Value >( 323 ) / static_cast< Value >( 360 );
(*this)[2] = -static_cast< Value >( 11 ) / static_cast< Value >( 30 );
(*this)[3] = static_cast< Value >( 53 ) / static_cast< Value >( 360 );
(*this)[4] = -static_cast< Value >( 19 ) / static_cast< Value >( 720 );
}
};
template< class Value >
class adams_moulton_coefficients< Value , 6 > : public std::array< Value , 6 >
{
public:
adams_moulton_coefficients( void )
: std::array< Value , 6 >()
{
(*this)[0] = static_cast< Value >( 95 ) / static_cast< Value >( 288 );
(*this)[1] = static_cast< Value >( 1427 ) / static_cast< Value >( 1440 );
(*this)[2] = -static_cast< Value >( 133 ) / static_cast< Value >( 240 );
(*this)[3] = static_cast< Value >( 241 ) / static_cast< Value >( 720 );
(*this)[4] = -static_cast< Value >( 173 ) / static_cast< Value >( 1440 );
(*this)[5] = static_cast< Value >( 3 ) / static_cast< Value >( 160 );
}
};
template< class Value >
class adams_moulton_coefficients< Value , 7 > : public std::array< Value , 7 >
{
public:
adams_moulton_coefficients( void )
: std::array< Value , 7 >()
{
(*this)[0] = static_cast< Value >( 19087 ) / static_cast< Value >( 60480 );
(*this)[1] = static_cast< Value >( 2713 ) / static_cast< Value >( 2520 );
(*this)[2] = -static_cast< Value >( 15487 ) / static_cast< Value >( 20160 );
(*this)[3] = static_cast< Value >( 586 ) / static_cast< Value >( 945 );
(*this)[4] = -static_cast< Value >( 6737 ) / static_cast< Value >( 20160 );
(*this)[5] = static_cast< Value >( 263 ) / static_cast< Value >( 2520 );
(*this)[6] = -static_cast< Value >( 863 ) / static_cast< Value >( 60480 );
}
};
template< class Value >
class adams_moulton_coefficients< Value , 8 > : public std::array< Value , 8 >
{
public:
adams_moulton_coefficients( void )
: std::array< Value , 8 >()
{
(*this)[0] = static_cast< Value >( 5257 ) / static_cast< Value >( 17280 );
(*this)[1] = static_cast< Value >( 139849 ) / static_cast< Value >( 120960 );
(*this)[2] = -static_cast< Value >( 4511 ) / static_cast< Value >( 4480 );
(*this)[3] = static_cast< Value >( 123133 ) / static_cast< Value >( 120960 );
(*this)[4] = -static_cast< Value >( 88547 ) / static_cast< Value >( 120960 );
(*this)[5] = static_cast< Value >( 1537 ) / static_cast< Value >( 4480 );
(*this)[6] = -static_cast< Value >( 11351 ) / static_cast< Value >( 120960 );
(*this)[7] = static_cast< Value >( 275 ) / static_cast< Value >( 24192 );
}
};
} // detail
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_MOULTON_COEFFICIENTS_HPP_INCLUDED

View File

@@ -0,0 +1,207 @@
/*
boost/numeric/odeint/stepper/detail/adaptive_adams_coefficients.hpp
[begin_description]
Calculation of the coefficients for the adaptive adams stepper.
[end_description]
Copyright 2017 Valentin Noah Hartmann
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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAPTIVE_ADAMS_COEFFICIENTS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAPTIVE_ADAMS_COEFFICIENTS_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/detail/rotating_buffer.hpp>
#include <boost/numeric/odeint/util/state_wrapper.hpp>
#include <boost/numeric/odeint/util/is_resizeable.hpp>
#include <boost/numeric/odeint/util/resizer.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/util/bind.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
#include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
#include <array>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template<
size_t Steps,
class Deriv,
class Value = double,
class Time = double,
class Algebra = typename algebra_dispatcher< Deriv >::algebra_type,
class Operations = typename operations_dispatcher< Deriv >::operations_type,
class Resizer = initially_resizer
>
class adaptive_adams_coefficients
{
public:
static const size_t steps = Steps;
typedef unsigned short order_type;
static const order_type order_value = steps;
typedef Value value_type;
typedef Deriv deriv_type;
typedef Time time_type;
typedef state_wrapper< deriv_type > wrapped_deriv_type;
typedef rotating_buffer< time_type , steps+1 > time_storage_type;
typedef Algebra algebra_type;
typedef Operations operations_type;
typedef Resizer resizer_type;
typedef adaptive_adams_coefficients< Steps , Deriv , Value , Time , Algebra , Operations , Resizer > aac_type;
adaptive_adams_coefficients( const algebra_type &algebra = algebra_type())
:m_eo(1), m_steps_init(1), beta(), phi(), m_ns(0), m_time_storage(),
m_algebra(algebra),
m_phi_resizer()
{
for (size_t i=0; i<order_value+2; ++i)
{
c[i] = 1.0/(i+1);
c[c_size+i] = 1.0/((i+1)*(i+2));
}
g[0] = c[0];
g[1] = c[c_size];
beta[0][0] = 1;
beta[1][0] = 1;
gs[0] = 1.0;
gs[1] = -1.0/2;
gs[2] = -1.0/12;
gs[3] = -1.0/24;
gs[4] = -19.0/720;
gs[5] = -3.0/160;
gs[6] = -863.0/60480;
gs[7] = -275.0/24192;
gs[8] = -33953.0/3628800;
gs[9] = 35.0/4436;
gs[10] = 40.0/5891;
gs[11] = 37.0/6250;
gs[12] = 25.0/4771;
gs[13] = 40.0/8547;
};
void predict(time_type t, time_type dt)
{
using std::abs;
m_time_storage[0] = t;
if (abs(m_time_storage[0] - m_time_storage[1] - dt) > 1e-16 || m_eo >= m_ns)
{
m_ns = 0;
}
else if (m_ns < order_value + 2)
{
m_ns++;
}
for(size_t i=1+m_ns; i<m_eo+1 && i<m_steps_init; ++i)
{
time_type diff = m_time_storage[0] - m_time_storage[i];
beta[0][i] = beta[0][i-1]*(m_time_storage[0] + dt - m_time_storage[i-1])/diff;
}
for(size_t i=2+m_ns; i<m_eo+2 && i<m_steps_init+1; ++i)
{
time_type diff = m_time_storage[0] + dt - m_time_storage[i-1];
for(size_t j=0; j<m_eo+1-i+1; ++j)
{
c[c_size*i+j] = c[c_size*(i-1)+j] - c[c_size*(i-1)+j+1]*dt/diff;
}
g[i] = c[c_size*i];
}
};
void do_step(const deriv_type &dxdt, const int o = 0)
{
m_phi_resizer.adjust_size(dxdt, [this](auto&& arg) { return this->resize_phi_impl<deriv_type>(std::forward<decltype(arg)>(arg)); });
phi[o][0].m_v = dxdt;
for(size_t i=1; i<m_eo+3 && i<m_steps_init+2 && i<order_value+2; ++i)
{
if (o == 0)
{
this->m_algebra.for_each3(phi[o][i].m_v, phi[o][i-1].m_v, phi[o+1][i-1].m_v,
typename Operations::template scale_sum2<value_type, value_type>(1.0, -beta[o][i-1]));
}
else
{
this->m_algebra.for_each2(phi[o][i].m_v, phi[o][i-1].m_v,
typename Operations::template scale_sum1<value_type>(1.0));
}
}
};
void confirm()
{
beta.rotate();
phi.rotate();
m_time_storage.rotate();
if(m_steps_init < order_value+1)
{
++m_steps_init;
}
};
void reset() { m_eo = 1; m_steps_init = 1; };
size_t m_eo;
size_t m_steps_init;
rotating_buffer<std::array<value_type, order_value+1>, 2> beta; // beta[0] = beta(n)
rotating_buffer<std::array<wrapped_deriv_type, order_value+2>, 3> phi; // phi[0] = phi(n+1)
std::array<value_type, order_value + 2> g;
std::array<value_type, 14> gs;
private:
template< class StateType >
bool resize_phi_impl( const StateType &x )
{
bool resized( false );
for(size_t i=0; i<(order_value + 2); ++i)
{
resized |= adjust_size_by_resizeability( phi[0][i], x, typename is_resizeable<deriv_type>::type() );
resized |= adjust_size_by_resizeability( phi[1][i], x, typename is_resizeable<deriv_type>::type() );
resized |= adjust_size_by_resizeability( phi[2][i], x, typename is_resizeable<deriv_type>::type() );
}
return resized;
};
size_t m_ns;
time_storage_type m_time_storage;
static const size_t c_size = order_value + 2;
std::array<value_type, c_size*c_size> c;
algebra_type m_algebra;
resizer_type m_phi_resizer;
};
} // detail
} // odeint
} // numeric
} // boost
#endif

View File

@@ -0,0 +1,247 @@
/*
[auto_generated]
boost/numeric/odeint/stepper/detail/generic_rk_algorithm.hpp
[begin_description]
Implementation of the generic Runge-Kutta method.
[end_description]
Copyright 2011-2013 Mario Mulansky
Copyright 2011-2012 Karsten Ahnert
Copyright 2012 Christoph Koke
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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_GENERIC_RK_ALGORITHM_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_GENERIC_RK_ALGORITHM_HPP_INCLUDED
#include <boost/static_assert.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/copy.hpp>
#include <boost/mpl/size_t.hpp>
#include <boost/fusion/algorithm.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/fusion/sequence.hpp>
#include <array>
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
#include <boost/numeric/odeint/algebra/default_operations.hpp>
#include <boost/numeric/odeint/stepper/detail/generic_rk_call_algebra.hpp>
#include <boost/numeric/odeint/stepper/detail/generic_rk_operations.hpp>
#include <boost/numeric/odeint/util/bind.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< class T , class Constant >
struct array_wrapper
{
typedef const typename std::array< T , Constant::value > type;
};
template< class T , size_t i >
struct stage
{
T c;
std::array< T , i > a;
};
template< class T , class Constant >
struct stage_wrapper
{
typedef stage< T , Constant::value > type;
};
template<
size_t StageCount,
class Value ,
class Algebra ,
class Operations
>
class generic_rk_algorithm {
public:
typedef mpl::range_c< size_t , 1 , StageCount > stage_indices;
typedef typename boost::fusion::result_of::as_vector
<
typename boost::mpl::copy
<
stage_indices ,
boost::mpl::inserter
<
boost::mpl::vector0< > ,
boost::mpl::push_back< boost::mpl::_1 , array_wrapper< Value , boost::mpl::_2 > >
>
>::type
>::type coef_a_type;
typedef std::array< Value , StageCount > coef_b_type;
typedef std::array< Value , StageCount > coef_c_type;
typedef typename boost::fusion::result_of::as_vector
<
typename boost::mpl::push_back
<
typename boost::mpl::copy
<
stage_indices,
boost::mpl::inserter
<
boost::mpl::vector0<> ,
boost::mpl::push_back< boost::mpl::_1 , stage_wrapper< Value , boost::mpl::_2 > >
>
>::type ,
stage< Value , StageCount >
>::type
>::type stage_vector_base;
struct stage_vector : public stage_vector_base
{
struct do_insertion
{
stage_vector_base &m_base;
const coef_a_type &m_a;
const coef_c_type &m_c;
do_insertion( stage_vector_base &base , const coef_a_type &a , const coef_c_type &c )
: m_base( base ) , m_a( a ) , m_c( c ) { }
template< class Index >
void operator()( Index ) const
{
//boost::fusion::at< Index >( m_base ) = stage< double , Index::value+1 , intermediate_stage >( m_c[ Index::value ] , boost::fusion::at< Index >( m_a ) );
boost::fusion::at< Index >( m_base ).c = m_c[ Index::value ];
boost::fusion::at< Index >( m_base ).a = boost::fusion::at< Index >( m_a );
}
};
struct print_butcher
{
const stage_vector_base &m_base;
std::ostream &m_os;
print_butcher( const stage_vector_base &base , std::ostream &os )
: m_base( base ) , m_os( os )
{ }
template<class Index>
void operator()(Index) const {
m_os << boost::fusion::at<Index>(m_base).c << " | ";
for( size_t i=0 ; i<Index::value ; ++i )
m_os << boost::fusion::at<Index>(m_base).a[i] << " ";
m_os << std::endl;
}
};
stage_vector( const coef_a_type &a , const coef_b_type &b , const coef_c_type &c )
{
typedef boost::mpl::range_c< size_t , 0 , StageCount-1 > indices;
boost::mpl::for_each< indices >( do_insertion( *this , a , c ) );
boost::fusion::at_c< StageCount - 1 >( *this ).c = c[ StageCount - 1 ];
boost::fusion::at_c< StageCount - 1 >( *this ).a = b;
}
void print( std::ostream &os ) const
{
typedef boost::mpl::range_c< size_t , 0 , StageCount > indices;
boost::mpl::for_each< indices >( print_butcher( *this , os ) );
}
};
template< class System , class StateIn , class StateTemp , class DerivIn , class Deriv ,
class StateOut , class Time >
struct calculate_stage
{
Algebra &algebra;
System &system;
const StateIn &x;
StateTemp &x_tmp;
StateOut &x_out;
const DerivIn &dxdt;
Deriv *F;
Time t;
Time dt;
calculate_stage( Algebra &_algebra , System &_system , const StateIn &_x , const DerivIn &_dxdt , StateOut &_out ,
StateTemp &_x_tmp , Deriv *_F , Time _t , Time _dt )
: algebra( _algebra ) , system( _system ) , x( _x ) , x_tmp( _x_tmp ) , x_out( _out) , dxdt( _dxdt ) , F( _F ) , t( _t ) , dt( _dt )
{}
template< typename T , size_t stage_number >
void inline operator()( stage< T , stage_number > const &stage ) const
//typename stage_fusion_wrapper< T , mpl::size_t< stage_number > , intermediate_stage >::type const &stage ) const
{
if( stage_number > 1 )
{
#ifdef BOOST_MSVC
#pragma warning( disable : 4307 34 )
#endif
system( x_tmp , F[stage_number-2].m_v , t + stage.c * dt );
#ifdef BOOST_MSVC
#pragma warning( default : 4307 34 )
#endif
}
//std::cout << stage_number-2 << ", t': " << t + stage.c * dt << std::endl;
if( stage_number < StageCount )
detail::template generic_rk_call_algebra< stage_number , Algebra >()( algebra , x_tmp , x , dxdt , F ,
detail::generic_rk_scale_sum< stage_number , Operations , Value , Time >( stage.a , dt) );
// algebra_type::template for_eachn<stage_number>( x_tmp , x , dxdt , F ,
// typename operations_type::template scale_sumn< stage_number , time_type >( stage.a , dt ) );
else
detail::template generic_rk_call_algebra< stage_number , Algebra >()( algebra , x_out , x , dxdt , F ,
detail::generic_rk_scale_sum< stage_number , Operations , Value , Time >( stage.a , dt ) );
// algebra_type::template for_eachn<stage_number>( x_out , x , dxdt , F ,
// typename operations_type::template scale_sumn< stage_number , time_type >( stage.a , dt ) );
}
};
generic_rk_algorithm( const coef_a_type &a , const coef_b_type &b , const coef_c_type &c )
: m_stages( a , b , c )
{ }
template< class System , class StateIn , class DerivIn , class Time , class StateOut , class StateTemp , class Deriv >
void inline do_step( Algebra &algebra , System system , const StateIn &in , const DerivIn &dxdt ,
Time t , StateOut &out , Time dt ,
StateTemp &x_tmp , Deriv F[StageCount-1] ) const
{
typedef typename odeint::unwrap_reference< System >::type unwrapped_system_type;
unwrapped_system_type &sys = system;
boost::fusion::for_each( m_stages , calculate_stage<
unwrapped_system_type , StateIn , StateTemp , DerivIn , Deriv , StateOut , Time >
( algebra , sys , in , dxdt , out , x_tmp , F , t , dt ) );
}
private:
stage_vector m_stages;
};
}
}
}
}
#endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_GENERIC_RK_ALGORITHM_HPP_INCLUDED

View File

@@ -0,0 +1,263 @@
/*
[auto_generated]
boost/numeric/odeint/stepper/detail/generic_rk_call_algebra.hpp
[begin_description]
Algebra caller for the generic Runge-Kutta methods.
[end_description]
Copyright 2011-2012 Mario Mulansky
Copyright 2011-2012 Karsten Ahnert
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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_GENERIC_RK_CALL_ALGEBRA_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_GENERIC_RK_CALL_ALGEBRA_HPP_INCLUDED
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< size_t StageNumber , class Algebra >
struct generic_rk_call_algebra;
template< class Algebra >
struct generic_rk_call_algebra< 1 , Algebra >
{
typedef Algebra algebra_type;
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( algebra_type &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 * /* s4_array */ , Op op ) const
{
algebra.for_each3( s1 , s2 , s3 , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( algebra_type &algebra , S1 &s1 , S2 &s2 , S4 * /* s4_array */ , Op op ) const
{
algebra.for_each2( s1 , s2 , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 2 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[1] , Op op ) const
{
algebra.for_each4( s1 , s2 , s3 , s4_array[0].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[1] , Op op ) const
{
algebra.for_each3( s1 , s2 , s4_array[0].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 3 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[2] , Op op ) const
{
algebra.for_each5( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[2] , Op op ) const
{
algebra.for_each4( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 4 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[3] , Op op ) const
{
algebra.for_each6( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[3] , Op op ) const
{
algebra.for_each5( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 5 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[4] , Op op ) const
{
algebra.for_each7( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[4] , Op op ) const
{
algebra.for_each6( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 6 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[5] , Op op ) const
{
algebra.for_each8( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[5] , Op op ) const
{
algebra.for_each7( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 7 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[6] , Op op ) const
{
algebra.for_each9( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[6] , Op op ) const
{
algebra.for_each8( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 8 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[7] , Op op ) const
{
algebra.for_each10( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[7] , Op op ) const
{
algebra.for_each9( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 9 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[8] , Op op ) const
{
algebra.for_each11( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[8] , Op op ) const
{
algebra.for_each10( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 10 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[9] , Op op ) const
{
algebra.for_each12( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , s4_array[8].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[9] , Op op ) const
{
algebra.for_each11( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , s4_array[8].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 11 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[10] , Op op ) const
{
algebra.for_each13( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , s4_array[8].m_v , s4_array[9].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[10] , Op op ) const
{
algebra.for_each12( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , s4_array[8].m_v , s4_array[9].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 12 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[11] , Op op ) const
{
algebra.for_each14( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , s4_array[8].m_v , s4_array[9].m_v , s4_array[10].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[11] , Op op ) const
{
algebra.for_each13( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , s4_array[8].m_v , s4_array[9].m_v , s4_array[10].m_v , op );
}
};
template< class Algebra >
struct generic_rk_call_algebra< 13 , Algebra >
{
template< class S1 , class S2 , class S3 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S3 &s3 , S4 s4_array[12] , Op op ) const
{
algebra.for_each15( s1 , s2 , s3 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , s4_array[8].m_v , s4_array[9].m_v , s4_array[10].m_v , s4_array[11].m_v , op );
}
template< class S1 , class S2 , class S4 , class Op>
void operator()( Algebra &algebra , S1 &s1 , S2 &s2 , S4 s4_array[12] , Op op ) const
{
algebra.for_each14( s1 , s2 , s4_array[0].m_v , s4_array[1].m_v , s4_array[2].m_v , s4_array[3].m_v , s4_array[4].m_v ,
s4_array[5].m_v , s4_array[6].m_v , s4_array[7].m_v , s4_array[8].m_v , s4_array[9].m_v , s4_array[10].m_v , s4_array[11].m_v , op );
}
};
}
}
}
}
#endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_GENERIC_RK_CALL_ALGEBRA_HPP_INCLUDED

View File

@@ -0,0 +1,252 @@
/*
[auto_generated]
boost/numeric/odeint/stepper/detail/generic_rk_operations.hpp
[begin_description]
Operations caller for the generic Runge Kutta method.
[end_description]
Copyright 2011 Mario Mulansky
Copyright 2011-2012 Karsten Ahnert
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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_GENERIC_RK_OPERATIONS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_GENERIC_RK_OPERATIONS_HPP_INCLUDED
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< size_t StageNumber , class Operations , class Fac , class Time >
struct generic_rk_scale_sum;
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 1 , Operations , Fac , Time > : public Operations::template scale_sum2< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,1> &a , Time dt ) : Operations::template scale_sum2< Fac , Time >( 1.0 , a[0]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 2 , Operations , Fac , Time > : public Operations::template scale_sum3< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,2> &a , Time dt )
: Operations::template scale_sum3< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 3 , Operations , Fac , Time > : public Operations::template scale_sum4< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,3> &a , Time dt )
: Operations::template scale_sum4< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 4 , Operations , Fac , Time > : public Operations::template scale_sum5< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,4> &a , Time dt )
: Operations::template scale_sum5< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 5 , Operations , Fac , Time > : public Operations::template scale_sum6< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,5> &a , Time dt )
: Operations::template scale_sum6< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 6 , Operations , Fac , Time > : public Operations::template scale_sum7< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,6> &a , Time dt )
: Operations::template scale_sum7< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt , a[5]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 7 , Operations , Fac , Time > : public Operations::template scale_sum8< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,7> &a , Time dt )
: Operations::template scale_sum8< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt , a[5]*dt , a[6]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 8 , Operations , Fac , Time > : public Operations::template scale_sum9< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,8> &a , Time dt )
: Operations::template scale_sum9< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt ,
a[5]*dt , a[6]*dt , a[7]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 9 , Operations , Fac , Time > : public Operations::template scale_sum10< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,9> &a , Time dt )
: Operations::template scale_sum10< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt ,
a[5]*dt , a[6]*dt , a[7]*dt , a[8]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 10 , Operations , Fac , Time > : public Operations::template scale_sum11< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,10> &a , Time dt )
: Operations::template scale_sum11< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt ,
a[5]*dt , a[6]*dt , a[7]*dt , a[8]*dt , a[9]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 11 , Operations , Fac , Time > : public Operations::template scale_sum12< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,11> &a , Time dt )
: Operations::template scale_sum12< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt ,
a[5]*dt , a[6]*dt , a[7]*dt , a[8]*dt , a[9]*dt , a[10]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 12 , Operations , Fac , Time > : public Operations::template scale_sum13< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,12> &a , Time dt )
: Operations::template scale_sum13< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt ,
a[5]*dt , a[6]*dt , a[7]*dt , a[8]*dt , a[9]*dt , a[10]*dt , a[11]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum< 13 , Operations , Fac , Time > : public Operations::template scale_sum14< Fac , Time >
{
generic_rk_scale_sum( const std::array<Fac,13> &a , Time dt )
: Operations::template scale_sum14< Fac , Time >( 1.0 , a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt ,
a[5]*dt , a[6]*dt , a[7]*dt , a[8]*dt , a[9]*dt , a[10]*dt , a[11]*dt , a[12]*dt )
{ }
typedef void result_type;
};
// for error estimates
template< size_t StageNumber , class Operations , class Fac , class Time >
struct generic_rk_scale_sum_err;
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum_err< 1 , Operations , Fac , Time > : public Operations::template scale_sum1< Time >
{
generic_rk_scale_sum_err( const std::array<Fac,1> &a , Time dt ) : Operations::template scale_sum1< Time >( a[0]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum_err< 2 , Operations , Fac , Time > : public Operations::template scale_sum2< Time >
{
generic_rk_scale_sum_err( const std::array<Fac,2> &a , Time dt )
: Operations::template scale_sum2< Time >( a[0]*dt , a[1]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum_err< 3 , Operations , Fac , Time > : public Operations::template scale_sum3< Time >
{
generic_rk_scale_sum_err( const std::array<Fac,3> &a , Time dt )
: Operations::template scale_sum3< Time >( a[0]*dt , a[1]*dt , a[2]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum_err< 4 , Operations , Fac , Time > : public Operations::template scale_sum4< Time >
{
generic_rk_scale_sum_err( const std::array<Fac,4> &a , Time dt )
: Operations::template scale_sum4< Time >( a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum_err< 5 , Operations , Fac , Time > : public Operations::template scale_sum5< Fac >
{
generic_rk_scale_sum_err( const std::array<Fac,5> &a , Time dt )
: Operations::template scale_sum5< Time >( a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt )
{ }
typedef void result_type;
};
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum_err< 6 , Operations , Fac , Time > : public Operations::template scale_sum6< Time >
{
generic_rk_scale_sum_err( const std::array<Fac,6> &a , Time dt )
: Operations::template scale_sum6< Time >( a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt , a[5]*dt )
{ }
typedef void result_type;
};
// for rk87
template< class Operations , class Fac , class Time >
struct generic_rk_scale_sum_err< 13 , Operations , Fac , Time > : public Operations::template scale_sum13< Time >
{
generic_rk_scale_sum_err( const std::array<Fac,13> &a , Time dt )
: Operations::template scale_sum13< Time >( a[0]*dt , a[1]*dt , a[2]*dt , a[3]*dt , a[4]*dt , a[5]*dt ,
a[6]*dt , a[7]*dt , a[8]*dt , a[9]*dt , a[10]*dt , a[11]*dt , a[12]*dt )
{ }
typedef void result_type;
};
}
}
}
}
#endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_GENERIC_RK_OPERATIONS_HPP_INCLUDED

View File

@@ -0,0 +1,199 @@
/*
boost/numeric/odeint/stepper/detail/pid_step_adjuster.hpp
[begin_description]
Implementation of the stepsize controller for the controlled adams bashforth moulton stepper.
[end_description]
Copyright 2017 Valentin Noah Hartmann
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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_PID_STEP_ADJUSTER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_PID_STEP_ADJUSTER_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/detail/rotating_buffer.hpp>
#include <boost/numeric/odeint/stepper/detail/pid_step_adjuster_coefficients.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
#include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
#include <math.h>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template<
class Value = double,
class Time = double
>
struct pid_op
{
public:
typedef Value value_type;
typedef Time time_type;
const double beta1;
const double beta2;
const double beta3;
const double alpha1;
const double alpha2;
const time_type dt1;
const time_type dt2;
const time_type dt3;
const size_t m_steps;
pid_op(const size_t steps, const double _dt1, const double _dt2, const double _dt3,
const double b1 = 1, const double b2 = 0, const double b3 = 0, const double a1 = 0, const double a2 = 0)
:beta1(b1), beta2(b2), beta3(b3), alpha1(a1), alpha2(a2),
dt1(_dt1), dt2(_dt2), dt3(_dt3),
m_steps(steps)
{};
template<class T1, class T2, class T3, class T4>
void operator()(T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
{
using std::abs;
t1 = adapted_pow(abs(t2), -beta1/(m_steps + 1)) *
adapted_pow(abs(t3), -beta2/(m_steps + 1)) *
adapted_pow(abs(t4), -beta3/(m_steps + 1)) *
adapted_pow(abs(dt1/dt2), -alpha1/(m_steps + 1))*
adapted_pow(abs(dt2/dt3), -alpha2/(m_steps + 1));
t1 = 1/t1;
};
template<class T1, class T2>
void operator()(T1 &t1, const T2 &t2)
{
using std::abs;
t1 = adapted_pow(abs(t2), -beta1/(m_steps + 1));
t1 = 1/t1;
};
private:
template<class T>
inline value_type adapted_pow(T base, double exp)
{
if(exp == 0)
{
return 1;
}
else if (exp > 0)
{
return pow(base, exp);
}
else
{
return 1/pow(base, -exp);
}
};
};
template<
class State,
class Value = double,
class Deriv = State,
class Time = double,
class Algebra = typename algebra_dispatcher< State >::algebra_type,
class Operations = typename operations_dispatcher< Deriv >::operations_type,
size_t Type = BASIC
>
struct pid_step_adjuster
{
public:
static double threshold() { return 0.9; };
typedef State state_type;
typedef Value value_type;
typedef Deriv deriv_type;
typedef Time time_type;
typedef Algebra algebra_type;
typedef Operations operations_type;
typedef rotating_buffer<state_type, 3> error_storage_type;
typedef rotating_buffer<time_type, 3> time_storage_type;
typedef pid_step_adjuster_coefficients<Type> coeff_type;
pid_step_adjuster(double abs_tol = 1e-6, double rel_tol = 1e-6, time_type dtmax = 1.0)
:m_dtmax(dtmax), m_error_storage(), m_dt_storage(), m_init(0),
m_abs_tol(abs_tol), m_rel_tol(rel_tol)
{};
time_type adjust_stepsize(const size_t steps, time_type dt, state_type &err, const state_type &x, const deriv_type &dxdt)
{
using std::abs;
m_algebra.for_each3( err , x , dxdt ,
typename operations_type::template rel_error< value_type >( m_abs_tol , m_rel_tol , 1.0 , 1.0 * abs(get_unit_value( dt )) ) );
m_error_storage[0] = err;
m_dt_storage[0] = dt;
if(m_init >= 2)
{
m_algebra.for_each4(err, m_error_storage[0], m_error_storage[1], m_error_storage[2],
pid_op<>(steps, m_dt_storage[0], m_dt_storage[1], m_dt_storage[2],
m_coeff[0], m_coeff[1], m_coeff[2], m_coeff[3], m_coeff[4]));
}
else
{
m_algebra.for_each2(err, m_error_storage[0],
pid_op<>(steps, m_dt_storage[0], m_dt_storage[1], m_dt_storage[2], 0.7));
}
value_type ratio = 1 / m_algebra.norm_inf(err);
value_type kappa = 1.0;
ratio = 1.0 + kappa*atan((ratio - 1) / kappa);
if(ratio*dt >= m_dtmax)
{
ratio = m_dtmax / dt;
}
if(ratio >= threshold())
{
m_error_storage.rotate();
m_dt_storage.rotate();
++m_init;
}
else
{
m_init = 0;
}
return dt * static_cast<time_type>(ratio);
};
private:
algebra_type m_algebra;
time_type m_dtmax;
error_storage_type m_error_storage;
time_storage_type m_dt_storage;
size_t m_init;
double m_abs_tol;
double m_rel_tol;
coeff_type m_coeff;
};
} // detail
} // odeint
} // numeric
} // boost
#endif

View File

@@ -0,0 +1,180 @@
/*
boost/numeric/odeint/stepper/detail/pid_step_adjuster_coefficients.hpp
[begin_description]
Coefficients for the PID stepsize controller.
[end_description]
Copyright 2017 Valentin Noah Hartmann
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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_PID_STEP_ADJUSTER_COEFFICIENTS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_PID_STEP_ADJUSTER_COEFFICIENTS_HPP_INCLUDED
#include <array>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
enum adjuster_type{
BASIC,
H0211,
H211b,
H211PI,
H0312,
H312b,
H312PID,
H0321,
H321
};
template<int Type>
class pid_step_adjuster_coefficients;
template<>
class pid_step_adjuster_coefficients<BASIC> : public std::array<double, 5>
{
public:
pid_step_adjuster_coefficients()
: std::array<double, 5>()
{
(*this)[0] = 1.0;
(*this)[1] = 0.0;
(*this)[2] = 0.0;
(*this)[3] = 0.0;
(*this)[4] = 0.0;
}
};
template<>
class pid_step_adjuster_coefficients<H0211> : public std::array<double, 5>
{
public:
pid_step_adjuster_coefficients()
: std::array<double, 5>()
{
(*this)[0] = 1.0 / 2.0;
(*this)[1] = 1.0 / 2.0;
(*this)[2] = 0.0;
(*this)[3] = 1.0 / 2.0;
(*this)[4] = 0.0;
}
};
template<>
class pid_step_adjuster_coefficients<H211b> : public std::array<double, 5>
{
public:
pid_step_adjuster_coefficients()
: std::array<double, 5>()
{
(*this)[0] = 1.0 / 5.0;
(*this)[1] = 2.0 / 5.0;
(*this)[2] = 0.0;
(*this)[3] = 1.0 / 5.0;
(*this)[4] = 0.0;
}
};
template<>
class pid_step_adjuster_coefficients<H211PI> : public std::array<double, 5>
{
public:
pid_step_adjuster_coefficients()
: std::array<double, 5>()
{
(*this)[0] = 1.0 / 6.0;
(*this)[1] = 2.0 / 6.0;
(*this)[2] = 0.0;
(*this)[3] = 0.0;
(*this)[4] = 0.0;
}
};
template<>
class pid_step_adjuster_coefficients<H0312> : public std::array<double, 5>
{
public:
pid_step_adjuster_coefficients()
: std::array<double, 5>()
{
(*this)[0] = 1.0 / 4.0;
(*this)[1] = 2.0 / 2.0;
(*this)[2] = 1.0 / 4.0;
(*this)[3] = 3.0 / 4.0;
(*this)[4] = 1.0 / 4.0;
}
};
template<>
class pid_step_adjuster_coefficients<H312b> : public std::array<double, 5>
{
public:
pid_step_adjuster_coefficients()
: std::array<double, 5>()
{
(*this)[0] = 1.0 / 6.0;
(*this)[1] = 2.0 / 6.0;
(*this)[2] = 1.0 / 6.0;
(*this)[3] = 3.0 / 6.0;
(*this)[4] = 1.0 / 6.0;
}
};
template<>
class pid_step_adjuster_coefficients<H312PID> : public std::array<double, 5>
{
public:
pid_step_adjuster_coefficients()
: std::array<double, 5>()
{
(*this)[0] = 1.0 / 18.0;
(*this)[1] = 2.0 / 9.0;
(*this)[2] = 1.0 / 18.0;
(*this)[3] = 0.0;
(*this)[4] = 0.0;
}
};
template<>
class pid_step_adjuster_coefficients<H0321> : public std::array<double, 5>
{
public:
pid_step_adjuster_coefficients()
: std::array<double, 5>()
{
(*this)[0] = 5.0 / 4.0;
(*this)[1] = 1.0 / 2.0;
(*this)[2] = -3.0 / 4.0;
(*this)[3] = -1.0 / 4.0;
(*this)[4] = -3.0 / 4.0;
}
};
template<>
class pid_step_adjuster_coefficients<H321> : public std::array<double, 5>
{
public:
pid_step_adjuster_coefficients()
: std::array<double, 5>()
{
(*this)[0] = 1.0 / 3.0;
(*this)[1] = 1.0 / 18.0;
(*this)[2] = -5.0 / 18.0;
(*this)[3] = -5.0 / 16.0;
(*this)[4] = -1.0 / 6.0;
}
};
} // detail
} // odeint
} // numeric
} // boost
#endif

View File

@@ -0,0 +1,84 @@
/*
[auto_generated]
boost/numeric/odeint/stepper/detail/rotating_buffer.hpp
[begin_description]
Implemetation of a rotating (cyclic) buffer for use in the Adam Bashforth stepper
[end_description]
Copyright 2011 Karsten Ahnert
Copyright 2011 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)
*/
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED
#include <array>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< class T , size_t N >
class rotating_buffer
{
public:
typedef T value_type;
const static size_t dim = N;
rotating_buffer( void ) : m_first( 0 )
{ }
size_t size( void ) const
{
return dim;
}
value_type& operator[]( size_t i )
{
return m_data[ get_index( i ) ];
}
const value_type& operator[]( size_t i ) const
{
return m_data[ get_index( i ) ];
}
void rotate( void )
{
if( m_first == 0 )
m_first = dim-1;
else
--m_first;
}
protected:
value_type m_data[N];
private:
size_t get_index( size_t i ) const
{
return ( ( i + m_first ) % dim );
}
size_t m_first;
};
} // detail
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED