Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 08:18:11

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 #include <type_traits>
0032 
0033 namespace boost {
0034 namespace numeric {
0035 namespace odeint {
0036     
0037 template< typename T >
0038 struct is_multi_array
0039 {
0040     typedef std::false_type type;
0041     const static bool value = type::value;
0042 };
0043     
0044 template< typename T >
0045 struct is_resizeable_multi_array
0046 {
0047     typedef std::false_type type;
0048     const static bool value = type::value;
0049 };
0050 
0051 
0052 
0053 template< typename V , size_t Dim , typename A >
0054 struct is_multi_array< boost::multi_array< V , Dim , A > >
0055 {
0056     typedef std::true_type type;
0057     const static bool value = type::value;
0058 };
0059 
0060 template< typename V , size_t Dim , typename A >
0061 struct is_resizeable_multi_array< boost::multi_array< V , Dim , A > >
0062 {
0063     typedef std::true_type type;
0064     const static bool value = type::value;
0065 };
0066 
0067 
0068 
0069 
0070 template< typename T  >
0071 struct is_resizeable_sfinae< T , typename boost::enable_if< typename is_resizeable_multi_array< T >::type >::type >
0072 {
0073     typedef std::true_type type;
0074     const static bool value = type::value;
0075 };
0076 
0077 
0078 
0079 
0080 
0081 template< typename T1 , typename T2  >
0082 struct same_size_impl_sfinae< T1 , T2 ,
0083                        typename boost::enable_if<
0084                            typename boost::mpl::and_< 
0085                                is_multi_array< T1 > ,
0086                                is_multi_array< T2 > ,
0087                                boost::mpl::bool_< T1::dimensionality == T2::dimensionality >
0088                            >::type
0089                        >::type >
0090 {
0091     static bool same_size( T1 const &x1 , T2 const &x2 )
0092     {
0093         for( size_t i=0 ; i<T1::dimensionality ; ++i )
0094         {
0095             if( x1.shape()[i] != x2.shape()[i] ) return false;
0096             if( x1.index_bases()[i] != x2.index_bases()[i] ) return false;
0097         }
0098         return true;
0099     }
0100 };
0101 
0102 
0103 template< typename T1 , typename T2 >
0104 struct resize_impl_sfinae< T1 , T2 ,
0105                     typename boost::enable_if<
0106                         typename boost::mpl::and_<
0107                             is_resizeable_multi_array< T1 > ,
0108                             is_multi_array< T2 > ,
0109                             boost::mpl::bool_< T1::dimensionality == T2::dimensionality >
0110                         >::type
0111                     >::type >
0112 {
0113     static void resize( T1 &x1 , const T2 &x2 )
0114     {
0115         std::array< int , T1::dimensionality > extents;
0116         for( size_t i=0 ; i<T1::dimensionality ; ++i ) extents[i] = x2.shape()[i];
0117         x1.resize( extents );
0118         std::array< int , T1::dimensionality > origins;
0119         for( size_t i=0 ; i<T1::dimensionality ; ++i ) origins[i] = x2.index_bases()[i];
0120         x1.reindex( origins );
0121     }
0122 };
0123                             
0124 
0125 
0126 } // namespace odeint
0127 } // namespace numeric
0128 } // namespace boost
0129 
0130 
0131 #endif // BOOST_NUMERIC_ODEINT_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED