Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:58

0001 /*
0002   [auto_generated]
0003   boost/numeric/odeint/util/multi_array_adaption.hpp
0004 
0005   [begin_description]
0006   tba.
0007   [end_description]
0008 
0009   Copyright 2009-2012 Karsten Ahnert
0010   Copyright 2009-2012 Mario Mulansky
0011 
0012   Distributed under the Boost Software License, Version 1.0.
0013   (See accompanying file LICENSE_1_0.txt or
0014   copy at http://www.boost.org/LICENSE_1_0.txt)
0015 */
0016 
0017 
0018 #ifndef BOOST_NUMERIC_ODEINT_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED
0019 #define BOOST_NUMERIC_ODEINT_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED
0020 
0021 
0022 
0023 #include <boost/numeric/odeint/util/is_resizeable.hpp>
0024 #include <boost/numeric/odeint/util/resize.hpp>
0025 #include <boost/numeric/odeint/util/same_size.hpp>
0026 
0027 #include <boost/mpl/and.hpp>
0028 #include <boost/mpl/bool.hpp>
0029 #include <boost/multi_array.hpp>
0030 
0031 
0032 namespace boost {
0033 namespace numeric {
0034 namespace odeint {
0035     
0036 template< typename T >
0037 struct is_multi_array
0038 {
0039     typedef boost::false_type type;
0040     const static bool value = type::value;
0041 };
0042     
0043 template< typename T >
0044 struct is_resizeable_multi_array
0045 {
0046     typedef boost::false_type type;
0047     const static bool value = type::value;
0048 };
0049 
0050 
0051 
0052 template< typename V , size_t Dim , typename A >
0053 struct is_multi_array< boost::multi_array< V , Dim , A > >
0054 {
0055     typedef boost::true_type type;
0056     const static bool value = type::value;
0057 };
0058 
0059 template< typename V , size_t Dim , typename A >
0060 struct is_resizeable_multi_array< boost::multi_array< V , Dim , A > >
0061 {
0062     typedef boost::true_type type;
0063     const static bool value = type::value;
0064 };
0065 
0066 
0067 
0068 
0069 template< typename T  >
0070 struct is_resizeable_sfinae< T , typename boost::enable_if< typename is_resizeable_multi_array< T >::type >::type >
0071 {
0072     typedef boost::true_type type;
0073     const static bool value = type::value;
0074 };
0075 
0076 
0077 
0078 
0079 
0080 template< typename T1 , typename T2  >
0081 struct same_size_impl_sfinae< T1 , T2 ,
0082                        typename boost::enable_if<
0083                            typename boost::mpl::and_< 
0084                                is_multi_array< T1 > ,
0085                                is_multi_array< T2 > ,
0086                                boost::mpl::bool_< T1::dimensionality == T2::dimensionality >
0087                            >::type
0088                        >::type >
0089 {
0090     static bool same_size( T1 const &x1 , T2 const &x2 )
0091     {
0092         for( size_t i=0 ; i<T1::dimensionality ; ++i )
0093         {
0094             if( x1.shape()[i] != x2.shape()[i] ) return false;
0095             if( x1.index_bases()[i] != x2.index_bases()[i] ) return false;
0096         }
0097         return true;
0098     }
0099 };
0100 
0101 
0102 template< typename T1 , typename T2 >
0103 struct resize_impl_sfinae< T1 , T2 ,
0104                     typename boost::enable_if<
0105                         typename boost::mpl::and_<
0106                             is_resizeable_multi_array< T1 > ,
0107                             is_multi_array< T2 > ,
0108                             boost::mpl::bool_< T1::dimensionality == T2::dimensionality >
0109                         >::type
0110                     >::type >
0111 {
0112     static void resize( T1 &x1 , const T2 &x2 )
0113     {
0114         boost::array< int , T1::dimensionality > extents;
0115         for( size_t i=0 ; i<T1::dimensionality ; ++i ) extents[i] = x2.shape()[i];
0116         x1.resize( extents );
0117         boost::array< int , T1::dimensionality > origins;
0118         for( size_t i=0 ; i<T1::dimensionality ; ++i ) origins[i] = x2.index_bases()[i];
0119         x1.reindex( origins );
0120     }
0121 };
0122                             
0123 
0124 
0125 } // namespace odeint
0126 } // namespace numeric
0127 } // namespace boost
0128 
0129 
0130 #endif // BOOST_NUMERIC_ODEINT_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED