Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:52

0001 /*
0002   [auto_generated]
0003   boost/numeric/odeint/external/vexcl/vexcl_norm_inf.hpp
0004 
0005   [begin_description]
0006   vector_space_norm_inf specialization for vexcl
0007   [end_description]
0008 
0009   Copyright 2009-2013 Karsten Ahnert
0010   Copyright 2009-2013 Mario Mulansky
0011 
0012   Distributed under the Boost Software License, Version 1.0.
0013   (See accompanying file LICENSE_1_0.txt or
0014   copy at http://www.boost.org/LICENSE_1_0.txt)
0015 */
0016 
0017 
0018 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED
0019 #define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED
0020 
0021 #include <map>
0022 #include <algorithm>
0023 
0024 #include <vexcl/vector.hpp>
0025 #include <vexcl/multivector.hpp>
0026 #include <vexcl/reductor.hpp>
0027 
0028 #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
0029 
0030 namespace boost {
0031 namespace numeric {
0032 namespace odeint {
0033 
0034 // specialization for vexcl vector
0035 template <typename T>
0036 struct vector_space_norm_inf< vex::vector<T> > {
0037     typedef T result_type;
0038 
0039     T operator()( const vex::vector<T> &x ) const {
0040         const auto &max = vex::get_reductor<T, vex::MAX>(x.queue_list());
0041 
0042         return max( fabs(x) );
0043     }
0044 };
0045 
0046 // specialization for vexcl multivector
0047 template <typename T, size_t N>
0048 struct vector_space_norm_inf< vex::multivector<T, N> > {
0049     typedef T result_type;
0050 
0051     T operator()( const vex::multivector<T, N> &x ) const {
0052         const auto &max = vex::get_reductor<T, vex::MAX>(x.queue_list());
0053 
0054         // Reducing a multivector results in std::array<T, N>:
0055         auto m = max( fabs(x) );
0056 
0057         // We will need to reduce it even further:
0058         return *std::max_element(m.begin(), m.end());
0059     }
0060 };
0061 
0062 
0063 } // namespace odeint
0064 } // namespace numeric
0065 } // namespace boost
0066 
0067 
0068 #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED