1 /* 2 [auto_generated] 3 boost/numeric/odeint/util/multi_array_adaption.hpp 4 5 [begin_description] 6 tba. 7 [end_description] 8 9 Copyright 2009-2012 Karsten Ahnert 10 Copyright 2009-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_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED 19 #define BOOST_NUMERIC_ODEINT_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED 20 21 22 23 #include <boost/numeric/odeint/util/is_resizeable.hpp> 24 #include <boost/numeric/odeint/util/resize.hpp> 25 #include <boost/numeric/odeint/util/same_size.hpp> 26 27 #include <boost/mpl/and.hpp> 28 #include <boost/mpl/bool.hpp> 29 #include <boost/multi_array.hpp> 30 31 32 namespace boost { 33 namespace numeric { 34 namespace odeint { 35 36 template< typename T > 37 struct is_multi_array 38 { 39 typedef boost::false_type type; 40 const static bool value = type::value; 41 }; 42 43 template< typename T > 44 struct is_resizeable_multi_array 45 { 46 typedef boost::false_type type; 47 const static bool value = type::value; 48 }; 49 50 51 52 template< typename V , size_t Dim , typename A > 53 struct is_multi_array< boost::multi_array< V , Dim , A > > 54 { 55 typedef boost::true_type type; 56 const static bool value = type::value; 57 }; 58 59 template< typename V , size_t Dim , typename A > 60 struct is_resizeable_multi_array< boost::multi_array< V , Dim , A > > 61 { 62 typedef boost::true_type type; 63 const static bool value = type::value; 64 }; 65 66 67 68 69 template< typename T > 70 struct is_resizeable_sfinae< T , typename boost::enable_if< typename is_resizeable_multi_array< T >::type >::type > 71 { 72 typedef boost::true_type type; 73 const static bool value = type::value; 74 }; 75 76 77 78 79 80 template< typename T1 , typename T2 > 81 struct same_size_impl_sfinae< T1 , T2 , 82 typename boost::enable_if< 83 typename boost::mpl::and_< 84 is_multi_array< T1 > , 85 is_multi_array< T2 > , 86 boost::mpl::bool_< T1::dimensionality == T2::dimensionality > 87 >::type 88 >::type > 89 { same_sizeboost::numeric::odeint::same_size_impl_sfinae90 static bool same_size( T1 const &x1 , T2 const &x2 ) 91 { 92 for( size_t i=0 ; i<T1::dimensionality ; ++i ) 93 { 94 if( x1.shape()[i] != x2.shape()[i] ) return false; 95 if( x1.index_bases()[i] != x2.index_bases()[i] ) return false; 96 } 97 return true; 98 } 99 }; 100 101 102 template< typename T1 , typename T2 > 103 struct resize_impl_sfinae< T1 , T2 , 104 typename boost::enable_if< 105 typename boost::mpl::and_< 106 is_resizeable_multi_array< T1 > , 107 is_multi_array< T2 > , 108 boost::mpl::bool_< T1::dimensionality == T2::dimensionality > 109 >::type 110 >::type > 111 { resizeboost::numeric::odeint::resize_impl_sfinae112 static void resize( T1 &x1 , const T2 &x2 ) 113 { 114 boost::array< int , T1::dimensionality > extents; 115 for( size_t i=0 ; i<T1::dimensionality ; ++i ) extents[i] = x2.shape()[i]; 116 x1.resize( extents ); 117 boost::array< int , T1::dimensionality > origins; 118 for( size_t i=0 ; i<T1::dimensionality ; ++i ) origins[i] = x2.index_bases()[i]; 119 x1.reindex( origins ); 120 } 121 }; 122 123 124 125 } // namespace odeint 126 } // namespace numeric 127 } // namespace boost 128 129 130 #endif // BOOST_NUMERIC_ODEINT_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED 131