]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/odeint/include/boost/numeric/odeint/external/mtl4/mtl4_resize.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / numeric / odeint / include / boost / numeric / odeint / external / mtl4 / mtl4_resize.hpp
1 /*
2 [begin_description]
3 Modification of the implicit Euler method, works with the MTL4 matrix library only.
4 [end_description]
5
6 Copyright 2012-2013 Andreas Angelopoulos
7 Copyright 2012-2013 Karsten Ahnert
8 Copyright 2012-2013 Mario Mulansky
9
10 Distributed under the Boost Software License, Version 1.0.
11 (See accompanying file LICENSE_1_0.txt or
12 copy at http://www.boost.org/LICENSE_1_0.txt)
13 */
14
15
16 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_RESIZE_HPP_INCLUDED
17 #define BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_RESIZE_HPP_INCLUDED
18
19 #include <boost/numeric/odeint/util/is_resizeable.hpp>
20 #include <boost/numeric/odeint/util/resize.hpp>
21 #include <boost/numeric/odeint/util/same_size.hpp>
22
23 #include <boost/numeric/mtl/vector/dense_vector.hpp>
24 #include <boost/numeric/mtl/matrix/dense2D.hpp>
25 #include <boost/numeric/mtl/matrix/compressed2D.hpp>
26
27
28 namespace boost {
29 namespace numeric {
30 namespace odeint {
31
32
33 template< class Value , class Parameters >
34 struct is_resizeable< mtl::dense_vector< Value , Parameters > >
35 {
36 typedef boost::true_type type;
37 const static bool value = type::value;
38 };
39
40 template< class Value , class Parameters >
41 struct is_resizeable< mtl::dense2D< Value , Parameters > >
42 {
43 typedef boost::true_type type;
44 const static bool value = type::value;
45 };
46
47 template< class Value , class Parameters >
48 struct is_resizeable< mtl::compressed2D< Value , Parameters > >
49 {
50 typedef boost::true_type type;
51 const static bool value = type::value;
52 };
53
54
55
56
57 template< class Value , class Parameters >
58 struct same_size_impl< mtl::dense_vector< Value , Parameters > , mtl::dense_vector< Value , Parameters > >
59 {
60 static bool same_size( const mtl::dense_vector< Value , Parameters > &v1 ,
61 const mtl::dense_vector< Value , Parameters > &v2 )
62 {
63 return mtl::size( v1 ) == mtl::size( v2 );
64 }
65 };
66
67 template< class Value , class Parameters >
68 struct resize_impl< mtl::dense_vector< Value , Parameters > , mtl::dense_vector< Value , Parameters > >
69 {
70 static void resize( mtl::dense_vector< Value , Parameters > &v1 ,
71 const mtl::dense_vector< Value , Parameters > &v2 )
72 {
73 v1.change_dim( mtl::size( v2 ) );
74 }
75 };
76
77
78
79 template< class Value , class MatrixParameters , class VectorParameters >
80 struct same_size_impl< mtl::dense2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
81 {
82 static bool same_size( const mtl::dense2D< Value , MatrixParameters > &m ,
83 const mtl::dense_vector< Value , VectorParameters > &v )
84 {
85 return ( ( mtl::size( v ) == m.num_cols() ) && ( mtl::size( v ) == m.num_rows() ) );
86 }
87 };
88
89 template< class Value , class MatrixParameters , class VectorParameters >
90 struct resize_impl< mtl::dense2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
91 {
92 static void resize( mtl::dense2D< Value , MatrixParameters > &m ,
93 const mtl::dense_vector< Value , VectorParameters > &v )
94 {
95 m.change_dim( mtl::size( v ) , mtl::size( v ) , false );
96 }
97 };
98
99
100
101
102 template< class Value , class MatrixParameters , class VectorParameters >
103 struct same_size_impl< mtl::compressed2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
104 {
105 static bool same_size( const mtl::compressed2D< Value , MatrixParameters > &m ,
106 const mtl::dense_vector< Value , VectorParameters > &v )
107 {
108 return ( ( mtl::size( v ) == m.num_cols() ) && ( mtl::size( v ) == m.num_rows() ) );
109 }
110 };
111
112 template< class Value , class MatrixParameters , class VectorParameters >
113 struct resize_impl< mtl::compressed2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
114 {
115 static void resize( mtl::compressed2D< Value , MatrixParameters > &m ,
116 const mtl::dense_vector< Value , VectorParameters > &v )
117 {
118 m.change_dim( mtl::size( v ) , mtl::size( v ) );
119 }
120 };
121
122
123
124
125
126
127
128
129 } // namespace odeint
130 } // namespace numeric
131 } // namespace boost
132
133 #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_RESIZE_HPP_INCLUDED