bulirsch_stoer.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/stepper/bulirsch_stoer.hpp
  4. [begin_description]
  5. Implementation of the Burlish-Stoer method. As described in
  6. Ernst Hairer, Syvert Paul Norsett, Gerhard Wanner
  7. Solving Ordinary Differential Equations I. Nonstiff Problems.
  8. Springer Series in Comput. Mathematics, Vol. 8, Springer-Verlag 1987, Second revised edition 1993.
  9. [end_description]
  10. Copyright 2009-2011 Karsten Ahnert
  11. Copyright 2009-2011 Mario Mulansky
  12. Distributed under the Boost Software License, Version 1.0.
  13. (See accompanying file LICENSE_1_0.txt or
  14. copy at http://www.boost.org/LICENSE_1_0.txt)
  15. */
  16. #ifndef BOOST_NUMERIC_ODEINT_STEPPER_BULIRSCH_STOER_HPP_INCLUDED
  17. #define BOOST_NUMERIC_ODEINT_STEPPER_BULIRSCH_STOER_HPP_INCLUDED
  18. #include <iostream>
  19. #include <algorithm>
  20. #include <boost/config.hpp> // for min/max guidelines
  21. #include <boost/numeric/odeint/util/bind.hpp>
  22. #include <boost/numeric/odeint/util/unwrap_reference.hpp>
  23. #include <boost/numeric/odeint/stepper/controlled_runge_kutta.hpp>
  24. #include <boost/numeric/odeint/stepper/modified_midpoint.hpp>
  25. #include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
  26. #include <boost/numeric/odeint/algebra/range_algebra.hpp>
  27. #include <boost/numeric/odeint/algebra/default_operations.hpp>
  28. #include <boost/numeric/odeint/util/state_wrapper.hpp>
  29. #include <boost/numeric/odeint/util/is_resizeable.hpp>
  30. #include <boost/numeric/odeint/util/resizer.hpp>
  31. #include <boost/numeric/odeint/util/unit_helper.hpp>
  32. #include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
  33. namespace boost {
  34. namespace numeric {
  35. namespace odeint {
  36. template<
  37. class State ,
  38. class Value = double ,
  39. class Deriv = State ,
  40. class Time = Value ,
  41. class Algebra = range_algebra ,
  42. class Operations = default_operations ,
  43. class Resizer = initially_resizer
  44. >
  45. class bulirsch_stoer {
  46. public:
  47. typedef State state_type;
  48. typedef Value value_type;
  49. typedef Deriv deriv_type;
  50. typedef Time time_type;
  51. typedef Algebra algebra_type;
  52. typedef Operations operations_type;
  53. typedef Resizer resizer_type;
  54. #ifndef DOXYGEN_SKIP
  55. typedef state_wrapper< state_type > wrapped_state_type;
  56. typedef state_wrapper< deriv_type > wrapped_deriv_type;
  57. typedef controlled_stepper_tag stepper_category;
  58. typedef bulirsch_stoer< State , Value , Deriv , Time , Algebra , Operations , Resizer > controlled_error_bs_type;
  59. typedef typename inverse_time< time_type >::type inv_time_type;
  60. typedef std::vector< value_type > value_vector;
  61. typedef std::vector< time_type > time_vector;
  62. typedef std::vector< inv_time_type > inv_time_vector; //should be 1/time_type for boost.units
  63. typedef std::vector< value_vector > value_matrix;
  64. typedef std::vector< size_t > int_vector;
  65. typedef std::vector< wrapped_state_type > state_table_type;
  66. #endif //DOXYGEN_SKIP
  67. const static size_t m_k_max = 8;
  68. bulirsch_stoer(
  69. value_type eps_abs = 1E-6 , value_type eps_rel = 1E-6 ,
  70. value_type factor_x = 1.0 , value_type factor_dxdt = 1.0 )
  71. : m_error_checker( eps_abs , eps_rel , factor_x, factor_dxdt ) , m_midpoint() ,
  72. m_last_step_rejected( false ) , m_first( true ) ,
  73. m_interval_sequence( m_k_max+1 ) ,
  74. m_coeff( m_k_max+1 ) ,
  75. m_cost( m_k_max+1 ) ,
  76. m_table( m_k_max ) ,
  77. STEPFAC1( 0.65 ) , STEPFAC2( 0.94 ) , STEPFAC3( 0.02 ) , STEPFAC4( 4.0 ) , KFAC1( 0.8 ) , KFAC2( 0.9 )
  78. {
  79. BOOST_USING_STD_MIN();
  80. BOOST_USING_STD_MAX();
  81. /* initialize sequence of stage numbers and work */
  82. for( unsigned short i = 0; i < m_k_max+1; i++ )
  83. {
  84. m_interval_sequence[i] = 2 * (i+1);
  85. if( i == 0 )
  86. m_cost[i] = m_interval_sequence[i];
  87. else
  88. m_cost[i] = m_cost[i-1] + m_interval_sequence[i];
  89. m_coeff[i].resize(i);
  90. for( size_t k = 0 ; k < i ; ++k )
  91. {
  92. const value_type r = static_cast< value_type >( m_interval_sequence[i] ) / static_cast< value_type >( m_interval_sequence[k] );
  93. m_coeff[i][k] = 1.0 / ( r*r - static_cast< value_type >( 1.0 ) ); // coefficients for extrapolation
  94. }
  95. // crude estimate of optimal order
  96. m_current_k_opt = 4;
  97. /* no calculation because log10 might not exist for value_type!
  98. const value_type logfact( -log10( max BOOST_PREVENT_MACRO_SUBSTITUTION( eps_rel , static_cast< value_type >(1.0E-12) ) ) * 0.6 + 0.5 );
  99. m_current_k_opt = max BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast<value_type>( 1 ) , min BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast<value_type>( m_k_max-1 ) , logfact ));
  100. */
  101. }
  102. }
  103. /*
  104. * Version 1 : try_step( sys , x , t , dt )
  105. *
  106. * The overloads are needed to solve the forwarding problem
  107. */
  108. template< class System , class StateInOut >
  109. controlled_step_result try_step( System system , StateInOut &x , time_type &t , time_type &dt )
  110. {
  111. return try_step_v1( system , x , t, dt );
  112. }
  113. /**
  114. * \brief Second version to solve the forwarding problem, can be used with Boost.Range as StateInOut.
  115. */
  116. template< class System , class StateInOut >
  117. controlled_step_result try_step( System system , const StateInOut &x , time_type &t , time_type &dt )
  118. {
  119. return try_step_v1( system , x , t, dt );
  120. }
  121. /*
  122. * Version 2 : try_step( sys , x , dxdt , t , dt )
  123. *
  124. * this version does not solve the forwarding problem, boost.range can not be used
  125. */
  126. template< class System , class StateInOut , class DerivIn >
  127. controlled_step_result try_step( System system , StateInOut &x , const DerivIn &dxdt , time_type &t , time_type &dt )
  128. {
  129. m_xnew_resizer.adjust_size( x , detail::bind( &controlled_error_bs_type::template resize_m_xnew< StateInOut > , detail::ref( *this ) , detail::_1 ) );
  130. controlled_step_result res = try_step( system , x , dxdt , t , m_xnew.m_v , dt );
  131. if( res == success )
  132. {
  133. boost::numeric::odeint::copy( m_xnew.m_v , x );
  134. }
  135. return res;
  136. }
  137. /*
  138. * Version 3 : try_step( sys , in , t , out , dt )
  139. *
  140. * this version does not solve the forwarding problem, boost.range can not be used
  141. */
  142. template< class System , class StateIn , class StateOut >
  143. typename boost::disable_if< boost::is_same< StateIn , time_type > , controlled_step_result >::type
  144. try_step( System system , const StateIn &in , time_type &t , StateOut &out , time_type &dt )
  145. {
  146. typename odeint::unwrap_reference< System >::type &sys = system;
  147. m_dxdt_resizer.adjust_size( in , detail::bind( &controlled_error_bs_type::template resize_m_dxdt< StateIn > , detail::ref( *this ) , detail::_1 ) );
  148. sys( in , m_dxdt.m_v , t );
  149. return try_step( system , in , m_dxdt.m_v , t , out , dt );
  150. }
  151. /*
  152. * Full version : try_step( sys , in , dxdt_in , t , out , dt )
  153. *
  154. * contains the actual implementation
  155. */
  156. template< class System , class StateIn , class DerivIn , class StateOut >
  157. controlled_step_result try_step( System system , const StateIn &in , const DerivIn &dxdt , time_type &t , StateOut &out , time_type &dt )
  158. {
  159. BOOST_USING_STD_MIN();
  160. BOOST_USING_STD_MAX();
  161. static const value_type val1( 1.0 );
  162. typename odeint::unwrap_reference< System >::type &sys = system;
  163. if( m_resizer.adjust_size( in , detail::bind( &controlled_error_bs_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) )
  164. {
  165. reset(); // system resized -> reset
  166. }
  167. if( dt != m_dt_last )
  168. {
  169. reset(); // step size changed from outside -> reset
  170. }
  171. bool reject( true );
  172. time_vector h_opt( m_k_max+1 );
  173. inv_time_vector work( m_k_max+1 );
  174. time_type new_h = dt;
  175. /* m_current_k_opt is the estimated current optimal stage number */
  176. for( size_t k = 0 ; k <= m_current_k_opt+1 ; k++ )
  177. {
  178. /* the stage counts are stored in m_interval_sequence */
  179. m_midpoint.set_steps( m_interval_sequence[k] );
  180. if( k == 0 )
  181. {
  182. m_midpoint.do_step( sys , in , dxdt , t , out , dt );
  183. /* the first step, nothing more to do */
  184. }
  185. else
  186. {
  187. m_midpoint.do_step( sys , in , dxdt , t , m_table[k-1].m_v , dt );
  188. extrapolate( k , m_table , m_coeff , out );
  189. // get error estimate
  190. m_algebra.for_each3( m_err.m_v , out , m_table[0].m_v ,
  191. typename operations_type::template scale_sum2< value_type , value_type >( val1 , -val1 ) );
  192. const value_type error = m_error_checker.error( m_algebra , in , dxdt , m_err.m_v , dt );
  193. h_opt[k] = calc_h_opt( dt , error , k );
  194. work[k] = static_cast<value_type>( m_cost[k] ) / h_opt[k];
  195. if( (k == m_current_k_opt-1) || m_first )
  196. { // convergence before k_opt ?
  197. if( error < 1.0 )
  198. {
  199. //convergence
  200. reject = false;
  201. if( (work[k] < KFAC2*work[k-1]) || (m_current_k_opt <= 2) )
  202. {
  203. // leave order as is (except we were in first round)
  204. m_current_k_opt = min BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast<int>(m_k_max)-1 , max BOOST_PREVENT_MACRO_SUBSTITUTION( 2 , static_cast<int>(k)+1 ) );
  205. new_h = h_opt[k];
  206. new_h *= static_cast<value_type>( m_cost[k+1] ) / static_cast<value_type>( m_cost[k] );
  207. } else {
  208. m_current_k_opt = min BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast<int>(m_k_max)-1 , max BOOST_PREVENT_MACRO_SUBSTITUTION( 2 , static_cast<int>(k) ) );
  209. new_h = h_opt[k];
  210. }
  211. break;
  212. }
  213. else if( should_reject( error , k ) && !m_first )
  214. {
  215. reject = true;
  216. new_h = h_opt[k];
  217. break;
  218. }
  219. }
  220. if( k == m_current_k_opt )
  221. { // convergence at k_opt ?
  222. if( error < 1.0 )
  223. {
  224. //convergence
  225. reject = false;
  226. if( (work[k-1] < KFAC2*work[k]) )
  227. {
  228. m_current_k_opt = max BOOST_PREVENT_MACRO_SUBSTITUTION( 2 , static_cast<int>(m_current_k_opt)-1 );
  229. new_h = h_opt[m_current_k_opt];
  230. }
  231. else if( (work[k] < KFAC2*work[k-1]) && !m_last_step_rejected )
  232. {
  233. m_current_k_opt = min BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast<int>(m_k_max-1) , static_cast<int>(m_current_k_opt)+1 );
  234. new_h = h_opt[k];
  235. new_h *= m_cost[m_current_k_opt]/m_cost[k];
  236. } else
  237. new_h = h_opt[m_current_k_opt];
  238. break;
  239. }
  240. else if( should_reject( error , k ) )
  241. {
  242. reject = true;
  243. new_h = h_opt[m_current_k_opt];
  244. break;
  245. }
  246. }
  247. if( k == m_current_k_opt+1 )
  248. { // convergence at k_opt+1 ?
  249. if( error < 1.0 )
  250. { //convergence
  251. reject = false;
  252. if( work[k-2] < KFAC2*work[k-1] )
  253. m_current_k_opt = max BOOST_PREVENT_MACRO_SUBSTITUTION( 2 , static_cast<int>(m_current_k_opt)-1 );
  254. if( (work[k] < KFAC2*work[m_current_k_opt]) && !m_last_step_rejected )
  255. m_current_k_opt = min BOOST_PREVENT_MACRO_SUBSTITUTION( static_cast<int>(m_k_max)-1 , static_cast<int>(k) );
  256. new_h = h_opt[m_current_k_opt];
  257. } else
  258. {
  259. reject = true;
  260. new_h = h_opt[m_current_k_opt];
  261. }
  262. break;
  263. }
  264. }
  265. }
  266. if( !reject )
  267. {
  268. t += dt;
  269. }
  270. if( !m_last_step_rejected || boost::numeric::odeint::detail::less_with_sign(new_h, dt, dt) )
  271. {
  272. m_dt_last = new_h;
  273. dt = new_h;
  274. }
  275. m_last_step_rejected = reject;
  276. m_first = false;
  277. if( reject )
  278. return fail;
  279. else
  280. return success;
  281. }
  282. /** \brief Resets the internal state of the stepper */
  283. void reset()
  284. {
  285. m_first = true;
  286. m_last_step_rejected = false;
  287. }
  288. /* Resizer methods */
  289. template< class StateIn >
  290. void adjust_size( const StateIn &x )
  291. {
  292. resize_m_dxdt( x );
  293. resize_m_xnew( x );
  294. resize_impl( x );
  295. m_midpoint.adjust_size();
  296. }
  297. private:
  298. template< class StateIn >
  299. bool resize_m_dxdt( const StateIn &x )
  300. {
  301. return adjust_size_by_resizeability( m_dxdt , x , typename is_resizeable<deriv_type>::type() );
  302. }
  303. template< class StateIn >
  304. bool resize_m_xnew( const StateIn &x )
  305. {
  306. return adjust_size_by_resizeability( m_xnew , x , typename is_resizeable<state_type>::type() );
  307. }
  308. template< class StateIn >
  309. bool resize_impl( const StateIn &x )
  310. {
  311. bool resized( false );
  312. for( size_t i = 0 ; i < m_k_max ; ++i )
  313. resized |= adjust_size_by_resizeability( m_table[i] , x , typename is_resizeable<state_type>::type() );
  314. resized |= adjust_size_by_resizeability( m_err , x , typename is_resizeable<state_type>::type() );
  315. return resized;
  316. }
  317. template< class System , class StateInOut >
  318. controlled_step_result try_step_v1( System system , StateInOut &x , time_type &t , time_type &dt )
  319. {
  320. typename odeint::unwrap_reference< System >::type &sys = system;
  321. m_dxdt_resizer.adjust_size( x , detail::bind( &controlled_error_bs_type::template resize_m_dxdt< StateInOut > , detail::ref( *this ) , detail::_1 ) );
  322. sys( x , m_dxdt.m_v ,t );
  323. return try_step( system , x , m_dxdt.m_v , t , dt );
  324. }
  325. template< class StateInOut >
  326. void extrapolate( size_t k , state_table_type &table , const value_matrix &coeff , StateInOut &xest )
  327. /* polynomial extrapolation, see http://www.nr.com/webnotes/nr3web21.pdf
  328. uses the obtained intermediate results to extrapolate to dt->0
  329. */
  330. {
  331. static const value_type val1 = static_cast< value_type >( 1.0 );
  332. for( int j=k-1 ; j>0 ; --j )
  333. {
  334. m_algebra.for_each3( table[j-1].m_v , table[j].m_v , table[j-1].m_v ,
  335. typename operations_type::template scale_sum2< value_type , value_type >( val1 + coeff[k][j] , -coeff[k][j] ) );
  336. }
  337. m_algebra.for_each3( xest , table[0].m_v , xest ,
  338. typename operations_type::template scale_sum2< value_type , value_type >( val1 + coeff[k][0] , -coeff[k][0]) );
  339. }
  340. time_type calc_h_opt( time_type h , value_type error , size_t k ) const
  341. /* calculates the optimal step size for a given error and stage number */
  342. {
  343. BOOST_USING_STD_MIN();
  344. BOOST_USING_STD_MAX();
  345. using std::pow;
  346. value_type expo( 1.0/(2*k+1) );
  347. value_type facmin = pow BOOST_PREVENT_MACRO_SUBSTITUTION( STEPFAC3 , expo );
  348. value_type fac;
  349. if (error == 0.0)
  350. fac=1.0/facmin;
  351. else
  352. {
  353. fac = STEPFAC2 / pow BOOST_PREVENT_MACRO_SUBSTITUTION( error / STEPFAC1 , expo );
  354. fac = max BOOST_PREVENT_MACRO_SUBSTITUTION( facmin/STEPFAC4 , min BOOST_PREVENT_MACRO_SUBSTITUTION( 1.0/facmin , fac ) );
  355. }
  356. return h*fac;
  357. }
  358. controlled_step_result set_k_opt( size_t k , const inv_time_vector &work , const time_vector &h_opt , time_type &dt )
  359. /* calculates the optimal stage number */
  360. {
  361. if( k == 1 )
  362. {
  363. m_current_k_opt = 2;
  364. return success;
  365. }
  366. if( (work[k-1] < KFAC1*work[k]) || (k == m_k_max) )
  367. { // order decrease
  368. m_current_k_opt = k-1;
  369. dt = h_opt[ m_current_k_opt ];
  370. return success;
  371. }
  372. else if( (work[k] < KFAC2*work[k-1]) || m_last_step_rejected || (k == m_k_max-1) )
  373. { // same order - also do this if last step got rejected
  374. m_current_k_opt = k;
  375. dt = h_opt[ m_current_k_opt ];
  376. return success;
  377. }
  378. else
  379. { // order increase - only if last step was not rejected
  380. m_current_k_opt = k+1;
  381. dt = h_opt[ m_current_k_opt-1 ] * m_cost[ m_current_k_opt ] / m_cost[ m_current_k_opt-1 ] ;
  382. return success;
  383. }
  384. }
  385. bool in_convergence_window( size_t k ) const
  386. {
  387. if( (k == m_current_k_opt-1) && !m_last_step_rejected )
  388. return true; // decrease stepsize only if last step was not rejected
  389. return ( (k == m_current_k_opt) || (k == m_current_k_opt+1) );
  390. }
  391. bool should_reject( value_type error , size_t k ) const
  392. {
  393. if( k == m_current_k_opt-1 )
  394. {
  395. const value_type d = m_interval_sequence[m_current_k_opt] * m_interval_sequence[m_current_k_opt+1] /
  396. (m_interval_sequence[0]*m_interval_sequence[0]);
  397. //step will fail, criterion 17.3.17 in NR
  398. return ( error > d*d );
  399. }
  400. else if( k == m_current_k_opt )
  401. {
  402. const value_type d = m_interval_sequence[m_current_k_opt] / m_interval_sequence[0];
  403. return ( error > d*d );
  404. } else
  405. return error > 1.0;
  406. }
  407. default_error_checker< value_type, algebra_type , operations_type > m_error_checker;
  408. modified_midpoint< state_type , value_type , deriv_type , time_type , algebra_type , operations_type , resizer_type > m_midpoint;
  409. bool m_last_step_rejected;
  410. bool m_first;
  411. time_type m_dt_last;
  412. time_type m_t_last;
  413. size_t m_current_k_opt;
  414. algebra_type m_algebra;
  415. resizer_type m_dxdt_resizer;
  416. resizer_type m_xnew_resizer;
  417. resizer_type m_resizer;
  418. wrapped_state_type m_xnew;
  419. wrapped_state_type m_err;
  420. wrapped_deriv_type m_dxdt;
  421. int_vector m_interval_sequence; // stores the successive interval counts
  422. value_matrix m_coeff;
  423. int_vector m_cost; // costs for interval count
  424. state_table_type m_table; // sequence of states for extrapolation
  425. const value_type STEPFAC1 , STEPFAC2 , STEPFAC3 , STEPFAC4 , KFAC1 , KFAC2;
  426. };
  427. /******** DOXYGEN ********/
  428. /**
  429. * \class bulirsch_stoer
  430. * \brief The Bulirsch-Stoer algorithm.
  431. *
  432. * The Bulirsch-Stoer is a controlled stepper that adjusts both step size
  433. * and order of the method. The algorithm uses the modified midpoint and
  434. * a polynomial extrapolation compute the solution.
  435. *
  436. * \tparam State The state type.
  437. * \tparam Value The value type.
  438. * \tparam Deriv The type representing the time derivative of the state.
  439. * \tparam Time The time representing the independent variable - the time.
  440. * \tparam Algebra The algebra type.
  441. * \tparam Operations The operations type.
  442. * \tparam Resizer The resizer policy type.
  443. */
  444. /**
  445. * \fn bulirsch_stoer::bulirsch_stoer( value_type eps_abs , value_type eps_rel , value_type factor_x , value_type factor_dxdt )
  446. * \brief Constructs the bulirsch_stoer class, including initialization of
  447. * the error bounds.
  448. *
  449. * \param eps_abs Absolute tolerance level.
  450. * \param eps_rel Relative tolerance level.
  451. * \param factor_x Factor for the weight of the state.
  452. * \param factor_dxdt Factor for the weight of the derivative.
  453. */
  454. /**
  455. * \fn bulirsch_stoer::try_step( System system , StateInOut &x , time_type &t , time_type &dt )
  456. * \brief Tries to perform one step.
  457. *
  458. * This method tries to do one step with step size dt. If the error estimate
  459. * is to large, the step is rejected and the method returns fail and the
  460. * step size dt is reduced. If the error estimate is acceptably small, the
  461. * step is performed, success is returned and dt might be increased to make
  462. * the steps as large as possible. This method also updates t if a step is
  463. * performed. Also, the internal order of the stepper is adjusted if required.
  464. *
  465. * \param system The system function to solve, hence the r.h.s. of the ODE.
  466. * It must fulfill the Simple System concept.
  467. * \param x The state of the ODE which should be solved. Overwritten if
  468. * the step is successful.
  469. * \param t The value of the time. Updated if the step is successful.
  470. * \param dt The step size. Updated.
  471. * \return success if the step was accepted, fail otherwise.
  472. */
  473. /**
  474. * \fn bulirsch_stoer::try_step( System system , StateInOut &x , const DerivIn &dxdt , time_type &t , time_type &dt )
  475. * \brief Tries to perform one step.
  476. *
  477. * This method tries to do one step with step size dt. If the error estimate
  478. * is to large, the step is rejected and the method returns fail and the
  479. * step size dt is reduced. If the error estimate is acceptably small, the
  480. * step is performed, success is returned and dt might be increased to make
  481. * the steps as large as possible. This method also updates t if a step is
  482. * performed. Also, the internal order of the stepper is adjusted if required.
  483. *
  484. * \param system The system function to solve, hence the r.h.s. of the ODE.
  485. * It must fulfill the Simple System concept.
  486. * \param x The state of the ODE which should be solved. Overwritten if
  487. * the step is successful.
  488. * \param dxdt The derivative of state.
  489. * \param t The value of the time. Updated if the step is successful.
  490. * \param dt The step size. Updated.
  491. * \return success if the step was accepted, fail otherwise.
  492. */
  493. /**
  494. * \fn bulirsch_stoer::try_step( System system , const StateIn &in , time_type &t , StateOut &out , time_type &dt )
  495. * \brief Tries to perform one step.
  496. *
  497. * \note This method is disabled if state_type=time_type to avoid ambiguity.
  498. *
  499. * This method tries to do one step with step size dt. If the error estimate
  500. * is to large, the step is rejected and the method returns fail and the
  501. * step size dt is reduced. If the error estimate is acceptably small, the
  502. * step is performed, success is returned and dt might be increased to make
  503. * the steps as large as possible. This method also updates t if a step is
  504. * performed. Also, the internal order of the stepper is adjusted if required.
  505. *
  506. * \param system The system function to solve, hence the r.h.s. of the ODE.
  507. * It must fulfill the Simple System concept.
  508. * \param in The state of the ODE which should be solved.
  509. * \param t The value of the time. Updated if the step is successful.
  510. * \param out Used to store the result of the step.
  511. * \param dt The step size. Updated.
  512. * \return success if the step was accepted, fail otherwise.
  513. */
  514. /**
  515. * \fn bulirsch_stoer::try_step( System system , const StateIn &in , const DerivIn &dxdt , time_type &t , StateOut &out , time_type &dt )
  516. * \brief Tries to perform one step.
  517. *
  518. * This method tries to do one step with step size dt. If the error estimate
  519. * is to large, the step is rejected and the method returns fail and the
  520. * step size dt is reduced. If the error estimate is acceptably small, the
  521. * step is performed, success is returned and dt might be increased to make
  522. * the steps as large as possible. This method also updates t if a step is
  523. * performed. Also, the internal order of the stepper is adjusted if required.
  524. *
  525. * \param system The system function to solve, hence the r.h.s. of the ODE.
  526. * It must fulfill the Simple System concept.
  527. * \param in The state of the ODE which should be solved.
  528. * \param dxdt The derivative of state.
  529. * \param t The value of the time. Updated if the step is successful.
  530. * \param out Used to store the result of the step.
  531. * \param dt The step size. Updated.
  532. * \return success if the step was accepted, fail otherwise.
  533. */
  534. /**
  535. * \fn bulirsch_stoer::adjust_size( const StateIn &x )
  536. * \brief Adjust the size of all temporaries in the stepper manually.
  537. * \param x A state from which the size of the temporaries to be resized is deduced.
  538. */
  539. }
  540. }
  541. }
  542. #endif // BOOST_NUMERIC_ODEINT_STEPPER_BULIRSCH_STOER_HPP_INCLUDED