annotate DEPENDENCIES/generic/include/boost/numeric/odeint/util/resize.hpp @ 76:e58ce2aebd18 emscripten

Merge from default branch
author Chris Cannam
date Thu, 30 Oct 2014 13:25:25 +0000
parents 2665513ce2d3
children c530137014c0
rev   line source
Chris@16 1 /*
Chris@16 2 [auto_generated]
Chris@16 3 boost/numeric/odeint/util/state_wrapper.hpp
Chris@16 4
Chris@16 5 [begin_description]
Chris@16 6 State wrapper for the state type in all stepper. The state wrappers are responsible for construction,
Chris@16 7 destruction, copying construction, assignment and resizing.
Chris@16 8 [end_description]
Chris@16 9
Chris@16 10 Copyright 2009-2011 Karsten Ahnert
Chris@16 11 Copyright 2009-2011 Mario Mulansky
Chris@16 12
Chris@16 13 Distributed under the Boost Software License, Version 1.0.
Chris@16 14 (See accompanying file LICENSE_1_0.txt or
Chris@16 15 copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 16 */
Chris@16 17
Chris@16 18
Chris@16 19 #ifndef BOOST_NUMERIC_ODEINT_UTIL_RESIZE_HPP_INCLUDED
Chris@16 20 #define BOOST_NUMERIC_ODEINT_UTIL_RESIZE_HPP_INCLUDED
Chris@16 21
Chris@16 22 #include <boost/range.hpp>
Chris@16 23
Chris@16 24 #include <boost/utility/enable_if.hpp>
Chris@16 25 #include <boost/fusion/include/is_sequence.hpp>
Chris@16 26 #include <boost/fusion/include/zip_view.hpp>
Chris@16 27 #include <boost/fusion/include/vector.hpp>
Chris@16 28 #include <boost/fusion/include/make_fused.hpp>
Chris@16 29 #include <boost/fusion/include/for_each.hpp>
Chris@16 30
Chris@16 31 #include <boost/numeric/odeint/util/is_resizeable.hpp>
Chris@16 32
Chris@16 33 namespace boost {
Chris@16 34 namespace numeric {
Chris@16 35 namespace odeint {
Chris@16 36
Chris@16 37 // resize function
Chris@16 38 // standard implementation relies on boost.range and resize member function
Chris@16 39 template< class StateOut , class StateIn , class Enabler = void >
Chris@16 40 struct resize_impl
Chris@16 41 {
Chris@16 42 static void resize( StateOut &x1 , const StateIn &x2 )
Chris@16 43 {
Chris@16 44 x1.resize( boost::size( x2 ) );
Chris@16 45 }
Chris@16 46 };
Chris@16 47
Chris@16 48
Chris@16 49 // do not overload or specialize this function, specialize resize_impl<> instead
Chris@16 50 template< class StateOut , class StateIn >
Chris@16 51 void resize( StateOut &x1 , const StateIn &x2 )
Chris@16 52 {
Chris@16 53 resize_impl< StateOut , StateIn >::resize( x1 , x2 );
Chris@16 54 }
Chris@16 55
Chris@16 56
Chris@16 57 namespace detail {
Chris@16 58
Chris@16 59 struct resizer
Chris@16 60 {
Chris@16 61 typedef void result_type;
Chris@16 62
Chris@16 63 template< class StateOut , class StateIn >
Chris@16 64 void operator()( StateOut &x1 , const StateIn &x2 ) const
Chris@16 65 {
Chris@16 66 resize_op( x1 , x2 , typename is_resizeable< StateOut >::type() );
Chris@16 67 }
Chris@16 68
Chris@16 69 template< class StateOut , class StateIn >
Chris@16 70 void resize_op( StateOut &x1 , const StateIn &x2 , boost::true_type ) const
Chris@16 71 {
Chris@16 72 resize( x1 , x2 );
Chris@16 73 }
Chris@16 74
Chris@16 75 template< class StateOut , class StateIn >
Chris@16 76 void resize_op( StateOut &x1 , const StateIn &x2 , boost::false_type ) const
Chris@16 77 {
Chris@16 78 }
Chris@16 79
Chris@16 80 };
Chris@16 81 } // namespace detail
Chris@16 82
Chris@16 83
Chris@16 84 /*
Chris@16 85 * specialization for fusion sequences
Chris@16 86 */
Chris@16 87 template< class FusionSeq >
Chris@16 88 struct resize_impl< FusionSeq , FusionSeq , typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSeq >::type >::type >
Chris@16 89 {
Chris@16 90 static void resize( FusionSeq &x1 , const FusionSeq &x2 )
Chris@16 91 {
Chris@16 92 typedef boost::fusion::vector< FusionSeq& , const FusionSeq& > Sequences;
Chris@16 93 Sequences sequences( x1 , x2 );
Chris@16 94 boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( detail::resizer() ) );
Chris@16 95 }
Chris@16 96 };
Chris@16 97
Chris@16 98
Chris@16 99
Chris@16 100
Chris@16 101 }
Chris@16 102 }
Chris@16 103 }
Chris@16 104
Chris@16 105
Chris@16 106
Chris@16 107 #endif // BOOST_NUMERIC_ODEINT_UTIL_RESIZE_HPP_INCLUDED