2 Copyright 2011 Mario Mulansky
3 Copyright 2012 Karsten Ahnert
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE_1_0.txt or
7 copy at http://www.boost.org/LICENSE_1_0.txt)
13 #ifndef VECTOR_VECTOR_RESIZE_HPP
14 #define VECTOR_VECTOR_RESIZE_HPP
18 #include <boost/range.hpp>
20 namespace boost { namespace numeric { namespace odeint {
23 struct is_resizeable< std::vector< std::vector< double > > >
25 typedef boost::true_type type;
26 const static bool value = type::value;
30 struct same_size_impl< std::vector< std::vector< double > > , std::vector< std::vector< double > > >
32 typedef std::vector< std::vector< double > > state_type;
34 static bool same_size( const state_type &x1 ,
35 const state_type &x2 )
37 bool same = ( boost::size( x1 ) == boost::size( x2 ) );
40 typename state_type::const_iterator begin1 = boost::begin( x1 );
41 typename state_type::const_iterator begin2 = boost::begin( x2 );
42 while( begin1 != boost::end( x1 ) )
43 same &= ( boost::size( *begin1++ ) == boost::size( *begin2++ ) );
49 struct resize_impl< std::vector< std::vector< double > > , std::vector< std::vector< double > > >
51 typedef std::vector< std::vector< double > > state_type;
53 static void resize( state_type &x1 , const state_type &x2 )
55 x1.resize( boost::size( x2 ) );
56 typename state_type::iterator begin1 = boost::begin( x1 );
57 typename state_type::const_iterator begin2 = boost::begin( x2 );
58 while( begin1 != boost::end( x1 ) )
59 (*begin1++).resize( boost::size( *begin2++ ) );
64 struct state_wrapper< std::vector< std::vector< double > > >
66 typedef std::vector< std::vector< double > > state_type;
67 typedef state_wrapper< state_type > state_wrapper_type;
68 typedef boost::true_type is_resizeable;
72 template< class State >
73 bool same_size( const State &x )
75 bool same = ( boost::size( m_v ) == boost::size( x ) );
78 typename state_type::iterator begin1 = boost::begin( m_v );
79 typename State::const_iterator begin2 = boost::begin( x );
80 while( begin1 != boost::end( m_v ) )
81 same &= ( boost::size( *begin1++ ) == boost::size( *begin2++ ) );
85 template< class State >
86 bool resize( const State &x )
90 m_v.resize( boost::size( x ) );
91 typename state_type::iterator begin1 = boost::begin( m_v );
92 typename State::const_iterator begin2 = boost::begin( x );
93 while( begin1 != boost::end( m_v ) )
94 (*begin1++).resize( boost::size( *begin2++ ) );