resizer.hpp 1.9 KB

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