compute_resize.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/external/compute/compute_resize.hpp
  4. [begin_description]
  5. Enable resizing for Boost.Compute vector
  6. [end_description]
  7. Copyright 2009-2011 Karsten Ahnert
  8. Copyright 2009-2011 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_EXTERNAL_COMPUTE_COMPUTE_RESIZE_HPP_DEFINED
  14. #define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_RESIZE_HPP_DEFINED
  15. #include <boost/compute/container/vector.hpp>
  16. #include <boost/numeric/odeint/util/copy.hpp>
  17. #include <type_traits>
  18. namespace boost {
  19. namespace numeric {
  20. namespace odeint {
  21. template< class T, class A >
  22. struct is_resizeable< boost::compute::vector< T , A > >
  23. {
  24. struct type : public std::true_type { };
  25. const static bool value = type::value;
  26. };
  27. template< class T, class A >
  28. struct same_size_impl< boost::compute::vector< T, A > , boost::compute::vector< T, A > >
  29. {
  30. static bool same_size( const boost::compute::vector< T, A > &x , const boost::compute::vector< T, A > &y )
  31. {
  32. return x.size() == y.size();
  33. }
  34. };
  35. template< class T, class A >
  36. struct resize_impl< boost::compute::vector< T, A > , boost::compute::vector< T, A > >
  37. {
  38. static void resize( boost::compute::vector< T, A > &x , const boost::compute::vector< T, A > &y )
  39. {
  40. x.resize( y.size() );
  41. }
  42. };
  43. template< class Container1, class T, class A >
  44. struct copy_impl< Container1 , boost::compute::vector< T, A > >
  45. {
  46. static void copy( const Container1 &from , boost::compute::vector< T, A > &to )
  47. {
  48. boost::compute::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) );
  49. }
  50. };
  51. template< class T, class A, class Container2 >
  52. struct copy_impl< boost::compute::vector< T, A > , Container2 >
  53. {
  54. static void copy( const boost::compute::vector< T, A > &from , Container2 &to )
  55. {
  56. boost::compute::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) );
  57. }
  58. };
  59. template< class T, class A >
  60. struct copy_impl< boost::compute::vector< T, A > , boost::compute::vector< T, A > >
  61. {
  62. static void copy( const boost::compute::vector< T, A > &from , boost::compute::vector< T, A > &to )
  63. {
  64. boost::compute::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) );
  65. }
  66. };
  67. } // odeint
  68. } // numeric
  69. } // boost
  70. #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_RESIZE_HPP_DEFINED