algebra_dispatcher.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/algebra/algebra_dispatcher.hpp
  4. [begin_description]
  5. Algebra dispatcher to automatically chose suitable algebra.
  6. [end_description]
  7. Copyright 2013 Karsten Ahnert
  8. Copyright 2013 Mario Mulansky
  9. Distributed under the Boost Software License, Version 1.0.
  10. (See accompanying file LICENSE_1_0.txt or
  11. copy at http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. #ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_ALGEBRA_DISPATCHER_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_ALGEBRA_ALGEBRA_DISPATCHER_HPP_INCLUDED
  15. #include <boost/numeric/odeint/config.hpp>
  16. #include <complex>
  17. #include <boost/type_traits/is_floating_point.hpp>
  18. #include <boost/numeric/ublas/vector.hpp>
  19. #include <boost/numeric/ublas/matrix.hpp>
  20. #include <boost/numeric/odeint/algebra/range_algebra.hpp>
  21. #include <boost/numeric/odeint/algebra/array_algebra.hpp>
  22. #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
  23. #include <boost/array.hpp>
  24. namespace boost {
  25. namespace numeric {
  26. namespace odeint {
  27. template< class StateType , class Enabler = void >
  28. struct algebra_dispatcher_sfinae
  29. {
  30. // range_algebra is the standard algebra
  31. typedef range_algebra algebra_type;
  32. };
  33. template< class StateType >
  34. struct algebra_dispatcher : algebra_dispatcher_sfinae< StateType > { };
  35. // specialize for array
  36. template< class T , size_t N >
  37. struct algebra_dispatcher< boost::array< T , N > >
  38. {
  39. typedef array_algebra algebra_type;
  40. };
  41. //specialize for some integral types
  42. template< typename T >
  43. struct algebra_dispatcher_sfinae< T , typename boost::enable_if< typename boost::is_floating_point< T >::type >::type >
  44. {
  45. typedef vector_space_algebra algebra_type;
  46. };
  47. template< typename T >
  48. struct algebra_dispatcher< std::complex<T> >
  49. {
  50. typedef vector_space_algebra algebra_type;
  51. };
  52. ///* think about that again....
  53. // specialize for ublas vector and matrix types
  54. template< class T , class A >
  55. struct algebra_dispatcher< boost::numeric::ublas::vector< T , A > >
  56. {
  57. typedef vector_space_algebra algebra_type;
  58. };
  59. template< class T , class L , class A >
  60. struct algebra_dispatcher< boost::numeric::ublas::matrix< T , L , A > >
  61. {
  62. typedef vector_space_algebra algebra_type;
  63. };
  64. //*/
  65. }
  66. }
  67. }
  68. #ifdef BOOST_NUMERIC_ODEINT_CXX11
  69. // c++11 mode: specialization for std::array if available
  70. #include <array>
  71. namespace boost {
  72. namespace numeric {
  73. namespace odeint {
  74. // specialize for std::array
  75. template< class T , size_t N >
  76. struct algebra_dispatcher< std::array< T , N > >
  77. {
  78. typedef array_algebra algebra_type;
  79. };
  80. } } }
  81. #endif
  82. #endif