diff --git a/boost/numeric/odeint.hpp b/boost/numeric/odeint.hpp index f3be32bc..939008cf 100644 --- a/boost/numeric/odeint.hpp +++ b/boost/numeric/odeint.hpp @@ -71,4 +71,9 @@ #include +#include +#include +#include +#include + #endif // BOOST_NUMERIC_ODEINT_HPP_INCLUDED diff --git a/doc/boost_numeric_odeint/concepts.html b/doc/boost_numeric_odeint/concepts.html index c827a21b..6c6e772c 100644 --- a/doc/boost_numeric_odeint/concepts.html +++ b/doc/boost_numeric_odeint/concepts.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/concepts/controlled_stepper.html b/doc/boost_numeric_odeint/concepts/controlled_stepper.html index 5080fa77..c2ae125b 100644 --- a/doc/boost_numeric_odeint/concepts/controlled_stepper.html +++ b/doc/boost_numeric_odeint/concepts/controlled_stepper.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/concepts/dense_output_stepper.html b/doc/boost_numeric_odeint/concepts/dense_output_stepper.html index 2e65df2f..eb122b2f 100644 --- a/doc/boost_numeric_odeint/concepts/dense_output_stepper.html +++ b/doc/boost_numeric_odeint/concepts/dense_output_stepper.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/concepts/error_stepper.html b/doc/boost_numeric_odeint/concepts/error_stepper.html index 6b77b102..bbe46ef7 100644 --- a/doc/boost_numeric_odeint/concepts/error_stepper.html +++ b/doc/boost_numeric_odeint/concepts/error_stepper.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/concepts/implicit_system.html b/doc/boost_numeric_odeint/concepts/implicit_system.html index 7a47dedb..51be7ef5 100644 --- a/doc/boost_numeric_odeint/concepts/implicit_system.html +++ b/doc/boost_numeric_odeint/concepts/implicit_system.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/concepts/simple_symplectic_system.html b/doc/boost_numeric_odeint/concepts/simple_symplectic_system.html index 07e82fe4..eab3bae7 100644 --- a/doc/boost_numeric_odeint/concepts/simple_symplectic_system.html +++ b/doc/boost_numeric_odeint/concepts/simple_symplectic_system.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/concepts/state_algebra_operations.html b/doc/boost_numeric_odeint/concepts/state_algebra_operations.html index a77ed130..6feedb65 100644 --- a/doc/boost_numeric_odeint/concepts/state_algebra_operations.html +++ b/doc/boost_numeric_odeint/concepts/state_algebra_operations.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/concepts/state_wrapper.html b/doc/boost_numeric_odeint/concepts/state_wrapper.html index 885eefdd..6669af39 100644 --- a/doc/boost_numeric_odeint/concepts/state_wrapper.html +++ b/doc/boost_numeric_odeint/concepts/state_wrapper.html @@ -9,8 +9,6 @@ -
-
PrevUpHome
diff --git a/doc/boost_numeric_odeint/concepts/stepper.html b/doc/boost_numeric_odeint/concepts/stepper.html index 6c5e2b7a..3e952dfc 100644 --- a/doc/boost_numeric_odeint/concepts/stepper.html +++ b/doc/boost_numeric_odeint/concepts/stepper.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/concepts/symplectic_system.html b/doc/boost_numeric_odeint/concepts/symplectic_system.html index 66f172b3..922a7e61 100644 --- a/doc/boost_numeric_odeint/concepts/symplectic_system.html +++ b/doc/boost_numeric_odeint/concepts/symplectic_system.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/concepts/system.html b/doc/boost_numeric_odeint/concepts/system.html index 6663cdb1..ccbf96e7 100644 --- a/doc/boost_numeric_odeint/concepts/system.html +++ b/doc/boost_numeric_odeint/concepts/system.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/getting_started.html b/doc/boost_numeric_odeint/getting_started.html index d4328221..fd0d55e4 100644 --- a/doc/boost_numeric_odeint/getting_started.html +++ b/doc/boost_numeric_odeint/getting_started.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/getting_started/overview.html b/doc/boost_numeric_odeint/getting_started/overview.html index 9f39702c..0666bdeb 100644 --- a/doc/boost_numeric_odeint/getting_started/overview.html +++ b/doc/boost_numeric_odeint/getting_started/overview.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/getting_started/short_example.html b/doc/boost_numeric_odeint/getting_started/short_example.html index 80f072b0..2f9e5a2d 100644 --- a/doc/boost_numeric_odeint/getting_started/short_example.html +++ b/doc/boost_numeric_odeint/getting_started/short_example.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/getting_started/usage__compilation__headers.html b/doc/boost_numeric_odeint/getting_started/usage__compilation__headers.html index ca790227..8275fd09 100644 --- a/doc/boost_numeric_odeint/getting_started/usage__compilation__headers.html +++ b/doc/boost_numeric_odeint/getting_started/usage__compilation__headers.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/odeint_in_detail.html b/doc/boost_numeric_odeint/odeint_in_detail.html index d48c5cc8..8a40dea7 100644 --- a/doc/boost_numeric_odeint/odeint_in_detail.html +++ b/doc/boost_numeric_odeint/odeint_in_detail.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
@@ -25,6 +23,7 @@ functions
Integrate functions
+
Iterators
State types, algebras and operations
Using diff --git a/doc/boost_numeric_odeint/odeint_in_detail/generation_functions.html b/doc/boost_numeric_odeint/odeint_in_detail/generation_functions.html index f6673c03..77156109 100644 --- a/doc/boost_numeric_odeint/odeint_in_detail/generation_functions.html +++ b/doc/boost_numeric_odeint/odeint_in_detail/generation_functions.html @@ -10,8 +10,6 @@ -
-
diff --git a/doc/boost_numeric_odeint/odeint_in_detail/integrate_functions.html b/doc/boost_numeric_odeint/odeint_in_detail/integrate_functions.html index af378eda..0d0a4f5b 100644 --- a/doc/boost_numeric_odeint/odeint_in_detail/integrate_functions.html +++ b/doc/boost_numeric_odeint/odeint_in_detail/integrate_functions.html @@ -7,13 +7,11 @@ - + -
-
-PrevUpHomeNext +PrevUpHomeNext

