3 boost/numeric/odeint/algebra/algebra_dispatcher.hpp
6 Algebra dispatcher to automatically chose suitable algebra.
9 Copyright 2013 Karsten Ahnert
10 Copyright 2013 Mario Mulansky
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)
17 #ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_ALGEBRA_DISPATCHER_HPP_INCLUDED
18 #define BOOST_NUMERIC_ODEINT_ALGEBRA_ALGEBRA_DISPATCHER_HPP_INCLUDED
20 #include <boost/numeric/odeint/config.hpp>
23 #include <boost/type_traits/is_floating_point.hpp>
25 #include <boost/numeric/ublas/vector.hpp>
26 #include <boost/numeric/ublas/matrix.hpp>
28 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
29 #include <boost/numeric/odeint/algebra/array_algebra.hpp>
30 #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
32 #include <boost/array.hpp>
39 template< class StateType , class Enabler = void >
40 struct algebra_dispatcher_sfinae
42 // range_algebra is the standard algebra
43 typedef range_algebra algebra_type;
46 template< class StateType >
47 struct algebra_dispatcher : algebra_dispatcher_sfinae< StateType > { };
49 // specialize for array
50 template< class T , size_t N >
51 struct algebra_dispatcher< boost::array< T , N > >
53 typedef array_algebra algebra_type;
56 //specialize for some integral types
57 template< typename T >
58 struct algebra_dispatcher_sfinae< T , typename boost::enable_if< typename boost::is_floating_point< T >::type >::type >
60 typedef vector_space_algebra algebra_type;
63 template< typename T >
64 struct algebra_dispatcher< std::complex<T> >
66 typedef vector_space_algebra algebra_type;
69 ///* think about that again....
70 // specialize for ublas vector and matrix types
71 template< class T , class A >
72 struct algebra_dispatcher< boost::numeric::ublas::vector< T , A > >
74 typedef vector_space_algebra algebra_type;
77 template< class T , class L , class A >
78 struct algebra_dispatcher< boost::numeric::ublas::matrix< T , L , A > >
80 typedef vector_space_algebra algebra_type;
88 #ifdef BOOST_NUMERIC_ODEINT_CXX11
90 // c++11 mode: specialization for std::array if available
98 // specialize for std::array
99 template< class T , size_t N >
100 struct algebra_dispatcher< std::array< T , N > >
102 typedef array_algebra algebra_type;