Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/algebra/fusion_algebra.hpp
0004 
0005  [begin_description]
0006  Algebra for boost::fusion sequences.
0007  [end_description]
0008 
0009  Copyright 2011-2013 Karsten Ahnert
0010  Copyright 2011-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_ALGEBRA_FUSION_ALGEBRA_HPP_INCLUDED
0019 #define BOOST_NUMERIC_ODEINT_ALGEBRA_FUSION_ALGEBRA_HPP_INCLUDED
0020 
0021 #include <algorithm>
0022 
0023 #include <boost/numeric/odeint/config.hpp>
0024 
0025 #include <boost/fusion/container/vector.hpp>
0026 #include <boost/fusion/algorithm/iteration/for_each.hpp>
0027 #include <boost/fusion/view/zip_view.hpp>
0028 #include <boost/fusion/functional/generation/make_fused.hpp>
0029 #include <boost/fusion/algorithm/iteration/accumulate.hpp>
0030 
0031 namespace boost {
0032 namespace numeric {
0033 namespace odeint {
0034 
0035 namespace detail {
0036 
0037     template< class Value >
0038     struct fusion_maximum
0039     {
0040         template< class Fac1 , class Fac2 >
0041         Value operator()( Fac1 t1 , const Fac2 t2 ) const
0042         {
0043             using std::abs;
0044             Value a1 = abs( get_unit_value( t1 ) ) , a2 = abs( get_unit_value( t2 ) );
0045             return ( a1 < a2 ) ? a2 : a1 ;
0046         }
0047 
0048         typedef Value result_type;
0049     };
0050 }
0051 
0052 /* specialize this if the fundamental numeric type in your fusion sequence is
0053  * anything else but double (most likely not)
0054  */
0055 template< typename Sequence >
0056 struct fusion_traits {
0057     typedef double value_type;
0058 };
0059 
0060 struct fusion_algebra
0061 {
0062     template< class S1 , class Op >
0063     static void for_each1( S1 &s1 , Op op )
0064     {
0065         boost::fusion::for_each( s1 , op );
0066     };
0067 
0068 
0069     template< class S1 , class S2 , class Op >
0070     static void for_each2( S1 &s1 , S2 &s2 , Op op )
0071     {
0072         typedef boost::fusion::vector< S1& , S2& > Sequences;
0073         Sequences sequences( s1 , s2 );
0074         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0075     }
0076 
0077 
0078     template< class S1 , class S2 , class S3 , class Op >
0079     static void for_each3( S1 &s1 , S2 &s2 , S3 &s3 , Op op )
0080     {
0081         typedef boost::fusion::vector< S1& , S2& , S3& > Sequences;
0082         Sequences sequences( s1 , s2 , s3 );
0083         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0084     }
0085 
0086     template< class S1 , class S2 , class S3 , class S4 , class Op >
0087     static void for_each4( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op )
0088     {
0089         typedef boost::fusion::vector< S1& , S2& , S3& , S4& > Sequences;
0090         Sequences sequences( s1 , s2 , s3 , s4 );
0091         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0092     }
0093 
0094 
0095     template< class S1 , class S2 , class S3 , class S4 , class S5 , class Op >
0096     static void for_each5( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , Op op )
0097     {
0098         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& > Sequences;
0099         Sequences sequences( s1 , s2 , s3 , s4 , s5 );
0100         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0101     }
0102 
0103 
0104     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class Op >
0105     static void for_each6( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , Op op )
0106     {
0107         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& > Sequences;
0108         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 );
0109         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0110     }
0111 
0112 
0113     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class Op >
0114     static void for_each7( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , Op op )
0115     {
0116         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& > Sequences;
0117         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 );
0118         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0119     }
0120 
0121 
0122     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class Op >
0123     static void for_each8( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , Op op )
0124     {
0125         BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 8 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
0126         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& > Sequences;
0127         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 );
0128         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0129     }
0130 
0131     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class Op >
0132     static void for_each9( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , Op op )
0133     {
0134         BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 9 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
0135         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& > Sequences;
0136         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 );
0137         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0138     }
0139 
0140     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class S10 , class Op >
0141     static void for_each10( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , Op op )
0142     {
0143         BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 10 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
0144         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& > Sequences;
0145         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 );
0146         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0147     }
0148 
0149     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class S10 , class S11 , class Op >
0150     static void for_each11( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , Op op )
0151     {
0152         BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 11 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
0153         BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 11 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" );
0154         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& > Sequences;
0155         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 );
0156         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0157     }
0158 
0159     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class Op >
0160     static void for_each12( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , Op op )
0161     {
0162         BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 12 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
0163         BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 12 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" );
0164         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& , S12& > Sequences;
0165         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 );
0166         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0167     }
0168 
0169     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class S13 , class Op >
0170     static void for_each13( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , S13 &s13 , Op op )
0171     {
0172         BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 13 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
0173         BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 13 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" );
0174         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& , S12& , S13& > Sequences;
0175         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 );
0176         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0177     }
0178 
0179     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class S13 , class S14 , class Op >
0180     static void for_each14( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , S13 &s13 , S14 &s14 , Op op )
0181     {
0182         BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 14 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
0183         BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 14 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" );
0184         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& , S12& , S13& , S14& > Sequences;
0185         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 , s14 );
0186         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0187     }
0188 
0189     template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class S13 , class S14 , class S15 , class Op >
0190     static void for_each15( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , S13 &s13 , S14 &s14 , S15 &s15 , Op op )
0191     {
0192         BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 15 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
0193         BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 15 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" );
0194         typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& , S12& , S13& , S14& , S15& > Sequences;
0195         Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 , s14 , s15 );
0196         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
0197     }
0198 
0199     template< class S >
0200     static typename fusion_traits< S >::value_type norm_inf( const S &s )
0201     {
0202         typedef typename fusion_traits< S >::value_type value_type;
0203         return boost::fusion::accumulate( s , static_cast<value_type>(0) ,
0204                                           detail::fusion_maximum<value_type>() );
0205     }
0206 
0207 };
0208 
0209 
0210 
0211 } // odeint
0212 } // numeric
0213 } // boost
0214 
0215 
0216 #endif // BOOST_NUMERIC_ODEINT_ALGEBRA_FUSION_ALGEBRA_HPP_INCLUDED