@@ -336,7 +334,7 @@
-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/odeint_in_detail/state_types__algebras_and_operations.html b/doc/boost_numeric_odeint/odeint_in_detail/state_types__algebras_and_operations.html index 7e940231..fa5b3a24 100644 --- a/doc/boost_numeric_odeint/odeint_in_detail/state_types__algebras_and_operations.html +++ b/doc/boost_numeric_odeint/odeint_in_detail/state_types__algebras_and_operations.html @@ -6,14 +6,12 @@ - + -
-
-PrevUpHomeNext +PrevUpHomeNext

@@ -1305,7 +1303,7 @@
-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/odeint_in_detail/steppers.html b/doc/boost_numeric_odeint/odeint_in_detail/steppers.html index 11d78908..ec2c73c4 100644 --- a/doc/boost_numeric_odeint/odeint_in_detail/steppers.html +++ b/doc/boost_numeric_odeint/odeint_in_detail/steppers.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
@@ -152,7 +150,7 @@ rk.do_step( sys1 , in , t , out , dt ); // Out-of-place transformation rk.do_step( sys1 , inout , dxdtin , t , dt ); // In-place tranformation of inout rk.do_step( sys1 , in , dxdtin , t , out , dt ); // Out-of-place transformation - +

@@ -2004,8 +2002,8 @@ { public: - typedef std::array< double , N > state_type; - typedef std::array< double , N > deriv_type; + typedef boost::array< double , N > state_type; + typedef boost::array< double , N > deriv_type; typedef double value_type; typedef double time_type; typedef unsigned short order_type; @@ -2091,7 +2089,7 @@

const static size_t N = 1;
-typedef std::array< double , N > state_type;
+typedef boost::array< double , N > state_type;
 
 struct ornstein_det
 {
@@ -2103,8 +2101,8 @@
 
 struct ornstein_stoch
 {
-    std::mt19937 m_rng;
-    std::normal_distribution<> m_dist;
+    boost::mt19937 m_rng;
+    boost::normal_distribution<> m_dist;
 
     ornstein_stoch( double sigma ) : m_rng() , m_dist( 0.0 , sigma ) { }
 
@@ -2281,14 +2279,12 @@ c3 = 2/3, a31 =  0 , a32 = 2/3
         

-
typedef array< double , 3 > state_type;
+
typedef boost::array< double , 3 > state_type;
 heun< state_type > h;
 state_type x = {{ 10.0 , 10.0 , 10.0 }};
 
 integrate_const( h , lorenz() , x , 0.0 , 100.0 , 0.01 ,
-   []( const state_type &_x , double _t ) {
-                     std::cout << _t << "\t" << _x[0] << "\t" << _x[1] << "\t" << _x[2] << "\n";
-   });
+                 streaming_observer( std::cout ) );
 

diff --git a/doc/boost_numeric_odeint/odeint_in_detail/using_boost__range.html b/doc/boost_numeric_odeint/odeint_in_detail/using_boost__range.html index 243b9ad2..99e19f34 100644 --- a/doc/boost_numeric_odeint/odeint_in_detail/using_boost__range.html +++ b/doc/boost_numeric_odeint/odeint_in_detail/using_boost__range.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/odeint_in_detail/using_boost__ref.html b/doc/boost_numeric_odeint/odeint_in_detail/using_boost__ref.html index 42f27e4b..157c1aab 100644 --- a/doc/boost_numeric_odeint/odeint_in_detail/using_boost__ref.html +++ b/doc/boost_numeric_odeint/odeint_in_detail/using_boost__ref.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/tutorial.html b/doc/boost_numeric_odeint/tutorial.html index 1403ebd2..4bbd6a0b 100644 --- a/doc/boost_numeric_odeint/tutorial.html +++ b/doc/boost_numeric_odeint/tutorial.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/tutorial/all_examples.html b/doc/boost_numeric_odeint/tutorial/all_examples.html index c8230edd..f013bee5 100644 --- a/doc/boost_numeric_odeint/tutorial/all_examples.html +++ b/doc/boost_numeric_odeint/tutorial/all_examples.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/tutorial/chaotic_systems_and_lyapunov_exponents.html b/doc/boost_numeric_odeint/tutorial/chaotic_systems_and_lyapunov_exponents.html index ceb7ba07..77c62ca4 100644 --- a/doc/boost_numeric_odeint/tutorial/chaotic_systems_and_lyapunov_exponents.html +++ b/doc/boost_numeric_odeint/tutorial/chaotic_systems_and_lyapunov_exponents.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
@@ -131,7 +129,6 @@ lorenz()( x , dxdt , t ); ... } -

This works fine and lorenz_with_lyap diff --git a/doc/boost_numeric_odeint/tutorial/harmonic_oscillator.html b/doc/boost_numeric_odeint/tutorial/harmonic_oscillator.html index 979fb77e..b6d5bdf8 100644 --- a/doc/boost_numeric_odeint/tutorial/harmonic_oscillator.html +++ b/doc/boost_numeric_odeint/tutorial/harmonic_oscillator.html @@ -10,8 +10,6 @@ -
-


PrevUpHomeNext
@@ -29,6 +27,8 @@ with Constant Step Size

Integration with Adaptive Step Size
+
Using + iterators

@@ -1448,6 +1448,26 @@ works.

+
+ +

+ odeint supports iterators for solving ODEs. That is you instantiate a pair + of iterators and instead of using the integrate routines with an appropriate + observer you put the iterators in one of the algorithm from the C++ standard + library or from Boost.Range. An example is +

+

+

+
std::for_each( make_adaptive_iterator_begin( controlled_stepper , harmonic_oscillator , x , 0.0 , 0.01 ) ,
+               make_adaptive_iterator_end( controlled_stepper , harmonic_oscillator , x , 0.0 , 0.01 ) ,
+               write_state() );
+
+

+

+

The full cpp file for this example can be found here: harmonic_oscillator.cpp

diff --git a/doc/boost_numeric_odeint/tutorial/references.html b/doc/boost_numeric_odeint/tutorial/references.html index fb2dfdb7..13fd9573 100644 --- a/doc/boost_numeric_odeint/tutorial/references.html +++ b/doc/boost_numeric_odeint/tutorial/references.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/tutorial/solar_system.html b/doc/boost_numeric_odeint/tutorial/solar_system.html index 5b0200b0..d2b567dc 100644 --- a/doc/boost_numeric_odeint/tutorial/solar_system.html +++ b/doc/boost_numeric_odeint/tutorial/solar_system.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
@@ -140,7 +138,7 @@ p​i2 / (2m​i) + H​q//... // more operators - +

diff --git a/doc/boost_numeric_odeint/tutorial/special_topics.html b/doc/boost_numeric_odeint/tutorial/special_topics.html index 6ca823f5..8776ef65 100644 --- a/doc/boost_numeric_odeint/tutorial/special_topics.html +++ b/doc/boost_numeric_odeint/tutorial/special_topics.html @@ -10,8 +10,6 @@ -
-


PrevUpHomeNext
@@ -435,8 +433,6 @@ integrate_const( runge_kutta4< container_type >() , boost::ref( ensemble ) , x , 0.0 , 100.0 , dt , boost::ref( obs ) ); cout << epsilon << "\t" << obs.get_K_mean() << endl; } - -

