]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/numeric/odeint/include/boost/numeric/odeint/util/multi_array_adaption.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / numeric / odeint / include / boost / numeric / odeint / util / multi_array_adaption.hpp
CommitLineData
7c673cae
FG
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
32namespace boost {
33namespace numeric {
34namespace odeint {
35
36template< typename T >
37struct is_multi_array
38{
39 typedef boost::false_type type;
40 const static bool value = type::value;
41};
42
43template< typename T >
44struct is_resizeable_multi_array
45{
46 typedef boost::false_type type;
47 const static bool value = type::value;
48};
49
50
51
52template< typename V , size_t Dim , typename A >
53struct 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
59template< typename V , size_t Dim , typename A >
60struct 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
69template< typename T >
70struct 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
80template< typename T1 , typename T2 >
81struct 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{
90 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
102template< typename T1 , typename T2 >
103struct 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{
112 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