details_generation_functions.qbk 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. [/============================================================================
  2. Boost.odeint
  3. Copyright 2012 Karsten Ahnert
  4. Copyright 2012 Mario Mulansky
  5. Copyright 2012 Sylwester Arabas
  6. Use, modification and distribution is subject to the Boost Software License,
  7. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. http://www.boost.org/LICENSE_1_0.txt)
  9. =============================================================================/]
  10. [section Generation functions]
  11. [import ../examples/generation_functions.cpp]
  12. In the __tutorial we have learned how we can use the generation functions `make_controlled` and `make_dense_output` to create controlled and dense output stepper from a simple stepper or an error stepper. The syntax of these two functions is very simple:
  13. [generation_functions_syntax_auto]
  14. The first two parameters are the absolute and the relative error tolerances and the third parameter is the stepper. Additionally, a second version exists where additionally a maximal step size is supplied which ensures the the step size is not increased above this value.
  15. In C++03 you can infer the type from the `result_of` mechanism:
  16. [generation_functions_syntax_result_of]
  17. To use your own steppers with the `make_controlled` or `make_dense_output` you need to specialize two class templates. Suppose your steppers are called `custom_stepper`, `custom_controller` and `custom_dense_output`. Then, the first class you need to specialize is `boost::numeric::get_controller`, a meta function returning the type of the controller:
  18. [generation_functions_get_controller]
  19. The second one is a factory class `boost::numeric::odeint::controller_factory` which constructs the controller from the tolerances and the stepper. In our dummy implementation this class is
  20. [generation_functions_controller_factory]
  21. This is all to use the `make_controlled` mechanism. Now you can use your controller via
  22. [generation_functions_example_custom_controller]
  23. For the dense_output_stepper everything works similar. Here you have to specialize `boost::numeric::odeint::get_dense_output` and `boost::numeric::odeint::dense_output_factory`. These two classes have the same syntax as their relatives `get_controller` and `controller_factory`.
  24. All controllers and dense-output steppers in odeint can be used with these mechanisms. In the table below you will find, which steppers is constructed from `make_controlled` or `make_dense_output` if applied on a stepper from odeint:
  25. [include make_controlled_table.qbk]
  26. [include make_dense_output_table.qbk]
  27. [endsect]