File indexing completed on 2025-01-18 09:42:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BOOST_NUMERIC_ODEINT_UTIL_N_ARY_HELPER_HPP_INCLUDED
0017 #define BOOST_NUMERIC_ODEINT_UTIL_N_ARY_HELPER_HPP_INCLUDED
0018
0019 #include <boost/preprocessor/repetition.hpp>
0020
0021
0022 #define BOOST_ODEINT_ENUM_TRAILING_SHIFTED_PARAMS(count, param) \
0023 BOOST_PP_COMMA_IF(BOOST_PP_DEC(count)) \
0024 BOOST_PP_ENUM_SHIFTED_PARAMS(count, param)
0025
0026 #define BOOST_ODEINT_ENUM_TRAILING_SHIFTED_BINARY_PARAMS(count, p1, p2) \
0027 BOOST_PP_COMMA_IF(BOOST_PP_DEC(count)) \
0028 BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(count, p1, p2)
0029
0030
0031
0032 #define BOOST_ODEINT_ENUM_LSHIFTED_BINARY_PARAMS(count, p1, p2, p3) \
0033 BOOST_PP_ENUM(count, BOOST_ODEINT_ENUM_LSHIFTED_BINARY_PARAMS_, (p1, p2, p3))
0034 #define BOOST_ODEINT_ENUM_LSHIFTED_BINARY_PARAMS_(z, n, data) \
0035 BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 0, data), n) \
0036 BOOST_PP_IF(n, \
0037 BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 2, data), BOOST_PP_DEC(n)), \
0038 BOOST_PP_TUPLE_ELEM(3, 1, data))
0039
0040
0041
0042 #define BOOST_ODEINT_ENUM_BINARY_STATEMENTS(count, p1, p2) \
0043 BOOST_PP_REPEAT(count, BOOST_ODEINT_ENUM_BINARY_STATEMENTS_, (p1, p2))
0044 #define BOOST_ODEINT_ENUM_BINARY_STATEMENTS_(z, n, data) \
0045 BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, data), n) \
0046 BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, data), n) ;
0047
0048
0049
0050 #define BOOST_ODEINT_ENUM_UNARY_CALLS(count, p1, p2) \
0051 BOOST_PP_ENUM(count, BOOST_ODEINT_ENUM_UNARY_CALLS_, (p1, p2))
0052 #define BOOST_ODEINT_ENUM_SHIFTED_UNARY_CALLS(count, p1, p2) \
0053 BOOST_PP_ENUM_SHIFTED(count, BOOST_ODEINT_ENUM_UNARY_CALLS_, (p1, p2))
0054 #define BOOST_ODEINT_ENUM_TRAILING_SHIFTED_UNARY_CALLS(count, p1, p2) \
0055 BOOST_PP_COMMA_IF(BOOST_PP_DEC(count)) \
0056 BOOST_PP_ENUM_SHIFTED(count, BOOST_ODEINT_ENUM_UNARY_CALLS_, (p1, p2))
0057 #define BOOST_ODEINT_ENUM_UNARY_CALLS_(z, n, data) \
0058 BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, data), n) \
0059 ( BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, data), n) )
0060
0061
0062
0063 #define BOOST_ODEINT_N_ARY_MAX 16
0064
0065
0066
0067 #define BOOST_ODEINT_GEN_SCALE_SUM(macro) \
0068 BOOST_PP_REPEAT_FROM_TO(1, BOOST_ODEINT_N_ARY_MAX, BOOST_ODEINT_GEN_SCALE_SUM_, macro)
0069 #define BOOST_ODEINT_GEN_SCALE_SUM_(z, n, macro) \
0070 template< BOOST_ODEINT_ENUM_LSHIFTED_BINARY_PARAMS(n, class Fac, = double, = Fac) > \
0071 struct BOOST_PP_CAT(scale_sum, n) \
0072 { \
0073 BOOST_ODEINT_ENUM_BINARY_STATEMENTS(n, const Fac, m_alpha) \
0074 \
0075 BOOST_PP_CAT(scale_sum, n) \
0076 ( BOOST_PP_ENUM_BINARY_PARAMS(n, Fac, alpha) ) \
0077 : BOOST_ODEINT_ENUM_UNARY_CALLS(n, m_alpha, alpha) {} \
0078 \
0079 template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), class T) > \
0080 void operator()( T0 &t0 \
0081 BOOST_ODEINT_ENUM_TRAILING_SHIFTED_BINARY_PARAMS(BOOST_PP_INC(n), const T, &t) \
0082 ) const \
0083 { macro(n) } \
0084 typedef void result_type; \
0085 };
0086
0087
0088 #define BOOST_ODEINT_GEN_FOR_EACH(macro) \
0089 BOOST_PP_REPEAT_FROM_TO(1, BOOST_ODEINT_N_ARY_MAX, BOOST_ODEINT_GEN_FOR_EACH_, macro)
0090 #define BOOST_ODEINT_GEN_FOR_EACH_(z, n, macro) \
0091 template< BOOST_PP_ENUM_PARAMS(n, class S) , class Op > \
0092 static void for_each##n ( BOOST_PP_ENUM_BINARY_PARAMS(n, S, &s) , Op op ) \
0093 { macro(n) }
0094
0095
0096 #endif