Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59731 - in sandbox/odeint: boost/numeric/odeint boost/numeric/odeint/detail libs/numeric/odeint/doc libs/numeric/odeint/doc/html libs/numeric/odeint/doc/html/odeint libs/numeric/odeint/examples
From: mario.mulansky_at_[hidden]
Date: 2010-02-17 11:47:36


Author: mariomulansky
Date: 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
New Revision: 59731
URL: http://svn.boost.org/trac/boost/changeset/59731

Log:
integrate_const interfaces now consistent, added adaptive integration section to tutorial
Added:
   sandbox/odeint/libs/numeric/odeint/examples/doc_integrate.cpp
      - copied, changed from r59728, /sandbox/odeint/libs/numeric/odeint/examples/doc_integrate_const.cpp
Removed:
   sandbox/odeint/libs/numeric/odeint/examples/doc_integrate_const.cpp
Text files modified:
   sandbox/odeint/boost/numeric/odeint/controlled_stepper_standard.hpp | 12 +++
   sandbox/odeint/boost/numeric/odeint/detail/iterator_algebra.hpp | 2
   sandbox/odeint/boost/numeric/odeint/error_checker_standard.hpp | 2
   sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp | 10 +-
   sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp | 38 ++++++------
   sandbox/odeint/libs/numeric/odeint/doc/Jamfile | 4
   sandbox/odeint/libs/numeric/odeint/doc/html/index.html | 39 ++++-------
   sandbox/odeint/libs/numeric/odeint/doc/html/odeint/short_example.html | 20 +++---
   sandbox/odeint/libs/numeric/odeint/doc/html/standalone_HTML.manifest | 3
   sandbox/odeint/libs/numeric/odeint/doc/odeint.qbk | 91 ----------------------------
   sandbox/odeint/libs/numeric/odeint/doc/tutorial.qbk | 126 ++++++++++++++++++++++++++++++++++++++-
   sandbox/odeint/libs/numeric/odeint/examples/doc_integrate.cpp | 19 +++++
   sandbox/odeint/libs/numeric/odeint/examples/lorenz_integrate_constant_step.cpp | 8 +-
   13 files changed, 209 insertions(+), 165 deletions(-)

Modified: sandbox/odeint/boost/numeric/odeint/controlled_stepper_standard.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/controlled_stepper_standard.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/controlled_stepper_standard.hpp 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -176,6 +176,18 @@
 
     };
 
+ template< class ErrorStepper >
+ controlled_stepper_standard< ErrorStepper > make_controlled_stepper_standard(
+ ErrorStepper &stepper,
+ ErrorStepper::time_type abs_err, ErrorStepper::time_type rel_err,
+ ErrorStepper::time_type factor_x, ErrorStepper::time_type factor_dxdt )
+ {
+ return controlled_stepper_standard< ErrorStepper >(
+ stepper , abs_err , rel_err , factor_x , factor_dxdt );
+ };
+
+
+
 } // namespace odeint
 } // namespace numeric
 } // namespace boost

Modified: sandbox/odeint/boost/numeric/odeint/detail/iterator_algebra.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/detail/iterator_algebra.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/detail/iterator_algebra.hpp 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -532,7 +532,7 @@
         class InputIterator1,
         class InputIterator2,
         class T >
