Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/external/thrust/thrust_operations.hpp
0004 
0005  [begin_description]
0006  Operations of thrust zipped iterators. Is the counterpart of the thrust_algebra.
0007  [end_description]
0008 
0009  Copyright 2010-2013 Mario Mulansky
0010  Copyright 2010-2012 Karsten Ahnert
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_EXTERNAL_THRUST_THRUST_OPERATIONS_HPP_INCLUDED
0019 #define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_OPERATIONS_HPP_INCLUDED
0020 
0021 namespace boost {
0022 namespace numeric {
0023 namespace odeint {
0024 
0025 #include <thrust/tuple.h>
0026 #include <thrust/iterator/zip_iterator.h>
0027 
0028 /**ToDo extend to scale_sum13 for rk78 */
0029 
0030 struct thrust_operations
0031 {
0032     template< class Fac1 = double , class Fac2 = Fac1 >
0033     struct scale_sum2
0034     {
0035         const Fac1 m_alpha1;
0036         const Fac2 m_alpha2;
0037 
0038         scale_sum2( const Fac1 alpha1 , const Fac2 alpha2 )
0039         : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
0040 
0041         template< class Tuple >
0042         __host__ __device__
0043         void operator()( Tuple t ) const
0044         {
0045             thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) + m_alpha2 * thrust::get<2>(t);
0046         }
0047     };
0048 
0049     template< class Fac1 = double , class Fac2 = Fac1 >
0050     struct scale_sum_swap2
0051     {
0052         const Fac1 m_alpha1;
0053         const Fac2 m_alpha2;
0054 
0055         scale_sum_swap2( const Fac1 alpha1 , const Fac2 alpha2 )
0056         : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
0057 
0058         template< class Tuple >
0059         __host__ __device__
0060         void operator()( Tuple t ) const
0061         {
0062             typename thrust::tuple_element<0,Tuple>::type tmp = thrust::get<0>(t);
0063             thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) + m_alpha2 * thrust::get<2>(t);
0064             thrust::get<1>(t) = tmp;
0065         }
0066     };
0067 
0068     template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 >
0069     struct scale_sum3
0070     {
0071         const Fac1 m_alpha1;
0072         const Fac2 m_alpha2;
0073         const Fac3 m_alpha3;
0074 
0075         scale_sum3( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 )
0076         : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) { }
0077 
0078         template< class Tuple >
0079         __host__ __device__
0080         void operator()( Tuple t ) const
0081         {
0082             thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
0083                     m_alpha2 * thrust::get<2>(t) +
0084                     m_alpha3 * thrust::get<3>(t);
0085         }
0086     };
0087 
0088 
0089     template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 >
0090     struct scale_sum4
0091     {
0092         const Fac1 m_alpha1;
0093         const Fac2 m_alpha2;
0094         const Fac3 m_alpha3;
0095         const Fac4 m_alpha4;
0096 
0097         scale_sum4( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 , const Fac4 alpha4 )
0098         : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ){ }
0099 
0100         template< class Tuple >
0101         __host__ __device__
0102         void operator()( Tuple t ) const
0103         {
0104             thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
0105                     m_alpha2 * thrust::get<2>(t) +
0106                     m_alpha3 * thrust::get<3>(t) +
0107                     m_alpha4 * thrust::get<4>(t);
0108         }
0109     };
0110 
0111 
0112     template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 ,
0113             class Fac4 = Fac3 , class Fac5 = Fac4 >
0114     struct scale_sum5
0115     {
0116         const Fac1 m_alpha1;
0117         const Fac2 m_alpha2;
0118         const Fac3 m_alpha3;
0119         const Fac4 m_alpha4;
0120         const Fac5 m_alpha5;
0121 
0122         scale_sum5( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 ,
0123                 const Fac4 alpha4 , const Fac5 alpha5 )
0124         : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) ,
0125           m_alpha4( alpha4 ) , m_alpha5( alpha5 ) { }
0126 
0127         template< class Tuple >
0128         __host__ __device__
0129         void operator()( Tuple t ) const
0130         {
0131             thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
0132                     m_alpha2 * thrust::get<2>(t) +
0133                     m_alpha3 * thrust::get<3>(t) +
0134                     m_alpha4 * thrust::get<4>(t) +
0135                     m_alpha5 * thrust::get<5>(t);
0136         }
0137     };
0138 
0139 
0140     template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 ,
0141             class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 >
0142     struct scale_sum6
0143     {
0144         const Fac1 m_alpha1;
0145         const Fac2 m_alpha2;
0146         const Fac3 m_alpha3;
0147         const Fac4 m_alpha4;
0148         const Fac5 m_alpha5;
0149         const Fac6 m_alpha6;
0150 
0151         scale_sum6( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 ,
0152                 const Fac4 alpha4 , const Fac5 alpha5 , const Fac6 alpha6 )
0153         : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) ,
0154           m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) { }
0155 
0156         template< class Tuple >
0157         __host__ __device__
0158         void operator()( Tuple t ) const
0159         {
0160             thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
0161                     m_alpha2 * thrust::get<2>(t) +
0162                     m_alpha3 * thrust::get<3>(t) +
0163                     m_alpha4 * thrust::get<4>(t) +
0164                     m_alpha5 * thrust::get<5>(t) +
0165                     m_alpha6 * thrust::get<6>(t);
0166         }
0167     };
0168 
0169 
0170     template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 ,
0171             class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 >
0172     struct scale_sum7
0173     {
0174         const Fac1 m_alpha1;
0175         const Fac2 m_alpha2;
0176         const Fac3 m_alpha3;
0177         const Fac4 m_alpha4;
0178         const Fac5 m_alpha5;
0179         const Fac6 m_alpha6;
0180         const Fac7 m_alpha7;
0181 
0182         scale_sum7( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 ,
0183                 const Fac4 alpha4 , const Fac5 alpha5 , const Fac6 alpha6 , const Fac7 alpha7 )
0184         : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) ,
0185           m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) { }
0186 
0187         template< class Tuple >
0188         __host__ __device__
0189         void operator()( Tuple t ) const
0190         {
0191             thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
0192                     m_alpha2 * thrust::get<2>(t) +
0193                     m_alpha3 * thrust::get<3>(t) +
0194                     m_alpha4 * thrust::get<4>(t) +
0195                     m_alpha5 * thrust::get<5>(t) +
0196                     m_alpha6 * thrust::get<6>(t) +
0197                     m_alpha7 * thrust::get<7>(t) ;
0198         }
0199     };
0200 
0201 
0202 
0203 
0204     template< class Fac1 = double >
0205     struct rel_error
0206     {
0207         const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt;
0208 
0209         rel_error( const Fac1 eps_abs , const Fac1 eps_rel , const Fac1 a_x , const Fac1 a_dxdt )
0210         : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt ) { }
0211 
0212 
0213         template< class Tuple >
0214         __host__ __device__
0215         void operator()( Tuple t ) const
0216         {
0217             using std::abs;
0218             thrust::get< 0 >( t ) = abs( thrust::get< 0 >( t ) ) /
0219                     ( m_eps_abs + m_eps_rel * ( m_a_x * abs( thrust::get< 1 >( t ) + m_a_dxdt * abs( thrust::get< 2 >( t ) ) ) ) );
0220         }
0221 
0222         typedef void result_type;
0223     };
0224 
0225 
0226 };
0227 
0228 } // odeint
0229 } // numeric
0230 } // boost
0231 
0232 
0233 #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_OPERATIONS_HPP_INCLUDED