diff --git a/doc/boost_numeric_odeint/tutorial/stiff_systems.html b/doc/boost_numeric_odeint/tutorial/stiff_systems.html index 8e627590..cf69f025 100644 --- a/doc/boost_numeric_odeint/tutorial/stiff_systems.html +++ b/doc/boost_numeric_odeint/tutorial/stiff_systems.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
diff --git a/doc/boost_numeric_odeint/tutorial/using_cuda_and_thrust.html b/doc/boost_numeric_odeint/tutorial/using_cuda_and_thrust.html index 9108a8f2..0f1cfe05 100644 --- a/doc/boost_numeric_odeint/tutorial/using_cuda_and_thrust.html +++ b/doc/boost_numeric_odeint/tutorial/using_cuda_and_thrust.html @@ -10,8 +10,6 @@ -
-
PrevUpHomeNext
@@ -178,8 +176,8 @@ static std::pair< value_type , value_type > get_mean( const state_type &x ) { value_type sin_sum = thrust::reduce( - thrust::make_transform_iterator( x.begin() , sin_functor() ) , - thrust::make_transform_iterator( x.end() , sin_functor() ) ); + thrust::make_transform_iterator( x.begin() , sin_functor() ) , + thrust::make_transform_iterator( x.end() , sin_functor() ) ); value_type cos_sum = thrust::reduce( thrust::make_transform_iterator( x.begin() , cos_functor() ) , thrust::make_transform_iterator( x.end() , cos_functor() ) ); diff --git a/doc/index.html b/doc/index.html index 5786185a..b3c30141 100644 --- a/doc/index.html +++ b/doc/index.html @@ -8,8 +8,6 @@ -
-
Next
@@ -24,7 +22,7 @@
-

