Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-06 08:22:00

0001 /*
0002 [begin_description]
0003 Modification of the implicit Euler method, works with the MTL4 matrix library only. 
0004 [end_description]
0005 
0006 Copyright 2012-2013 Andreas Angelopoulos
0007 Copyright 2012-2013 Karsten Ahnert
0008 Copyright 2012-2013 Mario Mulansky
0009 
0010 Distributed under the Boost Software License, Version 1.0.
0011 (See accompanying file LICENSE_1_0.txt or
0012 copy at http://www.boost.org/LICENSE_1_0.txt)
0013 */
0014 
0015 
0016 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_RESIZE_HPP_INCLUDED
0017 #define BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_RESIZE_HPP_INCLUDED
0018 
0019 #include <boost/numeric/odeint/util/is_resizeable.hpp>
0020 #include <boost/numeric/odeint/util/resize.hpp>
0021 #include <boost/numeric/odeint/util/same_size.hpp>
0022 
0023 #include <boost/numeric/mtl/vector/dense_vector.hpp>
0024 #include <boost/numeric/mtl/matrix/dense2D.hpp>
0025 #include <boost/numeric/mtl/matrix/compressed2D.hpp>
0026 
0027 #include <type_traits>
0028 
0029 namespace boost {
0030 namespace numeric {
0031 namespace odeint {
0032 
0033 
0034 template< class Value , class Parameters >
0035 struct is_resizeable< mtl::dense_vector< Value , Parameters > >
0036 { 
0037     typedef std::true_type type;
0038     const static bool value = type::value;
0039 };
0040 
0041 template< class Value , class Parameters >
0042 struct is_resizeable< mtl::dense2D< Value , Parameters > >
0043 {
0044     typedef std::true_type type;
0045     const static bool value = type::value;
0046 };
0047 
0048 template< class Value , class Parameters >
0049 struct is_resizeable< mtl::compressed2D< Value , Parameters > >
0050 {
0051     typedef std::true_type type;
0052     const static bool value = type::value;
0053 };
0054 
0055 
0056 
0057 
0058 template< class Value , class Parameters >
0059 struct same_size_impl< mtl::dense_vector< Value , Parameters > , mtl::dense_vector< Value , Parameters > >
0060 {
0061     static bool same_size( const mtl::dense_vector< Value , Parameters > &v1 ,
0062                            const mtl::dense_vector< Value , Parameters > &v2 )
0063     {
0064         return mtl::size( v1 ) == mtl::size( v2 );
0065     }
0066 };
0067 
0068 template< class Value , class Parameters >
0069 struct resize_impl< mtl::dense_vector< Value , Parameters > , mtl::dense_vector< Value , Parameters > >
0070 {
0071     static void resize( mtl::dense_vector< Value , Parameters > &v1 ,
0072                         const mtl::dense_vector< Value , Parameters > &v2 )
0073     {
0074         v1.change_dim( mtl::size( v2 ) );
0075     }
0076 };
0077 
0078 
0079 
0080 template< class Value , class MatrixParameters , class VectorParameters >
0081 struct same_size_impl< mtl::dense2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
0082 {
0083     static bool same_size( const mtl::dense2D< Value , MatrixParameters > &m , 
0084                            const mtl::dense_vector< Value , VectorParameters > &v )
0085     {
0086         return ( ( mtl::size( v ) == m.num_cols() ) && ( mtl::size( v ) == m.num_rows() ) );
0087     }
0088 };
0089 
0090 template< class Value , class MatrixParameters , class VectorParameters >
0091 struct resize_impl< mtl::dense2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
0092 {
0093     static void resize( mtl::dense2D< Value , MatrixParameters > &m , 
0094                         const mtl::dense_vector< Value , VectorParameters > &v )
0095     {
0096         m.change_dim( mtl::size( v ) , mtl::size( v ) , false );
0097     }
0098 };
0099 
0100 
0101 
0102 
0103 template< class Value , class MatrixParameters , class VectorParameters >
0104 struct same_size_impl< mtl::compressed2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
0105 {
0106     static bool same_size( const mtl::compressed2D< Value , MatrixParameters > &m , 
0107                            const mtl::dense_vector< Value , VectorParameters > &v )
0108     {
0109         return ( ( mtl::size( v ) == m.num_cols() ) && ( mtl::size( v ) == m.num_rows() ) );
0110     }
0111 };
0112 
0113 template< class Value , class MatrixParameters , class VectorParameters >
0114 struct resize_impl< mtl::compressed2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
0115 {
0116     static void resize( mtl::compressed2D< Value , MatrixParameters > &m , 
0117                         const mtl::dense_vector< Value , VectorParameters > &v )
0118     {
0119         m.change_dim( mtl::size( v ) , mtl::size( v ) );
0120     }
0121 };
0122 
0123 
0124 
0125 
0126 
0127 
0128 
0129 
0130 } // namespace odeint
0131 } // namespace numeric
0132 } // namespace boost
0133 
0134 #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_RESIZE_HPP_INCLUDED