dummy_steppers.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. [auto_generated]
  3. libs/numeric/odeint/test/dummy_steppers.hpp
  4. [begin_description]
  5. Dummy steppers for several tests.
  6. [end_description]
  7. Copyright 2012 Karsten Ahnert
  8. Copyright 2012 Mario Mulansky
  9. Distributed under the Boost Software License, Version 1.0.
  10. (See accompanying file LICENSE_1_0.txt or
  11. copy at http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. #ifndef BOOST_LIBS_NUMERIC_ODEINT_TEST_DUMMY_STEPPER_HPP_INCLUDED
  14. #define BOOST_LIBS_NUMERIC_ODEINT_TEST_DUMMY_STEPPER_HPP_INCLUDED
  15. #include <boost/array.hpp>
  16. #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
  17. #include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
  18. namespace boost {
  19. namespace numeric {
  20. namespace odeint {
  21. struct dummy_stepper
  22. {
  23. typedef double value_type;
  24. typedef value_type time_type;
  25. typedef boost::array< value_type , 1 > state_type;
  26. typedef state_type deriv_type;
  27. typedef unsigned short order_type;
  28. typedef stepper_tag stepper_category;
  29. order_type order( void ) const { return 1; }
  30. template< class System >
  31. void do_step( System sys , state_type &x , time_type t , time_type dt ) const
  32. {
  33. x[0] += 0.25;
  34. }
  35. };
  36. struct dummy_dense_output_stepper
  37. {
  38. typedef double value_type;
  39. typedef value_type time_type;
  40. typedef boost::array< value_type , 1 > state_type;
  41. typedef state_type deriv_type;
  42. typedef dense_output_stepper_tag stepper_category;
  43. void initialize( const state_type &x0 , time_type t0 , time_type dt0 )
  44. {
  45. m_x = x0;
  46. m_t = t0;
  47. m_dt = dt0;
  48. }
  49. template< class System >
  50. std::pair< time_type , time_type > do_step( System sys )
  51. {
  52. m_x[0] += 0.25;
  53. m_t += m_dt;
  54. return std::make_pair( m_t - m_dt , m_t );
  55. }
  56. void calc_state( time_type t_inter , state_type &x ) const
  57. {
  58. value_type theta = ( m_t - t_inter ) / m_dt;
  59. x[0] = m_x[0] - 0.25 * theta;
  60. }
  61. const time_type& current_time( void ) const
  62. {
  63. return m_t;
  64. }
  65. const state_type& current_state( void ) const
  66. {
  67. return m_x;
  68. }
  69. const time_type& current_time_step( void ) const
  70. {
  71. return m_dt;
  72. }
  73. state_type m_x;
  74. time_type m_t;
  75. time_type m_dt;
  76. };
  77. struct dummy_controlled_stepper
  78. {
  79. typedef double value_type;
  80. typedef value_type time_type;
  81. typedef boost::array< value_type , 1 > state_type;
  82. typedef state_type deriv_type;
  83. typedef controlled_stepper_tag stepper_category;
  84. template< class Sys >
  85. controlled_step_result try_step( Sys sys , state_type &x , time_type &t , time_type &dt ) const
  86. {
  87. x[0] += 0.25;
  88. t += dt;
  89. return success;
  90. }
  91. };
  92. } // odeint
  93. } // numeric
  94. } // boost
  95. #endif // BOOST_LIBS_NUMERIC_ODEINT_TEST_DUMMY_STEPPER_HPP_INCLUDED