3 boost/numeric/odeint/external/vexcl/vexcl_norm_inf.hpp
6 vector_space_norm_inf specialization for vexcl
9 Copyright 2009-2013 Karsten Ahnert
10 Copyright 2009-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)
18 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED
19 #define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED
24 #include <vexcl/vector.hpp>
25 #include <vexcl/multivector.hpp>
26 #include <vexcl/reductor.hpp>
28 #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
34 // specialization for vexcl vector
36 struct vector_space_norm_inf< vex::vector<T> > {
37 typedef T result_type;
39 T operator()( const vex::vector<T> &x ) const {
40 const auto &max = vex::get_reductor<T, vex::MAX>(x.queue_list());
42 return max( fabs(x) );
46 // specialization for vexcl multivector
47 template <typename T, size_t N>
48 struct vector_space_norm_inf< vex::multivector<T, N> > {
49 typedef T result_type;
51 T operator()( const vex::multivector<T, N> &x ) const {
52 const auto &max = vex::get_reductor<T, vex::MAX>(x.queue_list());
54 // Reducing a multivector results in std::array<T, N>:
55 auto m = max( fabs(x) );
57 // We will need to reduce it even further:
58 return *std::max_element(m.begin(), m.end());
64 } // namespace numeric
68 #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED