Chris@102
|
1 /*
|
Chris@102
|
2 [auto_generated]
|
Chris@102
|
3 boost/numeric/odeint/external/compute/compute_algebra.hpp
|
Chris@102
|
4
|
Chris@102
|
5 [begin_description]
|
Chris@102
|
6 An algebra for Boost.Compute vectors.
|
Chris@102
|
7 [end_description]
|
Chris@102
|
8
|
Chris@102
|
9 Copyright 2009-2011 Karsten Ahnert
|
Chris@102
|
10 Copyright 2009-2011 Mario Mulansky
|
Chris@102
|
11
|
Chris@102
|
12 Distributed under the Boost Software License, Version 1.0.
|
Chris@102
|
13 (See accompanying file LICENSE_1_0.txt or
|
Chris@102
|
14 copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
15 */
|
Chris@102
|
16
|
Chris@102
|
17
|
Chris@102
|
18 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_HPP_DEFINED
|
Chris@102
|
19 #define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_HPP_DEFINED
|
Chris@102
|
20
|
Chris@102
|
21 #include <boost/preprocessor/repetition.hpp>
|
Chris@102
|
22 #include <boost/compute.hpp>
|
Chris@102
|
23
|
Chris@102
|
24 namespace boost {
|
Chris@102
|
25 namespace numeric {
|
Chris@102
|
26 namespace odeint {
|
Chris@102
|
27
|
Chris@102
|
28 struct compute_algebra
|
Chris@102
|
29 {
|
Chris@102
|
30
|
Chris@102
|
31 #define BOOST_ODEINT_COMPUTE_STATE_PARAM(z, n, unused) \
|
Chris@102
|
32 StateType ## n &s ## n,
|
Chris@102
|
33
|
Chris@102
|
34 #define BOOST_ODEINT_COMPUTE_ALGEBRA(z, n, unused) \
|
Chris@102
|
35 template< BOOST_PP_ENUM_PARAMS(n, class StateType), class Operation > \
|
Chris@102
|
36 static void for_each ## n( \
|
Chris@102
|
37 BOOST_PP_REPEAT(n, BOOST_ODEINT_COMPUTE_STATE_PARAM, ~) \
|
Chris@102
|
38 Operation op \
|
Chris@102
|
39 ) \
|
Chris@102
|
40 { \
|
Chris@102
|
41 op( BOOST_PP_ENUM_PARAMS(n, s) ); \
|
Chris@102
|
42 }
|
Chris@102
|
43
|
Chris@102
|
44 BOOST_PP_REPEAT_FROM_TO(3, 9, BOOST_ODEINT_COMPUTE_ALGEBRA, ~)
|
Chris@102
|
45
|
Chris@102
|
46 #undef BOOST_ODEINT_COMPUTE_ALGEBRA
|
Chris@102
|
47 #undef BOOST_ODEINT_COMPUTE_STATE_PARAM
|
Chris@102
|
48
|
Chris@102
|
49 template < class S >
|
Chris@102
|
50 static typename S::value_type norm_inf( const S &s ) {
|
Chris@102
|
51 typedef typename S::value_type value_type;
|
Chris@102
|
52
|
Chris@102
|
53 BOOST_COMPUTE_FUNCTION(value_type, max_abs, (value_type, value_type),
|
Chris@102
|
54 {
|
Chris@102
|
55 return max(_1, fabs(_2));
|
Chris@102
|
56 });
|
Chris@102
|
57
|
Chris@102
|
58 return boost::compute::accumulate(s.begin(), s.end(), value_type(), max_abs);
|
Chris@102
|
59 }
|
Chris@102
|
60 };
|
Chris@102
|
61 } // odeint
|
Chris@102
|
62 } // numeric
|
Chris@102
|
63 } // boost
|
Chris@102
|
64
|
Chris@102
|
65 #endif
|