Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / numeric / odeint / stepper / generation / make_controlled.hpp
1 /*
2  [auto_generated]
3  boost/numeric/odeint/stepper/generation/make_controlled.hpp
4
5  [begin_description]
6  Factory function to simplify the creation of controlled steppers from error steppers.
7  [end_description]
8
9  Copyright 2011-2012 Karsten Ahnert
10  Copyright 2011-2012 Mario Mulansky
11
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
17
18 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_GENERATION_MAKE_CONTROLLED_HPP_INCLUDED
19 #define BOOST_NUMERIC_ODEINT_STEPPER_GENERATION_MAKE_CONTROLLED_HPP_INCLUDED
20
21
22
23
24 namespace boost {
25 namespace numeric {
26 namespace odeint {
27
28
29
30 // default template for the controller
31 template< class Stepper > struct get_controller { };
32
33
34
35 // default controller factory
36 template< class Stepper , class Controller >
37 struct controller_factory
38 {
39     Controller operator()(
40             typename Stepper::value_type abs_error ,
41             typename Stepper::value_type rel_error ,
42             const Stepper &stepper )
43     {
44         return Controller( abs_error , rel_error , stepper );
45     }
46 };
47
48
49
50
51 namespace result_of
52 {
53     template< class Stepper >
54     struct make_controlled
55     {
56         typedef typename get_controller< Stepper >::type type;
57     };
58 }
59
60
61 template< class Stepper >
62 typename result_of::make_controlled< Stepper >::type make_controlled(
63         typename Stepper::value_type abs_error ,
64         typename Stepper::value_type rel_error ,
65         const Stepper & stepper = Stepper() )
66 {
67     typedef Stepper stepper_type;
68     typedef typename result_of::make_controlled< stepper_type >::type controller_type;
69     typedef controller_factory< stepper_type , controller_type > factory_type;
70     factory_type factory;
71     return factory( abs_error , rel_error , stepper );
72 }
73
74
75
76 } // odeint
77 } // numeric
78 } // boost
79
80
81 #endif // BOOST_NUMERIC_ODEINT_STEPPER_GENERATION_MAKE_CONTROLLED_HPP_INCLUDED