File indexing completed on 2025-01-18 09:42:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_HPP_DEFINED
0019 #define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_HPP_DEFINED
0020
0021 #include <boost/preprocessor/repetition.hpp>
0022 #include <boost/compute.hpp>
0023
0024 namespace boost {
0025 namespace numeric {
0026 namespace odeint {
0027
0028 struct compute_algebra
0029 {
0030
0031 #define BOOST_ODEINT_COMPUTE_STATE_PARAM(z, n, unused) \
0032 StateType ## n &s ## n,
0033
0034 #define BOOST_ODEINT_COMPUTE_ALGEBRA(z, n, unused) \
0035 template< BOOST_PP_ENUM_PARAMS(n, class StateType), class Operation > \
0036 static void for_each ## n( \
0037 BOOST_PP_REPEAT(n, BOOST_ODEINT_COMPUTE_STATE_PARAM, ~) \
0038 Operation op \
0039 ) \
0040 { \
0041 op( BOOST_PP_ENUM_PARAMS(n, s) ); \
0042 }
0043
0044 BOOST_PP_REPEAT_FROM_TO(3, 9, BOOST_ODEINT_COMPUTE_ALGEBRA, ~)
0045
0046 #undef BOOST_ODEINT_COMPUTE_ALGEBRA
0047 #undef BOOST_ODEINT_COMPUTE_STATE_PARAM
0048
0049 template < class S >
0050 static typename S::value_type norm_inf( const S &s ) {
0051 typedef typename S::value_type value_type;
0052
0053 BOOST_COMPUTE_FUNCTION(value_type, max_abs, (value_type, value_type),
0054 {
0055 return max(_1, fabs(_2));
0056 });
0057
0058 return boost::compute::accumulate(s.begin(), s.end(), value_type(), max_abs);
0059 }
0060 };
0061 }
0062 }
0063 }
0064
0065 #endif