vexcl_norm_inf.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/external/vexcl/vexcl_norm_inf.hpp
  4. [begin_description]
  5. vector_space_norm_inf specialization for vexcl
  6. [end_description]
  7. Copyright 2009-2013 Karsten Ahnert
  8. Copyright 2009-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_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED
  14. #define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED
  15. #include <map>
  16. #include <algorithm>
  17. #include <vexcl/vector.hpp>
  18. #include <vexcl/multivector.hpp>
  19. #include <vexcl/reductor.hpp>
  20. #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
  21. namespace boost {
  22. namespace numeric {
  23. namespace odeint {
  24. // specialization for vexcl vector
  25. template <typename T>
  26. struct vector_space_norm_inf< vex::vector<T> > {
  27. typedef T result_type;
  28. T operator()( const vex::vector<T> &x ) const {
  29. const auto &max = vex::get_reductor<T, vex::MAX>(x.queue_list());
  30. return max( fabs(x) );
  31. }
  32. };
  33. // specialization for vexcl multivector
  34. template <typename T, size_t N>
  35. struct vector_space_norm_inf< vex::multivector<T, N> > {
  36. typedef T result_type;
  37. T operator()( const vex::multivector<T, N> &x ) const {
  38. const auto &max = vex::get_reductor<T, vex::MAX>(x.queue_list());
  39. // Reducing a multivector results in std::array<T, N>:
  40. auto m = max( fabs(x) );
  41. // We will need to reduce it even further:
  42. return *std::max_element(m.begin(), m.end());
  43. }
  44. };
  45. } // namespace odeint
  46. } // namespace numeric
  47. } // namespace boost
  48. #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED