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