- void weighted_error( OutputIterator y_begin,
+ void weighted_scale( OutputIterator y_begin,
                          OutputIterator y_end,
                          InputIterator1 x1_begin,
                          InputIterator2 x2_begin,

Modified: sandbox/odeint/boost/numeric/odeint/error_checker_standard.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/error_checker_standard.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/error_checker_standard.hpp 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -59,7 +59,7 @@
                 time_type dt,
                 container_type &scale )
         {
- detail::it_algebra::weighted_error( traits_type::begin(scale),
+ detail::it_algebra::weighted_scale( traits_type::begin(scale),
                                                 traits_type::end(scale),
                                                 traits_type::begin(x),
                                                 traits_type::end(dxdt),

Modified: sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -138,9 +138,9 @@
>
     size_t integrate(
             DynamicalSystem &system,
- ContainerType &x,
- T start ,
- T end ,
+ ContainerType &state,
+ T start_time ,
+ T end_time ,
             TimeInsertIterator time_inserter,
             StateInsertIterator state_inserter,
             T dt = 1E-4,
@@ -159,8 +159,8 @@
         // initialized with values from above
         
         // call the normal integrator
- return integrate(controlled_stepper, system, x,
- start, end, dt, time_inserter, state_inserter);
+ return integrate(controlled_stepper, system, state,
+ start_time, end_time, dt, time_inserter, state_inserter);
     }
     
 

Modified: sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -28,10 +28,10 @@
     size_t integrate_const(
         Stepper &stepper ,
         DynamicalSystem &system ,
- typename Stepper::time_type start_time ,
- typename Stepper::time_type dt ,
         typename Stepper::container_type &state ,
+ typename Stepper::time_type start_time ,
         typename Stepper::time_type end_time ,
+ typename Stepper::time_type dt ,
         Observer &observer
         )
     {
@@ -57,19 +57,19 @@
     size_t integrate_const(
         Stepper &stepper ,
         DynamicalSystem &system ,
- typename Stepper::time_type start_time ,
- typename Stepper::time_type dt ,
         typename Stepper::container_type &state ,
- typename Stepper::time_type end_time
+ typename Stepper::time_type start_time ,
+ typename Stepper::time_type end_time ,
+ typename Stepper::time_type dt
         )
     {
         return integrate_const(
- stepper , system , start_time , dt , state , end_time ,
- do_nothing_observer<
- typename Stepper::time_type ,
- typename Stepper::container_type ,
- DynamicalSystem >
- );
+ stepper , system , state, start_time , end_time , dt ,
+ do_nothing_observer<
+ typename Stepper::time_type ,
+ typename Stepper::container_type ,
+ DynamicalSystem >
+ );
     }
 
 
@@ -82,9 +82,9 @@
     typename Stepper::time_type integrate_const_steps(
         Stepper &stepper ,
         DynamicalSystem &system ,
+ typename Stepper::container_type &state ,
         typename Stepper::time_type start_time ,
         typename Stepper::time_type dt ,
- typename Stepper::container_type &state ,
         size_t num_of_steps ,
         Observer &observer
         )
@@ -110,19 +110,19 @@
     typename Stepper::time_type integrate_const_steps(
         Stepper &stepper ,
         DynamicalSystem &system ,
+ typename Stepper::container_type &state ,
         typename Stepper::time_type start_time ,
         typename Stepper::time_type dt ,
- typename Stepper::container_type &state ,
         size_t num_of_steps
         )
     {
         return integrate_const_steps(
- stepper , system , start_time , dt , state , num_of_steps ,
- do_nothing_observer<
- typename Stepper::time_type ,
- typename Stepper::container_type ,
- DynamicalSystem >
- );
+ stepper , system , state , start_time , dt , num_of_steps ,
+ do_nothing_observer<
+ typename Stepper::time_type ,
+ typename Stepper::container_type ,
+ DynamicalSystem >
+ );
     }
 
     

Modified: sandbox/odeint/libs/numeric/odeint/doc/Jamfile
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/doc/Jamfile (original)
+++ sandbox/odeint/libs/numeric/odeint/doc/Jamfile 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -1,6 +1,8 @@
 import quickbook ;
 
-xml odeint : odeint.qbk ;
+xml odeint :
+ odeint.qbk
+ ;
 
 boostbook standalone
         :

Modified: sandbox/odeint/libs/numeric/odeint/doc/html/index.html
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/doc/html/index.html (original)
+++ sandbox/odeint/libs/numeric/odeint/doc/html/index.html 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -1,10 +1,10 @@
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>Chapter&#160;1.&#160;boost.sandbox.numeric.odeint</title>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Chapter 1. boost.sandbox.numeric.odeint</title>
 <link rel="stylesheet" href="boostbook.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
-<link rel="home" href="index.html" title="Chapter&#160;1.&#160;boost.sandbox.numeric.odeint">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="index.html" title="Chapter 1. boost.sandbox.numeric.odeint">
 <link rel="next" href="odeint/short_example.html" title="Short Example">
 </head>
 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@@ -18,19 +18,19 @@
 </tr></table>
 <hr>
 <div class="spirit-nav"><a accesskey="n" href="odeint/short_example.html"><img src="../../doc/html/images/next.png" alt="Next"></a></div>
-<div class="chapter" title="Chapter&#160;1.&#160;boost.sandbox.numeric.odeint">
+<div class="chapter" lang="en">
 <div class="titlepage"><div>
 <div><h2 class="title">
-<a name="odeint"></a>Chapter&#160;1.&#160;boost.sandbox.numeric.odeint</h2></div>
+<a name="odeint"></a>Chapter 1. boost.sandbox.numeric.odeint</h2></div>
 <div><div class="author"><h3 class="author">
 <span class="firstname">Karsten</span> <span class="surname">Ahnert</span>
 </h3></div></div>
 <div><div class="author"><h3 class="author">
 <span class="firstname">Mario</span> <span class="surname">Mulansky</span>
 </h3></div></div>
-<div><p class="copyright">Copyright &#169; 2009 Karsten Ahnert and Mario Mulansky</p></div>
-<div><div class="legalnotice" title="Legal Notice">
-<a name="id366480"></a><p>
+<div><p class="copyright">Copyright © 2009 Karsten Ahnert and Mario Mulansky</p></div>
+<div><div class="legalnotice">
+<a name="id357869"></a><p>
         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)
       </p>
@@ -41,20 +41,11 @@
 <dl>
 <dt><span class="section">Overview</span></dt>
 <dt><span class="section">Short Example</span></dt>
-<dt><span class="section">Tutorial</span></dt>
+<dt><span class="section">Tutorial</span></dt>
 <dd><dl>
-<dt><span class="section">Define the ODE</span></dt>
-<dt><span class="section">Stepper Types</span></dt>
-<dt><span class="section"><a href="odeint/tutorial.html#odeint.tutorial.integration_with_constant_stepsize">Integration
- with Constant Stepsize</a></span></dt>
-<dt><span class="section"><a href="odeint/tutorial.html#odeint.tutorial.integration_with_adaptive_stepsize">Integration
- with Adaptive Stepsize</a></span></dt>
-</dl></dd>
-<dt><span class="section">Tutorial2</span></dt>
-<dd><dl>
-<dt><span class="section"><a href="boost_sandbox_numeric_odeint/tutorial2.html#boost_sandbox_numeric_odeint.tutorial2.harmonic_oscillator">Harmonic
+<dt><span class="section"><a href="boost_sandbox_numeric_odeint/tutorial.html#boost_sandbox_numeric_odeint.tutorial.harmonic_oscillator">Harmonic
       oscillator</a></span></dt>
-<dt><span class="section"><a href="boost_sandbox_numeric_odeint/tutorial2.html#boost_sandbox_numeric_odeint.tutorial2.solar_system">Solar
+<dt><span class="section"><a href="boost_sandbox_numeric_odeint/tutorial.html#boost_sandbox_numeric_odeint.tutorial.solar_system">Solar
       system</a></span></dt>
 </dl></dd>
 <dt><span class="section">Stepper</span></dt>
@@ -77,7 +68,7 @@
       your own traits</a></span></dt></dl></dd>
 </dl>
 </div>
-<div class="section" title="Overview">
+<div class="section" lang="en">
 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
 <a name="odeint.overview"></a><a class="link" href="index.html#odeint.overview" title="Overview">Overview</a>
 </h2></div></div></div>
@@ -95,7 +86,7 @@
       for real life problems and serves just as illustrative example. In <span class="bold"><strong>odeint</strong></span>, the following algorithms are implemented:
     </p>
 <div class="table">
-<a name="id335508"></a><p class="title"><b>Table&#160;1.1.&#160;Stepper Algorithms</b></p>
+<a name="id326900"></a><p class="title"><b>Table 1.1. Stepper Algorithms</b></p>
 <div class="table-contents"><table class="table" summary="Stepper Algorithms">
 <colgroup>
 <col>
@@ -265,7 +256,7 @@
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: February 16, 2010 at 14:51:53 GMT</small></p></td>
+<td align="left"><p><small>Last revised: February 17, 2010 at 16:45:45 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/odeint/libs/numeric/odeint/doc/html/odeint/short_example.html
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/doc/html/odeint/short_example.html (original)
+++ sandbox/odeint/libs/numeric/odeint/doc/html/odeint/short_example.html 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -1,13 +1,13 @@
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <title>Short Example</title>
 <link rel="stylesheet" href="../boostbook.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
-<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;boost.sandbox.numeric.odeint">
-<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;boost.sandbox.numeric.odeint">
-<link rel="prev" href="../index.html" title="Chapter&#160;1.&#160;boost.sandbox.numeric.odeint">
-<link rel="next" href="tutorial.html" title="Tutorial">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter 1. boost.sandbox.numeric.odeint">
+<link rel="up" href="../index.html" title="Chapter 1. boost.sandbox.numeric.odeint">
+<link rel="prev" href="../index.html" title="Chapter 1. boost.sandbox.numeric.odeint">
+<link rel="next" href="../boost_sandbox_numeric_odeint/tutorial.html" title="Tutorial">
 </head>
 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
 <table cellpadding="2" width="100%"><tr>
@@ -20,9 +20,9 @@
 </tr></table>
 <hr>
 <div class="spirit-nav">
-<a accesskey="p" href="../index.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+<a accesskey="p" href="../index.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../boost_sandbox_numeric_odeint/tutorial.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-<div class="section" title="Short Example">
+<div class="section" lang="en">
 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
 <a name="odeint.short_example"></a><a class="link" href="short_example.html" title="Short Example">Short Example</a>
 </h2></div></div></div>
@@ -146,7 +146,7 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2009 Karsten Ahnert and Mario Mulansky<p>
+<td align="right"><div class="copyright-footer">Copyright © 2009 Karsten Ahnert and Mario Mulansky<p>
         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)
       </p>
@@ -154,7 +154,7 @@
 </tr></table>
 <hr>
 <div class="spirit-nav">
-<a accesskey="p" href="../index.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
+<a accesskey="p" href="../index.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../boost_sandbox_numeric_odeint/tutorial.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
 </div>
 </body>
 </html>

Modified: sandbox/odeint/libs/numeric/odeint/doc/html/standalone_HTML.manifest
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/doc/html/standalone_HTML.manifest (original)
+++ sandbox/odeint/libs/numeric/odeint/doc/html/standalone_HTML.manifest 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -1,7 +1,6 @@
 index.html
 odeint/short_example.html
-odeint/tutorial.html
-boost_sandbox_numeric_odeint/tutorial2.html
+boost_sandbox_numeric_odeint/tutorial.html
 boost_sandbox_numeric_odeint/stepper.html
 boost_sandbox_numeric_odeint/integration_functions.html
 boost_sandbox_numeric_odeint/container_traits.html

Modified: sandbox/odeint/libs/numeric/odeint/doc/odeint.qbk
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/doc/odeint.qbk (original)
+++ sandbox/odeint/libs/numeric/odeint/doc/odeint.qbk 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -95,96 +95,7 @@
 
 [endsect]
 
-[section Tutorial]
-
-[section Define the ODE]
-First of all, you have to specify the datatype that represents a state of your
-system [*x]. Mathematically, this usually is an n-dimensional vector with
-real numbers or complex numbers as scalar objects. For odeint the most natural
-way is to use `vector< double >` or `vector< complex< double > >` to represent
-the system state. However, odeint can deal with other container types than
-vector as well, e.g. `tr1/array< double , N >` as long as it is able to obtain
-a ForwardIterator going through all of the container's elements. The scalar type
-must have several operators ( +, -, +=, -= ) and the `abs()`-fcuntion defined .
-Furthermore, one can choose the datatype of the time (that is, the parameter to
-which respect the differentiation is done). The standard type for this is
-`double`, but one might be able to choose, for example, `complex< double >` as
-well (untested). It must be possible to multiply the time type and the scalar
-type of the vector. For the most cases `vector< double >` as state type and the
-standard `double` for the time type should be sufficient.
-
-To integrate a differential equation numerically, one has to define the rhs of
-the equation ['x' = f(x)]. In odeint you supply this function in terms of
-an object that implements the ()-operator with a certain parameter structure.
-Hence, the straight forward way would be to just define a function, e.g:
-[rhs_function]
-The parameters of the function must follow the example above where [*x] is the
-current state, [*dxdt] is the derivative ['x'] and should be filled by the
-function with ['f(x)] and [*t] is the current time.
-
-A more sophisticated approach is to implement the system as a class where the
-rhs function is defined as the ()-operator of the class with the same parameter
-structure as above:
-[rhs_class]
-odeint can deal with instances of such classes instead of pure functions which
-allows for cleaner code.
-
-[endsect]
-
-[section Stepper Types]
-Numerical integration works iteratevly, that means you start at a state ['x(t)]
-and performs a timestep of length ['dt] to obtain the approximate state
-['x(t+dt)]. There exist many different methods to perform such a timestep each
-of which has a certain order ['q]. If the order of a method is ['q] than it is
-accurate up to term ['~dt^q] that means the error in ['x] made by such a step
-is ['~dt^(q+1)]. odeint provides several steppers of different orders from which
-you can choose. There are three types of steppers: [*Stepper], [*ErrorStepper]
-and [*ControlledStepper].
-
-[table Stepper Algorithms
- [[Method] [Class] [Order] [Error Estimation]]
- [[Euler] [stepper_euler] [1] [No]]
- [[Runge-Kutta 4] [stepper_rk4] [4] [No]]
- [[Runge-Kutta Cash-Karp] [stepper_rk5_ck] [5] [Yes (Order 4)]]
- [[Runge-Kutta Fehlberg] [stepper_rk78_fehlberg] [7] [Yes (Order 8)]]
- [[Midpoint] [stepper_midpoint] [variable] [No]]
- [[Bulirsch-Stoer] [controlled_stepper_bs] [variable] [Controlled]]
-]
-
-[endsect]
-
-[section Integration with Constant Stepsize]
-[import ../examples/doc_integrate_const.cpp]
-The basic stepper just performs one timestep and doesn't give you any
-information about the error that was made (except that you know it is of order
-q). Such steppers are used with constant stepsize that should be chosen small
-enough to have reasonable small errors. However, you should apply some sort of
-validity check of your results (such as observing conserved quantities) becasue
-you have no other control of the error. The following example defines basic
-stepper based on the classical Runge-Kutta scheme of 4th order.
-
-[define_stepper]
-
-The declaration of the stepper requires the state type as template parameter.
-The integration can now be done by using the `integrate_const( Stepper, System,
- start_time, step_size, state, end_time)` function from odeint:
-
-[integrate]
-
-This call integrates the system defined by `harmonic_oscillator` using the rk4
-method from t=0 to 10 with a stepsize dt=0.01 with the initial condition given
-in `x`. The result, ['x(t=10)] is stored in `x` (in-place).
-
-[endsect]
-
-[section Integration with Adaptive Stepsize]
-
-[endsect]
-
-[endsect]
-
-
-
+[import ../examples/doc_integrate.cpp]
 [include tutorial.qbk]
 
 [include steppers.qbk]

Modified: sandbox/odeint/libs/numeric/odeint/doc/tutorial.qbk
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/doc/tutorial.qbk (original)
+++ sandbox/odeint/libs/numeric/odeint/doc/tutorial.qbk 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -1,17 +1,131 @@
-[section Tutorial2]
-
-huhu
+[section Tutorial]
 
 [section Harmonic oscillator]
 
-define the system, via function and via classes
+[section Define the ODE]
+First of all, you have to specify the datatype that represents a state of your
+system [*x]. Mathematically, this usually is an n-dimensional vector with
+real numbers or complex numbers as scalar objects. For odeint the most natural
+way is to use `vector< double >` or `vector< complex< double > >` to represent
+the system state. However, odeint can deal with other container types than
+vector as well, e.g. `tr1/array< double , N >` as long as it is able to obtain
+a ForwardIterator going through all of the container's elements. The scalar type
+must have several operators ( +, -, +=, -= ) and the `abs()`-fcuntion defined .
+Furthermore, one can choose the datatype of the time (that is, the parameter to
+which respect the differentiation is done). The standard type for this is
+`double`, but one might be able to choose, for example, `complex< double >` as
+well (untested). It must be possible to multiply the time type and the scalar
+type of the vector. For the most cases `vector< double >` as state type and the
+standard `double` for the time type should be sufficient.
+
+To integrate a differential equation numerically, one has to define the rhs of
+the equation ['x' = f(x)]. In odeint you supply this function in terms of
+an object that implements the ()-operator with a certain parameter structure.
+Hence, the straight forward way would be to just define a function, e.g:
+
+[rhs_function]
+
+The parameters of the function must follow the example above where [*x] is the
+current state, [*dxdt] is the derivative ['x'] and should be filled by the
+function with ['f(x)] and [*t] is the current time.
+
+A more sophisticated approach is to implement the system as a class where the
+rhs function is defined as the ()-operator of the class with the same parameter
+structure as above:
 
-usage of the steppers
+[rhs_class]
+
+odeint can deal with instances of such classes instead of pure functions which
+allows for cleaner code.
+
+[endsect]
+
+[section Stepper Types]
+Numerical integration works iteratevly, that means you start at a state ['x(t)]
+and performs a timestep of length ['dt] to obtain the approximate state
+['x(t+dt)]. There exist many different methods to perform such a timestep each
+of which has a certain order ['q]. If the order of a method is ['q] than it is
+accurate up to term ['~dt^q] that means the error in ['x] made by such a step
+is ['~dt^(q+1)]. odeint provides several steppers of different orders from which
+you can choose. There are three types of steppers: [*Stepper], [*ErrorStepper]
+and [*ControlledStepper].
+
+[table Stepper Algorithms
+ [[Method] [Class] [Order] [Error Estimation]]
+ [[Euler] [stepper_euler] [1] [No]]
+ [[Runge-Kutta 4] [stepper_rk4] [4] [No]]
+ [[Runge-Kutta Cash-Karp] [stepper_rk5_ck] [5] [Yes (Order 4)]]
+ [[Runge-Kutta Fehlberg] [stepper_rk78_fehlberg] [7] [Yes (Order 8)]]
+ [[Midpoint] [stepper_midpoint] [variable] [No]]
+ [[Bulirsch-Stoer] [controlled_stepper_bs] [variable] [Controlled]]
+]
+
+[endsect]
+
+[section Integration with Constant Step Size]
+The basic stepper just performs one timestep and doesn't give you any
+information about the error that was made (except that you know it is of order
+q+1). Such steppers are used with constant step size that should be chosen small
+enough to have reasonable small errors. However, you should apply some sort of
+validity check of your results (such as observing conserved quantities) becasue
+you have no other control of the error. The following example defines a basic
+stepper based on the classical Runge-Kutta scheme of 4th order.
+
+[define_const_stepper]
+
+The declaration of the stepper requires the state type as template parameter.
+The integration can now be done by using the `integrate_const( Stepper, System,
+ state, start_time, end_time, step_size )` function from odeint:
+
+[integrate_const]
+
+This call integrates the system defined by `harmonic_oscillator` using the rk4
+method from t=0 to 10 with a stepsize dt=0.01 and the initial condition given
+in `x`. The result, ['x(t=10)] is stored in `x` (in-place).
+
+[endsect]
 
-usage of the integration functions
+[section Integration with Adaptive Step Size]
+To improve the numerical results and additionally minimize the computational
+effort, the application of a step size control is advisable.
+Step size control is realized via stepper algorithms that additionally provide an
+error estimation of the applied step.
+Odeint provides a number of such *ErrorSteppers* and we will show their usage on
+the example of stepper_rk5_ck -- a 5th order Runge-Kutta method with 4th order
+error estimation and coefficients introduced by Cash-Karp.
+
+[define_adapt_stepper]
+
+Given the error stepper, one still needs an instance that checks the error and
+adjusts the step size accordingly.
+In odeint, this is done by *ControlledSteppers*.
+The usual way to create a controlled stepper is via the
+`make_controlled_stepper_standard( ErrorStepper , eps_abs , eps_rel , a_x , a_dxdt )`
+function that takes an error stepper as parameter and four values defining the maximal
+absolute and relative error allowed for on integration step.
+The standard controlled stepper created by this method ensures that the error ['err]
+of the solution fulfills
+['err < eps_abs + eps_rel * ( a_x * |x| + a_dxdt * dt * |dxdt| ) ]
+by decreasesing the step size. Note, that the stepsize is also increased if the error
+gets too small compared to the rhs of the above relation.
+Now we have everything needed to integrate the harmonic oscillator using an adaptive
+step size method.
+Similar to the case with constant step size above, there exists a `integrate_adaptive`
+function with a similar parameter structure, but it requires the controlled stepper
+create by `make_controlled_stepper_standard`.
+
+[integrate_adapt]
+
+As above, this integrates the system defined by `harmonic_oscillator` using an adaptive
+step size method based on the rk5_ck scheme from t=0 to 10 with an initial step size of
+dt=0.01 (will be adjusted) and the initial condition given in x. The result, x(t=10), will
+also be stored in x (in-place).
 
 [endsect]
 
+[endsect]
+
+
 [section Solar system]
 
 define point types via operators

Copied: sandbox/odeint/libs/numeric/odeint/examples/doc_integrate.cpp (from r59728, /sandbox/odeint/libs/numeric/odeint/examples/doc_integrate_const.cpp)
==============================================================================
--- /sandbox/odeint/libs/numeric/odeint/examples/doc_integrate_const.cpp (original)
+++ sandbox/odeint/libs/numeric/odeint/examples/doc_integrate.cpp 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -32,13 +32,28 @@
 
     harm_osc harmonic_oscillator(0.15);
 
- //[ define_stepper
+ //[ define_const_stepper
     stepper_rk4< state_type > rk4;
     //]
 
- //[ integrate
+ //[ integrate_const
     integrate_const( rk4, harmonic_oscillator, 0.0, 0.01, x, 10.0 );
     //]
+
+
+ //[ define_adapt_stepper
+ stepper_rk5_ck< state_type > rk5;
+ //]
+
+ //[ define_conntrolled_stepper
+ controlled_stepper_standard< stepper_rk5_ck< state_type > >
+ controlled_rk5( rk5 , 1E-6 , 1E-7 , 1.0 , 1.0 );
+ //]
+
+ //[ integrate_adapt
+ integrate_adaptive( make_controlled_stepper_standard( rk5 , 1E-6 , 1E-7 , 1.0 , 1.0 ),
+ harmonic_oscillator, 0.0, 0.01, x, 10.0 );
+ //]
     
     cout << x[0] << '\t' << x[1] << endl;
 

Deleted: sandbox/odeint/libs/numeric/odeint/examples/doc_integrate_const.cpp
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/examples/doc_integrate_const.cpp 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
+++ (empty file)
@@ -1,45 +0,0 @@
-#include <iostream>
-
-#include <boost/numeric/odeint.hpp>
-
-using namespace std;
-
-/* The type of container used to hold the state vector */
-typedef std::vector<double> state_type;
-
-class harm_osc {
-
- double m_gam;
-
-public:
- harm_osc( double gam ) : m_gam(gam) { }
-
- void operator() (const state_type &x, state_type &dxdt, const double t)
- {
- dxdt[0] = x[1];
- dxdt[1] = -x[0] - m_gam*x[1];
- }
-};
-
-int main(int argc, char **argv)
-{
- using namespace std;
- using namespace boost::numeric::odeint;
-
- state_type x(2);
- x[0] = 1.0; // start at x=1.0, p=0.0
- x[1] = 0.0;
-
- harm_osc harmonic_oscillator(0.15);
-
- //[ define_stepper
- stepper_rk4< state_type > rk4;
- //]
-
- //[ integrate
- integrate_const( rk4, harmonic_oscillator, 0.0, 0.01, x, 10.0 );
- //]
-
- cout << x[0] << '\t' << x[1] << endl;
-
-}

Modified: sandbox/odeint/libs/numeric/odeint/examples/lorenz_integrate_constant_step.cpp
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/examples/lorenz_integrate_constant_step.cpp (original)
+++ sandbox/odeint/libs/numeric/odeint/examples/lorenz_integrate_constant_step.cpp 2010-02-17 11:47:34 EST (Wed, 17 Feb 2010)
@@ -66,14 +66,14 @@
 
     stepper_rk4< state_type > rk4;
     stepper_euler< state_type > euler;
- integrate_const( rk4 , lorenz , 0.0 , 0.01 , x , 100.0 ,
+ integrate_const( rk4 , lorenz , x , 0.0 , 100.0 , 0.01 ,
                cout << _1 << tab << _2[0] << "\n" );
 
- integrate_const_steps( rk4 , lorenz , 0.0 , 0.01 , x , 100 ,
+ integrate_const_steps( rk4 , lorenz , x, 0.0 , 0.01 , 100 ,
                      cout << _1 << tab << _2[0] << "\n" );
 
- integrate_const( rk4 , lorenz , 0.0 , 0.01 , x , 100.0 );
- integrate_const_steps( rk4 , lorenz , 0.0 , 0.01 , x , 1000 );
+ integrate_const( rk4 , lorenz , x , 0.0 , 100.0, 0.01 );
+ integrate_const_steps( rk4 , lorenz , x , 0.0 , 0.01 , 1000 );
 
 /* integrate( euler , lorenz , 0.0 , 0.01 , x , 100.0 ,
       cout << _1 << tab << _2[0] << "\n" );*/


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk