diff options
Diffstat (limited to 'boost/numeric/odeint/algebra')
-rw-r--r-- | boost/numeric/odeint/algebra/algebra_dispatcher.hpp | 87 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/array_algebra.hpp | 272 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/default_operations.hpp | 599 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/detail/extract_value_type.hpp | 52 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/detail/for_each.hpp | 165 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/detail/macros.hpp | 43 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/detail/norm_inf.hpp | 45 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/fusion_algebra.hpp | 216 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/fusion_algebra_dispatcher.hpp | 48 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/multi_array_algebra.hpp | 148 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/norm_result_type.hpp | 33 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/operations_dispatcher.hpp | 41 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/range_algebra.hpp | 142 | ||||
-rw-r--r-- | boost/numeric/odeint/algebra/vector_space_algebra.hpp | 178 |
14 files changed, 2069 insertions, 0 deletions
diff --git a/boost/numeric/odeint/algebra/algebra_dispatcher.hpp b/boost/numeric/odeint/algebra/algebra_dispatcher.hpp new file mode 100644 index 0000000000..df5aabac96 --- /dev/null +++ b/boost/numeric/odeint/algebra/algebra_dispatcher.hpp @@ -0,0 +1,87 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/algebra_dispatcher.hpp + + [begin_description] + Algebra dispatcher to automatically chose suitable algebra. + [end_description] + + Copyright 2013 Karsten Ahnert + Copyright 2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_ALGEBRA_DISPATCHER_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_ALGEBRA_DISPATCHER_HPP_INCLUDED + +#include <complex> + +#include <boost/type_traits/is_floating_point.hpp> + +#include <boost/numeric/ublas/vector.hpp> +#include <boost/numeric/ublas/matrix.hpp> + +#include <boost/numeric/odeint/algebra/range_algebra.hpp> +#include <boost/numeric/odeint/algebra/array_algebra.hpp> +#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp> + +#include <boost/array.hpp> + + +namespace boost { +namespace numeric { +namespace odeint { + +template< class StateType , class Enabler = void > +struct algebra_dispatcher_sfinae +{ + // range_algebra is the standard algebra^ + typedef range_algebra algebra_type; +}; + +template< class StateType > +struct algebra_dispatcher : algebra_dispatcher_sfinae< StateType > { }; + +//specialize for array +template< class T , size_t N > +struct algebra_dispatcher< boost::array< T , N > > +{ + typedef array_algebra algebra_type; +}; + +//specialize for some integral types +template< typename T > +struct algebra_dispatcher_sfinae< T , typename boost::enable_if< typename boost::is_floating_point< T >::type >::type > +{ + typedef vector_space_algebra algebra_type; +}; + +template< typename T > +struct algebra_dispatcher< std::complex<T> > +{ + typedef vector_space_algebra algebra_type; +}; + +///* think about that again.... +// specialize for ublas vector and matrix types +template< class T , class A > +struct algebra_dispatcher< boost::numeric::ublas::vector< T , A > > +{ + typedef vector_space_algebra algebra_type; +}; + +template< class T , class L , class A > +struct algebra_dispatcher< boost::numeric::ublas::matrix< T , L , A > > +{ + typedef vector_space_algebra algebra_type; +}; +//*/ + +} +} +} + +#endif diff --git a/boost/numeric/odeint/algebra/array_algebra.hpp b/boost/numeric/odeint/algebra/array_algebra.hpp new file mode 100644 index 0000000000..c565d6dd76 --- /dev/null +++ b/boost/numeric/odeint/algebra/array_algebra.hpp @@ -0,0 +1,272 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/array_algebra.hpp + + [begin_description] + Algebra for boost::array. Highly specialized for odeint. Const arguments are introduce to work with odeint. + [end_description] + + Copyright 2011-2013 Mario Mulansky + Copyright 2011-2012 Karsten Ahnert + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_ARRAY_ALGEBRA_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_ARRAY_ALGEBRA_HPP_INCLUDED + +#include <algorithm> +#include <boost/array.hpp> + +#include <boost/numeric/odeint/algebra/norm_result_type.hpp> + +namespace boost { +namespace numeric { +namespace odeint { + +struct array_algebra +{ + template< typename T , size_t dim , class Op > + static void for_each1( boost::array< T , dim > &s1 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] ); + } + + + template< typename T1 , typename T2 , size_t dim , class Op > + static void for_each2( boost::array< T1 , dim > &s1 , + const boost::array< T2 , dim > &s2 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each3( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] ); + } + + /* different const signature - required for the scale_sum_swap2 operation */ + template< typename T , size_t dim , class Op > + static void for_each3( boost::array< T , dim > &s1 , + boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each4( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each5( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each6( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each7( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , + const boost::array< T , dim > &s7 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] , s7[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each8( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , + const boost::array< T , dim > &s7 , + const boost::array< T , dim > &s8 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] , s7[i] , s8[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each9( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , + const boost::array< T , dim > &s7 , + const boost::array< T , dim > &s8 , + const boost::array< T , dim > &s9 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] , s7[i] , s8[i] , s9[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each10( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , + const boost::array< T , dim > &s7 , + const boost::array< T , dim > &s8 , + const boost::array< T , dim > &s9 , + const boost::array< T , dim > &s10 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] , s7[i] , s8[i] , s9[i] , s10[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each11( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , + const boost::array< T , dim > &s7 , + const boost::array< T , dim > &s8 , + const boost::array< T , dim > &s9 , + const boost::array< T , dim > &s10 , + const boost::array< T , dim > &s11 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] , s7[i] , s8[i] , s9[i] , s10[i] , s11[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each12( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , + const boost::array< T , dim > &s7 , + const boost::array< T , dim > &s8 , + const boost::array< T , dim > &s9 , + const boost::array< T , dim > &s10 , + const boost::array< T , dim > &s11 , + const boost::array< T , dim > &s12 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] , s7[i] , s8[i] , s9[i] , s10[i] , s11[i] , s12[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each13( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , + const boost::array< T , dim > &s7 , + const boost::array< T , dim > &s8 , + const boost::array< T , dim > &s9 , + const boost::array< T , dim > &s10 , + const boost::array< T , dim > &s11 , + const boost::array< T , dim > &s12 , + const boost::array< T , dim > &s13 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] , s7[i] , s8[i] , s9[i] , s10[i] , s11[i] , s12[i] , s13[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each14( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , + const boost::array< T , dim > &s7 , + const boost::array< T , dim > &s8 , + const boost::array< T , dim > &s9 , + const boost::array< T , dim > &s10 , + const boost::array< T , dim > &s11 , + const boost::array< T , dim > &s12 , + const boost::array< T , dim > &s13 , + const boost::array< T , dim > &s14 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] , s7[i] , s8[i] , s9[i] , s10[i] , s11[i] , s12[i] , s13[i] , s14[i] ); + } + + template< typename T , size_t dim , class Op > + static void for_each15( boost::array< T , dim > &s1 , + const boost::array< T , dim > &s2 , + const boost::array< T , dim > &s3 , + const boost::array< T , dim > &s4 , + const boost::array< T , dim > &s5 , + const boost::array< T , dim > &s6 , + const boost::array< T , dim > &s7 , + const boost::array< T , dim > &s8 , + const boost::array< T , dim > &s9 , + const boost::array< T , dim > &s10 , + const boost::array< T , dim > &s11 , + const boost::array< T , dim > &s12 , + const boost::array< T , dim > &s13 , + const boost::array< T , dim > &s14 , + const boost::array< T , dim > &s15 , Op op ) + { + for( size_t i=0 ; i<dim ; ++i ) + op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] , s7[i] , s8[i] , s9[i] , s10[i] , s11[i] , s12[i] , s13[i] , s14[i] , s15[i] ); + } + + + template< typename T , size_t dim > + static typename norm_result_type< boost::array< T , dim > >::type norm_inf( const boost::array< T , dim > &s ) + { + BOOST_USING_STD_MAX(); + using std::abs; + typedef typename norm_result_type< boost::array< T , dim > >::type result_type; + result_type init = static_cast< result_type >( 0 ); + for( size_t i=0 ; i<dim ; ++i ) + init = max BOOST_PREVENT_MACRO_SUBSTITUTION ( init , static_cast< result_type >(abs(s[i])) ); + return init; + } + +}; + +} +} +} + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_ARRAY_ALGEBRA_HPP_INCLUDED diff --git a/boost/numeric/odeint/algebra/default_operations.hpp b/boost/numeric/odeint/algebra/default_operations.hpp new file mode 100644 index 0000000000..b10944fa19 --- /dev/null +++ b/boost/numeric/odeint/algebra/default_operations.hpp @@ -0,0 +1,599 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/default_operations.hpp + + [begin_description] + Default operations. They work with the default numerical types, like float, double, complex< double> ... + [end_description] + + Copyright 2010-2012 Karsten Ahnert + Copyright 2010-2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_DEFAULT_OPERATIONS_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_DEFAULT_OPERATIONS_HPP_INCLUDED + +#include <algorithm> + +#include <boost/config.hpp> +#include <boost/array.hpp> + +#include <boost/numeric/odeint/util/unit_helper.hpp> + + +namespace boost { +namespace numeric { +namespace odeint { + + + +/* + * Notes: + * + * * the results structs are needed in order to work with fusion_algebra + */ +struct default_operations +{ + + template< class Fac1 = double > + struct scale + { + const Fac1 m_alpha1; + + scale( Fac1 alpha1 ) : m_alpha1( alpha1 ) { } + + template< class T1 > + void operator()( T1 &t1 ) const + { + t1 *= m_alpha1; + } + + typedef void result_type; + }; + + template< class Fac1 = double > + struct scale_sum1 + { + const Fac1 m_alpha1; + + scale_sum1( Fac1 alpha1 ) : m_alpha1( alpha1 ) { } + + template< class T1 , class T2 > + void operator()( T1 &t1 , const T2 &t2 ) const + { + t1 = m_alpha1 * t2; + } + + typedef void result_type; + }; + + + template< class Fac1 = double , class Fac2 = Fac1 > + struct scale_sum2 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + + scale_sum2( Fac1 alpha1 , Fac2 alpha2 ) : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { } + + template< class T1 , class T2 , class T3 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3; + } + + typedef void result_type; + }; + + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 > + struct scale_sum3 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + + scale_sum3( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) { } + + template< class T1 , class T2 , class T3 , class T4 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 ) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4; + } + + typedef void result_type; + }; + + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 > + struct scale_sum4 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + + scale_sum4( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5; + } + + typedef void result_type; + }; + + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 > + struct scale_sum5 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + + scale_sum5( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , Fac5 alpha5 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6; + } + + typedef void result_type; + }; + + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 > + struct scale_sum6 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + const Fac6 m_alpha6; + + scale_sum6( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , Fac5 alpha5 , Fac6 alpha6 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ){ } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 ,const T7 &t7) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7; + } + + typedef void result_type; + }; + + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 > + struct scale_sum7 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + const Fac6 m_alpha6; + const Fac7 m_alpha7; + + scale_sum7( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , + Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 ) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8; + } + + typedef void result_type; + }; + + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 > + struct scale_sum8 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + const Fac6 m_alpha6; + const Fac7 m_alpha7; + const Fac8 m_alpha8; + + scale_sum8( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , + Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 ) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9; + } + + typedef void result_type; + }; + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 > + struct scale_sum9 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + const Fac6 m_alpha6; + const Fac7 m_alpha7; + const Fac8 m_alpha8; + const Fac9 m_alpha9; + + scale_sum9( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , + Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 ) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10; + } + + typedef void result_type; + }; + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 > + struct scale_sum10 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + const Fac6 m_alpha6; + const Fac7 m_alpha7; + const Fac8 m_alpha8; + const Fac9 m_alpha9; + const Fac10 m_alpha10; + + scale_sum10( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , + Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 , Fac10 alpha10 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 ) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11; + } + + typedef void result_type; + }; + + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 > + struct scale_sum11 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + const Fac6 m_alpha6; + const Fac7 m_alpha7; + const Fac8 m_alpha8; + const Fac9 m_alpha9; + const Fac10 m_alpha10; + const Fac11 m_alpha11; + + scale_sum11( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , + Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 , + Fac10 alpha10 , Fac11 alpha11 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 ) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12; + } + + typedef void result_type; + }; + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 , class Fac12 = Fac11 > + struct scale_sum12 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + const Fac6 m_alpha6; + const Fac7 m_alpha7; + const Fac8 m_alpha8; + const Fac9 m_alpha9; + const Fac10 m_alpha10; + const Fac11 m_alpha11; + const Fac12 m_alpha12; + + scale_sum12( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , + Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 , + Fac10 alpha10 , Fac11 alpha11 , Fac12 alpha12 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) , m_alpha12( alpha12 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 , const T13 &t13 ) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12 + m_alpha12 * t13; + } + + typedef void result_type; + }; + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 , class Fac12 = Fac11 , class Fac13 = Fac12 > + struct scale_sum13 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + const Fac6 m_alpha6; + const Fac7 m_alpha7; + const Fac8 m_alpha8; + const Fac9 m_alpha9; + const Fac10 m_alpha10; + const Fac11 m_alpha11; + const Fac12 m_alpha12; + const Fac13 m_alpha13; + + scale_sum13( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , + Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 , + Fac10 alpha10 , Fac11 alpha11 , Fac12 alpha12 , Fac13 alpha13 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) , m_alpha12( alpha12 ) , m_alpha13( alpha13 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 , class T14 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 , const T13 &t13 , const T14 &t14 ) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12 + m_alpha12 * t13 + m_alpha13 * t14; + } + + typedef void result_type; + }; + + template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 , class Fac12 = Fac11 , class Fac13 = Fac12 , class Fac14 = Fac13 > + struct scale_sum14 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + const Fac3 m_alpha3; + const Fac4 m_alpha4; + const Fac5 m_alpha5; + const Fac6 m_alpha6; + const Fac7 m_alpha7; + const Fac8 m_alpha8; + const Fac9 m_alpha9; + const Fac10 m_alpha10; + const Fac11 m_alpha11; + const Fac12 m_alpha12; + const Fac13 m_alpha13; + const Fac14 m_alpha14; + + scale_sum14( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , + Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 , + Fac10 alpha10 , Fac11 alpha11 , Fac12 alpha12 , Fac13 alpha13 , Fac14 alpha14 ) + : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) , m_alpha12( alpha12 ) , m_alpha13( alpha13 ) , m_alpha14( alpha14 ) { } + + template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 , class T14 , class T15 > + void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 , const T13 &t13 , const T14 &t14 , const T15 &t15 ) const + { + t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12 + m_alpha12 * t13 + m_alpha13 * t14 + m_alpha14 * t15; + } + + typedef void result_type; + }; + + template< class Fac1 = double , class Fac2 = Fac1 > + struct scale_sum_swap2 + { + const Fac1 m_alpha1; + const Fac2 m_alpha2; + + scale_sum_swap2( Fac1 alpha1 , Fac2 alpha2 ) : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { } + + template< class T1 , class T2 , class T3 > + void operator()( T1 &t1 , T2 &t2 , const T3 &t3) const + { + const T1 tmp( t1 ); + t1 = m_alpha1 * t2 + m_alpha2 * t3; + t2 = tmp; + } + + typedef void result_type; + }; + + /* + * for usage in for_each2 + * + * Works with boost::units by eliminating the unit + */ + template< class Fac1 = double > + struct rel_error + { + const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt; + + rel_error( Fac1 eps_abs , Fac1 eps_rel , Fac1 a_x , Fac1 a_dxdt ) + : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt ) { } + + + template< class T1 , class T2 , class T3 > + void operator()( T3 &t3 , const T1 &t1 , const T2 &t2 ) const + { + using std::abs; + set_unit_value( t3 , abs( get_unit_value( t3 ) ) / ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( t1 ) ) + m_a_dxdt * abs( get_unit_value( t2 ) ) ) ) ); + } + + typedef void result_type; + }; + + + /* + * for usage in for_each3 + * + * used in the controller for the rosenbrock4 method + * + * Works with boost::units by eliminating the unit + */ + template< class Fac1 = double > + struct default_rel_error + { + const Fac1 m_eps_abs , m_eps_rel ; + + default_rel_error( Fac1 eps_abs , Fac1 eps_rel ) + : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) { } + + + /* + * xerr = xerr / ( eps_abs + eps_rel * max( x , x_old ) ) + */ + template< class T1 , class T2 , class T3 > + void operator()( T3 &t3 , const T1 &t1 , const T2 &t2 ) const + { + BOOST_USING_STD_MAX(); + using std::abs; + Fac1 x1 = abs( get_unit_value( t1 ) ) , x2 = abs( get_unit_value( t2 ) ); + set_unit_value( t3 , abs( get_unit_value( t3 ) ) / ( m_eps_abs + m_eps_rel * max BOOST_PREVENT_MACRO_SUBSTITUTION ( x1 , x2 ) ) ); + } + + typedef void result_type; + }; + + + + /* + * for usage in reduce + */ + + template< class Value > + struct maximum + { + template< class Fac1 , class Fac2 > + Value operator()( Fac1 t1 , const Fac2 t2 ) const + { + using std::abs; + Value a1 = abs( get_unit_value( t1 ) ) , a2 = abs( get_unit_value( t2 ) ); + return ( a1 < a2 ) ? a2 : a1 ; + } + + typedef Value result_type; + }; + + + template< class Fac1 = double > + struct rel_error_max + { + const Fac1 m_eps_abs , m_eps_rel; + + rel_error_max( Fac1 eps_abs , Fac1 eps_rel ) + : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) + { } + + template< class Res , class T1 , class T2 , class T3 > + Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &x_err ) + { + BOOST_USING_STD_MAX(); + using std::abs; + Res tmp = abs( get_unit_value( x_err ) ) / ( m_eps_abs + m_eps_rel * max BOOST_PREVENT_MACRO_SUBSTITUTION ( abs( x_old ) , abs( x ) ) ); + return max BOOST_PREVENT_MACRO_SUBSTITUTION ( r , tmp ); + } + }; + + + template< class Fac1 = double > + struct rel_error_max2 + { + const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt; + + rel_error_max2( Fac1 eps_abs , Fac1 eps_rel , Fac1 a_x , Fac1 a_dxdt ) + : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt ) + { } + + template< class Res , class T1 , class T2 , class T3 , class T4 > + Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &dxdt_old , const T4 &x_err ) + { + BOOST_USING_STD_MAX(); + using std::abs; + Res tmp = abs( get_unit_value( x_err ) ) / + ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( x_old ) ) + m_a_dxdt * abs( get_unit_value( dxdt_old ) ) ) ); + return max BOOST_PREVENT_MACRO_SUBSTITUTION ( r , tmp ); + } + }; + + + + + template< class Fac1 = double > + struct rel_error_l2 + { + const Fac1 m_eps_abs , m_eps_rel; + + rel_error_l2( Fac1 eps_abs , Fac1 eps_rel ) + : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) + { } + + template< class Res , class T1 , class T2 , class T3 > + Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &x_err ) + { + BOOST_USING_STD_MAX(); + using std::abs; + Res tmp = abs( get_unit_value( x_err ) ) / ( m_eps_abs + m_eps_rel * max BOOST_PREVENT_MACRO_SUBSTITUTION ( abs( x_old ) , abs( x ) ) ); + return r + tmp * tmp; + } + }; + + + + + template< class Fac1 = double > + struct rel_error_l2_2 + { + const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt; + + rel_error_l2_2( Fac1 eps_abs , Fac1 eps_rel , Fac1 a_x , Fac1 a_dxdt ) + : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt ) + { } + + template< class Res , class T1 , class T2 , class T3 , class T4 > + Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &dxdt_old , const T4 &x_err ) + { + using std::abs; + Res tmp = abs( get_unit_value( x_err ) ) / + ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( x_old ) ) + m_a_dxdt * abs( get_unit_value( dxdt_old ) ) ) ); + return r + tmp * tmp; + } + }; + + + + + + +}; + + +} // odeint +} // numeric +} // boost + + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_DEFAULT_OPERATIONS_HPP_INCLUDED diff --git a/boost/numeric/odeint/algebra/detail/extract_value_type.hpp b/boost/numeric/odeint/algebra/detail/extract_value_type.hpp new file mode 100644 index 0000000000..c5246bb6f4 --- /dev/null +++ b/boost/numeric/odeint/algebra/detail/extract_value_type.hpp @@ -0,0 +1,52 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/detail/extract_value_type.hpp + + [begin_description] + Extract true value type from complex types (eg. std::complex) + [end_description] + + Copyright 2013 Karsten Ahnert + Copyright 2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_EXTRACT_VALUE_TYPE_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_EXTRACT_VALUE_TYPE_HPP_INCLUDED + +#include <boost/utility.hpp> +#include <boost/mpl/has_xxx.hpp> + +BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type) + +namespace boost { +namespace numeric { +namespace odeint { +namespace detail { + +template< typename S , typename Enabler = void > +struct extract_value_type {}; + +// as long as value_types are defined we go down the value_type chain +// e.g. returning S::value_type::value_type::value_type + +template< typename S > +struct extract_value_type<S , typename boost::disable_if< has_value_type<S> >::type > +{ + // no value_type defined, return S + typedef S type; +}; + +template< typename S > +struct extract_value_type< S , typename boost::enable_if< has_value_type<S> >::type > +{ + // go down the value_type + typedef typename extract_value_type< typename S::value_type >::type type; +}; + +} } } } + +#endif diff --git a/boost/numeric/odeint/algebra/detail/for_each.hpp b/boost/numeric/odeint/algebra/detail/for_each.hpp new file mode 100644 index 0000000000..5387a47db6 --- /dev/null +++ b/boost/numeric/odeint/algebra/detail/for_each.hpp @@ -0,0 +1,165 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/detail/for_each.hpp + + [begin_description] + Default for_each implementations. + [end_description] + + Copyright 2010-2012 Karsten Ahnert + Copyright 2011 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_FOR_EACH_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_FOR_EACH_HPP_INCLUDED + +namespace boost { +namespace numeric { +namespace odeint { +namespace detail { + + + template< class Iterator1 , class Operation > + inline void for_each1( Iterator1 first1 , Iterator1 last1 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ ); + } + + + template< class Iterator1 , class Iterator2 , class Operation > + inline void for_each2( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ ); + } + + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Operation > + inline void for_each3( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ ); + } + + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Operation > + inline void for_each4( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, Iterator4 first4, Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ ); + } + + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Operation > + inline void for_each5( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ ); + } + + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Operation > + inline void for_each6( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ ); + } + + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Operation > + inline void for_each7( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ ); + } + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Iterator8 , class Operation > + inline void for_each8( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Iterator8 first8 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ , *first8++ ); + } + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Iterator8 , class Iterator9 , class Operation > + inline void for_each9( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Iterator8 first8 , + Iterator9 first9 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ , *first8++ , *first9++ ); + } + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Iterator8 , class Iterator9 , class Iterator10 , class Operation > + inline void for_each10( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Iterator8 first8 , + Iterator9 first9 , Iterator10 first10 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ , *first8++ , *first9++ , *first10++ ); + } + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Iterator8 , class Iterator9 , class Iterator10 , class Iterator11 , class Operation > + inline void for_each11( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Iterator8 first8 , + Iterator9 first9 , Iterator10 first10 , Iterator11 first11 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ , *first8++ , *first9++ , *first10++ , *first11++ ); + } + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Iterator8 , class Iterator9 , class Iterator10 , class Iterator11 , class Iterator12 , class Operation > + inline void for_each12( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Iterator8 first8 , + Iterator9 first9 , Iterator10 first10 , Iterator11 first11 , Iterator12 first12 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ , *first8++ , *first9++ , *first10++ , *first11++ , *first12++ ); + } + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Iterator8 , class Iterator9 , class Iterator10 , class Iterator11 , class Iterator12 , class Iterator13 , class Operation > + inline void for_each13( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Iterator8 first8 , + Iterator9 first9 , Iterator10 first10 , Iterator11 first11 , Iterator12 first12 , Iterator13 first13 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ , *first8++ , *first9++ , *first10++ , *first11++ , *first12++ , *first13++ ); + } + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Iterator8 , class Iterator9 , class Iterator10 , class Iterator11 , class Iterator12 , class Iterator13 , class Iterator14 , class Operation > + inline void for_each14( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Iterator8 first8 , + Iterator9 first9 , Iterator10 first10 , Iterator11 first11 , Iterator12 first12 , Iterator13 first13 , + Iterator14 first14 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ , *first8++ , *first9++ , *first10++ , *first11++ , *first12++ , *first13++ , *first14++ ); + } + + template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Iterator8 , class Iterator9 , class Iterator10 , class Iterator11 , class Iterator12 , class Iterator13 , class Iterator14 , class Iterator15 , class Operation > + inline void for_each15( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, + Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Iterator8 first8 , + Iterator9 first9 , Iterator10 first10 , Iterator11 first11 , Iterator12 first12 , Iterator13 first13 , + Iterator14 first14 , Iterator15 first15 , Operation op ) + { + for( ; first1 != last1 ; ) + op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ , *first8++ , *first9++ , *first10++ , *first11++ , *first12++ , *first13++ , *first14++ , *first15++ ); + } + + +} // detail +} // odeint +} // numeric +} // boost + + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_FOR_EACH_HPP_INCLUDED diff --git a/boost/numeric/odeint/algebra/detail/macros.hpp b/boost/numeric/odeint/algebra/detail/macros.hpp new file mode 100644 index 0000000000..9e18a8a2f0 --- /dev/null +++ b/boost/numeric/odeint/algebra/detail/macros.hpp @@ -0,0 +1,43 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/detail/macros.hpp + + [begin_description] + Some macros for type checking. + [end_description] + + Copyright 2010-2012 Karsten Ahnert + Copyright 2010 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_MACROS_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_MACROS_HPP_INCLUDED + + +//type traits aren't working with nvcc +#ifndef __CUDACC__ +#include <boost/type_traits.hpp> +#include <boost/static_assert.hpp> + +#define BOOST_ODEINT_CHECK_CONTAINER_TYPE( Type1 , Type2 ) \ + BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< Type1 >::type , Type2 >::value )) + +#else +//empty macro for nvcc +#define BOOST_ODEINT_CHECK_CONTAINER_TYPE( Type1 , Type2 ) + +#endif // __CUDACC__ + + + +/* +#define BOOST_ODEINT_CHECK_OPERATION_ARITY( Operation , Arity ) \ + BOOST_STATIC_ASSERT(( boost::function_traits< Operation >::arity == Arity )) + */ + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_MACROS_HPP_INCLUDED diff --git a/boost/numeric/odeint/algebra/detail/norm_inf.hpp b/boost/numeric/odeint/algebra/detail/norm_inf.hpp new file mode 100644 index 0000000000..3d32c99bee --- /dev/null +++ b/boost/numeric/odeint/algebra/detail/norm_inf.hpp @@ -0,0 +1,45 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/detail/norm_inf.hpp + + [begin_description] + Default reduce implementation. + [end_description] + + Copyright 2013 Karsten Ahnert + Copyright 2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_NORM_INF_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_NORM_INF_HPP_INCLUDED + +#include <cmath> + +namespace boost { +namespace numeric { +namespace odeint { +namespace detail { + +template< typename Value , class Iterator1 > +inline Value norm_inf( Iterator1 first1 , Iterator1 last1 , Value init ) +{ + using std::max; + using std::abs; + for( ; first1 != last1 ; ) + init = max( init , abs( *first1++ ) ); + return init; +} + + +} // detail +} // odeint +} // numeric +} // boost + + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_NORM_INF_HPP_INCLUDED diff --git a/boost/numeric/odeint/algebra/fusion_algebra.hpp b/boost/numeric/odeint/algebra/fusion_algebra.hpp new file mode 100644 index 0000000000..0055e5d4de --- /dev/null +++ b/boost/numeric/odeint/algebra/fusion_algebra.hpp @@ -0,0 +1,216 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/fusion_algebra.hpp + + [begin_description] + Algebra for boost::fusion sequences. + [end_description] + + Copyright 2011-2013 Karsten Ahnert + Copyright 2011-2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_FUSION_ALGEBRA_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_FUSION_ALGEBRA_HPP_INCLUDED + +#include <algorithm> + +#include <boost/numeric/odeint/config.hpp> + +#include <boost/fusion/container/vector.hpp> +#include <boost/fusion/algorithm/iteration/for_each.hpp> +#include <boost/fusion/view/zip_view.hpp> +#include <boost/fusion/functional/generation/make_fused.hpp> +#include <boost/fusion/algorithm/iteration/accumulate.hpp> + +namespace boost { +namespace numeric { +namespace odeint { + +namespace detail { + + template< class Value > + struct fusion_maximum + { + template< class Fac1 , class Fac2 > + Value operator()( Fac1 t1 , const Fac2 t2 ) const + { + using std::abs; + Value a1 = abs( get_unit_value( t1 ) ) , a2 = abs( get_unit_value( t2 ) ); + return ( a1 < a2 ) ? a2 : a1 ; + } + + typedef Value result_type; + }; +} + +/* specialize this if the fundamental numeric type in your fusion sequence is + * anything else but double (most likely not) + */ +template< typename Sequence > +struct fusion_traits { + typedef double value_type; +}; + +struct fusion_algebra +{ + template< class S1 , class Op > + static void for_each1( S1 &s1 , Op op ) + { + boost::fusion::for_each( s1 , op ); + }; + + + template< class S1 , class S2 , class Op > + static void for_each2( S1 &s1 , S2 &s2 , Op op ) + { + typedef boost::fusion::vector< S1& , S2& > Sequences; + Sequences sequences( s1 , s2 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + + template< class S1 , class S2 , class S3 , class Op > + static void for_each3( S1 &s1 , S2 &s2 , S3 &s3 , Op op ) + { + typedef boost::fusion::vector< S1& , S2& , S3& > Sequences; + Sequences sequences( s1 , s2 , s3 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + template< class S1 , class S2 , class S3 , class S4 , class Op > + static void for_each4( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op ) + { + typedef boost::fusion::vector< S1& , S2& , S3& , S4& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class Op > + static void for_each5( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , Op op ) + { + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class Op > + static void for_each6( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , Op op ) + { + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class Op > + static void for_each7( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , Op op ) + { + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class Op > + static void for_each8( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , Op op ) + { + BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 8 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" ); + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class Op > + static void for_each9( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , Op op ) + { + BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 9 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" ); + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class S10 , class Op > + 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 ) + { + BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 10 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" ); + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + 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 > + 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 ) + { + BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 11 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" ); + BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 11 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" ); + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + 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 > + 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 ) + { + BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 12 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" ); + BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 12 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" ); + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& , S12& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + 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 > + 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 ) + { + BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 13 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" ); + BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 13 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" ); + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& , S12& , S13& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + 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 > + 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 ) + { + BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 14 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" ); + BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 14 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" ); + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& , S12& , S13& , S14& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 , s14 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + 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 > + 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 ) + { + BOOST_STATIC_ASSERT_MSG( BOOST_FUSION_INVOKE_MAX_ARITY >= 15 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" ); + BOOST_STATIC_ASSERT_MSG( BOOST_RESULT_OF_NUM_ARGS >= 15 , "Macro Parameter BOOST_RESULT_OF_NUM_ARGS to small!" ); + typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& , S9& , S10& , S11& , S12& , S13& , S14& , S15& > Sequences; + Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 , s14 , s15 ); + boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) ); + } + + template< class S > + static typename fusion_traits< S >::value_type norm_inf( const S &s ) + { + typedef typename fusion_traits< S >::value_type value_type; + return boost::fusion::accumulate( s , static_cast<value_type>(0) , + detail::fusion_maximum<value_type>() ); + } + +}; + + + +} // odeint +} // numeric +} // boost + + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_FUSION_ALGEBRA_HPP_INCLUDED diff --git a/boost/numeric/odeint/algebra/fusion_algebra_dispatcher.hpp b/boost/numeric/odeint/algebra/fusion_algebra_dispatcher.hpp new file mode 100644 index 0000000000..4bfc5c26ba --- /dev/null +++ b/boost/numeric/odeint/algebra/fusion_algebra_dispatcher.hpp @@ -0,0 +1,48 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/fusion_algebra_dispatcher.hpp + + [begin_description] + tba. + [end_description] + + Copyright 2013 Karsten Ahnert + Copyright 2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_FUSION_ALGEBRA_DISPATCHER_HPP_DEFINED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_FUSION_ALGEBRA_DISPATCHER_HPP_DEFINED + +#include <boost/numeric/odeint/algebra/fusion_algebra.hpp> +#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp> + +#include <boost/utility/enable_if.hpp> +#include <boost/fusion/include/is_sequence.hpp> + + + +namespace boost { +namespace numeric { +namespace odeint { + +// specialization for fusion sequences +template< class FusionSequence > +struct algebra_dispatcher_sfinae< FusionSequence , + typename boost::enable_if< + typename boost::fusion::traits::is_sequence< FusionSequence >::type >::type > +{ + typedef fusion_algebra algebra_type; +}; + + +} // namespace odeint +} // namespace numeric +} // namespace boost + + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_FUSION_ALGEBRA_DISPATCHER_HPP_DEFINED diff --git a/boost/numeric/odeint/algebra/multi_array_algebra.hpp b/boost/numeric/odeint/algebra/multi_array_algebra.hpp new file mode 100644 index 0000000000..4d1fc16c3a --- /dev/null +++ b/boost/numeric/odeint/algebra/multi_array_algebra.hpp @@ -0,0 +1,148 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/multi_array_algebra.hpp + + [begin_description] + tba. + [end_description] + + Copyright 2009-2012 Karsten Ahnert + Copyright 2009-2012 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_MULTI_ARRAY_ALGEBRA_HPP_DEFINED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_MULTI_ARRAY_ALGEBRA_HPP_DEFINED + + +#include <boost/numeric/odeint/algebra/detail/for_each.hpp> +#include <boost/numeric/odeint/algebra/detail/norm_inf.hpp> +#include <boost/numeric/odeint/algebra/norm_result_type.hpp> +#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp> + + +namespace boost { +namespace numeric { +namespace odeint { + +// not ready +struct multi_array_algebra +{ + template< class S1 , class Op > + static void for_each1( S1 &s1 , Op op ) + { + detail::for_each1( s1.data() , s1.data() + s1.num_elements() , op ); + } + + template< class S1 , class S2 , class Op > + static void for_each2( S1 &s1 , S2 &s2 , Op op ) + { + detail::for_each2( s1.data() , s1.data() + s1.num_elements() , s2.data() , op ); + } + + template< class S1 , class S2 , class S3 , class Op > + static void for_each3( S1 &s1 , S2 &s2 , S3 &s3 , Op op ) + { + detail::for_each3( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class Op > + static void for_each4( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op ) + { + detail::for_each4( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class Op > + static void for_each5( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , Op op ) + { + detail::for_each5( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class Op > + static void for_each6( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , Op op ) + { + detail::for_each6( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class Op > + static void for_each7( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , Op op ) + { + detail::for_each7( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class Op > + static void for_each8( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , Op op ) + { + detail::for_each8( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class Op > + static void for_each9( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , Op op ) + { + detail::for_each9( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class Op > + 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 ) + { + detail::for_each10( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , op ); + } + + 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 > + 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 ) + { + detail::for_each11( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , s11.data() , op ); + } + + 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 > + 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 ) + { + detail::for_each12( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , s11.data() , s12.data() , op ); + } + + 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 > + 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 ) + { + detail::for_each13( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , s11.data() , s12.data() , s13.data() , op ); + } + + 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 > + 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 ) + { + detail::for_each14( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , s11.data() , s12.data() , s14.data() , op ); + } + + 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 > + 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 ) + { + detail::for_each15( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , s11.data() , s12.data() , s14.data() , s15.data() , op ); + } + + template< typename S > + static typename norm_result_type<S>::type norm_inf( const S &s ) + { + return detail::norm_inf( s.data() , s.data() + s.num_elements() , static_cast< typename norm_result_type<S>::type >( 0 ) ); + } +}; + +// template< class T , size_t N > +// struct algebra_dispatcher< boost::array< T , N > > +// { +// typedef array_algebra algebra_type; +// }; + + + + + + +} // namespace odeint +} // namespace numeric +} // namespace boost + + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_MULTI_ARRAY_ALGEBRA_HPP_DEFINED diff --git a/boost/numeric/odeint/algebra/norm_result_type.hpp b/boost/numeric/odeint/algebra/norm_result_type.hpp new file mode 100644 index 0000000000..0e99e8fcc2 --- /dev/null +++ b/boost/numeric/odeint/algebra/norm_result_type.hpp @@ -0,0 +1,33 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/norm_result_type.hpp + + [begin_description] + Calculates the type of the norm_inf operation for container types + [end_description] + + Copyright 2013 Karsten Ahnert + Copyright 2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_NORM_RESULT_TYPE_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_NORM_RESULT_TYPE_HPP_INCLUDED + +#include <boost/numeric/odeint/algebra/detail/extract_value_type.hpp> + +namespace boost { +namespace numeric { +namespace odeint { + +template< typename S , typename Enabler = void > +struct norm_result_type { + typedef typename detail::extract_value_type< S >::type type; +}; + +} } } + +#endif diff --git a/boost/numeric/odeint/algebra/operations_dispatcher.hpp b/boost/numeric/odeint/algebra/operations_dispatcher.hpp new file mode 100644 index 0000000000..faeb5e884d --- /dev/null +++ b/boost/numeric/odeint/algebra/operations_dispatcher.hpp @@ -0,0 +1,41 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/operations_dispatcher.hpp + + [begin_description] + Operations dispatcher to automatically chose suitable operations. + [end_description] + + Copyright 2013 Karsten Ahnert + Copyright 2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_OPERATIONS_DISPATCHER_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_OPERATIONS_DISPATCHER_HPP_INCLUDED + +#include <boost/numeric/odeint/algebra/default_operations.hpp> + +namespace boost { +namespace numeric { +namespace odeint { + +template< class StateType , class Enabler = void > +struct operations_dispatcher_sfinae +{ + typedef default_operations operations_type; +}; + +template< class StateType > +struct operations_dispatcher : operations_dispatcher_sfinae< StateType > {}; + +// no further specializations required + +} +} +} + +#endif diff --git a/boost/numeric/odeint/algebra/range_algebra.hpp b/boost/numeric/odeint/algebra/range_algebra.hpp new file mode 100644 index 0000000000..3d7695c812 --- /dev/null +++ b/boost/numeric/odeint/algebra/range_algebra.hpp @@ -0,0 +1,142 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/range_algebra.hpp + + [begin_description] + Default algebra, which works with the most state types, like vector< double >, boost::array< double >, boost::range. + Internally is uses boost::range to obtain the begin and end iterator of the according sequence. + [end_description] + + Copyright 2010-2013 Karsten Ahnert + Copyright 2010-2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_RANGE_ALGEBRA_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_RANGE_ALGEBRA_HPP_INCLUDED + +#include <boost/range.hpp> +#include <boost/mpl/size_t.hpp> + +#include <boost/numeric/odeint/algebra/detail/macros.hpp> +#include <boost/numeric/odeint/algebra/detail/for_each.hpp> +#include <boost/numeric/odeint/algebra/detail/norm_inf.hpp> +#include <boost/numeric/odeint/algebra/norm_result_type.hpp> + +namespace boost { +namespace numeric { +namespace odeint { + +struct range_algebra +{ + template< class S1 , class Op > + static void for_each1( S1 &s1 , Op op ) + { + detail::for_each1( boost::begin( s1 ) , boost::end( s1 ) , + op ); + } + + template< class S1 , class S2 , class Op > + static void for_each2( S1 &s1 , S2 &s2 , Op op ) + { + detail::for_each2( boost::begin( s1 ) , boost::end( s1 ) , + boost::begin( s2 ) , op ); + } + + template< class S1 , class S2 , class S3 , class Op > + static void for_each3( S1 &s1 , S2 &s2 , S3 &s3 , Op op ) + { + detail::for_each3( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class Op > + static void for_each4( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op ) + { + detail::for_each4( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class Op > + static void for_each5( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , Op op ) + { + detail::for_each5( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class Op > + static void for_each6( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , Op op ) + { + detail::for_each6( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class Op > + static void for_each7( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , Op op ) + { + detail::for_each7( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , boost::begin( s7 ) , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class Op > + static void for_each8( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , Op op ) + { + detail::for_each8( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , boost::begin( s7 ) , boost::begin( s8 ) , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class Op > + static void for_each9( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , Op op ) + { + detail::for_each9( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , boost::begin( s7 ) , boost::begin( s8 ) , boost::begin( s9 ) , op ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class Op > + 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 ) + { + detail::for_each10( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , boost::begin( s7 ) , boost::begin( s8 ) , boost::begin( s9 ) , boost::begin( s10 ) , op ); + } + + 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 > + 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 ) + { + detail::for_each11( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , boost::begin( s7 ) , boost::begin( s8 ) , boost::begin( s9 ) , boost::begin( s10 ) , boost::begin( s11 ) , op ); + } + + 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 > + 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 ) + { + detail::for_each12( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , boost::begin( s7 ) , boost::begin( s8 ) , boost::begin( s9 ) , boost::begin( s10 ) , boost::begin( s11 ) , boost::begin( s12 ) , op ); + } + + 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 > + 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 ) + { + detail::for_each13( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , boost::begin( s7 ) , boost::begin( s8 ) , boost::begin( s9 ) , boost::begin( s10 ) , boost::begin( s11 ) , boost::begin( s12 ) , boost::begin( s13 ) , op ); + } + + 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 > + 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 ) + { + detail::for_each14( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , boost::begin( s7 ) , boost::begin( s8 ) , boost::begin( s9 ) , boost::begin( s10 ) , boost::begin( s11 ) , boost::begin( s12 ) , boost::begin( s13 ) , boost::begin( s14 ) , op ); + } + + 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 > + 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 ) + { + detail::for_each15( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , boost::begin( s4 ) , boost::begin( s5 ) , boost::begin( s6 ) , boost::begin( s7 ) , boost::begin( s8 ) , boost::begin( s9 ) , boost::begin( s10 ) , boost::begin( s11 ) , boost::begin( s12 ) , boost::begin( s13 ) , boost::begin( s14 ) , boost::begin( s15 ) , op ); + } + + template< typename S > + static typename norm_result_type<S>::type norm_inf( const S &s ) + { + return detail::norm_inf( boost::begin( s ) , boost::end( s ) , + static_cast< typename norm_result_type<S>::type >( 0 ) ); + } + +}; + +} // odeint +} // numeric +} // boost + + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_RANGE_ALGEBRA_HPP_INCLUDED diff --git a/boost/numeric/odeint/algebra/vector_space_algebra.hpp b/boost/numeric/odeint/algebra/vector_space_algebra.hpp new file mode 100644 index 0000000000..17ff007eef --- /dev/null +++ b/boost/numeric/odeint/algebra/vector_space_algebra.hpp @@ -0,0 +1,178 @@ +/* + [auto_generated] + boost/numeric/odeint/algebra/vector_space_algebra.hpp + + [begin_description] + An algebra for types which have vector space semantics, hence types on which the operators +,-,* are well defined. + [end_description] + + Copyright 2010-2012 Karsten Ahnert + Copyright 2010-2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_VECTOR_SPACE_ALGEBRA_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_ALGEBRA_VECTOR_SPACE_ALGEBRA_HPP_INCLUDED + +#include <complex> + +#include <boost/type_traits/remove_reference.hpp> + + +namespace boost { +namespace numeric { +namespace odeint { + +/* + * This class template has to be overload in order to call vector_space_algebra::norm_inf + */ +template< class State > struct vector_space_norm_inf; + +/* + * Example: instantiation for sole doubles and complex + */ +template<> +struct vector_space_norm_inf< double > +{ + typedef double result_type; + double operator()( double x ) const + { + using std::abs; + return abs(x); + } +}; + +template<> +struct vector_space_norm_inf< float > +{ + typedef float result_type; + result_type operator()( float x ) const + { + using std::abs; + return abs(x); + } +}; + +template< typename T > +struct vector_space_norm_inf< std::complex<T> > +{ + typedef T result_type; + result_type operator()( std::complex<T> x ) const + { + using std::abs; + return abs( x ); + } +}; + +struct vector_space_algebra +{ + template< class S1 , class Op > + static void for_each1( S1 &s1 , Op op ) + { + // ToDo : build checks, that the +-*/ operators are well defined + op( s1 ); + } + + template< class S1 , class S2 , class Op > + static void for_each2( S1 &s1 , S2 &s2 , Op op ) + { + op( s1 , s2 ); + } + + template< class S1 , class S2 , class S3 , class Op > + static void for_each3( S1 &s1 , S2 &s2 , S3 &s3 , Op op ) + { + op( s1 , s2 , s3 ); + } + + template< class S1 , class S2 , class S3 , class S4 , class Op > + static void for_each4( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op ) + { + op( s1 , s2 , s3 , s4 ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class Op > + static void for_each5( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , Op op ) + { + op( s1 , s2 , s3 , s4 , s5 ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class Op > + static void for_each6( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , Op op ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class Op > + static void for_each7( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , Op op ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 , s7 ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class Op > + static void for_each8( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , Op op ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class Op > + static void for_each9( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , Op op ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 ); + } + + template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class Op > + 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 ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 ); + } + + 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 > + 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 ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 ); + } + + 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 > + 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 ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 ); + } + + 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 > + 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 ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 ); + } + + 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 > + 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 ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 , s14 ); + } + + 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 > + 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 ) + { + op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 , s14 , s15 ); + } + + template< class S > + static typename boost::numeric::odeint::vector_space_norm_inf< S >::result_type norm_inf( const S &s ) + { + boost::numeric::odeint::vector_space_norm_inf< S > n; + return n( s ); + } +}; + + +} // odeint +} // numeric +} // boost + + +#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_VECTOR_SPACE_ALGEBRA_HPP_INCLUDED |