123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- /*
- [auto_generated]
- boost/numeric/odeint/algebra/array_algebra.hpp
- [begin_description]
- Algebra for Arrays. Highly specialized for odeint. Const arguments are
- introduce to work with odeint.
- The Array algebra can be used for Array structures with two template
- parameters:
- Array<T, N>
- [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 >
- template < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each1( Array< T, dim > &s1, Op op )
- {
- for( size_t i=0 ; i<dim ; ++i )
- op( s1[i] );
- }
- template < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each2( Array< T, dim > &s1, const Array< T, dim > &s2,
- Op op )
- {
- for( size_t i=0 ; i<dim ; ++i )
- op( s1[i] , s2[i] );
- }
- template < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each3( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each3( Array< T , dim > &s1 ,
- Array< T , dim > &s2 ,
- const Array< T , dim > &s3 , Op op )
- {
- for( size_t i=0 ; i<dim ; ++i )
- op( s1[i] , s2[i] , s3[i] );
- }
- template < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each4( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 , Op op )
- {
- for( size_t i=0 ; i<dim ; ++i )
- op( s1[i] , s2[i] , s3[i] , s4[i] );
- }
- template < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each5( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each6( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each7( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const Array< T , dim > &s6 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each8( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const Array< T , dim > &s6 ,
- const Array< T , dim > &s7 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each9( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const Array< T , dim > &s6 ,
- const Array< T , dim > &s7 ,
- const Array< T , dim > &s8 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each10( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const Array< T , dim > &s6 ,
- const Array< T , dim > &s7 ,
- const Array< T , dim > &s8 ,
- const Array< T , dim > &s9 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each11( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const Array< T , dim > &s6 ,
- const Array< T , dim > &s7 ,
- const Array< T , dim > &s8 ,
- const Array< T , dim > &s9 ,
- const Array< T , dim > &s10 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each12( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const Array< T , dim > &s6 ,
- const Array< T , dim > &s7 ,
- const Array< T , dim > &s8 ,
- const Array< T , dim > &s9 ,
- const Array< T , dim > &s10 ,
- const Array< T , dim > &s11 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each13( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const Array< T , dim > &s6 ,
- const Array< T , dim > &s7 ,
- const Array< T , dim > &s8 ,
- const Array< T , dim > &s9 ,
- const Array< T , dim > &s10 ,
- const Array< T , dim > &s11 ,
- const Array< T , dim > &s12 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each14( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const Array< T , dim > &s6 ,
- const Array< T , dim > &s7 ,
- const Array< T , dim > &s8 ,
- const Array< T , dim > &s9 ,
- const Array< T , dim > &s10 ,
- const Array< T , dim > &s11 ,
- const Array< T , dim > &s12 ,
- const Array< T , dim > &s13 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim, class Op >
- static void for_each15( Array< T , dim > &s1 ,
- const Array< T , dim > &s2 ,
- const Array< T , dim > &s3 ,
- const Array< T , dim > &s4 ,
- const Array< T , dim > &s5 ,
- const Array< T , dim > &s6 ,
- const Array< T , dim > &s7 ,
- const Array< T , dim > &s8 ,
- const Array< T , dim > &s9 ,
- const Array< T , dim > &s10 ,
- const Array< T , dim > &s11 ,
- const Array< T , dim > &s12 ,
- const Array< T , dim > &s13 ,
- const Array< T , dim > &s14 ,
- const 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 < template < typename, size_t > class Array, typename T,
- size_t dim>
- static typename norm_result_type< Array< T , dim > >::type norm_inf( const Array< T , dim > &s )
- {
- BOOST_USING_STD_MAX();
- using std::abs;
- typedef typename norm_result_type< 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
|