Chris@16
|
1 /*
|
Chris@16
|
2 [auto_generated]
|
Chris@16
|
3 boost/numeric/odeint/util/resizer.hpp
|
Chris@16
|
4
|
Chris@16
|
5 [begin_description]
|
Chris@16
|
6 Implementation of the resizers.
|
Chris@16
|
7 [end_description]
|
Chris@16
|
8
|
Chris@101
|
9 Copyright 2011-2012 Mario Mulansky
|
Chris@101
|
10 Copyright 2011 Karsten Ahnert
|
Chris@16
|
11
|
Chris@16
|
12 Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
13 (See accompanying file LICENSE_1_0.txt or
|
Chris@16
|
14 copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
15 */
|
Chris@16
|
16
|
Chris@16
|
17
|
Chris@16
|
18 #ifndef BOOST_NUMERIC_ODEINT_UTIL_RESIZER_HPP_INCLUDED
|
Chris@16
|
19 #define BOOST_NUMERIC_ODEINT_UTIL_RESIZER_HPP_INCLUDED
|
Chris@16
|
20
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/numeric/odeint/util/is_resizeable.hpp>
|
Chris@16
|
23 #include <boost/numeric/odeint/util/same_size.hpp>
|
Chris@16
|
24 #include <boost/numeric/odeint/util/resize.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 namespace boost {
|
Chris@16
|
27 namespace numeric {
|
Chris@16
|
28 namespace odeint {
|
Chris@16
|
29
|
Chris@16
|
30 template< class ResizeWrappedState , class State >
|
Chris@16
|
31 bool adjust_size_by_resizeability( ResizeWrappedState &x , const State &y , boost::true_type )
|
Chris@16
|
32 {
|
Chris@16
|
33 if ( !same_size( x.m_v , y ) )
|
Chris@16
|
34 {
|
Chris@16
|
35 resize( x.m_v , y );
|
Chris@16
|
36 return true;
|
Chris@16
|
37 }
|
Chris@16
|
38 else
|
Chris@16
|
39 return false;
|
Chris@16
|
40 }
|
Chris@16
|
41
|
Chris@16
|
42 template< class ResizeWrappedState , class State >
|
Chris@16
|
43 bool adjust_size_by_resizeability( ResizeWrappedState & /* x */ , const State & /* y */ , boost::false_type )
|
Chris@16
|
44 {
|
Chris@16
|
45 return false;
|
Chris@16
|
46 }
|
Chris@16
|
47
|
Chris@16
|
48 struct always_resizer
|
Chris@16
|
49 {
|
Chris@16
|
50 template< class State , class ResizeFunction >
|
Chris@16
|
51 bool adjust_size( const State &x , ResizeFunction f )
|
Chris@16
|
52 {
|
Chris@16
|
53 return f( x );
|
Chris@16
|
54 }
|
Chris@16
|
55 };
|
Chris@16
|
56
|
Chris@16
|
57
|
Chris@16
|
58 struct initially_resizer
|
Chris@16
|
59 {
|
Chris@16
|
60
|
Chris@16
|
61 bool m_initialized;
|
Chris@16
|
62
|
Chris@16
|
63 initially_resizer() : m_initialized( false )
|
Chris@16
|
64 { }
|
Chris@16
|
65
|
Chris@16
|
66 template< class State , class ResizeFunction >
|
Chris@16
|
67 bool adjust_size( const State &x , ResizeFunction f )
|
Chris@16
|
68 {
|
Chris@16
|
69 if( !m_initialized )
|
Chris@16
|
70 {
|
Chris@16
|
71 m_initialized = true;
|
Chris@16
|
72 return f( x );
|
Chris@16
|
73 } else
|
Chris@16
|
74 return false;
|
Chris@16
|
75 }
|
Chris@16
|
76 };
|
Chris@16
|
77
|
Chris@16
|
78
|
Chris@16
|
79 struct never_resizer
|
Chris@16
|
80 {
|
Chris@16
|
81 template< class State , class ResizeFunction >
|
Chris@16
|
82 bool adjust_size( const State &x , ResizeFunction f )
|
Chris@16
|
83 {
|
Chris@16
|
84 return false;
|
Chris@16
|
85 }
|
Chris@16
|
86 };
|
Chris@16
|
87
|
Chris@16
|
88
|
Chris@16
|
89 }
|
Chris@16
|
90 }
|
Chris@16
|
91 }
|
Chris@16
|
92
|
Chris@16
|
93 #endif // BOOST_NUMERIC_ODEINT_UTIL_RESIZER_HPP_INCLUDED
|