Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/util/n_ary_helper.hpp
0004 
0005  Macros to generate scale_sumN and for_eachN functors.
0006 
0007  Copyright 2013 Karsten Ahnert
0008  Copyright 2013 Mario Mulansky
0009  Copyright 2013 Pascal Germroth
0010 
0011  Distributed under the Boost Software License, Version 1.0.
0012  (See accompanying file LICENSE_1_0.txt or
0013  copy at http://www.boost.org/LICENSE_1_0.txt)
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 // like BOOST_PP_ENUM_SHIFTED but with a comma in front like _TRAILING
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 // like BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(n, p1, p2) but p2 is shifted left.
0031 // generate "p1 ## 0 = p2, p1 ## 1 = p3 ## 0, p1 ## 2 = p3 ## 1"
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 // like BOOST_PP_ENUM_BINARY_PARAMS(n, p1, p2) but with statements.
0041 // "p1 ## 0 p2 ## 0 ; p1 ## 1 p2 ## 1 ; ..."
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 // like BOOST_PP_ENUM_BINARY_PARAMS(n, p1, p2) but p2 is in parens.
0049 // "p1 ## 0 (p2 ## 0) , p1 ## 1 (p2 ## 1) , ..."
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 // maximum arity + 1 for scale_sum and for_each
0063 #define BOOST_ODEINT_N_ARY_MAX 16
0064 
0065 
0066 // generate scale_sum1 to scale_sumN, operator body generated by macro(N)
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 // generate for_each1 to for_eachN, body generated by macro(N)
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