+

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)

@@ -65,6 +63,7 @@ functions
Integrate functions
+
Iterators
State types, algebras and operations
Using @@ -95,7 +94,7 @@
- +

Last revised: June 26, 2012 at 05:15:24 GMT

Last revised: August 14, 2012 at 07:33:18 GMT


diff --git a/libs/numeric/odeint/doc/details_iterators.qbk b/libs/numeric/odeint/doc/details_iterators.qbk index b233f29b..8316f00d 100644 --- a/libs/numeric/odeint/doc/details_iterators.qbk +++ b/libs/numeric/odeint/doc/details_iterators.qbk @@ -1,20 +1,91 @@ -[section ODE Iterators] +[section Iterators] -odeint supports iterators for iterating throught an ordinary differential equation. They offer you an alternative to the integrate functions. Furthermore, many of the standard algorithms in the C++ standard library and Boost.Range can be used with the odeint't iterators. + + +odeint supports iterators for iterating through an ordinary differential equation. They offer you an alternative to the integrate functions. Furthermore, many of the standard algorithms in the C++ standard library and Boost.Range can be used with the odeint't iterators. [warning odeint's iterators do not satisfy the iterator concepts defined in the standard completely. In detail the iterator transitivity is violated in some rare cases. But this is not relevant for all algorithms in the C++ standard library and in Boost.Range.] -odeint provides for four new iterators. +[import ../examples/const_step_iterator.cpp] + +Four iterators are provided. They are all single pass iterators. The first one is a iterator which solves the odeint with constant step size. An example is + +[const_step_iterator_accumulate] + +In this example all x-values of the solution are accumulated. The iterator itself does not occur directly in this example but it is generated by the factory functions `make_const_step_iterator_begin` and `make_const_step_iterator_end`. odeint also supports Boost.Range, that is you write the above example in a shortified form with the factory function `make_const_step_range` + +[const_step_iterator_accumulate_range] + +The second iterator type is also a iterator with const step size. But the value type of this iterator consists here of a pair of the time and the state of the solution of the ODE. An example is + +[const_step_time_iterator_accumulate_range] + +The factory functions are now `make_const_step_time_iterator_begin`, `make_const_step_time_iterator_end` and `make_const_step_time_range`. +[import ../examples/adaptive_iterator.cpp] + +The other two iterator types adaptive iterators which are completely analogous to the const step iterators. Examples are + +[adaptive_iterator_accumulate_range] + +[adaptive_time_iterator_accumulate_range] + + +[section const_step_iterator] + +* Definition: `const_step_iterator< Stepper , System >` +* `value_type` is `Stepper::state_type` +* Factory functions + * `make_const_step_iterator_begin( stepper , system , state , t_start , dt )` + * `make_const_step_iterator_end( stepper , system , state , t_end , dt )` + * `make_const_step_range( stepper , system , state , t_start , t_end , dt )` +* This stepper works with all steppers fullfilling the Stepper concept or the DenseOutputStepper concept. + + +[endsect] + +[section const_step_time_iterator] + +* Definition: `const_step_iterator< Stepper , System >` +* `value_type` is `std::pair< Stepper::state_type& , Stepper::time_type >` +* Factory functions + * `make_const_step_time_iterator_begin( stepper , system , state , t_start , dt )` + * `make_const_step_time_iterator_end( stepper , system , state , t_end , dt )` + * `make_const_step_time_range( stepper , system , state , t_start , t_end , dt )` +* This stepper works with all steppers fullfilling the Stepper concept or the DenseOutputStepper concept. + +[endsect] + + +[section adaptive_step_iterator] + +* Definition: `adaptive_iterator< Stepper , System >` +* `value_type` is `Stepper::state_type` +* Factory functions + * `make_adaptive_iterator_begin( stepper , system , state , t_start , dt )` + * `make_adaptive_iterator_end( stepper , system , state , t_end , dt )` + * `make_adaptive_range( stepper , system , state , t_start , t_end , dt )` +* This stepper works with all steppers fullfilling the ControlledStepper concept or the DenseOutputStepper concept. + + +[endsect] + +[section adaptive_step_time_iterator] + +* Definition: `adaptive_iterator< Stepper , System >` +* `value_type` is `std::pair< Stepper::state_type& , Stepper::time_type >` +* Factory functions + * `make_adaptive_time_iterator_begin( stepper , system , state , t_start , dt )` + * `make_adaptive_time_iterator_end( stepper , system , state , t_end , dt )` + * `make_adaptive_time_range( stepper , system , state , t_start , t_end , dt )` +* This stepper works with all steppers fullfilling the ControlledStepper concept or the DenseOutputStepper concept. + +[endsect] -const step iterator, factory functions -const step time iterator, factory functions -adaptive iterator, factory functions -adaptive time iterator, factory functions [endsect] diff --git a/libs/numeric/odeint/doc/tutorial_harmonic_oscillator.qbk b/libs/numeric/odeint/doc/tutorial_harmonic_oscillator.qbk index e17fbe2e..f7a217e8 100644 --- a/libs/numeric/odeint/doc/tutorial_harmonic_oscillator.qbk +++ b/libs/numeric/odeint/doc/tutorial_harmonic_oscillator.qbk @@ -91,6 +91,15 @@ When using `make_controlled` or `make_dense_output` one should be aware which ex [endsect] -The full cpp file for this example can be found here: [github_link libs/numeric/odeint/examples/harmonic_oscillator.cpp harmonic_oscillator.cpp] +[section Using iterators] + +odeint supports iterators for solving ODEs. That is you instantiate a pair of iterators and instead of using the integrate routines with an appropriate observer you put the iterators in one of the algorithm from the C++ standard library or from Boost.Range. An example is + +[harm_iterator_const_step] + +[endsect] + +The full cpp file for this example can be found here: [github_link libs/numeric/odeint/examples/harmonic_oscillator.cpp harmonic_oscillator.cpp] + [endsect] diff --git a/libs/numeric/odeint/examples/adaptive_iterator.cpp b/libs/numeric/odeint/examples/adaptive_iterator.cpp index 599411bd..e905121f 100644 --- a/libs/numeric/odeint/examples/adaptive_iterator.cpp +++ b/libs/numeric/odeint/examples/adaptive_iterator.cpp @@ -146,12 +146,14 @@ int main( int argc , char **argv ) // boost::range::accumulate { + //[adaptive_time_iterator_accumulate_range auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); state_type x = {{ 10.0 , 10.0 , 10.0 }}; double res = boost::accumulate( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 , []( double sum , const pair< state_type& , double > &x ) { return sum + x.first[0]; } ); cout << res << endl; + //] } @@ -310,12 +312,14 @@ int main( int argc , char **argv ) // boost::range::accumulate { + //[adaptive_iterator_accumulate_range auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); state_type x = {{ 10.0 , 10.0 , 10.0 }}; double res = boost::accumulate( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 , []( double sum , const state_type& x ) { return sum + x[0]; } ); cout << res << endl; + //] } diff --git a/libs/numeric/odeint/examples/const_step_iterator.cpp b/libs/numeric/odeint/examples/const_step_iterator.cpp index 0455b7c4..df2a3ed9 100644 --- a/libs/numeric/odeint/examples/const_step_iterator.cpp +++ b/libs/numeric/odeint/examples/const_step_iterator.cpp @@ -74,6 +74,7 @@ int main( int argc , char **argv ) // std::accumulate { + //[ const_step_iterator_accumulate runge_kutta4< state_type > stepper; state_type x = {{ 10.0 , 10.0 , 10.0 }}; double res = std::accumulate( make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , 0.01 ) , @@ -82,6 +83,7 @@ int main( int argc , char **argv ) []( double sum , const state_type &x ) { return sum + x[0]; } ); cout << res << endl; + //] } @@ -162,22 +164,26 @@ int main( int argc , char **argv ) // boost::range::accumulate { + //[const_step_iterator_accumulate_range runge_kutta4< state_type > stepper; state_type x = {{ 10.0 , 10.0 , 10.0 }}; double res = boost::accumulate( make_const_step_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 , []( double sum , const state_type &x ) { return sum + x[0]; } ); cout << res << endl; + //] } // boost::range::accumulate with time iterator { + //[const_step_time_iterator_accumulate_range runge_kutta4< state_type > stepper; state_type x = {{ 10.0 , 10.0 , 10.0 }}; double res = boost::accumulate( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 , []( double sum , const std::pair< state_type &, double > &x ) { return sum + x.first[0]; } ); cout << res << endl; + //] } diff --git a/libs/numeric/odeint/examples/harmonic_oscillator.cpp b/libs/numeric/odeint/examples/harmonic_oscillator.cpp index 4ef89132..2448cdd8 100644 --- a/libs/numeric/odeint/examples/harmonic_oscillator.cpp +++ b/libs/numeric/odeint/examples/harmonic_oscillator.cpp @@ -61,6 +61,14 @@ struct push_back_state_and_time }; //] +struct write_state +{ + void operator()( const state_type &x ) const + { + std::cout << x[0] << "\t" << x[1] << "\n"; + } +}; + int main(int /* argc */ , char** /* argv */ ) { @@ -166,4 +174,11 @@ int main(int /* argc */ , char** /* argv */ ) harmonic_oscillator , x , 0.0 , 10.0 , 0.01 ); //] + + //[harm_iterator_const_step + std::for_each( make_adaptive_iterator_begin( controlled_stepper , harmonic_oscillator , x , 0.0 , 0.01 ) , + make_adaptive_iterator_end( controlled_stepper , harmonic_oscillator , x , 0.0 , 0.01 ) , + write_state() ); + //] + }