This commit is contained in:
2026-03-23 20:54:41 +08:00
commit e13b3650e9
4596 changed files with 1015768 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
/*
[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 <type_traits>
#include <complex>
#include <array>
#include <boost/numeric/odeint/config.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>
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< std::array< T , N > >
{
typedef array_algebra algebra_type;
};
//specialize for some integral types
template< typename T >
struct algebra_dispatcher_sfinae< T , typename std::enable_if< std::is_floating_point< T >::value >::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

View File

@@ -0,0 +1,293 @@
/*
[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 <array>
#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

View File

@@ -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 <array>
#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

View File

@@ -0,0 +1,51 @@
/*
[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 <type_traits>
#include <boost/utility.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.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
{
typedef S 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 std::enable_if< has_value_type<S>::value >::type >
: mpl::if_< std::is_same< S, typename S::value_type > ,
mpl::identity< S > , // cut the recursion if S and S::value_type are the same
extract_value_type< typename S::value_type > >::type
{};
} } } }
#endif

View File

@@ -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

View File

@@ -0,0 +1,35 @@
/*
[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
#include <type_traits>
//type traits aren't working with nvcc
#ifndef __CUDACC__
#define BOOST_ODEINT_CHECK_CONTAINER_TYPE( Type1 , Type2 ) \
static_assert(( std::is_same< typename std::remove_const< Type1 >::type , Type2 >::value ));
#else
//empty macro for nvcc
#define BOOST_ODEINT_CHECK_CONTAINER_TYPE( Type1 , Type2 )
#endif // __CUDACC__
#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_MACROS_HPP_INCLUDED

View File

@@ -0,0 +1,46 @@
/*
[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>
#include <algorithm>
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

View File

@@ -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 )
{
static_assert( 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 )
{
static_assert( 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 )
{
static_assert( 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 )
{
static_assert( BOOST_FUSION_INVOKE_MAX_ARITY >= 11 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
static_assert( 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 )
{
static_assert( BOOST_FUSION_INVOKE_MAX_ARITY >= 12 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
static_assert( 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 )
{
static_assert( BOOST_FUSION_INVOKE_MAX_ARITY >= 13 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
static_assert( 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 )
{
static_assert( BOOST_FUSION_INVOKE_MAX_ARITY >= 14 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
static_assert( 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 )
{
static_assert( BOOST_FUSION_INVOKE_MAX_ARITY >= 15 , "Macro Parameter BOOST_FUSION_INVOKE_MAX_ARITY to small!" );
static_assert( 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

View File

@@ -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

View File

@@ -0,0 +1,146 @@
/*
[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/multi_array.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>
#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() , s13.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() , s13.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::multi_array< T , N > >
{
typedef multi_array_algebra algebra_type;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_MULTI_ARRAY_ALGEBRA_HPP_DEFINED

View File

@@ -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

View File

@@ -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

View File

@@ -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 >, std::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

View File

@@ -0,0 +1,175 @@
/*
[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>
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, class Enabler = void > 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

View File

@@ -0,0 +1,53 @@
/*
[auto_generated]
boost/numeric/odeint/config.hpp
[begin_description]
Sets configurations for odeint and used libraries. Should be included before any other odeint library
[end_description]
Copyright 2011-2012 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_CONFIG_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_CONFIG_HPP_INCLUDED
//increase macro variable to allow rk78 scheme
#ifndef FUSION_MAX_VECTOR_SIZE
#define FUSION_MAX_VECTOR_SIZE 15
#endif
/*
* the following definitions are only required if fusion vectors are used as state types
* in the rk78 scheme
* they should be defined by the user if required, see e.g. libs/numeric/examples/harmonic_oscillator_units.cpp
*/
#ifndef BOOST_FUSION_INVOKE_MAX_ARITY
#define BOOST_FUSION_INVOKE_MAX_ARITY 15
#endif
#ifndef BOOST_RESULT_OF_NUM_ARGS
#define BOOST_RESULT_OF_NUM_ARGS 15
#endif
#include <boost/config.hpp>
#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
#define BOOST_NUMERIC_ODEINT_CXX11 1
#endif
#endif // BOOST_NUMERIC_ODEINT_CONFIG_HPP_INCLUDED

View File

@@ -0,0 +1,55 @@
/*
[auto_generated]
boost/numeric/odeint/external/blaze/blaze_algebra_dispatcher.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_EXTERNAL_BLAZE_BLAZE_ALGEBRA_DISPATCHER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_BLAZE_BLAZE_ALGEBRA_DISPATCHER_HPP_INCLUDED
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
#include <blaze/math/dense/StaticVector.h>
#include <blaze/math/dense/DynamicVector.h>
namespace boost {
namespace numeric {
namespace odeint {
template< typename T , size_t N , bool TF >
struct algebra_dispatcher< blaze::StaticVector< T , N , TF > >
{
typedef vector_space_algebra algebra_type;
};
template< typename T , bool TF >
struct algebra_dispatcher< blaze::DynamicVector< T , TF > >
{
typedef vector_space_algebra algebra_type;
};
}
}
}
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_BLAZE_BLAZE_ALGEBRA_DISPATCHER_HPP_INCLUDED

View File

@@ -0,0 +1,64 @@
/*
[auto_generated]
boost/numeric/odeint/external/blaze/blaze_resize.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_EXTERNAL_BLAZE_BLAZE_RESIZE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_BLAZE_BLAZE_RESIZE_HPP_INCLUDED
#include <boost/numeric/odeint/util/is_resizeable.hpp>
#include <boost/numeric/odeint/util/resize.hpp>
#include <boost/numeric/odeint/util/same_size.hpp>
#include <blaze/math/dense/DynamicVector.h>
#include <type_traits>
namespace boost {
namespace numeric {
namespace odeint {
template< typename T , bool TF >
struct is_resizeable< blaze::DynamicVector< T , TF > >
{
typedef std::true_type type;
const static bool value = type::value;
};
template< typename T1 , bool TF1, typename T2 , bool TF2 >
struct same_size_impl< blaze::DynamicVector< T1 , TF1 > , blaze::DynamicVector< T2 , TF2 > >
{
static bool same_size( const blaze::DynamicVector< T1 , TF1 > &x1 , const blaze::DynamicVector< T2 , TF2 > &x2 )
{
return x1.size() == x2.size();
}
};
template< typename T1 , bool TF1, typename T2 , bool TF2 >
struct resize_impl< blaze::DynamicVector< T1 , TF1 > , blaze::DynamicVector< T2 , TF2 > >
{
static void resize( blaze::DynamicVector< T1 , TF1 > &x1 , const blaze::DynamicVector< T2 , TF2 > &x2 )
{
x1.resize( x2.size() );
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_BLAZE_BLAZE_RESIZE_HPP_INCLUDED

View File

@@ -0,0 +1,27 @@
/*
[auto_generated]
boost/numeric/odeint/external/compute/compute.hpp
[begin_description]
includes all headers required for using odeint with Boost.Compute
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_EXTERNAL_COMPUTE_COMPUTE_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_HPP_DEFINED
#include <boost/numeric/odeint/external/compute/compute_algebra.hpp>
#include <boost/numeric/odeint/external/compute/compute_operations.hpp>
#include <boost/numeric/odeint/external/compute/compute_algebra_dispatcher.hpp>
#include <boost/numeric/odeint/external/compute/compute_operations_dispatcher.hpp>
#include <boost/numeric/odeint/external/compute/compute_resize.hpp>
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_HPP_DEFINED

View File

@@ -0,0 +1,65 @@
/*
[auto_generated]
boost/numeric/odeint/external/compute/compute_algebra.hpp
[begin_description]
An algebra for Boost.Compute vectors.
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_HPP_DEFINED
#include <boost/preprocessor/repetition.hpp>
#include <boost/compute.hpp>
namespace boost {
namespace numeric {
namespace odeint {
struct compute_algebra
{
#define BOOST_ODEINT_COMPUTE_STATE_PARAM(z, n, unused) \
StateType ## n &s ## n,
#define BOOST_ODEINT_COMPUTE_ALGEBRA(z, n, unused) \
template< BOOST_PP_ENUM_PARAMS(n, class StateType), class Operation > \
static void for_each ## n( \
BOOST_PP_REPEAT(n, BOOST_ODEINT_COMPUTE_STATE_PARAM, ~) \
Operation op \
) \
{ \
op( BOOST_PP_ENUM_PARAMS(n, s) ); \
}
BOOST_PP_REPEAT_FROM_TO(3, 9, BOOST_ODEINT_COMPUTE_ALGEBRA, ~)
#undef BOOST_ODEINT_COMPUTE_ALGEBRA
#undef BOOST_ODEINT_COMPUTE_STATE_PARAM
template < class S >
static typename S::value_type norm_inf( const S &s ) {
typedef typename S::value_type value_type;
BOOST_COMPUTE_FUNCTION(value_type, max_abs, (value_type, value_type),
{
return max(_1, fabs(_2));
});
return boost::compute::accumulate(s.begin(), s.end(), value_type(), max_abs);
}
};
} // odeint
} // numeric
} // boost
#endif

View File

@@ -0,0 +1,41 @@
/*
[auto_generated]
boost/numeric/odeint/external/compute/compute_algebra_dispatcher.hpp
[begin_description]
algebra_dispatcher specialization for Boost.Compute
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_DISPATCHER_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_DISPATCHER_HPP_DEFINED
#include <boost/compute/container/vector.hpp>
#include <boost/numeric/odeint/external/compute/compute_algebra.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
namespace boost {
namespace numeric {
namespace odeint {
// specialization for Boost.Compute vector
template< class T , class A >
struct algebra_dispatcher< boost::compute::vector< T , A > >
{
typedef compute_algebra algebra_type;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_DISPATCHER_HPP_DEFINED

View File

@@ -0,0 +1,198 @@
/*
[auto_generated]
boost/numeric/odeint/external/compute/compute_operations.hpp
[begin_description]
Operations of Boost.Compute zipped iterators. Is the counterpart of the compute_algebra.
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_EXTERNAL_COMPUTE_COMPUTE_OPERATIONS_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_OPERATIONS_HPP_DEFINED
#include <boost/preprocessor/repetition.hpp>
#include <boost/compute.hpp>
namespace boost {
namespace numeric {
namespace odeint {
struct compute_operations {
#define BOOST_ODEINT_COMPUTE_TEMPL_FAC(z, n, unused) \
, class Fac ## n = BOOST_PP_CAT(Fac, BOOST_PP_DEC(n))
#define BOOST_ODEINT_COMPUTE_MEMB_FAC(z, n, unused) \
const Fac ## n m_alpha ## n;
#define BOOST_ODEINT_COMPUTE_PRM_FAC(z, n, unused) \
BOOST_PP_COMMA_IF(n) const Fac ## n alpha ## n
#define BOOST_ODEINT_COMPUTE_INIT_FAC(z, n, unused) \
BOOST_PP_COMMA_IF(n) m_alpha ## n (alpha ## n)
#define BOOST_ODEINT_COMPUTE_PRM_STATE(z, n, unused) \
BOOST_PP_COMMA_IF(n) StateType ## n &s ## n
#define BOOST_ODEINT_COMPUTE_BEGIN_STATE(z, n, unused) \
BOOST_PP_COMMA_IF( BOOST_PP_DEC(n) ) s ## n.begin()
#define BOOST_ODEINT_COMPUTE_END_STATE(z, n, unused) \
BOOST_PP_COMMA_IF( BOOST_PP_DEC(n) ) s ## n.end()
#define BOOST_ODEINT_COMPUTE_LAMBDA(z, n, unused) \
BOOST_PP_EXPR_IF(n, +) m_alpha ## n * bc::lambda::get< n >(bc::_1)
#define BOOST_ODEINT_COMPUTE_OPERATIONS(z, n, unused) \
template< \
class Fac0 = double \
BOOST_PP_REPEAT_FROM_TO(1, n, BOOST_ODEINT_COMPUTE_TEMPL_FAC, ~) \
> \
struct scale_sum ## n { \
BOOST_PP_REPEAT(n, BOOST_ODEINT_COMPUTE_MEMB_FAC, ~) \
scale_sum ## n( \
BOOST_PP_REPEAT(n, BOOST_ODEINT_COMPUTE_PRM_FAC, ~) \
) \
: BOOST_PP_REPEAT(n, BOOST_ODEINT_COMPUTE_INIT_FAC, ~) \
{ } \
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), class StateType) > \
void operator()( \
BOOST_PP_REPEAT( \
BOOST_PP_INC(n), \
BOOST_ODEINT_COMPUTE_PRM_STATE, ~) \
) const \
{ \
namespace bc = boost::compute; \
bc::transform( \
bc::make_zip_iterator( \
boost::make_tuple( \
BOOST_PP_REPEAT_FROM_TO( \
1, BOOST_PP_INC(n), \
BOOST_ODEINT_COMPUTE_BEGIN_STATE, ~) \
) \
), \
bc::make_zip_iterator( \
boost::make_tuple( \
BOOST_PP_REPEAT_FROM_TO( \
1, BOOST_PP_INC(n), \
BOOST_ODEINT_COMPUTE_END_STATE, ~) \
) \
), \
s0.begin(), \
BOOST_PP_REPEAT(n, BOOST_ODEINT_COMPUTE_LAMBDA, ~) \
); \
} \
};
BOOST_PP_REPEAT_FROM_TO(2, 8, BOOST_ODEINT_COMPUTE_OPERATIONS, ~)
#undef BOOST_ODEINT_COMPUTE_TEMPL_FAC
#undef BOOST_ODEINT_COMPUTE_MEMB_FAC
#undef BOOST_ODEINT_COMPUTE_PRM_FAC
#undef BOOST_ODEINT_COMPUTE_INIT_FAC
#undef BOOST_ODEINT_COMPUTE_PRM_STATE
#undef BOOST_ODEINT_COMPUTE_BEGIN_STATE
#undef BOOST_ODEINT_COMPUTE_END_STATE
#undef BOOST_ODEINT_COMPUTE_LAMBDA
#undef BOOST_ODEINT_COMPUTE_OPERATIONS
template<class Fac1 = double, class Fac2 = Fac1>
struct scale_sum_swap2 {
const Fac1 m_alpha1;
const Fac2 m_alpha2;
scale_sum_swap2(const Fac1 alpha1, const Fac2 alpha2)
: m_alpha1(alpha1), m_alpha2(alpha2) { }
template<class State0, class State1, class State2>
void operator()(State0 &s0, State1 &s1, State2 &s2) const {
namespace bc = boost::compute;
bc::command_queue &queue = bc::system::default_queue();
const bc::context &context = queue.get_context();
const char source[] = BOOST_COMPUTE_STRINGIZE_SOURCE(
kernel void scale_sum_swap2(
F1 a1, F2 a2,
global T0 *x0, global T1 *x1, global T2 *x2,
)
{
uint i = get_global_id(0);
T0 tmp = x0[i];
x0[i] = a1 * x1[i] + a2 * x2[i];
x1[i] = tmp;
}
);
std::stringstream options;
options
<< " -DT0=" << bc::type_name<typename State0::value_type>()
<< " -DT1=" << bc::type_name<typename State1::value_type>()
<< " -DT2=" << bc::type_name<typename State2::value_type>()
<< " -DF1=" << bc::type_name<Fac1>()
<< " -DF2=" << bc::type_name<Fac2>();
bc::program program =
bc::program::build_with_source(source, context, options.str());
bc::kernel kernel(program, "scale_sum_swap2");
kernel.set_arg(0, m_alpha1);
kernel.set_arg(1, m_alpha2);
kernel.set_arg(2, s0.get_buffer());
kernel.set_arg(3, s1.get_buffer());
kernel.set_arg(4, s2.get_buffer());
queue.enqueue_1d_range_kernel(kernel, 0, s0.size());
}
};
template<class Fac1 = double>
struct rel_error {
const Fac1 m_eps_abs, m_eps_rel, m_a_x, m_a_dxdt;
rel_error(const Fac1 eps_abs, const Fac1 eps_rel, const Fac1 a_x, const 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 State0, class State1, class State2>
void operator()(State0 &s0, State1 &s1, State2 &s2) const {
namespace bc = boost::compute;
using bc::_1;
using bc::lambda::get;
bc::for_each(
bc::make_zip_iterator(
boost::make_tuple(
s0.begin(),
s1.begin(),
s2.begin()
)
),
bc::make_zip_iterator(
boost::make_tuple(
s0.end(),
s1.end(),
s2.end()
)
),
get<0>(_1) = abs( get<0>(_1) ) /
(m_eps_abs + m_eps_rel * (m_a_x * abs(get<1>(_1) + m_a_dxdt * abs(get<2>(_1)))))
);
}
};
};
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_OPERATIONS_HPP_DEFINED

View File

@@ -0,0 +1,44 @@
/*
[auto_generated]
boost/numeric/odeint/external/compute/compute_operations_dispatcher.hpp
[begin_description]
operations_dispatcher specialization for Boost.Compute
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_EXTERNAL_COMPUTE_COMPUTE_OPERATIONS_DISPATCHER_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_OPERATIONS_DISPATCHER_HPP_DEFINED
#include <boost/compute/container/vector.hpp>
#include <boost/numeric/odeint/external/compute/compute_operations.hpp>
#include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
namespace boost {
namespace numeric {
namespace odeint {
// specialization for Boost.Compute vector
template< class T , class A >
struct operations_dispatcher< boost::compute::vector< T , A > >
{
typedef compute_operations operations_type;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_OPERATIONS_DISPATCHER_HPP_DEFINED

View File

@@ -0,0 +1,92 @@
/*
[auto_generated]
boost/numeric/odeint/external/compute/compute_resize.hpp
[begin_description]
Enable resizing for Boost.Compute vector
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_EXTERNAL_COMPUTE_COMPUTE_RESIZE_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_RESIZE_HPP_DEFINED
#include <boost/compute/container/vector.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <type_traits>
namespace boost {
namespace numeric {
namespace odeint {
template< class T, class A >
struct is_resizeable< boost::compute::vector< T , A > >
{
struct type : public std::true_type { };
const static bool value = type::value;
};
template< class T, class A >
struct same_size_impl< boost::compute::vector< T, A > , boost::compute::vector< T, A > >
{
static bool same_size( const boost::compute::vector< T, A > &x , const boost::compute::vector< T, A > &y )
{
return x.size() == y.size();
}
};
template< class T, class A >
struct resize_impl< boost::compute::vector< T, A > , boost::compute::vector< T, A > >
{
static void resize( boost::compute::vector< T, A > &x , const boost::compute::vector< T, A > &y )
{
x.resize( y.size() );
}
};
template< class Container1, class T, class A >
struct copy_impl< Container1 , boost::compute::vector< T, A > >
{
static void copy( const Container1 &from , boost::compute::vector< T, A > &to )
{
boost::compute::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) );
}
};
template< class T, class A, class Container2 >
struct copy_impl< boost::compute::vector< T, A > , Container2 >
{
static void copy( const boost::compute::vector< T, A > &from , Container2 &to )
{
boost::compute::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) );
}
};
template< class T, class A >
struct copy_impl< boost::compute::vector< T, A > , boost::compute::vector< T, A > >
{
static void copy( const boost::compute::vector< T, A > &from , boost::compute::vector< T, A > &to )
{
boost::compute::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) );
}
};
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_RESIZE_HPP_DEFINED

View File

@@ -0,0 +1,27 @@
/*
[auto_generated]
boost/numeric/odeint/external/eigen/eigen.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_EXTERNAL_EIGEN_EIGEN_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_HPP_INCLUDED
#include <boost/numeric/odeint/external/eigen/eigen_algebra.hpp>
#include <boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.hpp>
#include <boost/numeric/odeint/external/eigen/eigen_resize.hpp>
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_HPP_INCLUDED

View File

@@ -0,0 +1,98 @@
/*
[auto_generated]
boost/numeric/odeint/external/eigen/eigen_algebra.hpp
[begin_description]
tba.
[end_description]
Copyright 2013 Christian Shelton
Copyright 2013 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_EXTERNAL_EIGEN_EIGEN_ALGEBRA_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_HPP_INCLUDED
#include <Eigen/Dense>
#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
// Necessary routines for Eigen matrices to work with vector_space_algebra
// from odeint
// (that is, it lets odeint treat the eigen matrices correctly, knowing
// how to add, multiply, compute the norm, etc)
namespace Eigen {
template<typename D>
inline const
typename Eigen::CwiseBinaryOp<
internal::scalar_sum_op<typename internal::traits<D>::Scalar>,
typename DenseBase<D>::ConstantReturnType,
const D>
operator+(const typename Eigen::MatrixBase<D> &m,
const typename Eigen::internal::traits<D>::Scalar &s) {
return CwiseBinaryOp<
internal::scalar_sum_op<typename internal::traits<D>::Scalar>,
typename DenseBase<D>::ConstantReturnType,
const D>(DenseBase<D>::Constant(m.rows(), m.cols(), s), m.derived());
}
template<typename D>
inline const
typename Eigen::CwiseBinaryOp<
internal::scalar_sum_op<typename internal::traits<D>::Scalar>,
typename DenseBase<D>::ConstantReturnType,
const D>
operator+(const typename Eigen::internal::traits<D>::Scalar &s,
const typename Eigen::MatrixBase<D> &m) {
return CwiseBinaryOp<
internal::scalar_sum_op<typename internal::traits<D>::Scalar>,
typename DenseBase<D>::ConstantReturnType,
const D>(DenseBase<D>::Constant(m.rows(), m.cols(), s), m.derived());
}
template<typename D1,typename D2>
inline const
typename Eigen::CwiseBinaryOp<
typename Eigen::internal::scalar_quotient_op<
typename Eigen::internal::traits<D1>::Scalar>,
const D1, const D2>
operator/(const Eigen::MatrixBase<D1> &x1, const Eigen::MatrixBase<D2> &x2) {
return x1.cwiseQuotient(x2);
}
template< typename D >
inline const
typename Eigen::CwiseUnaryOp<
typename Eigen::internal::scalar_abs_op<
typename Eigen::internal::traits< D >::Scalar > ,
const D >
abs( const Eigen::MatrixBase< D > &m ) {
return m.cwiseAbs();
}
} // end Eigen namespace
namespace boost {
namespace numeric {
namespace odeint {
template<typename B,int S1,int S2,int O, int M1, int M2>
struct vector_space_norm_inf< Eigen::Matrix<B,S1,S2,O,M1,M2> >
{
typedef B result_type;
result_type operator()( const Eigen::Matrix<B,S1,S2,O,M1,M2> &m ) const
{
return m.template lpNorm<Eigen::Infinity>();
}
};
} } } // end boost::numeric::odeint namespace
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_HPP_INCLUDED

View File

@@ -0,0 +1,49 @@
/*
[auto_generated]
boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.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_EXTERNAL_EIGEN_EIGEN_ALGEBRA_DISPATCHER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_DISPATCHER_HPP_INCLUDED
namespace boost {
namespace numeric {
namespace odeint {
template< class Derived >
struct algebra_dispatcher_sfinae< Derived ,
typename boost::enable_if< typename boost::is_base_of< Eigen::MatrixBase< Derived > , Derived >::type >::type >
{
typedef vector_space_algebra algebra_type;
};
template < class Derived >
struct algebra_dispatcher_sfinae< Derived ,
typename boost::enable_if< typename boost::is_base_of< Eigen::ArrayBase< Derived > , Derived >::type >::type >
{
typedef vector_space_algebra algebra_type;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_DISPATCHER_HPP_INCLUDED

View File

@@ -0,0 +1,103 @@
/*
[auto_generated]
boost/numeric/odeint/external/eigen/eigen_resize.hpp
[begin_description]
tba.
[end_description]
Copyright 2013 Ankur Sinha
Copyright 2013 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_EXTERNAL_EIGEN_EIGEN_RESIZE_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_RESIZE_HPP_DEFINED
#include <type_traits>
#include <boost/numeric/odeint/util/is_resizeable.hpp>
#include <boost/numeric/odeint/util/resize.hpp>
#include <boost/numeric/odeint/util/same_size.hpp>
#include <Eigen/Dense>
namespace boost {
namespace numeric {
namespace odeint {
template< class Derived >
struct is_resizeable_sfinae< Derived ,
typename std::enable_if< std::is_base_of< Eigen::MatrixBase< Derived > , Derived >::value >::type >
{
typedef std::integral_constant<bool, true> type;
const static bool value = type::value;
};
template < class Derived >
struct is_resizeable_sfinae< Derived ,
typename std::enable_if< std::is_base_of< Eigen::ArrayBase< Derived > , Derived >::value >::type >
{
typedef std::integral_constant<bool, true> type;
const static bool value = type::value;
};
template< class Derived >
struct same_size_impl_sfinae< Derived , Derived ,
typename std::enable_if< std::is_base_of< Eigen::MatrixBase< Derived > , Derived >::value >::type >
{
static bool same_size( const Eigen::MatrixBase< Derived > &m1 , const Eigen::MatrixBase< Derived > &m2 )
{
return ( ( m1.innerSize () == m2.innerSize () ) && ( m1.outerSize() == m2.outerSize() ) );
}
};
template< class Derived >
struct same_size_impl_sfinae< Derived , Derived ,
typename std::enable_if< std::is_base_of< Eigen::ArrayBase< Derived > , Derived >::value >::type >
{
static bool same_size( const Eigen::ArrayBase< Derived > &v1 , const Eigen::ArrayBase< Derived > &v2 )
{
return ( ( v1.innerSize () == v2.innerSize () ) && ( v1.outerSize() == v2.outerSize() ) );
}
};
template< class Derived >
struct resize_impl_sfinae< Derived , Derived ,
typename std::enable_if< std::is_base_of< Eigen::MatrixBase< Derived > , Derived >::value >::type >
{
static void resize( Eigen::MatrixBase< Derived > &m1 , const Eigen::MatrixBase< Derived > &m2 )
{
m1.derived().resizeLike(m2);
}
};
template< class Derived >
struct resize_impl_sfinae< Derived , Derived ,
typename std::enable_if< std::is_base_of< Eigen::ArrayBase< Derived > , Derived >::value >::type >
{
static void resize( Eigen::ArrayBase< Derived > &v1 , const Eigen::ArrayBase< Derived > &v2 )
{
v1.derived().resizeLike(v2);
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_RESIZE_HPP_DEFINED

View File

@@ -0,0 +1,228 @@
/*
[auto_generated]
boost/numeric/odeint/external/gsl/gsl_wrapper.hpp
[begin_description]
Wrapper for gsl_vector.
[end_description]
Copyright 2011-2012 Mario Mulansky
Copyright 2011 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_EXTERNAL_GSL_GSL_WRAPPER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_GSL_GSL_WRAPPER_HPP_INCLUDED
#include <new>
#include <gsl/gsl_vector.h>
#include <boost/range.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/numeric/odeint/util/state_wrapper.hpp>
#include <boost/numeric/odeint/util/is_resizeable.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
class const_gsl_vector_iterator;
/*
* defines an iterator for gsl_vector
*/
class gsl_vector_iterator : public boost::iterator_facade< gsl_vector_iterator , double , boost::random_access_traversal_tag >
{
public :
gsl_vector_iterator( void ): m_p(0) , m_stride( 0 ) { }
explicit gsl_vector_iterator( gsl_vector *p ) : m_p( p->data ) , m_stride( p->stride ) { }
friend gsl_vector_iterator end_iterator( gsl_vector * );
private :
friend class boost::iterator_core_access;
friend class const_gsl_vector_iterator;
void increment( void ) { m_p += m_stride; }
void decrement( void ) { m_p -= m_stride; }
void advance( ptrdiff_t n ) { m_p += n*m_stride; }
bool equal( const gsl_vector_iterator &other ) const { return this->m_p == other.m_p; }
bool equal( const const_gsl_vector_iterator &other ) const;
double& dereference( void ) const { return *m_p; }
double *m_p;
size_t m_stride;
};
/*
* defines an const iterator for gsl_vector
*/
class const_gsl_vector_iterator : public boost::iterator_facade< const_gsl_vector_iterator , const double , boost::random_access_traversal_tag >
{
public :
const_gsl_vector_iterator( void ): m_p(0) , m_stride( 0 ) { }
explicit const_gsl_vector_iterator( const gsl_vector *p ) : m_p( p->data ) , m_stride( p->stride ) { }
const_gsl_vector_iterator( const gsl_vector_iterator &p ) : m_p( p.m_p ) , m_stride( p.m_stride ) { }
private :
friend class boost::iterator_core_access;
friend class gsl_vector_iterator;
friend const_gsl_vector_iterator end_iterator( const gsl_vector * );
void increment( void ) { m_p += m_stride; }
void decrement( void ) { m_p -= m_stride; }
void advance( ptrdiff_t n ) { m_p += n*m_stride; }
bool equal( const const_gsl_vector_iterator &other ) const { return this->m_p == other.m_p; }
bool equal( const gsl_vector_iterator &other ) const { return this->m_p == other.m_p; }
const double& dereference( void ) const { return *m_p; }
const double *m_p;
size_t m_stride;
};
bool gsl_vector_iterator::equal( const const_gsl_vector_iterator &other ) const { return this->m_p == other.m_p; }
gsl_vector_iterator end_iterator( gsl_vector *x )
{
gsl_vector_iterator iter( x );
iter.m_p += iter.m_stride * x->size;
return iter;
}
const_gsl_vector_iterator end_iterator( const gsl_vector *x )
{
const_gsl_vector_iterator iter( x );
iter.m_p += iter.m_stride * x->size;
return iter;
}
namespace boost
{
template<>
struct range_mutable_iterator< gsl_vector* >
{
typedef gsl_vector_iterator type;
};
template<>
struct range_const_iterator< gsl_vector* >
{
typedef const_gsl_vector_iterator type;
};
} // namespace boost
// template<>
inline gsl_vector_iterator range_begin( gsl_vector *x )
{
return gsl_vector_iterator( x );
}
// template<>
inline const_gsl_vector_iterator range_begin( const gsl_vector *x )
{
return const_gsl_vector_iterator( x );
}
// template<>
inline gsl_vector_iterator range_end( gsl_vector *x )
{
return end_iterator( x );
}
// template<>
inline const_gsl_vector_iterator range_end( const gsl_vector *x )
{
return end_iterator( x );
}
namespace boost {
namespace numeric {
namespace odeint {
template<>
struct is_resizeable< gsl_vector* >
{
//struct type : public std::integral_constant<bool, true> { };
typedef std::integral_constant<bool, true> type;
const static bool value = type::value;
};
template <>
struct same_size_impl< gsl_vector* , gsl_vector* >
{
static bool same_size( const gsl_vector* x , const gsl_vector* y )
{
return x->size == y->size;
}
};
template <>
struct resize_impl< gsl_vector* , gsl_vector* >
{
static void resize( gsl_vector* &x , const gsl_vector* y )
{
gsl_vector_free( x );
x = gsl_vector_alloc( y->size );
}
};
template<>
struct state_wrapper< gsl_vector* >
{
typedef double value_type;
typedef gsl_vector* state_type;
typedef state_wrapper< gsl_vector* > state_wrapper_type;
state_type m_v;
state_wrapper( )
{
m_v = gsl_vector_alloc( 1 );
}
state_wrapper( const state_wrapper_type &x )
{
resize( m_v , x.m_v );
gsl_vector_memcpy( m_v , x.m_v );
}
~state_wrapper()
{
gsl_vector_free( m_v );
}
};
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_GSL_GSL_WRAPPER_HPP_INCLUDED

View File

@@ -0,0 +1,181 @@
/*
[auto_generated]
boost/numeric/odeint/external/mkl/mkl_operations.hpp
[begin_description]
Wrapper classes for intel math kernel library types.
Get a free, non-commercial download of MKL at
http://software.intel.com/en-us/articles/non-commercial-software-download/
[end_description]
Copyright 2010-2011 Mario Mulansky
Copyright 2011-2013 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_EXTERNAL_MKL_MKL_OPERATIONS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_MKL_MKL_OPERATIONS_HPP_INCLUDED
#include <iostream>
#include <mkl_cblas.h>
#include <boost/numeric/odeint/algebra/default_operations.hpp>
/* exemplary example for writing bindings to the Intel MKL library
* see test/mkl for how to use mkl with odeint
* this is a quick and dirty implementation showing the general possibility.
* It works only with containers based on double and sequential memory allocation.
*/
namespace boost {
namespace numeric {
namespace odeint {
/* only defined for doubles */
struct mkl_operations
{
//template< class Fac1 , class Fac2 > struct scale_sum2;
template< class F1 = double , class F2 = F1 >
struct scale_sum2
{
typedef double Fac1;
typedef double Fac2;
const Fac1 m_alpha1;
const Fac2 m_alpha2;
scale_sum2( const Fac1 alpha1 , const 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;
// we get Containers that have size() and [i]-access
const int n = t1.size();
//boost::numeric::odeint::copy( t1 , t3 );
if( &(t2[0]) != &(t1[0]) )
{
cblas_dcopy( n , &(t2[0]) , 1 , &(t1[0]) , 1 );
}
cblas_dscal( n , m_alpha1 , &(t1[0]) , 1 );
cblas_daxpy( n , m_alpha2 , &(t3[0]) , 1 , &(t1[0]) , 1 );
//daxpby( &n , &m_alpha2 , &(t3[0]) , &one , &m_alpha1 , &(t1[0]) , &one );
}
};
template< class F1 = double , class F2 = F1 , class F3 = F2 >
struct scale_sum3
{
typedef double Fac1;
typedef double Fac2;
typedef double Fac3;
const Fac1 m_alpha1;
const Fac2 m_alpha2;
const Fac3 m_alpha3;
scale_sum3( const Fac1 alpha1 , const Fac2 alpha2 , const 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;
// we get Containers that have size() and [i]-access
const int n = t1.size();
//boost::numeric::odeint::copy( t1 , t3 );
if( &(t2[0]) != &(t1[0]) )
{
cblas_dcopy( n , &(t2[0]) , 1 , &(t1[0]) , 1 );
}
cblas_dscal( n , m_alpha1 , &(t1[0]) , 1 );
cblas_daxpy( n , m_alpha2 , &(t3[0]) , 1 , &(t1[0]) , 1 );
//daxpby( &n , &m_alpha2 , &(t3[0]) , &one , &m_alpha1 , &(t1[0]) , &one );
cblas_daxpy( n , m_alpha3 , &(t4[0]) , 1 , &(t1[0]) , 1 );
}
};
template< class F1 = double , class F2 = F1 , class F3 = F2 , class F4 = F3 >
struct scale_sum4
{
typedef double Fac1;
typedef double Fac2;
typedef double Fac3;
typedef double Fac4;
const Fac1 m_alpha1;
const Fac2 m_alpha2;
const Fac3 m_alpha3;
const Fac4 m_alpha4;
scale_sum4( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 , const 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;
// we get Containers that have size() and [i]-access
const int n = t1.size();
//boost::numeric::odeint::copy( t1 , t3 );
if( &(t2[0]) != &(t1[0]) )
{
cblas_dcopy( n , &(t2[0]) , 1 , &(t1[0]) , 1 );
}
cblas_dscal( n , m_alpha1 , &(t1[0]) , 1 );
cblas_daxpy( n , m_alpha2 , &(t3[0]) , 1 , &(t1[0]) , 1 );
//daxpby( &n , &m_alpha2 , &(t3[0]) , &one , &m_alpha1 , &(t1[0]) , &one );
cblas_daxpy( n , m_alpha3 , &(t4[0]) , 1 , &(t1[0]) , 1 );
cblas_daxpy( n , m_alpha4 , &(t5[0]) , 1 , &(t1[0]) , 1 );
}
};
template< class F1 = double , class F2 = F1 , class F3 = F2 , class F4 = F3 , class F5 = F4 >
struct scale_sum5
{
typedef double Fac1;
typedef double Fac2;
typedef double Fac3;
typedef double Fac4;
typedef double Fac5;
const Fac1 m_alpha1;
const Fac2 m_alpha2;
const Fac3 m_alpha3;
const Fac4 m_alpha4;
const Fac5 m_alpha5;
scale_sum5( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 , const Fac4 alpha4 , const 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;
// we get Containers that have size() and [i]-access
const int n = t1.size();
//boost::numeric::odeint::copy( t1 , t3 );
if( &(t2[0]) != &(t1[0]) )
{
cblas_dcopy( n , &(t2[0]) , 1 , &(t1[0]) , 1 );
}
cblas_dscal( n , m_alpha1 , &(t1[0]) , 1 );
cblas_daxpy( n , m_alpha2 , &(t3[0]) , 1 , &(t1[0]) , 1 );
//daxpby( &n , &m_alpha2 , &(t3[0]) , &one , &m_alpha1 , &(t1[0]) , &one );
cblas_daxpy( n , m_alpha3 , &(t4[0]) , 1 , &(t1[0]) , 1 );
cblas_daxpy( n , m_alpha4 , &(t5[0]) , 1 , &(t1[0]) , 1 );
cblas_daxpy( n , m_alpha5 , &(t6[0]) , 1 , &(t1[0]) , 1 );
}
};
};
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_MKL_MKL_OPERATIONS_HPP_INCLUDED

View File

@@ -0,0 +1,25 @@
/*
[auto_generated]
boost/numeric/odeint/external/mpi/mpi.hpp
[begin_description]
Wrappers for MPI.
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
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_EXTERNAL_MPI_MPI_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_HPP_INCLUDED
#include <boost/numeric/odeint/external/mpi/mpi_vector_state.hpp>
#include <boost/numeric/odeint/external/mpi/mpi_nested_algebra.hpp>
#endif

View File

@@ -0,0 +1,62 @@
/*
[auto_generated]
boost/numeric/odeint/external/mpi/mpi_nested_algebra.hpp
[begin_description]
Nested parallelized algebra for MPI.
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
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_EXTERNAL_MPI_MPI_NESTED_ALGEBRA_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_NESTED_ALGEBRA_HPP_INCLUDED
#include <boost/numeric/odeint/algebra/norm_result_type.hpp>
#include <boost/numeric/odeint/util/n_ary_helper.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/** \brief MPI-parallelized algebra, wrapping another algebra.
*/
template< class InnerAlgebra >
struct mpi_nested_algebra
{
// execute the InnerAlgebra on each node's local data.
#define BOOST_ODEINT_GEN_BODY(n) \
InnerAlgebra::for_each##n( \
BOOST_PP_ENUM_BINARY_PARAMS(n, s, () BOOST_PP_INTERCEPT) , \
op \
);
BOOST_ODEINT_GEN_FOR_EACH(BOOST_ODEINT_GEN_BODY)
#undef BOOST_ODEINT_GEN_BODY
template< class NestedState >
static typename norm_result_type< typename NestedState::value_type >::type norm_inf( const NestedState &s )
{
typedef typename norm_result_type< typename NestedState::value_type >::type result_type;
// local maximum
result_type value = InnerAlgebra::norm_inf( s() );
// global maximum
return boost::mpi::all_reduce(s.world, value, boost::mpi::maximum<result_type>());
}
};
}
}
}
#endif

View File

@@ -0,0 +1,113 @@
/*
[auto_generated]
boost/numeric/odeint/external/mpi/mpi_state.hpp
[begin_description]
A generic split state, storing partial data on each node.
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
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_EXTERNAL_MPI_MPI_STATE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_STATE_HPP_INCLUDED
#include <vector>
#include <algorithm>
#include <boost/mpi.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/util/split.hpp>
#include <boost/numeric/odeint/util/resize.hpp>
#include <boost/numeric/odeint/util/same_size.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
#include <boost/numeric/odeint/external/mpi/mpi_nested_algebra.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/** \brief A container which has its contents distributed among the nodes.
*/
template< class InnerState >
struct mpi_state
{
typedef InnerState value_type;
// the node's local data.
InnerState m_data;
boost::mpi::communicator world;
mpi_state() {}
mpi_state(boost::mpi::communicator comm) : world(comm) {}
inline InnerState &operator()() { return m_data; }
inline const InnerState &operator()() const { return m_data; }
};
template< class InnerState >
struct is_resizeable< mpi_state< InnerState > >
: is_resizeable< InnerState > { };
template< class InnerState1 , class InnerState2 >
struct same_size_impl< mpi_state< InnerState1 > , mpi_state< InnerState2 > >
{
static bool same_size( const mpi_state< InnerState1 > &x , const mpi_state< InnerState2 > &y )
{
const bool local = boost::numeric::odeint::same_size(x(), y());
return boost::mpi::all_reduce(x.world, local, mpi::bitwise_and<bool>());
}
};
template< class InnerState1 , class InnerState2 >
struct resize_impl< mpi_state< InnerState1 > , mpi_state< InnerState2 > >
{
static void resize( mpi_state< InnerState1 > &x , const mpi_state< InnerState2 > &y )
{
// resize local parts on each node.
boost::numeric::odeint::resize(x(), y());
}
};
/** \brief Copy data between mpi_states of same size. */
template< class InnerState1 , class InnerState2 >
struct copy_impl< mpi_state< InnerState1 > , mpi_state< InnerState2 > >
{
static void copy( const mpi_state< InnerState1 > &from , mpi_state< InnerState2 > &to )
{
// copy local parts on each node.
boost::numeric::odeint::copy(from(), to());
}
};
/** \brief Use `mpi_algebra` for `mpi_state`. */
template< class InnerState >
struct algebra_dispatcher< mpi_state< InnerState > >
{
typedef mpi_nested_algebra<
typename algebra_dispatcher< InnerState >::algebra_type
> algebra_type;
};
}
}
}
#endif

View File

@@ -0,0 +1,95 @@
/*
[auto_generated]
boost/numeric/odeint/external/mpi/mpi_vector_state.hpp
[begin_description]
Copying a container from/to an mpi_state splits/joins it.
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
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_EXTERNAL_MPI_MPI_VECTOR_STATE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_VECTOR_STATE_HPP_INCLUDED
#include <vector>
#include <algorithm>
#include <boost/mpi.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/util/split_adaptor.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
#include <boost/numeric/odeint/external/mpi/mpi_state.hpp>
#include <boost/numeric/odeint/tools/assert.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/** \brief Split data from some container on node 0 to the slaves.
* Source must be a model of Random Access Range. */
template< class Source , class InnerState >
struct split_impl< Source, mpi_state< InnerState >,
typename boost::enable_if< boost::has_range_const_iterator<Source> >::type >
{
typedef typename boost::range_iterator<const Source>::type iterator;
static void split( const Source &from, mpi_state< InnerState > &to )
{
std::vector< InnerState > pieces;
if(to.world.rank() == 0) {
const size_t num = static_cast<size_t>(to.world.size());
pieces.resize(num);
for(size_t i = 0 ; i < num ; i++) {
iterator_range<iterator> part = detail::make_split_range(from, i, num);
boost::numeric::odeint::resize(pieces[i], part);
boost::numeric::odeint::copy(part, pieces[i]);
}
}
// send to nodes
boost::mpi::scatter(to.world, pieces, to(), 0);
}
};
/** \brief Merge data from an mpi_state to some container on node 0.
* Target must be a model Single Pass Range. */
template< class Target, class InnerState >
struct unsplit_impl< mpi_state< InnerState >, Target,
typename boost::enable_if< boost::has_range_iterator<Target> >::type >
{
typedef typename boost::range_iterator<Target>::type iterator;
static void unsplit( const mpi_state< InnerState > &from , Target &to )
{
std::vector< InnerState > pieces;
// send data to root
boost::mpi::gather(from.world, from(), pieces, 0);
if(from.world.rank() == 0) {
// check target size
size_t total_size = 0;
for(size_t i = 0 ; i < pieces.size() ; i++)
total_size += boost::size(pieces[i]);
BOOST_NUMERIC_ODEINT_ASSERT( total_size <= boost::size(to) );
// copy parts
iterator out = boost::begin(to);
for(size_t i = 0 ; i < pieces.size() ; i++)
out = boost::copy(pieces[i], out);
}
}
};
}
}
}
#endif

View File

@@ -0,0 +1,161 @@
/*
[begin_description]
Modification of the implicit Euler method, works with the MTL4 matrix library only.
[end_description]
Copyright 2012-2013 Andreas Angelopoulos
Copyright 2012-2013 Karsten Ahnert
Copyright 2012-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_EXTERNAL_IMPLICIT_EULER_MTL4_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_IMPLICIT_EULER_MTL4_HPP_INCLUDED
#include <utility>
#include <boost/numeric/odeint/util/bind.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/external/mtl4/mtl4_resize.hpp>
#include <boost/numeric/mtl/mtl.hpp>
#include <boost/numeric/itl/itl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template< class ValueType , class Resizer = initially_resizer >
class implicit_euler_mtl4
{
public:
typedef ValueType value_type;
typedef value_type time_type;
typedef mtl::dense_vector<value_type> state_type;
typedef state_wrapper< state_type > wrapped_state_type;
typedef state_type deriv_type;
typedef state_wrapper< deriv_type > wrapped_deriv_type;
typedef mtl::compressed2D< value_type > matrix_type;
typedef state_wrapper< matrix_type > wrapped_matrix_type;
typedef Resizer resizer_type;
typedef stepper_tag stepper_category;
typedef implicit_euler_mtl4< ValueType , Resizer > stepper_type;
implicit_euler_mtl4( const value_type epsilon = 1E-6 )
: m_epsilon( epsilon ) , m_resizer() ,
m_dxdt() , m_x() ,
m_identity() , m_jacobi()
{ }
template< class System >
void do_step( System system , state_type &x , time_type t , time_type dt )
{
typedef typename odeint::unwrap_reference< System >::type system_type;
typedef typename odeint::unwrap_reference< typename system_type::first_type >::type deriv_func_type;
typedef typename odeint::unwrap_reference< typename system_type::second_type >::type jacobi_func_type;
system_type &sys = system;
deriv_func_type &deriv_func = sys.first;
jacobi_func_type &jacobi_func = sys.second;
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
m_identity.m_v = 1;
t += dt;
m_x.m_v = x;
deriv_func( x , m_dxdt.m_v , t );
jacobi_func( x , m_jacobi.m_v , t );
m_dxdt.m_v *= -dt;
m_jacobi.m_v *= dt;
m_jacobi.m_v -= m_identity.m_v ;
// using ilu_0 preconditioning -incomplete LU factorisation
// itl::pc::diagonal<matrix_type,double> L(m_jacobi.m_v);
itl::pc::ilu_0<matrix_type> L( m_jacobi.m_v );
solve( m_jacobi.m_v , m_x.m_v , m_dxdt.m_v , L );
x+= m_x.m_v;
}
template< class StateType >
void adjust_size( const StateType &x )
{
resize_impl( x );
}
private:
/*
Applying approximate iterative linear solvers
default solver is Biconjugate gradient stabilized method
itl::bicgstab(A, x, b, L, iter);
*/
template < class LinearOperator, class HilbertSpaceX, class HilbertSpaceB, class Preconditioner>
void solve(const LinearOperator& A, HilbertSpaceX& x, const HilbertSpaceB& b,
const Preconditioner& L, int max_iteractions =500)
{
// Termination criterion: r < 1e-6 * b or N iterations
itl::basic_iteration< double > iter( b , max_iteractions , 1e-6 );
itl::bicgstab( A , x , b , L , iter );
}
template< class StateIn >
bool resize_impl( const StateIn &x )
{
bool resized = false;
resized |= adjust_size_by_resizeability( m_dxdt , x , typename is_resizeable<deriv_type>::type() );
resized |= adjust_size_by_resizeability( m_x , x , typename is_resizeable<state_type>::type() );
resized |= adjust_size_by_resizeability( m_identity , x , typename is_resizeable<matrix_type>::type() );
resized |= adjust_size_by_resizeability( m_jacobi , x , typename is_resizeable<matrix_type>::type() );
return resized;
}
private:
value_type m_epsilon;
resizer_type m_resizer;
wrapped_deriv_type m_dxdt;
wrapped_state_type m_x;
wrapped_matrix_type m_identity;
wrapped_matrix_type m_jacobi;
};
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_IMPLICIT_EULER_MTL4_HPP_INCLUDED

View File

@@ -0,0 +1,23 @@
/*
[auto_generated]
/boost/numeric/odeint/external/mtl4/mtl4.hpp
[begin_description]
includes all headers required for using mtl4 with odeint
[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_EXTERNAL_MTL4_MTL4_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_MTL4_HPP_INCLUDED
#include <boost/numeric/odeint/external/mtl4/mtl4_algebra_dispatcher.hpp>
#include <boost/numeric/odeint/external/mtl4/mtl4_resize.hpp>
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_MTL4_INCLUDED

View File

@@ -0,0 +1,99 @@
/*
[auto_generated]
boost/numeric/odeint/external/mtl4/mtl4_algebra_dispatcher.hpp
[begin_description]
specialization of the algebra dispatcher for mtl4
[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_MTL4_MTL4_ALGEBRA_DISPATCHER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_MTL4_MTL4_ALGEBRA_DISPATCHER_HPP_INCLUDED
#include <boost/numeric/mtl/mtl.hpp>
#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template<typename Value, typename Parameters>
struct algebra_dispatcher< mtl::dense_vector< Value , Parameters > >
{
typedef vector_space_algebra algebra_type;
};
template<typename Value, typename Parameters>
struct algebra_dispatcher< mtl::dense2D< Value , Parameters > >
{
typedef vector_space_algebra algebra_type;
};
template<typename Value , size_t BitMask , typename Parameters>
struct algebra_dispatcher< mtl::morton_dense< Value , BitMask, Parameters > >
{
typedef vector_space_algebra algebra_type;
};
template<typename Value, typename Parameters>
struct algebra_dispatcher< mtl::compressed2D< Value , Parameters > >
{
typedef vector_space_algebra algebra_type;
};
// specialization of infinity norm calculation
template<typename Value, typename Parameters>
struct vector_space_norm_inf< mtl::dense_vector< Value , Parameters > >
{
typedef Value result_type;
Value operator()( const mtl::dense_vector< Value , Parameters > &x ) const
{
return mtl::infinity_norm(x);
}
};
template<typename Value, typename Parameters>
struct vector_space_norm_inf< mtl::dense2D< Value , Parameters > >
{
typedef Value result_type;
Value operator()( const mtl::dense2D< Value , Parameters > &x ) const
{
return mtl::infinity_norm(x);
}
};
template<typename Value , size_t BitMask , typename Parameters>
struct vector_space_norm_inf< mtl::morton_dense< Value , BitMask , Parameters > >
{
typedef Value result_type;
Value operator()( const mtl::morton_dense< Value , BitMask , Parameters > &x ) const
{
return mtl::infinity_norm(x);
}
};
template<typename Value, typename Parameters>
struct vector_space_norm_inf< mtl::compressed2D< Value , Parameters > >
{
typedef Value result_type;
Value operator()( const mtl::compressed2D< Value , Parameters > &x ) const
{
return mtl::infinity_norm(x);
}
};
}
}
}
#endif // BOOST_NUMERIC_ODEINT_MTL4_MTL4_ALGEBRA_DISPATCHER_INCLUDED

View File

@@ -0,0 +1,134 @@
/*
[begin_description]
Modification of the implicit Euler method, works with the MTL4 matrix library only.
[end_description]
Copyright 2012-2013 Andreas Angelopoulos
Copyright 2012-2013 Karsten Ahnert
Copyright 2012-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_EXTERNAL_MTL4_RESIZE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_RESIZE_HPP_INCLUDED
#include <boost/numeric/odeint/util/is_resizeable.hpp>
#include <boost/numeric/odeint/util/resize.hpp>
#include <boost/numeric/odeint/util/same_size.hpp>
#include <boost/numeric/mtl/vector/dense_vector.hpp>
#include <boost/numeric/mtl/matrix/dense2D.hpp>
#include <boost/numeric/mtl/matrix/compressed2D.hpp>
#include <type_traits>
namespace boost {
namespace numeric {
namespace odeint {
template< class Value , class Parameters >
struct is_resizeable< mtl::dense_vector< Value , Parameters > >
{
typedef std::true_type type;
const static bool value = type::value;
};
template< class Value , class Parameters >
struct is_resizeable< mtl::dense2D< Value , Parameters > >
{
typedef std::true_type type;
const static bool value = type::value;
};
template< class Value , class Parameters >
struct is_resizeable< mtl::compressed2D< Value , Parameters > >
{
typedef std::true_type type;
const static bool value = type::value;
};
template< class Value , class Parameters >
struct same_size_impl< mtl::dense_vector< Value , Parameters > , mtl::dense_vector< Value , Parameters > >
{
static bool same_size( const mtl::dense_vector< Value , Parameters > &v1 ,
const mtl::dense_vector< Value , Parameters > &v2 )
{
return mtl::size( v1 ) == mtl::size( v2 );
}
};
template< class Value , class Parameters >
struct resize_impl< mtl::dense_vector< Value , Parameters > , mtl::dense_vector< Value , Parameters > >
{
static void resize( mtl::dense_vector< Value , Parameters > &v1 ,
const mtl::dense_vector< Value , Parameters > &v2 )
{
v1.change_dim( mtl::size( v2 ) );
}
};
template< class Value , class MatrixParameters , class VectorParameters >
struct same_size_impl< mtl::dense2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
{
static bool same_size( const mtl::dense2D< Value , MatrixParameters > &m ,
const mtl::dense_vector< Value , VectorParameters > &v )
{
return ( ( mtl::size( v ) == m.num_cols() ) && ( mtl::size( v ) == m.num_rows() ) );
}
};
template< class Value , class MatrixParameters , class VectorParameters >
struct resize_impl< mtl::dense2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
{
static void resize( mtl::dense2D< Value , MatrixParameters > &m ,
const mtl::dense_vector< Value , VectorParameters > &v )
{
m.change_dim( mtl::size( v ) , mtl::size( v ) , false );
}
};
template< class Value , class MatrixParameters , class VectorParameters >
struct same_size_impl< mtl::compressed2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
{
static bool same_size( const mtl::compressed2D< Value , MatrixParameters > &m ,
const mtl::dense_vector< Value , VectorParameters > &v )
{
return ( ( mtl::size( v ) == m.num_cols() ) && ( mtl::size( v ) == m.num_rows() ) );
}
};
template< class Value , class MatrixParameters , class VectorParameters >
struct resize_impl< mtl::compressed2D< Value , MatrixParameters > , mtl::dense_vector< Value , VectorParameters > >
{
static void resize( mtl::compressed2D< Value , MatrixParameters > &m ,
const mtl::dense_vector< Value , VectorParameters > &v )
{
m.change_dim( mtl::size( v ) , mtl::size( v ) );
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_MTL4_RESIZE_HPP_INCLUDED

View File

@@ -0,0 +1,25 @@
//==============================================================================
// Copyright 2014 LRI UMR 8623 CNRS/Univ Paris Sud XI
// Copyright 2014 NumScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_NT2_NT2_ALGEBRA_DISPATCHER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_NT2_NT2_ALGEBRA_DISPATCHER_HPP_INCLUDED
#include <nt2/core/container/table/table.hpp>
#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
namespace boost { namespace numeric { namespace odeint {
template<typename T, typename S>
struct algebra_dispatcher<nt2::container::table<T,S> >
{
typedef vector_space_algebra algebra_type;
};
} } }
#endif

View File

@@ -0,0 +1,33 @@
//==============================================================================
// Copyright 2014 LASMEA UMR 6602 CNRS/Univ. Clermont II
// Copyright 2014 LRI UMR 8623 CNRS/Univ Paris Sud XI
// Copyright 2014 MetaScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_NT2_NT2_COPY_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_NT2_NT2_COPY_HPP_INCLUDED
#include <nt2/core/container/table/table.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
namespace boost { namespace numeric { namespace odeint {
template<typename T, typename S>
struct copy_impl< nt2::container::table<T,S>
, nt2::container::table<T,S>
>
{
static void copy ( const nt2::container::table<T,S> &v1
, nt2::container::table<T,S> &v2
)
{
v2 = v1;
}
};
} } }
#endif

View File

@@ -0,0 +1,31 @@
//==============================================================================
// Copyright 2014 LRI UMR 8623 CNRS/Univ Paris Sud XI
// Copyright 2014 NumScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_NT2_NT2_NORM_INF_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_NT2_NT2_NORM_INF_HPP_INCLUDED
#include <nt2/core/container/table/table.hpp>
#include <nt2/include/functions/globalmax.hpp>
#include <nt2/include/functions/abs.hpp>
#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
namespace boost { namespace numeric { namespace odeint
{
template<typename T, typename S>
struct vector_space_norm_inf<nt2::container::table<T,S> >
{
typedef T result_type;
result_type operator()(const nt2::container::table<T,S> &v1) const
{
return nt2::globalmax(nt2::abs(v1));
}
};
} } }
#endif

View File

@@ -0,0 +1,54 @@
//==============================================================================
// Copyright 2014 LRI UMR 8623 CNRS/Univ Paris Sud XI
// Copyright 2014 NumScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_NT2_NT2_RESIZE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_NT2_NT2_RESIZE_HPP_INCLUDED
#include <nt2/core/container/table/table.hpp>
#include <boost/numeric/odeint/util/same_size.hpp>
#include <type_traits>
namespace boost { namespace numeric { namespace odeint {
template<typename T, typename S>
struct is_resizeable< nt2::container::table<T,S> >
{
typedef std::true_type type;
static const bool value = type::value;
};
template<typename T, typename S>
struct same_size_impl< nt2::container::table<T,S>
, nt2::container::table<T,S>
>
{
static bool same_size ( const nt2::container::table<T,S> &v1
, const nt2::container::table<T,S> &v2
)
{
return v1.extent() == v2.extent();
}
};
template<typename T, typename S>
struct resize_impl< nt2::container::table<T,S>
, nt2::container::table<T,S>
>
{
static void resize ( nt2::container::table<T,S> &v1
, const nt2::container::table<T,S> &v2
)
{
v1.resize( v2.extent() );
}
};
} } }
#endif

View File

@@ -0,0 +1,31 @@
/*
[auto_generated]
boost/numeric/odeint/external/openmp/openmp.hpp
[begin_description]
Wrappers for OpenMP.
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
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_EXTERNAL_OPENMP_OPENMP_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_OPENMP_OPENMP_HPP_INCLUDED
// level 1: parallel iteration over random access container
#include <boost/numeric/odeint/external/openmp/openmp_range_algebra.hpp>
// level 2: split range state
#include <boost/numeric/odeint/external/openmp/openmp_state.hpp>
// level 3: process a random access container of sub-states in parallel
#include <boost/numeric/odeint/external/openmp/openmp_nested_algebra.hpp>
#endif

View File

@@ -0,0 +1,281 @@
/*
[auto_generated]
boost/numeric/odeint/external/openmp/openmp_nested_algebra.hpp
[begin_description]
Nested parallelized algebra for OpenMP.
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
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_EXTERNAL_OPENMP_OPENMP_NESTED_ALGEBRA_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_OPENMP_OPENMP_NESTED_ALGEBRA_HPP_INCLUDED
#include <boost/range.hpp>
#include <boost/numeric/odeint/algebra/norm_result_type.hpp>
#include <boost/numeric/odeint/util/n_ary_helper.hpp>
#include <boost/numeric/odeint/tools/assert.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/** \brief OpenMP-parallelized algebra, wrapping another, non-parallelized algebra.
*
* NestedState must be a model of Random Access Range, where the elements are sub-states
* which will be processed in parallel.
*/
template< class InnerAlgebra >
struct openmp_nested_algebra
{
#if __cplusplus >= 201103L // C++11 supports _Pragma
#define BOOST_ODEINT_GEN_LOCAL(z, n, unused) \
BOOST_NUMERIC_ODEINT_ASSERT_MSG( len == boost::size(s ## n), "All nested state ranges must have the same size." ); \
typename boost::range_iterator<S ## n>::type beg ## n = boost::begin(s ## n);
#define BOOST_ODEINT_GEN_BODY(n) \
const size_t len = boost::size(s0); \
BOOST_PP_REPEAT(n, BOOST_ODEINT_GEN_LOCAL, ~) \
_Pragma("omp parallel for schedule(runtime)") \
for( size_t i = 0 ; i < len ; i++ ) \
InnerAlgebra::for_each##n( \
BOOST_PP_ENUM_BINARY_PARAMS(n, beg, [i] BOOST_PP_INTERCEPT) , \
op \
);
BOOST_ODEINT_GEN_FOR_EACH(BOOST_ODEINT_GEN_BODY)
#undef BOOST_ODEINT_GEN_BODY
#undef BOOST_ODEINT_GEN_LOCAL
#else
template< class S0 , class Op > static void for_each1 ( S0 &s0 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each1( beg0 [i] , op );
}
template< class S0 , class S1 , class Op > static void for_each2 ( S0 &s0 , S1 &s1 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each2( beg0 [i] , beg1 [i] , op );
}
template< class S0 , class S1 , class S2 , class Op > static void for_each3 ( S0 &s0 , S1 &s1 , S2 &s2 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each3( beg0 [i] , beg1 [i] , beg2 [i] , op );
}
template< class S0 , class S1 , class S2 , class S3 , class Op > static void for_each4 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each4( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , op );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class Op > static void for_each5 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each5( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , op );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class Op > static void for_each6 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each6( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , op );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class Op > static void for_each7 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each7( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , op );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class Op > static void for_each8 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each8( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , op );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class Op > static void for_each9 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each9( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , op );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class Op > static void for_each10 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each10( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , op );
}
template< class S0 , 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_each11 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each11( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] , op );
}
template< class S0 , 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_each12 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
typename boost::range_iterator<S11>::type beg11 = boost::begin(s11);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each12( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] , beg11 [i] , op );
}
template< class S0 , 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_each13 ( S0 &s0 , 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 ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
typename boost::range_iterator<S11>::type beg11 = boost::begin(s11);
typename boost::range_iterator<S12>::type beg12 = boost::begin(s12);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each13( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] , beg11 [i] , beg12 [i] , op );
}
template< class S0 , 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_each14 ( S0 &s0 , 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 ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
typename boost::range_iterator<S11>::type beg11 = boost::begin(s11);
typename boost::range_iterator<S12>::type beg12 = boost::begin(s12);
typename boost::range_iterator<S13>::type beg13 = boost::begin(s13);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each14( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] , beg11 [i] , beg12 [i] , beg13 [i] , op );
}
template< class S0 , 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_each15 ( S0 &s0 , 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 ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
typename boost::range_iterator<S11>::type beg11 = boost::begin(s11);
typename boost::range_iterator<S12>::type beg12 = boost::begin(s12);
typename boost::range_iterator<S13>::type beg13 = boost::begin(s13);
typename boost::range_iterator<S14>::type beg14 = boost::begin(s14);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) InnerAlgebra::for_each15( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] , beg11 [i] , beg12 [i] , beg13 [i] , beg14 [i] , op );
}
#endif
template< class NestedState >
static typename norm_result_type< typename NestedState::value_type >::type norm_inf( const NestedState &s )
{
typedef typename boost::range_iterator<const NestedState>::type iterator;
typedef typename std::iterator_traits<iterator>::value_type value_type;
typedef typename norm_result_type<value_type>::type result_type;
result_type init = static_cast< result_type >( 0 );
const size_t len = boost::size(s);
iterator beg = boost::begin(s);
# pragma omp parallel for reduction(max: init) schedule(dynamic)
for( size_t i = 0 ; i < len ; i++ )
init = (std::max)( init , InnerAlgebra::norm_inf( beg[i] ) );
return init;
}
};
}
}
}
#endif

View File

@@ -0,0 +1,276 @@
/*
[auto_generated]
boost/numeric/odeint/external/openmp/openmp_range_algebra.hpp
[begin_description]
Range algebra for OpenMP.
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
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_EXTERNAL_OPENMP_OPENMP_RANGE_ALGEBRA_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_OPENMP_OPENMP_RANGE_ALGEBRA_HPP_INCLUDED
#include <boost/range.hpp>
#include <boost/numeric/odeint/algebra/norm_result_type.hpp>
#include <boost/numeric/odeint/util/n_ary_helper.hpp>
#include <boost/numeric/odeint/tools/assert.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/** \brief OpenMP-parallelized range algebra.
*
* State must be a model of Random Access Range.
*/
struct openmp_range_algebra
{
#if __cplusplus >= 201103L // C++11 supports _Pragma
#define BOOST_ODEINT_GEN_LOCAL(z, n, unused) \
BOOST_NUMERIC_ODEINT_ASSERT_MSG( len == boost::size(s ## n), "All state ranges must have the same size." ); \
typename boost::range_iterator<S ## n>::type beg ## n = boost::begin(s ## n);
#define BOOST_ODEINT_GEN_BODY(n) \
const size_t len = boost::size(s0); \
BOOST_PP_REPEAT(n, BOOST_ODEINT_GEN_LOCAL, ~) \
_Pragma("omp parallel for schedule(runtime)") \
for( size_t i = 0 ; i < len ; i++ ) \
op( BOOST_PP_ENUM_BINARY_PARAMS(n, beg, [i] BOOST_PP_INTERCEPT) );
BOOST_ODEINT_GEN_FOR_EACH(BOOST_ODEINT_GEN_BODY)
#undef BOOST_ODEINT_GEN_BODY
#undef BOOST_ODEINT_GEN_LOCAL
#else
template< class S0 , class Op > static void for_each1 ( S0 &s0 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] );
}
template< class S0 , class S1 , class Op > static void for_each2 ( S0 &s0 , S1 &s1 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] );
}
template< class S0 , class S1 , class S2 , class Op > static void for_each3 ( S0 &s0 , S1 &s1 , S2 &s2 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] );
}
template< class S0 , class S1 , class S2 , class S3 , class Op > static void for_each4 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class Op > static void for_each5 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class Op > static void for_each6 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class Op > static void for_each7 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class Op > static void for_each8 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class Op > static void for_each9 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] );
}
template< class S0 , class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class S9 , class Op > static void for_each10 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] );
}
template< class S0 , 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_each11 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] );
}
template< class S0 , 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_each12 ( S0 &s0 , S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , Op op ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
typename boost::range_iterator<S11>::type beg11 = boost::begin(s11);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] , beg11 [i] );
}
template< class S0 , 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_each13 ( S0 &s0 , 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 ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
typename boost::range_iterator<S11>::type beg11 = boost::begin(s11);
typename boost::range_iterator<S12>::type beg12 = boost::begin(s12);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] , beg11 [i] , beg12 [i] );
}
template< class S0 , 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_each14 ( S0 &s0 , 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 ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
typename boost::range_iterator<S11>::type beg11 = boost::begin(s11);
typename boost::range_iterator<S12>::type beg12 = boost::begin(s12);
typename boost::range_iterator<S13>::type beg13 = boost::begin(s13);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] , beg11 [i] , beg12 [i] , beg13 [i] );
}
template< class S0 , 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_each15 ( S0 &s0 , 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 ) {
const size_t len = boost::size(s0);
typename boost::range_iterator<S0>::type beg0 = boost::begin(s0);
typename boost::range_iterator<S1>::type beg1 = boost::begin(s1);
typename boost::range_iterator<S2>::type beg2 = boost::begin(s2);
typename boost::range_iterator<S3>::type beg3 = boost::begin(s3);
typename boost::range_iterator<S4>::type beg4 = boost::begin(s4);
typename boost::range_iterator<S5>::type beg5 = boost::begin(s5);
typename boost::range_iterator<S6>::type beg6 = boost::begin(s6);
typename boost::range_iterator<S7>::type beg7 = boost::begin(s7);
typename boost::range_iterator<S8>::type beg8 = boost::begin(s8);
typename boost::range_iterator<S9>::type beg9 = boost::begin(s9);
typename boost::range_iterator<S10>::type beg10 = boost::begin(s10);
typename boost::range_iterator<S11>::type beg11 = boost::begin(s11);
typename boost::range_iterator<S12>::type beg12 = boost::begin(s12);
typename boost::range_iterator<S13>::type beg13 = boost::begin(s13);
typename boost::range_iterator<S14>::type beg14 = boost::begin(s14);
#pragma omp parallel for schedule(runtime)
for( size_t i = 0 ; i < len ; i++ ) op( beg0 [i] , beg1 [i] , beg2 [i] , beg3 [i] , beg4 [i] , beg5 [i] , beg6 [i] , beg7 [i] , beg8 [i] , beg9 [i] , beg10 [i] , beg11 [i] , beg12 [i] , beg13 [i] , beg14 [i] );
}
#endif
template< class S >
static typename norm_result_type< S >::type norm_inf( const S &s )
{
using std::max;
using std::abs;
typedef typename norm_result_type< S >::type result_type;
result_type init = static_cast< result_type >( 0 );
const size_t len = boost::size(s);
typename boost::range_iterator<const S>::type beg = boost::begin(s);
# pragma omp parallel for reduction(max: init) schedule(dynamic)
for( size_t i = 0 ; i < len ; ++i )
init = max( init , abs( beg[i] ) );
return init;
}
};
}
}
}
#endif

View File

@@ -0,0 +1,172 @@
/*
[auto_generated]
boost/numeric/odeint/external/openmp/openmp_state.hpp
[begin_description]
Wrappers for OpenMP.
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
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_EXTERNAL_OPENMP_OPENMP_STATE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_OPENMP_OPENMP_STATE_HPP_INCLUDED
#include <omp.h>
#include <vector>
#include <algorithm>
#include <type_traits>
#include <boost/range/adaptor/sliced.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/util/split.hpp>
#include <boost/numeric/odeint/util/resize.hpp>
#include <boost/numeric/odeint/external/openmp/openmp_nested_algebra.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/** \brief A container that is split into distinct parts, for threading.
* Just a wrapper for vector<vector<T>>, use `copy` for splitting/joining.
*/
template< class T >
struct openmp_state : public std::vector< std::vector< T > >
{
openmp_state() {}
openmp_state(size_t n, const std::vector<T>& val = std::vector<T>())
: std::vector< std::vector< T > >(n, val) {}
template<class InputIterator>
openmp_state(InputIterator first, InputIterator last)
: std::vector< std::vector< T > >(first, last) {}
openmp_state(const std::vector< std::vector< T > > &orig)
: std::vector< std::vector< T > >(orig) {}
};
template< class T >
struct is_resizeable< openmp_state< T > > : std::true_type { };
template< class T >
struct same_size_impl< openmp_state< T > , openmp_state< T > >
{
static bool same_size( const openmp_state< T > &x , const openmp_state< T > &y )
{
if( x.size() != y.size() ) return false;
for( size_t i = 0 ; i != x.size() ; i++ )
if( x[i].size() != y[i].size() ) return false;
return true;
}
};
template< class T >
struct resize_impl< openmp_state< T > , openmp_state< T > >
{
static void resize( openmp_state< T > &x , const openmp_state< T > &y )
{
x.resize( y.size() );
# pragma omp parallel for schedule(dynamic)
for(size_t i = 0 ; i < x.size() ; i++)
x[i].resize( y[i].size() );
}
};
/** \brief Copy data between openmp_states of same size. */
template< class T >
struct copy_impl< openmp_state< T >, openmp_state< T > >
{
static void copy( const openmp_state< T > &from, openmp_state< T > &to )
{
# pragma omp parallel for schedule(dynamic)
for(size_t i = 0 ; i < from.size() ; i++)
std::copy( from[i].begin() , from[i].end() , to.begin() );
}
};
/** \brief Copy data from some container to an openmp_state and resize it.
* Target container size will determine number of blocks to split into.
* If it is empty, it will be resized to the maximum number of OpenMP threads.
* SourceContainer must support `s::value_type`, `s::const_iterator`, `s.begin()`, `s.end()` and `s.size()`,
* with Random Access Iterators; i.e. it must be a Random Access Container. */
template< class SourceContainer >
struct split_impl< SourceContainer, openmp_state< typename SourceContainer::value_type > >
{
static void split( const SourceContainer &from, openmp_state< typename SourceContainer::value_type > &to )
{
if(to.size() == 0) to.resize( omp_get_max_threads() );
const size_t part = from.size() / to.size();
# pragma omp parallel for schedule(dynamic)
for(size_t i = 0 ; i < to.size() ; i++) {
typedef typename SourceContainer::const_iterator it_t;
const it_t begin = from.begin() + i * part;
it_t end = begin + part;
// for cases where from.size() % to.size() > 0
if(i + 1 == to.size() || end > from.end()) end = from.end();
to[i].resize(end - begin);
std::copy(begin, end, to[i].begin());
}
}
};
/** \brief Copy data from an openmp_state to some container and resize it.
* TargetContainer must support `s::value_type`, `s::iterator`, `s.begin()` and `s.resize(n)`,
* i.e. it must be a `std::vector`. */
template< class TargetContainer >
struct unsplit_impl< openmp_state< typename TargetContainer::value_type >, TargetContainer >
{
static void unsplit( const openmp_state< typename TargetContainer::value_type > &from , TargetContainer &to )
{
// resize target
size_t total_size = 0;
for(size_t i = 0 ; i < from.size() ; i++)
total_size += from[i].size();
to.resize( total_size );
// copy parts
typename TargetContainer::iterator out = to.begin();
for(size_t i = 0 ; i < from.size() ; i++)
out = std::copy(from[i].begin(), from[i].end(), out);
}
};
/** \brief OpenMP-parallelized algebra.
* For use with openmp_state.
*/
typedef openmp_nested_algebra< range_algebra > openmp_algebra;
/** \brief Use `openmp_algebra` for `openmp_state`. */
template< class T >
struct algebra_dispatcher< openmp_state< T > >
{
typedef openmp_algebra algebra_type;
};
}
}
}
#endif

View File

@@ -0,0 +1,27 @@
/*
[auto_generated]
boost/numeric/odeint/external/thrust/thrust.hpp
[begin_description]
includes all headers required for using odeint with thrust
[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_EXTERNAL_THRUST_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_HPP_DEFINED
#include <boost/numeric/odeint/external/thrust/thrust_algebra.hpp>
#include <boost/numeric/odeint/external/thrust/thrust_operations.hpp>
#include <boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp>
#include <boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp>
#include <boost/numeric/odeint/external/thrust/thrust_resize.hpp>
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_HPP_DEFINED

View File

@@ -0,0 +1,217 @@
/*
[auto_generated]
boost/numeric/odeint/external/thrust/thrust_algebra.hpp
[begin_description]
An algebra for thrusts device_vectors.
[end_description]
Copyright 2010-2013 Mario Mulansky
Copyright 2010-2011 Karsten Ahnert
Copyright 2013 Kyle Lutz
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_EXTERNAL_THRUST_THRUST_ALGEBRA_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_HPP_INCLUDED
#include <thrust/device_vector.h>
#include <thrust/for_each.h>
#include <thrust/iterator/zip_iterator.h>
#include <boost/range.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// to use in thrust::reduce
template< class Value >
struct maximum
{
template< class Fac1 , class Fac2 >
__host__ __device__
Value operator()( const Fac1 t1 , const Fac2 t2 ) const
{
return ( abs( t1 ) < abs( t2 ) ) ? t2 : t1 ;
}
typedef Value result_type;
};
}
/** ToDO extend until for_each14 for rk78 */
/*
* The const versions are needed for boost.range to work, i.e.
* it allows you to do
* for_each1( make_pair( vec1.begin() , vec1.begin() + 10 ) , op );
*/
struct thrust_algebra
{
template< class StateType , class Operation >
static void for_each1( StateType &s , Operation op )
{
thrust::for_each( boost::begin(s) , boost::end(s) , op );
}
template< class StateType1 , class StateType2 , class Operation >
static void for_each2( StateType1 &s1 , StateType2 &s2 , Operation op )
{
thrust::for_each(
thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) ,
boost::begin(s2) ) ) ,
thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) ,
boost::end(s2) ) ) ,
op);
}
template< class StateType1 , class StateType2 , class StateType3 , class Operation >
static void for_each3( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , Operation op )
{
thrust::for_each(
thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) ,
boost::begin(s2) ,
boost::begin(s3) ) ) ,
thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) ,
boost::end(s2) ,
boost::end(s3) ) ) ,
op);
}
template< class StateType1 , class StateType2 , class StateType3 , class StateType4 ,
class Operation >
static void for_each4( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 ,
Operation op )
{
thrust::for_each(
thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) ,
boost::begin(s2) ,
boost::begin(s3) ,
boost::begin(s4) ) ) ,
thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) ,
boost::end(s2) ,
boost::end(s3) ,
boost::end(s4) ) ) ,
op);
}
template< class StateType1 , class StateType2 , class StateType3 ,
class StateType4 , class StateType5 ,class Operation >
static void for_each5( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 ,
StateType5 &s5 , Operation op )
{
thrust::for_each(
thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) ,
boost::begin(s2) ,
boost::begin(s3) ,
boost::begin(s4) ,
boost::begin(s5) ) ) ,
thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) ,
boost::end(s2) ,
boost::end(s3) ,
boost::end(s4) ,
boost::end(s5) ) ) ,
op);
}
template< class StateType1 , class StateType2 , class StateType3 ,
class StateType4 , class StateType5 , class StateType6 , class Operation >
static void for_each6( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 ,
StateType5 &s5 , StateType6 &s6 , Operation op )
{
thrust::for_each(
thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) ,
boost::begin(s2) ,
boost::begin(s3) ,
boost::begin(s4) ,
boost::begin(s5) ,
boost::begin(s6) ) ) ,
thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) ,
boost::end(s2) ,
boost::end(s3) ,
boost::end(s4) ,
boost::end(s5) ,
boost::end(s6) ) ) ,
op);
}
template< class StateType1 , class StateType2 , class StateType3 , class StateType4 ,
class StateType5 , class StateType6 , class StateType7 , class Operation >
static void for_each7( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 ,
StateType5 &s5 , StateType6 &s6 , StateType7 &s7 , Operation op )
{
thrust::for_each(
thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) ,
boost::begin(s2) ,
boost::begin(s3) ,
boost::begin(s4) ,
boost::begin(s5) ,
boost::begin(s6) ,
boost::begin(s7) ) ) ,
thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) ,
boost::end(s2) ,
boost::end(s3) ,
boost::end(s4) ,
boost::end(s5) ,
boost::end(s6) ,
boost::end(s7) ) ) ,
op);
}
template< class StateType1 , class StateType2 , class StateType3 , class StateType4 ,
class StateType5 , class StateType6 , class StateType7 , class StateType8 , class Operation >
static void for_each8( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 ,
StateType5 &s5 , StateType6 &s6 , StateType7 &s7 , StateType8 &s8 , Operation op )
{
thrust::for_each(
thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) ,
boost::begin(s2) ,
boost::begin(s3) ,
boost::begin(s4) ,
boost::begin(s5) ,
boost::begin(s6) ,
boost::begin(s7) ,
boost::begin(s8) ) ) ,
thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) ,
boost::end(s2) ,
boost::end(s3) ,
boost::end(s4) ,
boost::end(s5) ,
boost::end(s6) ,
boost::end(s7) ,
boost::end(s8) ) ) ,
op);
}
template< class S >
static typename S::value_type norm_inf( const S &s )
{
typedef typename S::value_type value_type;
return thrust::reduce( boost::begin( s ) , boost::end( s ) ,
static_cast<value_type>(0) ,
detail::maximum<value_type>() );
}
};
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_HPP_INCLUDED

View File

@@ -0,0 +1,118 @@
/*
[auto_generated]
boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp
[begin_description]
algebra_dispatcher specialization for thrust
[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_EXTERNAL_THRUST_THRUST_ALGEBRA_DISPATCHER_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_DISPATCHER_HPP_DEFINED
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <boost/numeric/odeint/external/thrust/thrust_algebra.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
// specializations for the standard thrust containers
namespace boost {
namespace numeric {
namespace odeint {
// specialization for thrust host_vector
template< class T , class A >
struct algebra_dispatcher< thrust::host_vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
// specialization for thrust device_vector
template< class T , class A >
struct algebra_dispatcher< thrust::device_vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
// add support for thrust backend vectors, if available
#include <thrust/version.h>
#if THRUST_VERSION >= 101000
#include <thrust/detail/vector_base.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct algebra_dispatcher< thrust::detail::vector_base< T , A > >
{
typedef thrust_algebra algebra_type;
};
} } }
#elif THRUST_VERSION >= 100600
// specialization for thrust cpp vector
#include <thrust/system/cpp/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct algebra_dispatcher< thrust::cpp::vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} } }
// specialization for thrust omp vector
#ifdef _OPENMP
#include <thrust/system/omp/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct algebra_dispatcher< thrust::omp::vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} } }
#endif // _OPENMP
// specialization for thrust tbb vector
#ifdef TBB_VERSION_MAJOR
#include <thrust/system/tbb/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct algebra_dispatcher< thrust::tbb::vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} } }
#endif // TBB_VERSION_MAJOR
// specialization for thrust cuda vector
#ifdef __CUDACC__
#include <thrust/system/cuda/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct algebra_dispatcher< thrust::cuda::vector< T , A > >
{
typedef thrust_algebra algebra_type;
};
} } }
#endif // __CUDACC__
#endif // THRUST_VERSION >= 100600
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_DISPATCHER_HPP_DEFINED

View File

@@ -0,0 +1,233 @@
/*
[auto_generated]
boost/numeric/odeint/external/thrust/thrust_operations.hpp
[begin_description]
Operations of thrust zipped iterators. Is the counterpart of the thrust_algebra.
[end_description]
Copyright 2010-2013 Mario Mulansky
Copyright 2010-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_EXTERNAL_THRUST_THRUST_OPERATIONS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_OPERATIONS_HPP_INCLUDED
namespace boost {
namespace numeric {
namespace odeint {
#include <thrust/tuple.h>
#include <thrust/iterator/zip_iterator.h>
/**ToDo extend to scale_sum13 for rk78 */
struct thrust_operations
{
template< class Fac1 = double , class Fac2 = Fac1 >
struct scale_sum2
{
const Fac1 m_alpha1;
const Fac2 m_alpha2;
scale_sum2( const Fac1 alpha1 , const Fac2 alpha2 )
: m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
template< class Tuple >
__host__ __device__
void operator()( Tuple t ) const
{
thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) + m_alpha2 * thrust::get<2>(t);
}
};
template< class Fac1 = double , class Fac2 = Fac1 >
struct scale_sum_swap2
{
const Fac1 m_alpha1;
const Fac2 m_alpha2;
scale_sum_swap2( const Fac1 alpha1 , const Fac2 alpha2 )
: m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
template< class Tuple >
__host__ __device__
void operator()( Tuple t ) const
{
typename thrust::tuple_element<0,Tuple>::type tmp = thrust::get<0>(t);
thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) + m_alpha2 * thrust::get<2>(t);
thrust::get<1>(t) = tmp;
}
};
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( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 )
: m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) { }
template< class Tuple >
__host__ __device__
void operator()( Tuple t ) const
{
thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
m_alpha2 * thrust::get<2>(t) +
m_alpha3 * thrust::get<3>(t);
}
};
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( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 , const Fac4 alpha4 )
: m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ){ }
template< class Tuple >
__host__ __device__
void operator()( Tuple t ) const
{
thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
m_alpha2 * thrust::get<2>(t) +
m_alpha3 * thrust::get<3>(t) +
m_alpha4 * thrust::get<4>(t);
}
};
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( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 ,
const Fac4 alpha4 , const Fac5 alpha5 )
: m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) ,
m_alpha4( alpha4 ) , m_alpha5( alpha5 ) { }
template< class Tuple >
__host__ __device__
void operator()( Tuple t ) const
{
thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
m_alpha2 * thrust::get<2>(t) +
m_alpha3 * thrust::get<3>(t) +
m_alpha4 * thrust::get<4>(t) +
m_alpha5 * thrust::get<5>(t);
}
};
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( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 ,
const Fac4 alpha4 , const Fac5 alpha5 , const Fac6 alpha6 )
: m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) ,
m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) { }
template< class Tuple >
__host__ __device__
void operator()( Tuple t ) const
{
thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
m_alpha2 * thrust::get<2>(t) +
m_alpha3 * thrust::get<3>(t) +
m_alpha4 * thrust::get<4>(t) +
m_alpha5 * thrust::get<5>(t) +
m_alpha6 * thrust::get<6>(t);
}
};
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( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 ,
const Fac4 alpha4 , const Fac5 alpha5 , const Fac6 alpha6 , const 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 Tuple >
__host__ __device__
void operator()( Tuple t ) const
{
thrust::get<0>(t) = m_alpha1 * thrust::get<1>(t) +
m_alpha2 * thrust::get<2>(t) +
m_alpha3 * thrust::get<3>(t) +
m_alpha4 * thrust::get<4>(t) +
m_alpha5 * thrust::get<5>(t) +
m_alpha6 * thrust::get<6>(t) +
m_alpha7 * thrust::get<7>(t) ;
}
};
template< class Fac1 = double >
struct rel_error
{
const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt;
rel_error( const Fac1 eps_abs , const Fac1 eps_rel , const Fac1 a_x , const 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 Tuple >
__host__ __device__
void operator()( Tuple t ) const
{
using std::abs;
thrust::get< 0 >( t ) = abs( thrust::get< 0 >( t ) ) /
( m_eps_abs + m_eps_rel * ( m_a_x * abs( thrust::get< 1 >( t ) + m_a_dxdt * abs( thrust::get< 2 >( t ) ) ) ) );
}
typedef void result_type;
};
};
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_OPERATIONS_HPP_INCLUDED

View File

@@ -0,0 +1,118 @@
/*
[auto_generated]
boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp
[begin_description]
operations_dispatcher specialization for thrust
[end_description]
Copyright 2013-2014 Karsten Ahnert
Copyright 2013-2014 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_EXTERNAL_THRUST_THRUST_OPERATIONS_DISPATCHER_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_OPERATIONS_DISPATCHER_HPP_DEFINED
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <boost/numeric/odeint/external/thrust/thrust_operations.hpp>
#include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
// support for the standard thrust containers
namespace boost {
namespace numeric {
namespace odeint {
// specialization for thrust host_vector
template< class T , class A >
struct operations_dispatcher< thrust::host_vector< T , A > >
{
typedef thrust_operations operations_type;
};
// specialization for thrust device_vector
template< class T , class A >
struct operations_dispatcher< thrust::device_vector< T , A > >
{
typedef thrust_operations operations_type;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
// add support for thrust backend vectors, if available
#include <thrust/version.h>
#if THRUST_VERSION >= 101000
#include <thrust/detail/vector_base.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct operations_dispatcher< thrust::detail::vector_base< T , A > >
{
typedef thrust_operations operations_type;
};
} } }
#elif THRUST_VERSION >= 100600
// specialization for thrust cpp vector
#include <thrust/system/cpp/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct operations_dispatcher< thrust::cpp::vector< T , A > >
{
typedef thrust_operations operations_type;
};
} } }
// specialization for thrust omp vector
#ifdef _OPENMP
#include <thrust/system/omp/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct operations_dispatcher< thrust::omp::vector< T , A > >
{
typedef thrust_operations operations_type;
};
} } }
#endif // _OPENMP
// specialization for thrust tbb vector
#ifdef TBB_VERSION_MAJOR
#include <thrust/system/tbb/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct operations_dispatcher< thrust::tbb::vector< T , A > >
{
typedef thrust_operations operations_type;
};
} } }
#endif // TBB_VERSION_MAJOR
// specialization for thrust cuda vector
#ifdef __CUDACC__
#include <thrust/system/cuda/vector.h>
namespace boost { namespace numeric { namespace odeint {
template< class T , class A >
struct operations_dispatcher< thrust::cuda::vector< T , A > >
{
typedef thrust_operations operations_type;
};
} } }
#endif // __CUDACC__
#endif // THRUST_VERSION >= 100600
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_OPERATIONS_DISPATCHER_HPP_DEFINED

View File

@@ -0,0 +1,197 @@
/*
[auto_generated]
boost/numeric/odeint/external/thrust/thrust_resize.hpp
[begin_description]
Enable resizing for thrusts device and host_vector.
[end_description]
Copyright 2010-2014 Mario Mulansky
Copyright 2010-2011 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_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED
#include <type_traits>
#include <boost/range.hpp>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/distance.h>
#include <boost/numeric/odeint/util/resize.hpp>
#include <boost/numeric/odeint/util/same_size.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
namespace boost {
namespace numeric {
namespace odeint {
// some macros that define the necessary utilities
#define ODEINT_THRUST_VECTOR_IS_RESIZEABLE( THRUST_VECTOR ) \
template< class T , class A > \
struct is_resizeable< THRUST_VECTOR<T,A> > \
{ \
struct type : public std::true_type { }; \
const static bool value = type::value; \
}; \
#define ODEINT_TRHUST_VECTOR_RESIZE_IMPL( THRUST_VECTOR ) \
template< class T, class A > \
struct resize_impl< THRUST_VECTOR<T,A> , THRUST_VECTOR<T,A> > \
{ \
static void resize( THRUST_VECTOR<T,A> &x , \
const THRUST_VECTOR<T,A> &y ) \
{ \
x.resize( y.size() ); \
} \
}; \
template< class T, class A, typename Range > \
struct resize_impl< THRUST_VECTOR<T,A> , Range > \
{ \
static void resize( THRUST_VECTOR<T,A> &x , \
const Range &y ) \
{ \
x.resize( thrust::distance(boost::begin(y), \
boost::end(y))); \
} \
}; \
#define ODEINT_THRUST_SAME_SIZE_IMPL( THRUST_VECTOR ) \
template< class T , class A > \
struct same_size_impl< THRUST_VECTOR<T,A> , THRUST_VECTOR<T,A> > \
{ \
static bool same_size( const THRUST_VECTOR<T,A> &x , \
const THRUST_VECTOR<T,A> &y ) \
{ \
return x.size() == y.size(); \
} \
}; \
template< class T , class A, typename Range > \
struct same_size_impl< THRUST_VECTOR<T,A> , Range > \
{ \
static bool same_size( const THRUST_VECTOR<T,A> &x , \
const Range &y ) \
{ \
return x.size() == thrust::distance(boost::begin(y), \
boost::end(y)); \
} \
}; \
#define ODEINT_THRUST_COPY_IMPL( THRUST_VECTOR ) \
template< class Container1 , class T , class A > \
struct copy_impl< Container1 , THRUST_VECTOR<T,A> > \
{ \
static void copy( const Container1 &from , THRUST_VECTOR<T,A> &to ) \
{ \
thrust::copy( boost::begin( from ) , boost::end( from ) , \
boost::begin( to ) ); \
} \
}; \
\
template< class T , class A , class Container2 > \
struct copy_impl< THRUST_VECTOR<T,A> , Container2 > \
{ \
static void copy( const THRUST_VECTOR<T,A> &from , Container2 &to ) \
{ \
thrust::copy( boost::begin( from ) , boost::end( from ) , \
boost::begin( to ) ); \
} \
}; \
\
template< class T , class A > \
struct copy_impl< THRUST_VECTOR<T,A> , THRUST_VECTOR<T,A> > \
{ \
static void copy( const THRUST_VECTOR<T,A> &from , \
THRUST_VECTOR<T,A> &to ) \
{ \
thrust::copy( boost::begin( from ) , boost::end( from ) , \
boost::begin( to ) ); \
} \
}; \
// add support for the standard thrust containers
ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::device_vector )
ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::device_vector )
ODEINT_THRUST_SAME_SIZE_IMPL( thrust::device_vector )
ODEINT_THRUST_COPY_IMPL( thrust::device_vector )
ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::host_vector )
ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::host_vector )
ODEINT_THRUST_SAME_SIZE_IMPL( thrust::host_vector )
ODEINT_THRUST_COPY_IMPL( thrust::host_vector )
} // odeint
} // numeric
} // boost
// add support for thrust backend vectors, if available
#include <thrust/version.h>
#if THRUST_VERSION >= 101000
#include <thrust/detail/vector_base.h>
namespace boost { namespace numeric { namespace odeint {
ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::detail::vector_base )
ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::detail::vector_base )
ODEINT_THRUST_SAME_SIZE_IMPL( thrust::detail::vector_base )
ODEINT_THRUST_COPY_IMPL( thrust::detail::vector_base )
} } }
#elif THRUST_VERSION >= 100600
#include <thrust/system/cpp/vector.h>
namespace boost { namespace numeric { namespace odeint {
ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cpp::vector )
ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cpp::vector )
ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cpp::vector )
ODEINT_THRUST_COPY_IMPL( thrust::cpp::vector )
} } }
#ifdef _OPENMP
#include <thrust/system/omp/vector.h>
namespace boost { namespace numeric { namespace odeint {
ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::omp::vector )
ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::omp::vector )
ODEINT_THRUST_SAME_SIZE_IMPL( thrust::omp::vector )
ODEINT_THRUST_COPY_IMPL( thrust::omp::vector )
} } }
#endif // _OPENMP
#ifdef TBB_VERSION_MAJOR
#include <thrust/system/tbb/vector.h>
namespace boost { namespace numeric { namespace odeint {
ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::tbb::vector )
ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::tbb::vector )
ODEINT_THRUST_SAME_SIZE_IMPL( thrust::tbb::vector )
ODEINT_THRUST_COPY_IMPL( thrust::tbb::vector )
} } }
#endif // TBB_VERSION_MAJOR
#ifdef __CUDACC__
#include <thrust/system/cuda/vector.h>
namespace boost { namespace numeric { namespace odeint {
ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cuda::vector )
ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cuda::vector )
ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cuda::vector )
ODEINT_THRUST_COPY_IMPL( thrust::cuda::vector )
} } }
#endif // __CUDACC__
#endif // THRUST_VERSION >= 100600
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED

View File

@@ -0,0 +1,28 @@
/*
[auto_generated]
boost/numeric/odeint/external/vexcl/vexcl.hpp
[begin_description]
includes all headers required for using vexcl in odeint
[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_EXTERNAL_VEXCL_VEXCL_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_HPP_DEFINED
#include <boost/numeric/odeint/external/vexcl/vexcl_algebra_dispatcher.hpp>
#include <boost/numeric/odeint/external/vexcl/vexcl_resize.hpp>
#include <boost/numeric/odeint/external/vexcl/vexcl_same_instance.hpp>
#include <boost/numeric/odeint/external/vexcl/vexcl_norm_inf.hpp>
#include <boost/numeric/odeint/external/vexcl/vexcl_abs.hpp>
#include <boost/numeric/odeint/external/vexcl/vexcl_copy.hpp>
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_HPP_DEFINED

View File

@@ -0,0 +1,61 @@
/*
[auto_generated]
boost/numeric/odeint/external/vexcl/vexcl_abs.hpp
[begin_description]
abs() specialization for vexcl
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_EXTERNAL_VEXCL_VEXCL_ABS_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_ABS_HPP_DEFINED
#include <vexcl/vector.hpp>
#include <vexcl/multivector.hpp>
#include <vexcl/operations.hpp>
namespace vex {
template <typename T, size_t N>
typename std::enable_if<
std::is_integral<T>::value,
typename boost::proto::result_of::make_expr<
boost::proto::tag::function,
abs_func,
const vex::multivector<T, N>&
>::type const
>::type
abs(const multivector<T, N> &arg) {
return boost::proto::make_expr<boost::proto::tag::function>(
abs_func(),
boost::ref(arg)
);
}
template <typename T, size_t N>
typename std::enable_if<
!std::is_integral<T>::value,
typename boost::proto::result_of::make_expr<
boost::proto::tag::function,
fabs_func,
const vex::multivector<T, N>&
>::type const
>::type
abs(const multivector<T, N> &arg) {
return boost::proto::make_expr<boost::proto::tag::function>(
fabs_func(),
boost::ref(arg)
);
}
} // namespace vex
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_ABS_HPP_DEFINED

View File

@@ -0,0 +1,51 @@
/*
[auto_generated]
boost/numeric/odeint/external/vexcl/vexcl_algebra_dispatcher.hpp
[begin_description]
algebra_dispatcher specialization for vexcl
[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_EXTERNAL_VEXCL_VEXCL_ALGEBRA_DISPATCHER_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_ALGEBRA_DISPATCHER_HPP_DEFINED
#include <vexcl/vector.hpp>
#include <vexcl/multivector.hpp>
#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
namespace boost {
namespace numeric {
namespace odeint {
// specialization for vexcl vector
template< typename T >
struct algebra_dispatcher< vex::vector< T > >
{
typedef vector_space_algebra algebra_type;
};
// specialization for vexcl multivector
template< typename T , size_t N >
struct algebra_dispatcher< vex::multivector< T , N > >
{
typedef vector_space_algebra algebra_type;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_ALGEBRA_DISPATCHER_HPP_DEFINED

View File

@@ -0,0 +1,55 @@
/*
[auto_generated]
boost/numeric/odeint/external/vexcl/vexcl_copy.hpp
[begin_description]
copy_impl specializations for vexcl
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_EXTERNAL_VEXCL_VEXCL_COPY_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_COPY_HPP_INCLUDED
#include <vexcl/vector.hpp>
#include <vexcl/multivector.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template< typename T1, typename T2 >
struct copy_impl< vex::vector<T1>, vex::vector<T2> >
{
static void copy( const vex::vector<T1> &from , vex::vector<T2> &to )
{
to = from;
}
};
template< typename T1, typename T2, size_t N >
struct copy_impl< vex::multivector<T1, N>, vex::multivector<T2, N> >
{
static void copy( const vex::multivector<T1, N> &from , vex::multivector<T2, N> &to )
{
to = from;
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_COPY_HPP_INCLUDED

View File

@@ -0,0 +1,68 @@
/*
[auto_generated]
boost/numeric/odeint/external/vexcl/vexcl_norm_inf.hpp
[begin_description]
vector_space_norm_inf specialization for vexcl
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED
#include <map>
#include <algorithm>
#include <vexcl/vector.hpp>
#include <vexcl/multivector.hpp>
#include <vexcl/reductor.hpp>
#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
namespace boost {
namespace numeric {
namespace odeint {
// specialization for vexcl vector
template <typename T>
struct vector_space_norm_inf< vex::vector<T> > {
typedef T result_type;
T operator()( const vex::vector<T> &x ) const {
const auto &max = vex::get_reductor<T, vex::MAX>(x.queue_list());
return max( fabs(x) );
}
};
// specialization for vexcl multivector
template <typename T, size_t N>
struct vector_space_norm_inf< vex::multivector<T, N> > {
typedef T result_type;
T operator()( const vex::multivector<T, N> &x ) const {
const auto &max = vex::get_reductor<T, vex::MAX>(x.queue_list());
// Reducing a multivector results in std::array<T, N>:
auto m = max( fabs(x) );
// We will need to reduce it even further:
return *std::max_element(m.begin(), m.end());
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_NORM_INF_HPP_DEFINED

View File

@@ -0,0 +1,96 @@
/*
[auto_generated]
boost/numeric/odeint/external/vexcl/vexcl_resize.hpp
[begin_description]
Enable resizing for vexcl vector and multivector.
[end_description]
Copyright 2012 Karsten Ahnert
Copyright 2012 Mario Mulansky
Copyright 2012 Denis Demidov
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_EXTERNAL_VEXCL_VEXCL_RESIZE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_RESIZE_HPP_INCLUDED
#include <type_traits>
#include <vexcl/vector.hpp>
#include <vexcl/multivector.hpp>
#include <boost/numeric/odeint/util/is_resizeable.hpp>
#include <boost/numeric/odeint/util/resize.hpp>
#include <boost/numeric/odeint/util/same_size.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* specializations for vex::vector< T >
*/
template< typename T >
struct is_resizeable< vex::vector< T > > : std::true_type { };
template< typename T >
struct resize_impl< vex::vector< T > , vex::vector< T > >
{
static void resize( vex::vector< T > &x1 , const vex::vector< T > &x2 )
{
x1.resize( x2.queue_list() , x2.size() );
}
};
template< typename T >
struct same_size_impl< vex::vector< T > , vex::vector< T > >
{
static bool same_size( const vex::vector< T > &x1 , const vex::vector< T > &x2 )
{
return x1.size() == x2.size();
}
};
/*
* specializations for vex::multivector< T >
*/
template< typename T , size_t N >
struct is_resizeable< vex::multivector< T , N > > : std::true_type { };
template< typename T , size_t N >
struct resize_impl< vex::multivector< T , N > , vex::multivector< T , N > >
{
static void resize( vex::multivector< T , N > &x1 , const vex::multivector< T , N > &x2 )
{
x1.resize( x2.queue_list() , x2.size() );
}
};
template< typename T , size_t N >
struct same_size_impl< vex::multivector< T , N > , vex::multivector< T , N > >
{
static bool same_size( const vex::multivector< T , N > &x1 , const vex::multivector< T , N > &x2 )
{
return x1.size() == x2.size();
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_RESIZE_HPP_INCLUDED

View File

@@ -0,0 +1,58 @@
/*
[auto_generated]
boost/numeric/odeint/external/vexcl/vexcl_same_instance.hpp
[begin_description]
Check if two VexCL containers are the same instance.
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_EXTERNAL_VEXCL_VEXCL_SAME_INSTANCE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_SAME_INSTANCE_HPP_INCLUDED
#include <vexcl/vector.hpp>
#include <vexcl/multivector.hpp>
#include <boost/numeric/odeint/util/same_instance.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template <typename T>
struct same_instance_impl< vex::vector<T> , vex::vector<T> >
{
static bool same_instance( const vex::vector<T> &x1 , const vex::vector<T> &x2 )
{
return
static_cast<const vex::vector<T>*>(&x1) ==
static_cast<const vex::vector<T>*>(&x2);
}
};
template <typename T, size_t N>
struct same_instance_impl< vex::multivector<T, N> , vex::multivector<T, N> >
{
static bool same_instance( const vex::multivector<T, N> &x1 , const vex::multivector<T, N> &x2 )
{
return
static_cast<const vex::multivector<T, N>*>(&x1) ==
static_cast<const vex::multivector<T, N>*>(&x2);
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VEXCL_VEXCL_SAME_INSTANCE_HPP_INCLUDED

View File

@@ -0,0 +1,226 @@
/*
[auto_generated]
boost/numeric/odeint/external/viennacl_operations.hpp
[begin_description]
ViennaCL operations.
[end_description]
Copyright 2012 Denis Demidov
Copyright 2012 Karsten Ahnert
Copyright 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_EXTERNAL_VIENNACL_VIENNACL_OPERATIONS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_VIENNACL_VIENNACL_OPERATIONS_HPP_INCLUDED
#include <viennacl/vector.hpp>
#ifdef VIENNACL_WITH_OPENCL
# include <viennacl/generator/custom_operation.hpp>
#endif
namespace boost {
namespace numeric {
namespace odeint {
#ifdef VIENNACL_WITH_OPENCL
struct viennacl_operations
{
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()( viennacl::vector<T1> &v1 ,
const viennacl::vector<T2> &v2 ,
const viennacl::vector<T3> &v3
) const
{
using namespace viennacl;
static generator::symbolic_vector <0, T1> sym_v1;
static generator::symbolic_vector <1, T2> sym_v2;
static generator::symbolic_vector <2, T3> sym_v3;
static generator::cpu_symbolic_scalar<3, Fac1> sym_a1;
static generator::cpu_symbolic_scalar<4, Fac2> sym_a2;
static generator::custom_operation op(
sym_v1 = sym_a1 * sym_v2
+ sym_a2 * sym_v3,
"scale_sum2"
);
ocl::enqueue( op(v1, v2, v3, m_alpha1, m_alpha2) );
}
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()( viennacl::vector<T1> &v1 ,
const viennacl::vector<T2> &v2 ,
const viennacl::vector<T3> &v3 ,
const viennacl::vector<T4> &v4
) const
{
using namespace viennacl;
static generator::symbolic_vector <0, T1> sym_v1;
static generator::symbolic_vector <1, T2> sym_v2;
static generator::symbolic_vector <2, T3> sym_v3;
static generator::symbolic_vector <3, T4> sym_v4;
static generator::cpu_symbolic_scalar<4, Fac1> sym_a1;
static generator::cpu_symbolic_scalar<5, Fac2> sym_a2;
static generator::cpu_symbolic_scalar<6, Fac3> sym_a3;
static generator::custom_operation op(
sym_v1 = sym_a1 * sym_v2
+ sym_a2 * sym_v3
+ sym_a3 * sym_v4,
"scale_sum3"
);
ocl::enqueue( op(v1, v2, v3, v4, m_alpha1, m_alpha2, m_alpha3) );
}
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()( viennacl::vector<T1> &v1 ,
const viennacl::vector<T2> &v2 ,
const viennacl::vector<T3> &v3 ,
const viennacl::vector<T4> &v4 ,
const viennacl::vector<T5> &v5
) const
{
using namespace viennacl;
static generator::symbolic_vector <0, T1> sym_v1;
static generator::symbolic_vector <1, T2> sym_v2;
static generator::symbolic_vector <2, T3> sym_v3;
static generator::symbolic_vector <3, T4> sym_v4;
static generator::symbolic_vector <4, T5> sym_v5;
static generator::cpu_symbolic_scalar<5, Fac1> sym_a1;
static generator::cpu_symbolic_scalar<6, Fac2> sym_a2;
static generator::cpu_symbolic_scalar<7, Fac3> sym_a3;
static generator::cpu_symbolic_scalar<8, Fac4> sym_a4;
static generator::custom_operation op(
sym_v1 = sym_a1 * sym_v2
+ sym_a2 * sym_v3
+ sym_a3 * sym_v4
+ sym_a4 * sym_v5,
"scale_sum4"
);
ocl::enqueue( op(v1, v2, v3, v4, v5,
m_alpha1, m_alpha2, m_alpha3, m_alpha4) );
}
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()( viennacl::vector<T1> &v1 ,
const viennacl::vector<T2> &v2 ,
const viennacl::vector<T3> &v3 ,
const viennacl::vector<T4> &v4 ,
const viennacl::vector<T5> &v5 ,
const viennacl::vector<T6> &v6
) const
{
using namespace viennacl;
static generator::symbolic_vector < 0, T1> sym_v1;
static generator::symbolic_vector < 1, T2> sym_v2;
static generator::symbolic_vector < 2, T3> sym_v3;
static generator::symbolic_vector < 3, T4> sym_v4;
static generator::symbolic_vector < 4, T5> sym_v5;
static generator::symbolic_vector < 5, T6> sym_v6;
static generator::cpu_symbolic_scalar< 6, Fac1> sym_a1;
static generator::cpu_symbolic_scalar< 7, Fac2> sym_a2;
static generator::cpu_symbolic_scalar< 8, Fac3> sym_a3;
static generator::cpu_symbolic_scalar< 9, Fac4> sym_a4;
static generator::cpu_symbolic_scalar<10, Fac5> sym_a5;
static generator::custom_operation op(
sym_v1 = sym_a1 * sym_v2
+ sym_a2 * sym_v3
+ sym_a3 * sym_v4
+ sym_a4 * sym_v5
+ sym_a5 * sym_v6,
"scale_sum5"
);
ocl::enqueue( op(v1, v2, v3, v4, v5, v6,
m_alpha1, m_alpha2, m_alpha3, m_alpha4, m_alpha5) );
}
typedef void result_type;
};
};
#else
struct viennacl_operations : public default_operations {};
#endif
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VIENNACL_VIENNACL_OPERATIONS_HPP_INCLUDED

View File

@@ -0,0 +1,68 @@
/*
[auto_generated]
boost/numeric/odeint/external/viennacl/viennacl_resize.hpp
[begin_description]
Enable resizing for viennacl vector.
[end_description]
Copyright 2012 Denis Demidov
Copyright 2012 Karsten Ahnert
Copyright 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_EXTERNAL_VIENNACL_VIENNACL_RESIZE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_EXTERNAL_VIENNACL_VIENNACL_RESIZE_HPP_INCLUDED
#include <type_traits>
#include <viennacl/vector.hpp>
#include <boost/numeric/odeint/util/is_resizeable.hpp>
#include <boost/numeric/odeint/util/resize.hpp>
#include <boost/numeric/odeint/util/same_size.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* specializations for viennacl::vector< T >
*/
template< typename T >
struct is_resizeable< viennacl::vector< T > > : std::true_type { };
template< typename T >
struct resize_impl< viennacl::vector< T > , viennacl::vector< T > >
{
static void resize( viennacl::vector< T > &x1 , const viennacl::vector< T > &x2 )
{
x1.resize( x2.size() , false );
}
};
template< typename T >
struct same_size_impl< viennacl::vector< T > , viennacl::vector< T > >
{
static bool same_size( const viennacl::vector< T > &x1 , const viennacl::vector< T > &x2 )
{
return x1.size() == x2.size();
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_VIENNACL_VIENNACL_RESIZE_HPP_INCLUDED

View File

@@ -0,0 +1,222 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/check_adapter.hpp
[begin_description]
Adapters to add checking facility to stepper and observer
[end_description]
Copyright 2015 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_INTEGRATE_CHECK_ADAPTER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_CHECK_ADAPTER_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template<class Stepper, class Checker,
class StepperCategory = typename base_tag<typename Stepper::stepper_category>::type>
class checked_stepper;
/**
* \brief Adapter to combine basic stepper and checker.
*/
template<class Stepper, class Checker>
class checked_stepper<Stepper, Checker, stepper_tag>
{
public:
typedef Stepper stepper_type;
typedef Checker checker_type;
// forward stepper typedefs
typedef typename stepper_type::state_type state_type;
typedef typename stepper_type::value_type value_type;
typedef typename stepper_type::deriv_type deriv_type;
typedef typename stepper_type::time_type time_type;
private:
stepper_type &m_stepper;
checker_type &m_checker;
public:
/**
* \brief Construct the checked_stepper.
*/
checked_stepper(stepper_type &stepper, checker_type &checker)
: m_stepper(stepper), m_checker(checker) { }
/**
* \brief forward of the do_step method
*/
template<class System, class StateInOut>
void do_step(System system, StateInOut &state, const time_type t, const time_type dt)
{
// do the step
m_stepper.do_step(system, state, t, dt);
// call the checker
m_checker();
}
};
/**
* \brief Adapter to combine controlled stepper and checker.
*/
template<class ControlledStepper, class Checker>
class checked_stepper<ControlledStepper, Checker, controlled_stepper_tag>
{
public:
typedef ControlledStepper stepper_type;
typedef Checker checker_type;
// forward stepper typedefs
typedef typename stepper_type::state_type state_type;
typedef typename stepper_type::value_type value_type;
typedef typename stepper_type::deriv_type deriv_type;
typedef typename stepper_type::time_type time_type;
private:
stepper_type &m_stepper;
checker_type &m_checker;
public:
/**
* \brief Construct the checked_stepper.
*/
checked_stepper(stepper_type &stepper, checker_type &checker)
: m_stepper(stepper), m_checker(checker) { }
/**
* \brief forward of the do_step method
*/
template< class System , class StateInOut >
controlled_step_result try_step( System system , StateInOut &state , time_type &t , time_type &dt )
{
// do the step
if( m_stepper.try_step(system, state, t, dt) == success )
{
// call the checker if step was successful
m_checker();
return success;
} else
{
// step failed -> return fail
return fail;
}
}
};
/**
* \brief Adapter to combine dense out stepper and checker.
*/
template<class DenseOutStepper, class Checker>
class checked_stepper<DenseOutStepper, Checker, dense_output_stepper_tag>
{
public:
typedef DenseOutStepper stepper_type;
typedef Checker checker_type;
// forward stepper typedefs
typedef typename stepper_type::state_type state_type;
typedef typename stepper_type::value_type value_type;
typedef typename stepper_type::deriv_type deriv_type;
typedef typename stepper_type::time_type time_type;
private:
stepper_type &m_stepper;
checker_type &m_checker;
public:
/**
* \brief Construct the checked_stepper.
*/
checked_stepper(stepper_type &stepper, checker_type &checker)
: m_stepper(stepper), m_checker(checker) { }
template< class System >
std::pair< time_type , time_type > do_step( System system )
{
m_checker();
return m_stepper.do_step(system);
}
/* provide the remaining dense out stepper interface */
template< class StateType >
void initialize( const StateType &x0 , time_type t0 , time_type dt0 )
{ m_stepper.initialize(x0, t0, dt0); }
template< class StateOut >
void calc_state( time_type t , StateOut &x ) const
{ m_stepper.calc_state(t, x); }
template< class StateOut >
void calc_state( time_type t , const StateOut &x ) const
{ m_stepper.calc_state(t, x); }
const state_type& current_state( void ) const
{ return m_stepper.current_state(); }
time_type current_time( void ) const
{ return m_stepper.current_time(); }
const state_type& previous_state( void ) const
{ return m_stepper.previous_state(); }
time_type previous_time( void ) const
{ return m_stepper.previous_time(); }
time_type current_time_step( void ) const
{ return m_stepper.current_time_step(); }
};
/**
* \brief Adapter to combine observer and checker.
*/
template<class Observer, class Checker>
class checked_observer
{
public:
typedef Observer observer_type;
typedef Checker checker_type;
private:
observer_type &m_observer;
checker_type &m_checker;
public:
checked_observer(observer_type &observer, checker_type &checker)
: m_observer(observer), m_checker(checker)
{}
template< class State , class Time >
void operator()(const State& state, Time t) const
{
// call the observer
m_observer(state, t);
// reset the checker
m_checker.reset();
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,70 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/functors.hpp
[begin_description]
some functors for the iterator based integrate routines
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED
#include <utility>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< class Observer >
struct obs_caller {
size_t &m_n;
Observer m_obs;
obs_caller( size_t &m , Observer &obs ) : m_n(m) , m_obs( obs ) {}
template< class State , class Time >
void operator()( std::pair< const State & , const Time & > x )
{
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
observer_type &obs = m_obs;
obs( x.first , x.second );
m_n++;
}
};
template< class Observer , class Time >
struct obs_caller_time {
Time &m_t;
Observer m_obs;
obs_caller_time( Time &t , Observer &obs ) : m_t(t) , m_obs( obs ) {}
template< class State >
void operator()( std::pair< const State & , const Time & > x )
{
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
observer_type &obs = m_obs;
obs( x.first , x.second );
m_t = x.second;
}
};
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED

View File

@@ -0,0 +1,161 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp
[begin_description]
Default Integrate adaptive implementation.
[end_description]
Copyright 2011-2013 Karsten Ahnert
Copyright 2011-2015 Mario Mulansky
Copyright 2012 Christoph Koke
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_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/integrate/max_step_checker.hpp>
#include <boost/numeric/odeint/integrate/detail/integrate_const.hpp>
#include <boost/numeric/odeint/util/bind.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
#include <iostream>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , stepper_tag );
/*
* integrate_adaptive for simple stepper is basically an integrate_const + some last step
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , stepper_tag
)
{
size_t steps = detail::integrate_const( stepper , system , start_state , start_time ,
end_time , dt , observer , stepper_tag() );
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
Time end = start_time + dt*steps;
if( less_with_sign( end , end_time , dt ) )
{ //make a last step to end exactly at end_time
st.do_step( system , start_state , end , end_time - end );
steps++;
obs( start_state , end_time );
}
return steps;
}
/*
* integrate adaptive for controlled stepper
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
Observer observer , controlled_stepper_tag
)
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
failed_step_checker fail_checker; // to throw a runtime_error if step size adjustment fails
size_t count = 0;
while( less_with_sign( start_time , end_time , dt ) )
{
obs( start_state , start_time );
if( less_with_sign( end_time , static_cast<Time>(start_time + dt) , dt ) )
{
dt = end_time - start_time;
}
controlled_step_result res;
do
{
res = st.try_step( system , start_state , start_time , dt );
fail_checker(); // check number of failed steps
}
while( res == fail );
fail_checker.reset(); // if we reach here, the step was successful -> reset fail checker
++count;
}
obs( start_state , start_time );
return count;
}
/*
* integrate adaptive for dense output steppers
*
* step size control is used if the stepper supports it
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , dense_output_stepper_tag )
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
size_t count = 0;
st.initialize( start_state , start_time , dt );
while( less_with_sign( st.current_time() , end_time , st.current_time_step() ) )
{
while( less_eq_with_sign( static_cast<Time>(st.current_time() + st.current_time_step()) ,
end_time ,
st.current_time_step() ) )
{ //make sure we don't go beyond the end_time
obs( st.current_state() , st.current_time() );
st.do_step( system );
++count;
}
// calculate time step to arrive exactly at end time
st.initialize( st.current_state() , st.current_time() , static_cast<Time>(end_time - st.current_time()) );
}
obs( st.current_state() , st.current_time() );
// overwrite start_state with the final point
boost::numeric::odeint::copy( st.current_state() , start_state );
return count;
}
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED

View File

@@ -0,0 +1,167 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_const.hpp
[begin_description]
integrate const implementation
[end_description]
Copyright 2012-2015 Mario Mulansky
Copyright 2012 Christoph Koke
Copyright 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_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_INCLUDED
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
Observer observer , controlled_stepper_tag
);
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , stepper_tag
)
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
Time time = start_time;
int step = 0;
// cast time+dt explicitely in case of expression templates (e.g. multiprecision)
while( less_eq_with_sign( static_cast<Time>(time+dt) , end_time , dt ) )
{
obs( start_state , time );
st.do_step( system , start_state , time , dt );
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
++step;
time = start_time + static_cast< typename unit_value_type<Time>::type >(step) * dt;
}
obs( start_state , time );
return step;
}
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , controlled_stepper_tag
)
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
Time time = start_time;
const Time time_step = dt;
int real_steps = 0;
int step = 0;
while( less_eq_with_sign( static_cast<Time>(time+time_step) , end_time , dt ) )
{
obs( start_state , time );
// integrate_adaptive_checked uses the given checker to throw if an overflow occurs
real_steps += detail::integrate_adaptive(stepper, system, start_state, time,
static_cast<Time>(time + time_step), dt,
null_observer(), controlled_stepper_tag());
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
step++;
time = start_time + static_cast< typename unit_value_type<Time>::type >(step) * time_step;
}
obs( start_state , time );
return real_steps;
}
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , dense_output_stepper_tag
)
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
Time time = start_time;
st.initialize( start_state , time , dt );
obs( start_state , time );
time += dt;
int obs_step( 1 );
int real_step( 0 );
while( less_eq_with_sign( static_cast<Time>(time+dt) , end_time , dt ) )
{
while( less_eq_with_sign( time , st.current_time() , dt ) )
{
st.calc_state( time , start_state );
obs( start_state , time );
++obs_step;
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
time = start_time + static_cast< typename unit_value_type<Time>::type >(obs_step) * dt;
}
// we have not reached the end, do another real step
if( less_with_sign( static_cast<Time>(st.current_time()+st.current_time_step()) ,
end_time ,
st.current_time_step() ) )
{
while( less_eq_with_sign( st.current_time() , time , dt ) )
{
st.do_step( system );
++real_step;
}
}
else if( less_with_sign( st.current_time() , end_time , st.current_time_step() ) )
{ // do the last step ending exactly on the end point
st.initialize( st.current_state() , st.current_time() , end_time - st.current_time() );
st.do_step( system );
++real_step;
}
}
// last observation, if we are still in observation interval
// might happen due to finite precision problems when computing the the time
if( less_eq_with_sign( time , end_time , dt ) )
{
st.calc_state( time , start_state );
obs( start_state , time );
}
return real_step;
}
} } } }
#endif

View File

@@ -0,0 +1,161 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp
[begin_description]
integrate steps implementation
[end_description]
Copyright 2012-2015 Mario Mulansky
Copyright 2012 Christoph Koke
Copyright 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_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive_checked(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
Observer observer, controlled_stepper_tag
);
/* basic version */
template< class Stepper , class System , class State , class Time , class Observer>
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , stepper_tag )
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
Time time = start_time;
for( size_t step = 0; step < num_of_steps ; ++step )
{
obs( start_state , time );
st.do_step( system , start_state , time , dt );
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
time = start_time + static_cast< typename unit_value_type<Time>::type >( step+1 ) * dt;
}
obs( start_state , time );
return time;
}
/* controlled version */
template< class Stepper , class System , class State , class Time , class Observer >
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , controlled_stepper_tag )
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
Time time = start_time;
Time time_step = dt;
for( size_t step = 0; step < num_of_steps ; ++step )
{
obs( start_state , time );
// integrate_adaptive_checked uses the given checker to throw if an overflow occurs
detail::integrate_adaptive(stepper, system, start_state, time, static_cast<Time>(time + time_step), dt,
null_observer(), controlled_stepper_tag());
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
time = start_time + static_cast< typename unit_value_type<Time>::type >(step+1) * time_step;
}
obs( start_state , time );
return time;
}
/* dense output version */
template< class Stepper , class System , class State , class Time , class Observer >
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , dense_output_stepper_tag )
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
Time time = start_time;
const Time end_time = start_time + static_cast< typename unit_value_type<Time>::type >(num_of_steps) * dt;
st.initialize( start_state , time , dt );
size_t step = 0;
while( step < num_of_steps )
{
while( less_with_sign( time , st.current_time() , st.current_time_step() ) )
{
st.calc_state( time , start_state );
obs( start_state , time );
++step;
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
time = start_time + static_cast< typename unit_value_type<Time>::type >(step) * dt;
}
// we have not reached the end, do another real step
if( less_with_sign( static_cast<Time>(st.current_time()+st.current_time_step()) ,
end_time ,
st.current_time_step() ) )
{
st.do_step( system );
}
else if( less_with_sign( st.current_time() , end_time , st.current_time_step() ) )
{ // do the last step ending exactly on the end point
st.initialize( st.current_state() , st.current_time() , static_cast<Time>(end_time - st.current_time()) );
st.do_step( system );
}
}
// make sure we really end exactly where we should end
while( st.current_time() < end_time )
{
if( less_with_sign( end_time ,
static_cast<Time>(st.current_time()+st.current_time_step()) ,
st.current_time_step() ) )
st.initialize( st.current_state() , st.current_time() , static_cast<Time>(end_time - st.current_time()) );
st.do_step( system );
}
// observation at final point
obs( st.current_state() , end_time );
return time;
}
}
}
}
}
#endif /* BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED */

View File

@@ -0,0 +1,179 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_times.hpp
[begin_description]
Default integrate times implementation.
[end_description]
Copyright 2011-2015 Mario Mulansky
Copyright 2012 Karsten Ahnert
Copyright 2012 Christoph Koke
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_INTEGRATE_DETAIL_INTEGRATE_TIMES_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_TIMES_HPP_INCLUDED
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
#include <boost/numeric/odeint/integrate/max_step_checker.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
/*
* integrate_times for simple stepper
*/
template<class Stepper, class System, class State, class TimeIterator, class Time, class Observer>
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
TimeIterator start_time , TimeIterator end_time , Time dt ,
Observer observer , stepper_tag
)
{
typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
stepper_type &st = stepper;
observer_type &obs = observer;
typedef typename unit_value_type<Time>::type time_type;
size_t steps = 0;
Time current_dt = dt;
while( true )
{
Time current_time = *start_time++;
obs( start_state , current_time );
if( start_time == end_time )
break;
while( less_with_sign( current_time , static_cast<time_type>(*start_time) , current_dt ) )
{
current_dt = min_abs( dt , *start_time - current_time );
st.do_step( system , start_state , current_time , current_dt );
current_time += current_dt;
steps++;
}
}
return steps;
}
/*
* integrate_times for controlled stepper
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
TimeIterator start_time , TimeIterator end_time , Time dt ,
Observer observer , controlled_stepper_tag
)
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
typedef typename unit_value_type<Time>::type time_type;
failed_step_checker fail_checker; // to throw a runtime_error if step size adjustment fails
size_t steps = 0;
while( true )
{
Time current_time = *start_time++;
obs( start_state , current_time );
if( start_time == end_time )
break;
while( less_with_sign( current_time , static_cast<time_type>(*start_time) , dt ) )
{
// adjust stepsize to end up exactly at the observation point
Time current_dt = min_abs( dt , *start_time - current_time );
if( st.try_step( system , start_state , current_time , current_dt ) == success )
{
++steps;
// successful step -> reset the fail counter, see #173
fail_checker.reset();
// continue with the original step size if dt was reduced due to observation
dt = max_abs( dt , current_dt );
}
else
{
fail_checker(); // check for possible overflow of failed steps in step size adjustment
dt = current_dt;
}
}
}
return steps;
}
/*
* integrate_times for dense output stepper
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
TimeIterator start_time , TimeIterator end_time , Time dt ,
Observer observer , dense_output_stepper_tag
)
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
typedef typename unit_value_type<Time>::type time_type;
if( start_time == end_time )
return 0;
TimeIterator last_time_iterator = end_time;
--last_time_iterator;
Time last_time_point = static_cast<time_type>(*last_time_iterator);
st.initialize( start_state , *start_time , dt );
obs( start_state , *start_time++ );
size_t count = 0;
while( start_time != end_time )
{
while( ( start_time != end_time ) && less_eq_with_sign( static_cast<time_type>(*start_time) , st.current_time() , st.current_time_step() ) )
{
st.calc_state( *start_time , start_state );
obs( start_state , *start_time );
start_time++;
}
// we have not reached the end, do another real step
if( less_eq_with_sign( st.current_time() + st.current_time_step() ,
last_time_point ,
st.current_time_step() ) )
{
st.do_step( system );
++count;
}
else if( start_time != end_time )
{ // do the last step ending exactly on the end point
st.initialize( st.current_state() , st.current_time() , last_time_point - st.current_time() );
st.do_step( system );
++count;
}
}
return count;
}
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED

View File

@@ -0,0 +1,133 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate.hpp
[begin_description]
Convenience methods which choose the stepper for the current ODE.
[end_description]
Copyright 2011-2013 Karsten Ahnert
Copyright 2011-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_INTEGRATE_INTEGRATE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_HPP_INCLUDED
#include <boost/utility/enable_if.hpp>
#include <boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp>
#include <boost/numeric/odeint/stepper/controlled_runge_kutta.hpp>
#include <boost/numeric/odeint/integrate/null_observer.hpp>
#include <boost/numeric/odeint/integrate/integrate_adaptive.hpp>
// for has_value_type trait
#include <boost/numeric/odeint/algebra/detail/extract_value_type.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* ToDo :
*
* determine type of dxdt for units
*
*/
template< class System , class State , class Time , class Observer >
typename boost::enable_if< typename has_value_type<State>::type , size_t >::type
integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
{
typedef controlled_runge_kutta< runge_kutta_dopri5< State , typename State::value_type , State , Time > > stepper_type;
return integrate_adaptive( stepper_type() , system , start_state , start_time , end_time , dt , observer );
}
template< class Value , class System , class State , class Time , class Observer >
size_t
integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
{
typedef controlled_runge_kutta< runge_kutta_dopri5< State , Value , State , Time > > stepper_type;
return integrate_adaptive( stepper_type() , system , start_state , start_time , end_time , dt , observer );
}
/*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class System , class State , class Time >
size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
{
return integrate( system , start_state , start_time , end_time , dt , null_observer() );
}
template< class Value , class System , class State , class Time >
size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
{
return integrate< Value >( system , start_state , start_time , end_time , dt , null_observer() );
}
/**
* \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
* \brief Integrates the ODE.
*
* Integrates the ODE given by system from start_time to end_time starting
* with start_state as initial condition and dt as initial time step.
* This function uses a dense output dopri5 stepper and performs an adaptive
* integration with step size control, thus dt changes during the integration.
* This method uses standard error bounds of 1E-6.
* After each step, the observer is called.
*
* \attention A second version of this function template exists which explicitly
* expects the value type as template parameter, i.e. integrate< double >( sys , x , t0 , t1 , dt , obs );
*
* \param system The system function to solve, hence the r.h.s. of the
* ordinary differential equation.
* \param start_state The initial state.
* \param start_time Start time of the integration.
* \param end_time End time of the integration.
* \param dt Initial step size, will be adjusted during the integration.
* \param observer Observer that will be called after each time step.
* \return The number of steps performed.
*/
/**
* \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
* \brief Integrates the ODE without observer calls.
*
* Integrates the ODE given by system from start_time to end_time starting
* with start_state as initial condition and dt as initial time step.
* This function uses a dense output dopri5 stepper and performs an adaptive
* integration with step size control, thus dt changes during the integration.
* This method uses standard error bounds of 1E-6.
* No observer is called.
*
* \attention A second version of this function template exists which explicitly
* expects the value type as template parameter, i.e. integrate< double >( sys , x , t0 , t1 , dt );
*
* \param system The system function to solve, hence the r.h.s. of the
* ordinary differential equation.
* \param start_state The initial state.
* \param start_time Start time of the integration.
* \param end_time End time of the integration.
* \param dt Initial step size, will be adjusted during the integration.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_HPP_INCLUDED

View File

@@ -0,0 +1,127 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_adaptive.hpp
[begin_description]
Adaptive integration of ODEs.
[end_description]
Copyright 2011-2013 Karsten Ahnert
Copyright 2011-2015 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_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/integrate/null_observer.hpp>
#include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
/*
* Suggestion for a new extendable version:
*
* integrator_adaptive< Stepper , System, State , Time , Observer , typename Stepper::stepper_category > integrator;
* return integrator.run( stepper , system , start_state , start_time , end_time , dt , observer );
*/
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
/**
* \brief integrate_adaptive without an observer.
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt )
{
return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_adaptive(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt )
{
return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/************* DOXYGEN ************/
/**
* \fn integrate_adaptive( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
* \brief Integrates the ODE with adaptive step size.
*
* This function integrates the ODE given by system with the given stepper.
* The observer is called after each step. If the stepper has no error
* control, the step size remains constant and the observer is called at
* equidistant time points t0+n*dt. If the stepper is a ControlledStepper,
* the step size is adjusted and the observer is called in non-equidistant
* intervals.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param start_time The initial time t0.
* \param end_time The final integration time tend.
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param observer Function/Functor called at equidistant time intervals.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED

View File

@@ -0,0 +1,195 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_const.hpp
[begin_description]
Constant integration of ODEs, meaning that the state of the ODE is observed on constant time intervals.
The routines makes full use of adaptive and dense-output methods.
[end_description]
Copyright 2011-2013 Karsten Ahnert
Copyright 2011-2015 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_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED
#include <type_traits>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/integrate/null_observer.hpp>
#include <boost/numeric/odeint/integrate/check_adapter.hpp>
#include <boost/numeric/odeint/integrate/detail/integrate_const.hpp>
#include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* Integrates with constant time step dt.
*/
template<class Stepper, class System, class State, class Time, class Observer, class StepOverflowChecker>
size_t integrate_const(
Stepper stepper, System system, State &start_state,
Time start_time, Time end_time, Time dt,
Observer observer, StepOverflowChecker checker
) {
typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
// we want to get as fast as possible to the end
// no overflow checks needed
BOOST_IF_CONSTEXPR (std::is_same<null_observer, Observer>::value) {
return detail::integrate_adaptive(
stepper, system, start_state,
start_time, end_time, dt,
observer, stepper_category());
}
else {
// unwrap references
typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
return detail::integrate_const(checked_stepper<stepper_type, checker_type>(stepper, checker),
system, start_state,
start_time, end_time, dt,
checked_observer<observer_type, checker_type>(observer, checker),
stepper_category());
}
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template<class Stepper, class System, class State, class Time, class Observer, class StepOverflowChecker >
size_t integrate_const(
Stepper stepper, System system, const State &start_state,
Time start_time, Time end_time, Time dt,
Observer observer, StepOverflowChecker checker
) {
typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
// we want to get as fast as possible to the end
BOOST_IF_CONSTEXPR (std::is_same<null_observer, Observer>::value) {
return detail::integrate_adaptive(
stepper, system, start_state,
start_time, end_time, dt,
observer, stepper_category());
}
else {
typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
return detail::integrate_const(checked_stepper<stepper_type, checker_type>(stepper, checker),
system, start_state,
start_time, end_time, dt,
checked_observer<observer_type, checker_type>(observer, checker),
stepper_category());
}
}
/**
* \brief integrate_const without step overflow checker
*/
template<class Stepper, class System, class State, class Time, class Observer>
size_t integrate_const(
Stepper stepper, System system, State &start_state,
Time start_time, Time end_time, Time dt, Observer observer)
{
typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
return detail::integrate_const(stepper, system, start_state,
start_time, end_time, dt, observer, stepper_category());
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template<class Stepper, class System, class State, class Time, class Observer>
size_t integrate_const(
Stepper stepper, System system, const State &start_state,
Time start_time, Time end_time, Time dt, Observer observer
) {
typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
return detail::integrate_const(stepper, system, start_state,
start_time, end_time, dt, observer, stepper_category());
}
/**
* \brief integrate_const without observer calls
*/
template<class Stepper, class System, class State, class Time>
size_t integrate_const(
Stepper stepper, System system, State &start_state,
Time start_time, Time end_time, Time dt
) {
return integrate_const(stepper, system, start_state, start_time, end_time, dt, null_observer());
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template<class Stepper, class System, class State, class Time>
size_t integrate_const(
Stepper stepper, System system, const State &start_state,
Time start_time, Time end_time, Time dt
) {
return integrate_const(stepper, system, start_state, start_time, end_time, dt, null_observer());
}
/********* DOXYGEN *********/
/**
* \fn integrate_const( Stepper stepper , System system , State &start_state , Time start_time ,
* Time end_time , Time dt , Observer observer , StepOverflowChecker checker )
* \brief Integrates the ODE with constant step size.
*
* Integrates the ODE defined by system using the given stepper.
* This method ensures that the observer is called at constant intervals dt.
* If the Stepper is a normal stepper without step size control, dt is also
* used for the numerical scheme. If a ControlledStepper is provided, the
* algorithm might reduce the step size to meet the error bounds, but it is
* ensured that the observer is always called at equidistant time points
* t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
* and the dense output is used to call the observer at equidistant time
* points.
* If a max_step_checker is provided as StepOverflowChecker, a
* no_progress_error is thrown if too many steps (default: 500) are performed
* without progress, i.e. in between observer calls. If no checker is provided,
* no such overflow check is performed.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param start_time The initial time t0.
* \param end_time The final integration time tend.
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param observer [optional] Function/Functor called at equidistant time intervals.
* \param checker [optional] Functor to check for step count overflows, if no
* checker is provided, no exception is thrown.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED

View File

@@ -0,0 +1,178 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_n_steps.hpp
[begin_description]
Integration of n steps with constant time size. Adaptive and dense-output methods are fully supported.
[end_description]
Copyright 2011-2013 Karsten Ahnert
Copyright 2011-2015 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_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/integrate/null_observer.hpp>
#include <boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp>
#include <boost/numeric/odeint/integrate/check_adapter.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* Integrates n steps
*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class Stepper , class System , class State , class Time , class Observer , class StepOverflowChecker >
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , StepOverflowChecker checker )
{
// unwrap references
typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
typedef typename stepper_type::stepper_category stepper_category;
return detail::integrate_n_steps(
checked_stepper<stepper_type, checker_type>(stepper, checker),
system , start_state ,
start_time , dt , num_of_steps ,
checked_observer<observer_type, checker_type>(observer, checker),
stepper_category() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time , class Observer , class StepOverflowChecker >
Time integrate_n_steps(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , StepOverflowChecker checker )
{
typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
typedef typename stepper_type::stepper_category stepper_category;
return detail::integrate_n_steps(
checked_stepper<stepper_type, checker_type>(stepper, checker),
system , start_state ,
start_time , dt , num_of_steps ,
checked_observer<observer_type, checker_type>(observer, checker),
stepper_category() );
}
/**
* \brief The same function as above, but without checker.
*/
template< class Stepper , class System , class State , class Time , class Observer >
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps , Observer observer )
{
typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
return detail::integrate_n_steps(
stepper , system , start_state ,
start_time , dt , num_of_steps ,
observer , stepper_category() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time , class Observer >
Time integrate_n_steps(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time dt , size_t num_of_steps , Observer observer )
{
typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
return detail::integrate_n_steps(
stepper , system , start_state ,
start_time , dt , num_of_steps ,
observer , stepper_category() );
}
/**
* \brief The same function as above, but without observer calls.
*/
template< class Stepper , class System , class State , class Time >
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps )
{
return integrate_n_steps(stepper, system, start_state, start_time,
dt, num_of_steps, null_observer());
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time >
Time integrate_n_steps(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time dt , size_t num_of_steps )
{
return integrate_n_steps(stepper, system, start_state, start_time,
dt, num_of_steps, null_observer());
}
/************* DOXYGEN *************/
/**
* \fn Time integrate_n_steps( Stepper stepper , System system , State &start_state , Time start_time , Time dt , size_t num_of_steps , Observer observer )
* \brief Integrates the ODE with constant step size.
*
* This function is similar to integrate_const. The observer is called at
* equidistant time intervals t0 + n*dt.
* If the Stepper is a normal stepper without step size control, dt is also
* used for the numerical scheme. If a ControlledStepper is provided, the
* algorithm might reduce the step size to meet the error bounds, but it is
* ensured that the observer is always called at equidistant time points
* t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
* and the dense output is used to call the observer at equidistant time
* points. The final integration time is always t0 + num_of_steps*dt.
* If a max_step_checker is provided as StepOverflowChecker, a
* no_progress_errror is thrown if too many steps (default: 500) are
* performed without progress, i.e. in between observer calls. If no
* checker is provided, no such overflow check is performed.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param start_time The initial time t0.
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param num_of_steps Number of steps to be performed
* \param observer Function/Functor called at equidistant time intervals.
* \param checker [optional] Functor to check for step count overflows, if no
* checker is provided, no exception is thrown.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED

View File

@@ -0,0 +1,220 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_times.hpp
[begin_description]
Integration of ODEs with observation at user defined points
[end_description]
Copyright 2011-2013 Karsten Ahnert
Copyright 2011-2015 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_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED
#include <boost/range.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/integrate/null_observer.hpp>
#include <boost/numeric/odeint/integrate/check_adapter.hpp>
#include <boost/numeric/odeint/integrate/detail/integrate_times.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* \brief Integrates while calling the observer at the time points given by sequence [times_start, time_end)
* the two overloads are needed in order to solve the forwarding problem
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer , class StepOverflowChecker >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
TimeIterator times_start , TimeIterator times_end , Time dt ,
Observer observer , StepOverflowChecker checker )
{
// unwrap references
typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
typedef typename stepper_type::stepper_category stepper_category;
// pass on checked stepper and observer
// checked_stepper/observer use references internally, so passing by value is fine
return detail::integrate_times(
checked_stepper<stepper_type, checker_type>(stepper, checker) ,
system , start_state ,
times_start , times_end , dt ,
checked_observer<observer_type, checker_type>(observer, checker),
stepper_category() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer , class StepOverflowChecker >
size_t integrate_times(
Stepper stepper , System system , const State &start_state ,
TimeIterator times_start , TimeIterator times_end , Time dt ,
Observer observer , StepOverflowChecker checker )
{
typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
typedef typename stepper_type::stepper_category stepper_category;
stepper_type &st = stepper;
observer_type &obs = observer;
checker_type &chk = checker;
return detail::integrate_times(
checked_stepper<stepper_type, checker_type>(stepper, checker) ,
system , start_state ,
times_start , times_end , dt ,
checked_observer<observer_type, checker_type>(observer, checker),
stepper_category() );
}
/**
* \brief The same function as above, but with the observation times given as range.
*/
template< class Stepper , class System , class State , class TimeRange , class Time , class Observer , class StepOverflowChecker >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
const TimeRange &times , Time dt ,
Observer observer , StepOverflowChecker checker )
{
return integrate_times(
stepper , system , start_state ,
boost::begin( times ) , boost::end( times ) , dt , observer , checker );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class TimeRange , class Time , class Observer , class StepOverflowChecker >
size_t integrate_times(
Stepper stepper , System system , const State &start_state ,
const TimeRange &times , Time dt ,
Observer observer , StepOverflowChecker checker )
{
return integrate_times(
stepper , system , start_state ,
boost::begin( times ) , boost::end( times ) , dt , observer , checker );
}
/*
* The same functions as above, but without a StepOverflowChecker
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
TimeIterator times_start , TimeIterator times_end , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
// simply don't use checked_* adapters
return detail::integrate_times(
stepper , system , start_state ,
times_start , times_end , dt ,
observer , stepper_category() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , const State &start_state ,
TimeIterator times_start , TimeIterator times_end , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_times(
stepper , system , start_state ,
times_start , times_end , dt ,
observer , stepper_category() );
}
/**
* \brief The same function as above, but with the observation times given as range.
*/
template< class Stepper , class System , class State , class TimeRange , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
const TimeRange &times , Time dt ,
Observer observer )
{
return integrate_times(
stepper , system , start_state ,
boost::begin( times ) , boost::end( times ) , dt , observer );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class TimeRange , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , const State &start_state ,
const TimeRange &times , Time dt ,
Observer observer )
{
return integrate_times(
stepper , system , start_state ,
boost::begin( times ) , boost::end( times ) , dt , observer);
}
/********* DOXYGEN ***********/
/**
* \fn size_t integrate_times( Stepper stepper , System system , State &start_state , TimeIterator times_start , TimeIterator times_end , Time dt , Observer observer )
* \brief Integrates the ODE with observer calls at given time points.
*
* Integrates the ODE given by system using the given stepper. This function
* does observer calls at the subsequent time points given by the range
* times_start, times_end. If the stepper has not step size control, the
* step size might be reduced occasionally to ensure observer calls exactly
* at the time points from the given sequence. If the stepper is a
* ControlledStepper, the step size is adjusted to meet the error bounds,
* but also might be reduced occasionally to ensure correct observer calls.
* If a DenseOutputStepper is provided, the dense output functionality is
* used to call the observer at the given times. The end time of the
* integration is always *(end_time-1).
* If a max_step_checker is provided as StepOverflowChecker, a
* no_progress_error is thrown if too many steps (default: 500) are
* performed without progress, i.e. in between observer calls. If no
* checker is provided, no such overflow check is performed.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param times_start Iterator to the start time
* \param times_end Iterator to the end time
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param observer Function/Functor called at equidistant time intervals.
* \param checker [optional] Functor to check for step count overflows, if no
* checker is provided, no exception is thrown.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED

View File

@@ -0,0 +1,114 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/max_step_checker.hpp
[begin_description]
Throws exception if too many steps are performed.
[end_description]
Copyright 2015 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_INTEGRATE_MAX_STEP_CHECKER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_MAX_STEP_CHECKER_HPP_INCLUDED
#include <stdexcept>
#include <cstdio>
#include <boost/throw_exception.hpp>
#include <boost/numeric/odeint/util/odeint_error.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/**
* \brief A class for performing overflow checks on the step count in integrate functions.
*
* Provide an instance of this class to integrate functions if you want to throw a runtime error if
* too many steps are performed without progress during the integrate routine.
*/
class max_step_checker
{
public:
protected:
const int m_max_steps;
int m_steps;
public:
/**
* \brief Construct the max_step_checker.
* max_steps is the maximal number of iterations allowed before runtime_error is thrown.
*/
max_step_checker(const int max_steps = 500)
: m_max_steps(max_steps)
{
reset();
}
/**
* \brief Resets the max_step_checker by setting the internal counter to 0.
*/
void reset()
{
m_steps = 0;
}
/**
* \brief Increases the counter and performs the iteration check
*/
void operator()(void)
{
if( m_steps++ >= m_max_steps )
{
char error_msg[200];
std::snprintf(error_msg, 200, "Max number of iterations exceeded (%d).", m_max_steps);
BOOST_THROW_EXCEPTION( no_progress_error(error_msg) );
}
}
};
/**
* \brief A class for performing overflow checks on the failed step count in step size adjustments.
*
* Used internally within the dense output stepper and integrate routines.
*/
class failed_step_checker : public max_step_checker
{
public:
/**
* \brief Construct the failed_step_checker.
* max_steps is the maximal number of iterations allowed before runtime_error is thrown.
*/
failed_step_checker(const int max_steps = 500)
: max_step_checker(max_steps)
{}
/**
* \brief Increases the counter and performs the iteration check
*/
void operator()(void)
{
if( m_steps++ >= m_max_steps )
{
char error_msg[200];
std::snprintf(error_msg, 200, "Max number of iterations exceeded (%d). A new step size was not found.", m_max_steps);
BOOST_THROW_EXCEPTION( step_adjustment_error(error_msg) );
}
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif

View File

@@ -0,0 +1,38 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/null_observer.hpp
[begin_description]
null_observer
[end_description]
Copyright 2011-2012 Karsten Ahnert
Copyright 2011-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_INTEGRATE_NULL_OBSERVER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_NULL_OBSERVER_HPP_INCLUDED
namespace boost {
namespace numeric {
namespace odeint {
struct null_observer
{
template< class State , class Time >
void operator()( const State& /* x */ , Time /* t */ ) const
{
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_NULL_OBSERVER_HPP_INCLUDED

View File

@@ -0,0 +1,55 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/observer_collection.hpp
[begin_description]
Collection of observers, which are all called during the evolution of the ODE.
[end_description]
Copyright 2011-2012 Karsten Ahnert
Copyright 2011-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_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
#include <vector>
#include <functional>
namespace boost {
namespace numeric {
namespace odeint {
template< class State , class Time >
class observer_collection
{
public:
typedef std::function< void( const State& , const Time& ) > observer_type;
typedef std::vector< observer_type > collection_type;
void operator()( const State& x , Time t )
{
for( size_t i=0 ; i<m_observers.size() ; ++i )
m_observers[i]( x , t );
}
collection_type& observers( void ) { return m_observers; }
const collection_type& observers( void ) const { return m_observers; }
private:
collection_type m_observers;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED

View File

@@ -0,0 +1,183 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/adaptive_iterator.hpp
[begin_description]
Iterator for iterating throught the solution of an ODE with adaptive step size. The dereferenced types containes also the time.
[end_description]
Copyright 2012-2013 Karsten Ahnert
Copyright 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_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the adaptive_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class adaptive_iterator : public adaptive_iterator_impl<
adaptive_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef adaptive_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
adaptive_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
: adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
adaptive_iterator( Stepper stepper , System sys , State &s )
: adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
template< class Stepper , class System , class State >
adaptive_iterator< Stepper , System , State > make_adaptive_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return adaptive_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
}
template< class Stepper , class System , class State >
adaptive_iterator< Stepper , System , State > make_adaptive_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return adaptive_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< adaptive_iterator< Stepper , System , State > , adaptive_iterator< Stepper , System , State > >
make_adaptive_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
adaptive_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
adaptive_iterator< Stepper , System , State >( stepper , system , x )
);
}
/**
* \class adaptive_iterator
*
* \brief ODE Iterator with adaptive step size. The value type of this iterator is the state type of the stepper.
*
* Implements an iterator representing the solution of an ODE from t_start
* to t_end evaluated at steps with an adaptive step size dt.
* After each iteration the iterator dereferences to the state x at the next
* time t+dt where dt is controlled by the stepper.
* This iterator can be used with ControlledSteppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_adaptive routine.
*
* adaptive_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_adaptive_iterator_begin( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function for adaptive_iterator. Constructs a begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state.
* \param t_start The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
* \returns The adaptive iterator.
*/
/**
* \fn make_adaptive_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for adaptive_iterator. Constructs a end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state.
* \returns The adaptive iterator.
*/
/**
* \fn make_adaptive_range( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function to construct a single pass range of adaptive iterators. A range is here a pair of adaptive_iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state.
* \param t_start The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
* \returns The adaptive range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,175 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/adaptive_time_iterator.hpp
[begin_description]
Iterator for iterating throught the solution of an ODE with adaptive step size. The dereferenced types containes also the time.
[end_description]
Copyright 2012-2013 Karsten Ahnert
Copyright 2012-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_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the adaptive_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class adaptive_time_iterator : public adaptive_iterator_impl<
adaptive_time_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef adaptive_time_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
adaptive_time_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
: adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
adaptive_time_iterator( Stepper stepper , System sys , State &s )
: adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
template< class Stepper , class System , class State >
adaptive_time_iterator< Stepper , System , State > make_adaptive_time_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return adaptive_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
}
template< class Stepper , class System , class State >
adaptive_time_iterator< Stepper , System , State > make_adaptive_time_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return adaptive_time_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< adaptive_time_iterator< Stepper , System , State > , adaptive_time_iterator< Stepper , System , State > >
make_adaptive_time_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
adaptive_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
adaptive_time_iterator< Stepper , System , State >( stepper , system , x ) );
}
/**
* \class adaptive_time_iterator
*
* \brief ODE Iterator with adaptive step size. The value type of this iterator is a std::pair containing state and time.
*
* Implements an iterator representing the solution of an ODE from t_start
* to t_end evaluated at steps with an adaptive step size dt.
* After each iteration the iterator dereferences to a pair containing state
* and time at the next time point t+dt where dt is controlled by the stepper.
* This iterator can be used with ControlledSteppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_adaptive routine.
*
* adaptive_iterator is a model of single-pass iterator.
*
* The value type of this iterator is a std::pair of state and time of the stepper.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_adaptive_time_iterator_begin( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function for adaptive_time_iterator. Constructs a begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
* \param t_start The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
* \returns The adaptive time iterator.
*/
/**
* \fn make_adaptive_time_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for adaptive_time_iterator. Constructs a end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
* \returns The adaptive time iterator.
*/
/**
* \fn make_adaptive_time_range( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function to construct a single pass range of adaptive time iterators. A range is here a pair of adaptive_time_iterators.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
* \param t_start The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
* \returns The adaptive time range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,180 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/const_step_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with constant step size.
[end_description]
Copyright 2012-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_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/const_step_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the const_step_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class const_step_iterator : public const_step_iterator_impl<
const_step_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef const_step_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
const_step_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
: const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
const_step_iterator( Stepper stepper , System sys , State &s )
: const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State >
const_step_iterator< Stepper , System, State > make_const_step_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return const_step_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
}
template< class Stepper , class System , class State >
const_step_iterator< Stepper , System , State > make_const_step_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return const_step_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< const_step_iterator< Stepper , System , State > , const_step_iterator< Stepper , System , State > >
make_const_step_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
const_step_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
const_step_iterator< Stepper , System , State >( stepper , system , x )
);
}
/**
* \class const_step_iterator
*
* \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper.
*
* Implements an iterator representing the solution of an ODE from t_start
* to t_end evaluated at steps with constant step size dt.
* After each iteration the iterator dereferences to the state x at the next
* time t+dt.
* This iterator can be used with Steppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_const routine.
*
* const_step_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_const_step_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function for const_step_iterator. Constructs a begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t_start The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
* \returns The const step iterator.
*/
/**
* \fn make_const_step_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for const_step_iterator. Constructs a end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \returns The const_step_iterator.
*/
/**
* \fn make_const_step_range( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function to construct a single pass range of const step iterators. A range is here a pair
* of const_step_iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
* \param t_start The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
* \returns The const step range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
//#include <boost/numeric/odeint/iterator/impl/const_step_iterator_dense_output_impl.hpp>
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,173 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/const_step_time_iterator.hpp
[begin_description]
Iterator for iterating throught the solution of an ODE with constant step size. The dereferences types containes also the time.
[end_description]
Copyright 2012-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_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/const_step_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the const_step_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class const_step_time_iterator : public const_step_iterator_impl<
const_step_time_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef const_step_time_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
const_step_time_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
: const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
const_step_time_iterator( Stepper stepper , System sys , State &s )
: const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
template< class Stepper , class System , class State >
const_step_time_iterator< Stepper , System , State > make_const_step_time_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return const_step_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
}
template< class Stepper , class System , class State >
const_step_time_iterator< Stepper , System , State > make_const_step_time_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return const_step_time_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< const_step_time_iterator< Stepper , System , State > , const_step_time_iterator< Stepper , System , State > >
make_const_step_time_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
const_step_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
const_step_time_iterator< Stepper , System , State >( stepper , system , x ) );
}
/**
* \class const_step_time_iterator
*
* \brief ODE Iterator with constant step size. The value type of this iterator is a std::pair containing state and time.
*
* Implements an iterator representing the solution of an ODE from t_start
* to t_end evaluated at steps with constant step size dt.
* After each iteration the iterator dereferences to a pair containing
* state and time at the next time point t+dt..
* This iterator can be used with Steppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_const routine.
*
* const_step_time_iterator is a model of single-pass iterator.
*
* The value type of this iterator is a pair with the state type and time type of the stepper.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_const_step_time_iterator_begin( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function for const_step_time_iterator. Constructs a begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_time_iterator stores a reference of s and changes its value during the iteration.
* \param t_start The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
* \returns The const step time iterator.
*/
/**
* \fn make_const_step_time_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for const_step_time_iterator. Constructs a end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_time_iterator store a reference of s and changes its value during the iteration.
* \returns The const step time iterator.
*/
/**
* \fn make_const_step_time_range( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt)
*
* \brief Factory function to construct a single pass range of const_step_time_iterator. A range is here a pair of const_step_time_iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_time_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
* \returns The const step time range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,199 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp
[begin_description]
Base class for const_step_iterator and adaptive_iterator.
[end_description]
Copyright 2012-2013 Karsten Ahnert
Copyright 2012-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_ITERATOR_DETAIL_ODE_ITERATOR_BASE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_ITERATOR_BASE_HPP_INCLUDED
#include <boost/iterator/iterator_facade.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
struct ode_state_iterator_tag {};
struct ode_state_time_iterator_tag {};
template< class Iterator , class Stepper , class System , class State , typename Tag >
class ode_iterator_base;
/* Specialization for the state iterator that has only state_type as its value_type */
template< class Iterator , class Stepper , class System , class State >
class ode_iterator_base< Iterator , Stepper , System , State , ode_state_iterator_tag >
: public boost::iterator_facade
<
Iterator ,
typename traits::state_type< Stepper >::type const ,
boost::single_pass_traversal_tag
>
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename unwrapped_stepper_type::time_type time_type;
typedef typename unwrapped_stepper_type::value_type ode_value_type;
public:
ode_iterator_base( stepper_type stepper , system_type sys , time_type t , time_type dt )
: m_stepper( stepper ) , m_system( sys ) ,
m_t( t ) , m_dt( dt ) , m_at_end( false )
{ }
ode_iterator_base( stepper_type stepper , system_type sys )
: m_stepper( stepper ) , m_system( sys ) ,
m_t() , m_dt() , m_at_end( true )
{ }
// this function is only for testing
bool same( const ode_iterator_base &iter ) const
{
return (
//( static_cast<Iterator>(*this).get_state() ==
// static_cast<Iterator>(iter).get_state ) &&
( m_t == iter.m_t ) &&
( m_dt == iter.m_dt ) &&
( m_at_end == iter.m_at_end )
);
}
protected:
friend class boost::iterator_core_access;
bool equal( ode_iterator_base const& other ) const
{
if( m_at_end == other.m_at_end )
{
return true;
}
else
{
return false;
}
}
const state_type& dereference() const
{
return static_cast<const Iterator*>(this)->get_state();
}
protected:
stepper_type m_stepper;
system_type m_system;
time_type m_t;
time_type m_dt;
bool m_at_end;
};
/* Specialization for the state-time iterator that has pair<state_type,time_type> as its value_type */
template< class Iterator , class Stepper , class System , class State >
class ode_iterator_base< Iterator , Stepper , System , State , ode_state_time_iterator_tag >
: public boost::iterator_facade
<
Iterator ,
std::pair< const State , const typename traits::time_type< Stepper >::type > ,
boost::single_pass_traversal_tag ,
std::pair< const State& , const typename traits::time_type< Stepper >::type& >
>
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename unwrapped_stepper_type::time_type time_type;
typedef typename unwrapped_stepper_type::value_type ode_value_type;
public:
ode_iterator_base( stepper_type stepper , system_type sys ,
time_type t , time_type dt )
: m_stepper( stepper ) , m_system( sys ) ,
m_t( t ) , m_dt( dt ) , m_at_end( false )
{ }
ode_iterator_base( stepper_type stepper , system_type sys )
: m_stepper( stepper ) , m_system( sys ) , m_at_end( true )
{ }
bool same( ode_iterator_base const& iter )
{
return (
//( static_cast<Iterator>(*this).get_state() ==
// static_cast<Iterator>(iter).get_state ) &&
( m_t == iter.m_t ) &&
( m_dt == iter.m_dt ) &&
( m_at_end == iter.m_at_end )
);
}
protected:
friend class boost::iterator_core_access;
bool equal( ode_iterator_base const& other ) const
{
if( m_at_end == other.m_at_end )
{
return true;
}
else
{
return false;
}
}
std::pair< const state_type& , const time_type& > dereference() const
{
return std::pair< const state_type & , const time_type & >(
static_cast<const Iterator*>(this)->get_state() , m_t );
}
stepper_type m_stepper;
system_type m_system;
time_type m_t;
time_type m_dt;
bool m_at_end;
};
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_ITERATOR_BASE_HPP_INCLUDED

View File

@@ -0,0 +1,251 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/detail/adaptive_iterator_impl.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_ITERATOR_DETAIL_ADAPTIVE_ITERATOR_IMPL_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ADAPTIVE_ITERATOR_IMPL_HPP_DEFINED
#include <boost/throw_exception.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template< class Iterator , class Stepper , class System , class State , typename Tag , typename StepperTag >
class adaptive_iterator_impl;
/*
* Specilization for controlled steppers
*/
/**
* \brief ODE Iterator with adaptive step size control. The value type of this iterator is the state type of the stepper.
*
* Implements an ODE iterator with adaptive step size control. Uses controlled steppers. adaptive_iterator is a model
* of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Iterator , class Stepper , class System , class State , typename Tag >
class adaptive_iterator_impl< Iterator , Stepper , System , State , Tag , controlled_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. adaptive_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
*/
adaptive_iterator_impl( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , t , dt ) , m_t_end( t_end ) , m_state( &s )
{
if( detail::less_with_sign( this->m_t_end , this->m_t , this->m_dt ) )
this->m_at_end = true;
}
/**
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. adaptive_iterator store a reference of s and changes its value during the iteration.
*/
adaptive_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
if( detail::less_with_sign( this->m_t , this->m_t_end , this->m_dt) )
{
if( detail::less_with_sign( this->m_t_end ,
static_cast<time_type>(this->m_t + this->m_dt) ,
this->m_dt ) )
{
this->m_dt = this->m_t_end - this->m_t;
}
unwrapped_stepper_type &stepper = this->m_stepper;
const size_t max_attempts = 1000;
size_t trials = 0;
controlled_step_result res = success;
do
{
res = stepper.try_step( this->m_system , *( this->m_state ) , this->m_t , this->m_dt );
++trials;
}
while( ( res == fail ) && ( trials < max_attempts ) );
if( trials == max_attempts )
{
BOOST_THROW_EXCEPTION( std::overflow_error( "Adaptive iterator : Maximal number of iterations reached. A step size could not be found." ));
}
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *this->m_state;
}
private:
time_type m_t_end;
state_type* m_state;
};
/*
* Specilization for dense outputer steppers
*/
/**
* \brief ODE Iterator with adaptive step size control. The value type of this iterator is the state type of the stepper.
*
* Implements an ODE iterator with adaptive step size control. Uses dense-output steppers. adaptive_iterator is a model
* of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Iterator , class Stepper , class System , class State , typename Tag >
class adaptive_iterator_impl< Iterator , Stepper , System , State , Tag , dense_output_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state.
* \param t The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
*/
adaptive_iterator_impl( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , t , dt ) , m_t_end( t_end )
{
if( detail::less_eq_with_sign( this->m_t , this->m_t_end , this->m_dt ) )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( s , this->m_t , this->m_dt );
} else {
this->m_at_end = true;
}
}
/**
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state.
*/
adaptive_iterator_impl( stepper_type stepper , system_type sys , state_type& /* s */ )
: base_type( stepper , sys ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
unwrapped_stepper_type &stepper = this->m_stepper;
if( detail::less_with_sign( this->m_t ,
this->m_t_end ,
stepper.current_time_step() ) )
{
if( detail::less_with_sign( this->m_t_end ,
static_cast<time_type>(this->m_t + stepper.current_time_step()) ,
stepper.current_time_step() ) )
{
// make stpper to end exactly at t_end
stepper.initialize( stepper.current_state() , stepper.current_time() ,
static_cast<time_type>(this->m_t_end-this->m_t) );
}
stepper.do_step( this->m_system );
this->m_t = stepper.current_time();
} else { // we have reached t_end
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
const unwrapped_stepper_type &stepper = this->m_stepper;
return stepper.current_state();
}
private:
time_type m_t_end;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ADAPTIVE_ITERATOR_IMPL_HPP_DEFINED

View File

@@ -0,0 +1,228 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/detail/const_step_iterator_impl.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_ITERATOR_DETAIL_CONST_STEP_ITERATOR_IMPL_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_CONST_STEP_ITERATOR_IMPL_HPP_DEFINED
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template< class Iterator , class Stepper , class System , class State , typename Tag , class StepperTag >
class const_step_iterator_impl;
/*
* Specilization for steppers and error steppers
*/
template< class Iterator , class Stepper , class System , class State , typename Tag >
class const_step_iterator_impl< Iterator , Stepper , System , State , Tag , stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a const_step_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
*/
const_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , t , dt ) , m_t_start( t ) , m_t_end( t_end ) , m_state( &s ) , m_step( 0 )
{
if( detail::less_with_sign( this->m_t_end , this->m_t , this->m_dt ) )
this->m_at_end = true;
}
/**
* \brief Constructs a const_step_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
*/
const_step_iterator_impl( stepper_type stepper , system_type sys , state_type& /* s */ )
: base_type( stepper , sys ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
if( detail::less_eq_with_sign( static_cast<time_type>(this->m_t+this->m_dt) ,
this->m_t_end , this->m_dt ) )
{
unwrapped_stepper_type &stepper = this->m_stepper;
stepper.do_step( this->m_system , *this->m_state , this->m_t , this->m_dt );
// use integer to compute current time to reduce roundoff errors
this->m_step++;
this->m_t = this->m_t_start + static_cast< typename unit_value_type<time_type>::type >(this->m_step)*this->m_dt;
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_type m_t_start;
time_type m_t_end;
state_type* m_state;
size_t m_step;
};
/*
* Specilization for dense output stepper
*/
/**
* \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper.
*
* Implements an ODE iterator solving the ODE with constant steps. Uses dense-output steppers.
* const_step_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Iterator , class Stepper , class System , class State , typename Tag >
class const_step_iterator_impl< Iterator , Stepper , System , State , Tag , dense_output_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a const_step_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
*/
const_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , t , dt ) , m_t_start( t ) , m_t_end( t_end ) , m_state( &s ) , m_step( 0 )
{
if( detail::less_eq_with_sign( this->m_t , this->m_t_end , this->m_dt ) )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( * ( this->m_state ) , this->m_t , this->m_dt );
} else {
this->m_at_end = true;
}
}
/**
* \brief Constructs a const_step_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
*/
const_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s )
{
}
protected:
friend class boost::iterator_core_access;
void increment( void )
{
if( detail::less_eq_with_sign( static_cast<time_type>(this->m_t+this->m_dt) ,
this->m_t_end , this->m_dt ) )
{
unwrapped_stepper_type &stepper = this->m_stepper;
// use integer to compute current time to reduce roundoff errors
this->m_step++;
this->m_t = this->m_t_start + static_cast< typename unit_value_type<time_type>::type >(this->m_step)*this->m_dt;
while( detail::less_with_sign( stepper.current_time() , this->m_t ,
stepper.current_time_step() ) )
{
stepper.do_step( this->m_system );
}
stepper.calc_state( this->m_t , *( this->m_state ) );
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_type m_t_start;
time_type m_t_end;
state_type* m_state;
size_t m_step;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_CONST_STEP_ITERATOR_IMPL_HPP_DEFINED

View File

@@ -0,0 +1,239 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/detail/n_step_iterator_impl.hpp
[begin_description]
tba.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_ITERATOR_DETAIL_N_STEP_ITERATOR_IMPL_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_N_STEP_ITERATOR_IMPL_HPP_DEFINED
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template< class Iterator , class Stepper , class System , class State , typename Tag , class StepperTag >
class n_step_iterator_impl;
/*
* Specilization for steppers and error steppers
*/
/**
* \brief ODE Iterator performing exactly n steps with constant step size. The value type of this iterator is the state type of the stepper.
*
* Implements an ODE iterator solving the ODE with constant step size. Uses steppers fulfilling the Stepper concept.
* n_step_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Iterator , class Stepper , class System , class State , typename Tag >
class n_step_iterator_impl< Iterator , Stepper , System , State , Tag , stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a n_step_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps the number of steps to be executed.
*/
n_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_type t , time_type dt , size_t num_of_steps )
: base_type( stepper , sys , t , dt ) , m_t_start( t ) , m_state( &s ) ,
m_steps(num_of_steps) , m_step( 0 )
{ }
/**
* \brief Constructs a const_step_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
*/
n_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
if( this->m_step < this->m_steps )
{
unwrapped_stepper_type &stepper = this->m_stepper;
stepper.do_step( this->m_system , *this->m_state , this->m_t , this->m_dt );
// use integer to compute current time to reduce roundoff errors
this->m_step++;
this->m_t = this->m_t_start + static_cast< typename unit_value_type<time_type>::type >(this->m_step)*this->m_dt;
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_type m_t_start;
time_type m_t_end;
state_type* m_state;
size_t m_steps;
size_t m_step;
};
/*
* Specilization for dense output stepper
*/
/**
* \brief ODE Iterator with step-size control and dense output.
*
* Implements an ODE iterator solving the ODE with constant steps. Uses dense-output steppers.
* n_step_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Iterator , class Stepper , class System , class State , typename Tag >
class n_step_iterator_impl< Iterator , Stepper , System , State , Tag , dense_output_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a const_step_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps the number of steps to be executed.
*/
n_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_type t , time_type dt , size_t num_of_steps )
: base_type( stepper , sys , t , dt ) , m_t_start( t ) , m_state( &s ) ,
m_steps( num_of_steps ) , m_step( 0 )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( * ( this->m_state ) , this->m_t , this->m_dt );
}
/**
* \brief Constructs a const_step_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
*/
n_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s )
{
}
protected:
friend class boost::iterator_core_access;
void increment( void )
{
if( this->m_step < this->m_steps )
{
unwrapped_stepper_type &stepper = this->m_stepper;
// use integer to compute current time to reduce roundoff errors
this->m_step++;
this->m_t = this->m_t_start + static_cast< typename unit_value_type<time_type>::type >(this->m_step)*this->m_dt;
while( detail::less_with_sign( stepper.current_time() , this->m_t ,
stepper.current_time_step() ) )
{
stepper.do_step( this->m_system );
}
stepper.calc_state( this->m_t , *( this->m_state ) );
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_type m_t_start;
time_type m_t_end;
state_type* m_state;
size_t m_steps;
size_t m_step;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_N_STEP_ITERATOR_IMPL_HPP_DEFINED

View File

@@ -0,0 +1,369 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/detail/times_iterator_impl.hpp
[begin_description]
tba.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_ITERATOR_DETAIL_TIMES_ITERATOR_IMPL_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_TIMES_ITERATOR_IMPL_HPP_DEFINED
#include <boost/throw_exception.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template< class Iterator , class Stepper , class System , class State , class TimeIterator ,
typename Tag , typename StepperTag >
class times_iterator_impl;
/*
* Specilization for basic steppers
*/
/**
* \brief ODE Iterator with constant step size.
*
* Implements an ODE iterator with observer calls at predefined times.
* Uses controlled steppers. times_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Iterator , class Stepper , class System , class State , class TimeIterator , typename Tag >
class times_iterator_impl< Iterator , Stepper , System , State , TimeIterator , Tag , stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef TimeIterator time_iterator_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a times_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. adaptive_iterator stores a reference of s and changes its value during the iteration.
* \param t_start Iterator to the begin of a sequence of time values.
* \param t_end Iterator to the begin of a sequence of time values.
* \param dt The (initial) time step.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_iterator_type t_start , time_iterator_type t_end , time_type dt )
: base_type( stepper , sys , *t_start , dt ) ,
m_t_start( t_start ) , m_t_end( t_end ) , m_state( &s )
{
if( t_start == t_end )
this->m_at_end = true;
}
/**
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. adaptive_iterator store a reference of s and changes its value during the iteration.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
unwrapped_stepper_type &stepper = this->m_stepper;
if( ++m_t_start != m_t_end )
{
while( detail::less_with_sign( this->m_t , static_cast<time_type>(*m_t_start) , this->m_dt ) )
{
const time_type current_dt = detail::min_abs( this->m_dt , static_cast<time_type>(*m_t_start) - this->m_t );
stepper.do_step( this->m_system , *( this->m_state ) , this->m_t , current_dt );
this->m_t += current_dt;
}
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_iterator_type m_t_start;
time_iterator_type m_t_end;
state_type* m_state;
};
/*
* Specilization for controlled steppers
*/
/**
* \brief ODE Iterator with adaptive step size control. The value type of this iterator is the state type of the stepper.
*
* Implements an ODE iterator with observer calls at predefined times.
* Uses controlled steppers. times_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Iterator , class Stepper , class System , class State , class TimeIterator , typename Tag >
class times_iterator_impl< Iterator , Stepper , System , State , TimeIterator , Tag , controlled_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef TimeIterator time_iterator_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a times_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. adaptive_iterator stores a reference of s and changes its value during the iteration.
* \param t_start Iterator to the begin of a sequence of time values.
* \param t_end Iterator to the begin of a sequence of time values.
* \param dt The (initial) time step.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_iterator_type t_start , time_iterator_type t_end , time_type dt )
: base_type( stepper , sys , *t_start , dt ) ,
m_t_start( t_start ) , m_t_end( t_end ) , m_state( &s )
{
if( t_start == t_end )
this->m_at_end = true;
}
/**
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. adaptive_iterator store a reference of s and changes its value during the iteration.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
if( ++m_t_start != m_t_end )
{
while( detail::less_with_sign( this->m_t , static_cast<time_type>(*m_t_start) , this->m_dt ) )
{
if( detail::less_with_sign( static_cast<time_type>(*m_t_start) - this->m_t , this->m_dt , this->m_dt ) )
{
// we want to end exactly at the time point
time_type current_dt = static_cast<time_type>(*m_t_start) - this->m_t;
step_loop( current_dt );
} else {
step_loop( this->m_dt );
}
}
} else {
this->m_at_end = true;
}
}
private:
void step_loop( time_type &dt )
{
unwrapped_stepper_type &stepper = this->m_stepper;
const size_t max_attempts = 1000;
size_t trials = 0;
controlled_step_result res = success;
do
{
res = stepper.try_step( this->m_system , *( this->m_state ) , this->m_t , dt );
++trials;
}
while( ( res == fail ) && ( trials < max_attempts ) );
if( trials == max_attempts )
{
BOOST_THROW_EXCEPTION( std::overflow_error( "Adaptive iterator : Maximal number of iterations reached. A step size could not be found." ) );
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_iterator_type m_t_start;
time_iterator_type m_t_end;
state_type* m_state;
};
/*
* Specilization for dense outputer steppers
*/
/**
* \brief ODE Iterator with step size control and dense output.
* Implements an ODE iterator with adaptive step size control. Uses dense-output steppers.
* times_iterator is a model of single-pass iterator.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Iterator , class Stepper , class System , class State , class TimeIterator , typename Tag >
class times_iterator_impl< Iterator , Stepper , System , State , TimeIterator , Tag , dense_output_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef TimeIterator time_iterator_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a times_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state.
* \param t_start Iterator to the begin of a sequence of time values.
* \param t_end Iterator to the begin of a sequence of time values.
* \param dt The (initial) time step.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_iterator_type t_start , time_iterator_type t_end , time_type dt )
: base_type( stepper , sys , *t_start , dt ) ,
m_t_start( t_start ) , m_t_end( t_end ) , m_final_time( *(t_end-1) ) ,
m_state( &s )
{
if( t_start != t_end )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( *( this->m_state ) , this->m_t , this->m_dt );
} else {
this->m_at_end = true;
}
}
/**
* \brief Constructs a times_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
unwrapped_stepper_type &st = this->m_stepper;
if( ++m_t_start != m_t_end )
{
this->m_t = static_cast<time_type>(*m_t_start);
while( detail::less_with_sign( st.current_time() , this->m_t , this->m_dt ) )
{
// make sure we don't go beyond the last point
if( detail::less_with_sign( m_final_time-st.current_time() , st.current_time_step() , st.current_time_step() ) )
{
st.initialize( st.current_state() , st.current_time() , m_final_time-st.current_time() );
}
st.do_step( this->m_system );
}
st.calc_state( this->m_t , *( this->m_state ) );
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_iterator_type m_t_start;
time_iterator_type m_t_end;
time_type m_final_time;
state_type* m_state;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_TIMES_ITERATOR_IMPL_HPP_DEFINED

View File

@@ -0,0 +1,70 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/functors.hpp
[begin_description]
some functors for the iterator based integrate routines
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED
#include <utility>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< class Observer >
struct obs_caller {
size_t &m_n;
Observer m_obs;
obs_caller( size_t &m , Observer &obs ) : m_n(m) , m_obs( obs ) {}
template< class State , class Time >
void operator()( std::pair< const State & , const Time & > x )
{
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
observer_type &obs = m_obs;
obs( x.first , x.second );
m_n++;
}
};
template< class Observer , class Time >
struct obs_caller_time {
Time &m_t;
Observer m_obs;
obs_caller_time( Time &t , Observer &obs ) : m_t(t) , m_obs( obs ) {}
template< class State >
void operator()( std::pair< const State & , const Time & > x )
{
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
observer_type &obs = m_obs;
obs( x.first , x.second );
m_t = x.second;
}
};
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED

View File

@@ -0,0 +1,121 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp
[begin_description]
Default Integrate adaptive implementation.
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#include <stdexcept>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_const.hpp>
#include <boost/numeric/odeint/iterator/adaptive_time_iterator.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
#include <boost/numeric/odeint/util/bind.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer>
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , stepper_tag );
/*
* integrate_adaptive for simple stepper is basically an integrate_const + some last step
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , stepper_tag
)
{
size_t steps = detail::integrate_const( stepper , system , start_state , start_time ,
end_time , dt , observer , stepper_tag() );
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
Time end = start_time + dt*steps;
if( less_with_sign( end , end_time , dt ) )
{ //make a last step to end exactly at end_time
st.do_step( system , start_state , end , end_time - end );
steps++;
obs( start_state , end_time );
}
return steps;
}
/*
* classical integrate adaptive
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
Observer observer , controlled_stepper_tag
)
{
size_t obs_calls = 0;
boost::for_each( make_adaptive_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
obs_caller< Observer >( obs_calls , observer ) );
return obs_calls-1;
}
/*
* integrate adaptive for dense output steppers
*
* step size control is used if the stepper supports it
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , dense_output_stepper_tag )
{
size_t obs_calls = 0;
boost::for_each( make_adaptive_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
obs_caller< Observer >( obs_calls , observer ) );
return obs_calls-1;
}
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED

View File

@@ -0,0 +1,111 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_const.hpp
[begin_description]
integrate const implementation
[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_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_INCLUDED
#include <boost/range/algorithm/for_each.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/iterator/const_step_time_iterator.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_adaptive.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
Observer observer , controlled_stepper_tag
);
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , stepper_tag
)
{
size_t obs_calls = 0;
boost::for_each( make_const_step_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
// should we use traits<Stepper>::state_type here instead of State? NO!
obs_caller< Observer >( obs_calls , observer ) );
// step integration steps gives step+1 observer calls
return obs_calls-1;
}
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , controlled_stepper_tag
)
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
Time time = start_time;
const Time time_step = dt;
int step = 0;
while( less_eq_with_sign( static_cast<Time>(time+time_step) , end_time , dt ) )
{
obs( start_state , time );
detail::integrate_adaptive( stepper , system , start_state , time , time+time_step , dt ,
null_observer() , controlled_stepper_tag() );
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
++step;
time = start_time + static_cast< typename unit_value_type<Time>::type >(step) * time_step;
}
obs( start_state , time );
return step;
}
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , dense_output_stepper_tag
)
{
size_t obs_calls = 0;
boost::for_each( make_const_step_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
obs_caller< Observer >( obs_calls , observer ) );
return obs_calls-1;
}
} } } }
#endif

View File

@@ -0,0 +1,107 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp
[begin_description]
integrate steps implementation
[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_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_adaptive.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
#include <boost/numeric/odeint/iterator/n_step_time_iterator.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
Observer observer , controlled_stepper_tag
);
/* basic version */
template< class Stepper , class System , class State , class Time , class Observer>
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , stepper_tag )
{
// ToDo: is there a better way to extract the final time?
Time t = start_time; // Assignment is only here to avoid warnings.
boost::for_each( make_n_step_time_range( stepper , system , start_state ,
start_time , dt , num_of_steps ) ,
obs_caller_time< Observer , Time >( t , observer ) );
return t;
}
/* controlled version */
template< class Stepper , class System , class State , class Time , class Observer>
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , controlled_stepper_tag )
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
Time time = start_time;
Time time_step = dt;
for( size_t step = 0; step < num_of_steps ; ++step )
{
obs( start_state , time );
detail::integrate_adaptive( stepper , system , start_state , time , static_cast<Time>(time+time_step) , dt ,
null_observer() , controlled_stepper_tag() );
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
time = start_time + static_cast< typename unit_value_type<Time>::type >(step+1) * time_step;
}
obs( start_state , time );
return time;
}
/* dense output version */
template< class Stepper , class System , class State , class Time , class Observer>
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , dense_output_stepper_tag )
{
// ToDo: is there a better way to extract the final time?
Time t = start_time; // Assignment is only here to avoid warnings.
boost::for_each( make_n_step_time_range( stepper , system , start_state ,
start_time , dt , num_of_steps ) ,
obs_caller_time< Observer , Time >( t , observer ) );
return t;
}
}
}
}
}
#endif /* BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED */

View File

@@ -0,0 +1,67 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_times.hpp
[begin_description]
Default integrate times implementation.
[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_INTEGRATE_DETAIL_INTEGRATE_TIMES_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_TIMES_HPP_INCLUDED
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/range/algorithm/for_each.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
#include <boost/numeric/odeint/iterator/times_time_iterator.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
/*
* integrate_times for all steppers
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer , class StepperTag >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
TimeIterator start_time , TimeIterator end_time , Time dt ,
Observer observer , StepperTag
)
{
size_t obs_calls = 0;
boost::for_each( make_times_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
// should we use traits<Stepper>::state_type here instead of State? NO!
obs_caller< Observer >( obs_calls , observer ) );
// step integration steps gives step+1 observer calls
return obs_calls-1;
}
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED

View File

@@ -0,0 +1,111 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate.hpp
[begin_description]
Convenience methods which choose the stepper for the current ODE.
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_INTEGRATE_INTEGRATE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_HPP_INCLUDED
#include <boost/utility/enable_if.hpp>
#include <boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp>
#include <boost/numeric/odeint/stepper/controlled_runge_kutta.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/integrate_adaptive.hpp>
// for has_value_type trait
#include <boost/numeric/odeint/algebra/detail/extract_value_type.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* ToDo :
*
* determine type of dxdt for units
*
*/
template< class System , class State , class Time , class Observer >
typename boost::enable_if< typename has_value_type<State>::type , size_t >::type
integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
{
typedef controlled_runge_kutta< runge_kutta_dopri5< State , typename State::value_type , State , Time > > stepper_type;
return integrate_adaptive( stepper_type() , system , start_state , start_time , end_time , dt , observer );
}
/*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class System , class State , class Time >
size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
{
return integrate( system , start_state , start_time , end_time , dt , null_observer() );
}
/**
* \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
* \brief Integrates the ODE.
*
* Integrates the ODE given by system from start_time to end_time starting
* with start_state as initial condition and dt as initial time step.
* This function uses a dense output dopri5 stepper and performs an adaptive
* integration with step size control, thus dt changes during the integration.
* This method uses standard error bounds of 1E-6.
* After each step, the observer is called.
*
* \param system The system function to solve, hence the r.h.s. of the
* ordinary differential equation.
* \param start_state The initial state.
* \param start_time Start time of the integration.
* \param end_time End time of the integration.
* \param dt Initial step size, will be adjusted during the integration.
* \param observer Observer that will be called after each time step.
* \return The number of steps performed.
*/
/**
* \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
* \brief Integrates the ODE without observer calls.
*
* Integrates the ODE given by system from start_time to end_time starting
* with start_state as initial condition and dt as initial time step.
* This function uses a dense output dopri5 stepper and performs an adaptive
* integration with step size control, thus dt changes during the integration.
* This method uses standard error bounds of 1E-6.
* No observer is called.
*
* \param system The system function to solve, hence the r.h.s. of the
* ordinary differential equation.
* \param start_state The initial state.
* \param start_time Start time of the integration.
* \param end_time End time of the integration.
* \param dt Initial step size, will be adjusted during the integration.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_HPP_INCLUDED

View File

@@ -0,0 +1,127 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_adaptive.hpp
[begin_description]
Adaptive integration of ODEs.
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_adaptive.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
/*
* Suggestion for a new extendable version:
*
* integrator_adaptive< Stepper , System, State , Time , Observer , typename Stepper::stepper_category > integrator;
* return integrator.run( stepper , system , start_state , start_time , end_time , dt , observer );
*/
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
/**
* \brief integrate_adaptive without an observer.
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt )
{
return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_adaptive(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt )
{
return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/************* DOXYGEN ************/
/**
* \fn integrate_adaptive( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
* \brief Integrates the ODE with adaptive step size.
*
* This function integrates the ODE given by system with the given stepper.
* The observer is called after each step. If the stepper has no error
* control, the step size remains constant and the observer is called at
* equidistant time points t0+n*dt. If the stepper is a ControlledStepper,
* the step size is adjusted and the observer is called in non-equidistant
* intervals.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param start_time The initial time t0.
* \param end_time The final integration time tend.
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param observer Function/Functor called at equidistant time intervals.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED

View File

@@ -0,0 +1,158 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_const.hpp
[begin_description]
Constant integration of ODEs, meaning that the state of the ODE is observed on constant time intervals.
The routines makes full use of adaptive and dense-output methods.
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED
#include <type_traits>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_const.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_adaptive.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* Integrates with constant time step dt.
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer
)
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
// we want to get as fast as possible to the end
BOOST_IF_CONSTEXPR ( std::is_same< null_observer , Observer >::value )
{
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
else
{
return detail::integrate_const( stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer
)
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
// we want to get as fast as possible to the end
BOOST_IF_CONSTEXPR ( std::is_same< null_observer , Observer >::value )
{
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
else
{
return detail::integrate_const( stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
}
/**
* \brief integrate_const without observer calls
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt
)
{
return integrate_const( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_const(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt
)
{
return integrate_const( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/********* DOXYGEN *********/
/**
* \fn integrate_const( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
* \brief Integrates the ODE with constant step size.
*
* Integrates the ODE defined by system using the given stepper.
* This method ensures that the observer is called at constant intervals dt.
* If the Stepper is a normal stepper without step size control, dt is also
* used for the numerical scheme. If a ControlledStepper is provided, the
* algorithm might reduce the step size to meet the error bounds, but it is
* ensured that the observer is always called at equidistant time points
* t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
* and the dense output is used to call the observer at equidistant time
* points.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param start_time The initial time t0.
* \param end_time The final integration time tend.
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param observer Function/Functor called at equidistant time intervals.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED

View File

@@ -0,0 +1,123 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_n_steps.hpp
[begin_description]
Integration of n steps with constant time size. Adaptive and dense-output methods are fully supported.
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_n_steps.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* Integrates n steps
*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class Stepper , class System , class State , class Time , class Observer>
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_n_steps(
stepper , system , start_state ,
start_time , dt , num_of_steps ,
observer , stepper_category() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time , class Observer >
Time integrate_n_steps(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_n_steps(
stepper , system , start_state ,
start_time , dt , num_of_steps ,
observer , stepper_category() );
}
/**
* \brief The same function as above, but without observer calls.
*/
template< class Stepper , class System , class State , class Time >
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps )
{
return integrate_n_steps( stepper , system , start_state , start_time , dt , num_of_steps , null_observer() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time >
Time integrate_n_steps(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time dt , size_t num_of_steps )
{
return integrate_n_steps( stepper , system , start_state , start_time , dt , num_of_steps , null_observer() );
}
/************* DOXYGEN *************/
/**
* \fn Time integrate_n_steps( Stepper stepper , System system , State &start_state , Time start_time , Time dt , size_t num_of_steps , Observer observer )
* \brief Integrates the ODE with constant step size.
*
* This function is similar to integrate_const. The observer is called at
* equidistant time intervals t0 + n*dt.
* If the Stepper is a normal stepper without step size control, dt is also
* used for the numerical scheme. If a ControlledStepper is provided, the
* algorithm might reduce the step size to meet the error bounds, but it is
* ensured that the observer is always called at equidistant time points
* t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
* and the dense output is used to call the observer at equidistant time
* points. The final integration time is always t0 + num_of_steps*dt.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param start_time The initial time t0.
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param num_of_steps Number of steps to be performed
* \param observer Function/Functor called at equidistant time intervals.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED

View File

@@ -0,0 +1,131 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_times.hpp
[begin_description]
Integration of ODEs with observation at user defined points
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED
#include <boost/range.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_times.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
TimeIterator times_start , TimeIterator times_end , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_times(
stepper , system , start_state ,
times_start , times_end , dt ,
observer , stepper_category() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , const State &start_state ,
TimeIterator times_start , TimeIterator times_end , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_times(
stepper , system , start_state ,
times_start , times_end , dt ,
observer , stepper_category() );
}
/**
* \brief The same function as above, but without observer calls.
*/
template< class Stepper , class System , class State , class TimeRange , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
const TimeRange &times , Time dt ,
Observer observer )
{
return integrate_times(
stepper , system , start_state ,
boost::begin( times ) , boost::end( times ) , dt , observer );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class TimeRange , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , const State &start_state ,
const TimeRange &times , Time dt ,
Observer observer )
{
return integrate_times(
stepper , system , start_state ,
boost::begin( times ) , boost::end( times ) , dt , observer );
}
/********* DOXYGEN ***********/
/**
* \fn size_t integrate_times( Stepper stepper , System system , State &start_state , TimeIterator times_start , TimeIterator times_end , Time dt , Observer observer )
* \brief Integrates the ODE with observer calls at given time points.
*
* Integrates the ODE given by system using the given stepper. This function
* does observer calls at the subsequent time points given by the range
* times_start, times_end. If the stepper has not step size control, the
* step size might be reduced occasionally to ensure observer calls exactly
* at the time points from the given sequence. If the stepper is a
* ControlledStepper, the step size is adjusted to meet the error bounds,
* but also might be reduced occasionally to ensure correct observer calls.
* If a DenseOutputStepper is provided, the dense output functionality is
* used to call the observer at the given times. The end time of the
* integration is always *(end_time-1).
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param times_start Iterator to the start time
* \param times_end Iterator to the end time
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param observer Function/Functor called at equidistant time intervals.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED

View File

@@ -0,0 +1,38 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/null_observer.hpp
[begin_description]
null_observer
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_INTEGRATE_NULL_OBSERVER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_NULL_OBSERVER_HPP_INCLUDED
namespace boost {
namespace numeric {
namespace odeint {
struct null_observer
{
template< class State , class Time >
void operator()( const State& /* x */ , Time /* t */ ) const
{
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_NULL_OBSERVER_HPP_INCLUDED

View File

@@ -0,0 +1,55 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/observer_collection.hpp
[begin_description]
Collection of observers, which are all called during the evolution of the ODE.
[end_description]
Copyright 2009-2011 Karsten Ahnert
Copyright 2009-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_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
#include <vector>
#include <functional>
namespace boost {
namespace numeric {
namespace odeint {
template< class State , class Time >
class observer_collection
{
public:
typedef std::function< void( const State& , const Time& ) > observer_type;
typedef std::vector< observer_type > collection_type;
void operator()( const State& x , Time t )
{
for( size_t i=0 ; i<m_observers.size() ; ++i )
m_observers[i]( x , t );
}
collection_type& observers( void ) { return m_observers; }
const collection_type& observers( void ) const { return m_observers; }
private:
collection_type m_observers;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED

View File

@@ -0,0 +1,168 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/n_step_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with constant step size performing exactly n steps.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_ITERATOR_N_STEP_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/n_step_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the n_step_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class n_step_iterator : public n_step_iterator_impl<
n_step_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef n_step_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
n_step_iterator( Stepper stepper , System sys , State &s , time_type t , time_type dt , size_t num_of_steps )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t , dt , num_of_steps )
{}
n_step_iterator( Stepper stepper , System sys , State &s )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State >
n_step_iterator< Stepper , System, State > make_n_step_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return n_step_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps );
}
template< class Stepper , class System , class State >
n_step_iterator< Stepper , System , State > make_n_step_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return n_step_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< n_step_iterator< Stepper , System , State > , n_step_iterator< Stepper , System , State > >
make_n_step_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return std::make_pair(
n_step_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ) ,
n_step_iterator< Stepper , System , State >( stepper , system , x )
);
}
/**
* \class n_step_iterator
*
* \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper.
*
* Implements an iterator representing the solution of an ODE starting from t
* with n steps and a constant step size dt.
* After each iteration the iterator dereferences to the state x at the next
* time t+dt.
* This iterator can be used with Steppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_n_steps routine.
*
* n_step_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_n_step_iterator_begin( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
*
* \brief Factory function for n_step_iterator. Constructs a begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step iterator.
*/
/**
* \fn make_n_step_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for n_step_iterator. Constructs an end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \returns The const_step_iterator.
*/
/**
* \fn make_n_step_range( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , , size_t num_of_steps )
*
* \brief Factory function to construct a single pass range of n-step iterators. A range is here a pair
* of n_step_iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,169 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/n_step_time_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with constant step size performing exactly n steps.
The dereferenced type contains also the time.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/n_step_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the n_step_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class n_step_time_iterator : public n_step_iterator_impl<
n_step_time_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef n_step_time_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
n_step_time_iterator( Stepper stepper , System sys , State &s , time_type t , time_type dt , size_t num_of_steps )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t , dt , num_of_steps )
{}
n_step_time_iterator( Stepper stepper , System sys , State &s )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State >
n_step_time_iterator< Stepper , System, State > make_n_step_time_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps );
}
template< class Stepper , class System , class State >
n_step_time_iterator< Stepper , System , State > make_n_step_time_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return n_step_time_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< n_step_time_iterator< Stepper , System , State > , n_step_time_iterator< Stepper , System , State > >
make_n_step_time_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return std::make_pair(
n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ) ,
n_step_time_iterator< Stepper , System , State >( stepper , system , x )
);
}
/**
* \class n_step_time_iterator
*
* \brief ODE Iterator with constant step size. The value type of this iterator is a std::pair containing state and time.
*
* Implements an iterator representing the solution of an ODE starting from t
* with n steps and a constant step size dt.
* After each iteration the iterator dereferences to a pair of state and time at the next
* time t+dt.
* This iterator can be used with Steppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_n_steps routine.
*
* n_step_time_iterator is a model of single-pass iterator.
*
* The value type of this iterator is pair of state and time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_n_step_time_iterator_begin( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
*
* \brief Factory function for n_step_time_iterator. Constructs a begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step iterator.
*/
/**
* \fn make_n_step_time_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for n_step_time_iterator. Constructs an end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \returns The const_step_iterator.
*/
/**
* \fn make_n_step_time_range( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
*
* \brief Factory function to construct a single pass range of n-step iterators. A range is here a pair
* of n_step_time_iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_TIME_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,189 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/times_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with oscillator calls at times from a given sequence.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_ITERATOR_TIMES_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/times_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the times_iterator_impl with the right tags */
template< class Stepper , class System , class State , class TimeIterator
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class times_iterator : public times_iterator_impl<
times_iterator< Stepper , System , State , TimeIterator , StepperTag > ,
Stepper , System , State , TimeIterator , detail::ode_state_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef times_iterator< Stepper , System , State , TimeIterator , StepperTag > iterator_type;
public:
times_iterator( Stepper stepper , System sys , State &s ,
TimeIterator t_start , TimeIterator t_end , time_type dt )
: times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator, detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
times_iterator( Stepper stepper , System sys , State &s )
: times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State , class TimeIterator >
times_iterator< Stepper , System, State , TimeIterator > make_times_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
{
return times_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt );
}
// ToDo: requires to specifically provide the TimeIterator template parameter, can this be improved?
template< class TimeIterator , class Stepper , class System , class State >
times_iterator< Stepper , System , State , TimeIterator > make_times_iterator_end(
Stepper stepper ,
System system ,
State &x )
//TimeIterator t_end )
{
return times_iterator< Stepper , System , State , TimeIterator >( stepper , system , x );
}
template< class Stepper , class System , class State , class TimeIterator >
std::pair< times_iterator< Stepper , System , State , TimeIterator > ,
times_iterator< Stepper , System , State , TimeIterator > >
make_times_range(
Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
times_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt ) ,
times_iterator< Stepper , System , State , TimeIterator >( stepper , system , x )
);
}
/**
* \class times_iterator
*
* \brief ODE Iterator with given evaluation points. The value type of this iterator is the state type of the stepper.
*
* Implements an iterator representing the solution of an ODE from *t_start
* to *t_end evaluated at time points given by the sequence t_start to t_end.
* t_start and t_end are iterators representing a sequence of time points
* where the solution of the ODE should be evaluated.
* After each iteration the iterator dereferences to the state x at the next
* time *t_start++ until t_end is reached.
* This iterator can be used with Steppers, ControlledSteppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_times routine.
*
* times_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
* \tparam State The state type of the ODE.
* \tparam TimeIterator The iterator type for the sequence of time points.
*/
/**
* \fn make_times_iterator_begin( Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function for times_iterator. Constructs a begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t_start Begin iterator of the sequence of evaluation time points.
* \param t_end End iterator of the sequence of evaluation time points.
* \param dt The initial time step.
* \returns The times iterator.
*/
/**
* \fn make_times_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for times_iterator. Constructs an end iterator.
*
* \tparam TimesIterator The iterator type of the time sequence, must be specifically provided.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \returns The times iterator.
*
* This function needs the TimeIterator type specifically defined as a
* template parameter.
*/
/**
* \fn make_times_range( Stepper stepper , System system , State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function to construct a single pass range of times iterators. A range is here a pair
* of times_iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
* \param t_start Begin iterator of the sequence of evaluation time points.
* \param t_end End iterator of the sequence of evaluation time points.
* \param dt The initial time step.
* \returns The times iterator range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,193 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/times_time_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with oscillator calls at times from a given sequence.
The dereferenced type contains also the time.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-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_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/times_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the times_iterator_impl with the right tags */
template< class Stepper , class System , class State , class TimeIterator
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class times_time_iterator : public times_iterator_impl<
times_time_iterator< Stepper , System , State , TimeIterator , StepperTag > ,
Stepper , System , State , TimeIterator , detail::ode_state_time_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef times_time_iterator< Stepper , System , State , TimeIterator , StepperTag > iterator_type;
public:
times_time_iterator( Stepper stepper , System sys , State &s ,
TimeIterator t_start , TimeIterator t_end , time_type dt )
: times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator, detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
times_time_iterator( Stepper stepper , System sys , State &s )
: times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State , class TimeIterator >
times_time_iterator< Stepper , System, State , TimeIterator > make_times_time_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
{
return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt );
}
// ToDo: requires to specifically provide the TimeIterator template parameter, can this be improved?
template< class TimeIterator , class Stepper , class System , class State >
times_time_iterator< Stepper , System , State , TimeIterator > make_times_time_iterator_end(
Stepper stepper ,
System system ,
State &x )
//TimeIterator t_end )
{
return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x );
}
template< class Stepper , class System , class State , class TimeIterator >
std::pair< times_time_iterator< Stepper , System , State , TimeIterator > ,
times_time_iterator< Stepper , System , State , TimeIterator > >
make_times_time_range(
Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt ) ,
times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x )
);
}
/**
* \class times_time_iterator
*
* \brief ODE Iterator with given evaluation points. The value type of this iterator is a std::pair containing state and time.
*
* Implements an iterator representing the solution of an ODE from *t_start
* to *t_end evaluated at time points given by the sequence t_start to t_end.
* t_start and t_end are iterators representing a sequence of time points
* where the solution of the ODE should be evaluated.
* After each iteration the iterator dereferences to a pair with the state
* and the time at the next evaluation point *t_start++ until t_end is reached.
* This iterator can be used with Steppers, ControlledSteppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_times routine.
*
* times_time_iterator is a model of single-pass iterator.
*
* The value type of this iterator is a pair of state and time type.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
* \tparam State The state type of the ODE.
* \tparam TimeIterator The iterator type for the sequence of time points.
*/
/**
* \fn make_times_time_iterator_begin( Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function for times_time_iterator. Constructs a begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t_start Begin iterator of the sequence of evaluation time points.
* \param t_end End iterator of the sequence of evaluation time points.
* \param dt The initial time step.
* \returns The times_time iterator.
*/
/**
* \fn make_times_time_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for times_time_iterator. Constructs an end iterator.
*
* \tparam TimesIterator The iterator type of the time sequence, must be specifically provided.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \returns The times_time iterator.
*
* This function needs the TimeIterator type specifically defined as a
* template parameter.
*/
/**
* \fn make_times_time_range( Stepper stepper , System system , State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function to construct a single pass range of times_time iterators. A range is here a pair
* of times_iterator.
*
* \param stepper The stepper to use during the iteration.
* \param system The system function (ODE) to solve.
* \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
* \param t_start Begin iterator of the sequence of evaluation time points.
* \param t_end End iterator of the sequence of evaluation time points.
* \param dt The initial time step.
* \returns The times_time iterator range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,418 @@
/*
[auto_generated]
boost/numeric/odeint/stepper/adams_bashforth.hpp
[begin_description]
Implementaton of the Adam-Bashforth method a multistep method used for the predictor step in the
Adams-Bashforth-Moulton method.
[end_description]
Copyright 2011-2013 Karsten Ahnert
Copyright 2011-2013 Mario Mulansky
Copyright 2012 Christoph Koke
Copyright 2013 Pascal Germroth
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_STEPPER_ADAMS_BASHFORTH_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_BASHFORTH_HPP_INCLUDED
#include <boost/static_assert.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/algebra/range_algebra.hpp>
#include <boost/numeric/odeint/algebra/default_operations.hpp>
#include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
#include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
#include <boost/numeric/odeint/util/state_wrapper.hpp>
#include <boost/numeric/odeint/util/is_resizeable.hpp>
#include <boost/numeric/odeint/util/resizer.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
#include <boost/numeric/odeint/stepper/extrapolation_stepper.hpp>
#include <boost/numeric/odeint/stepper/base/algebra_stepper_base.hpp>
#include <boost/numeric/odeint/stepper/detail/adams_bashforth_coefficients.hpp>
#include <boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp>
#include <boost/numeric/odeint/stepper/detail/rotating_buffer.hpp>
#include <boost/mpl/arithmetic.hpp>
#include <boost/mpl/min_max.hpp>
#include <boost/mpl/equal_to.hpp>
namespace mpl = boost::mpl;
namespace boost {
namespace numeric {
namespace odeint {
using mpl::int_;
/* if N >= 4, returns the smallest even number > N, otherwise returns 4 */
template < int N >
struct order_helper
: mpl::max< typename mpl::eval_if<
mpl::equal_to< mpl::modulus< int_< N >, int_< 2 > >,
int_< 0 > >,
int_< N >, int_< N + 1 > >::type,
int_< 4 > >::type
{ };
template<
size_t Steps ,
class State ,
class Value = double ,
class Deriv = State ,
class Time = Value ,
class Algebra = typename algebra_dispatcher< State >::algebra_type ,
class Operations = typename operations_dispatcher< State >::operations_type ,
class Resizer = initially_resizer ,
class InitializingStepper = extrapolation_stepper< order_helper<Steps>::value,
State, Value, Deriv, Time,
Algebra, Operations, Resizer >
>
class adams_bashforth : public algebra_stepper_base< Algebra , Operations >
{
#ifndef DOXYGEN_SKIP
static_assert(( Steps > 0 && Steps < 9 ), "Must have between 1 and 8 steps inclusive");
#endif
public :
typedef State state_type;
typedef state_wrapper< state_type > wrapped_state_type;
typedef Value value_type;
typedef Deriv deriv_type;
typedef state_wrapper< deriv_type > wrapped_deriv_type;
typedef Time time_type;
typedef Resizer resizer_type;
typedef stepper_tag stepper_category;
typedef InitializingStepper initializing_stepper_type;
typedef algebra_stepper_base< Algebra , Operations > algebra_stepper_base_type;
typedef typename algebra_stepper_base_type::algebra_type algebra_type;
typedef typename algebra_stepper_base_type::operations_type operations_type;
#ifndef DOXYGEN_SKIP
typedef adams_bashforth< Steps , State , Value , Deriv , Time , Algebra , Operations , Resizer , InitializingStepper > stepper_type;
#endif
static const size_t steps = Steps;
typedef unsigned short order_type;
static const order_type order_value = steps;
typedef detail::rotating_buffer< wrapped_deriv_type , steps > step_storage_type;
order_type order( void ) const { return order_value; }
adams_bashforth( const algebra_type &algebra = algebra_type() )
: algebra_stepper_base_type( algebra ) ,
m_step_storage() , m_resizer() , m_coefficients() ,
m_steps_initialized( 0 ) , m_initializing_stepper()
{ }
/*
* Version 1 : do_step( system , x , t , dt );
*
* solves the forwarding problem
*/
template< class System , class StateInOut >
void do_step( System system , StateInOut &x , time_type t , time_type dt )
{
do_step( system , x , t , x , dt );
}
/**
* \brief Second version to solve the forwarding problem, can be called with Boost.Range as StateInOut.
*/
template< class System , class StateInOut >
void do_step( System system , const StateInOut &x , time_type t , time_type dt )
{
do_step( system , x , t , x , dt );
}
/*
* Version 2 : do_step( system , in , t , out , dt );
*
* solves the forwarding problem
*/
template< class System , class StateIn , class StateOut >
void do_step( System system , const StateIn &in , time_type t , StateOut &out , time_type dt )
{
do_step_impl( system , in , t , out , dt );
}
/**
* \brief Second version to solve the forwarding problem, can be called with Boost.Range as StateOut.
*/
template< class System , class StateIn , class StateOut >
void do_step( System system , const StateIn &in , time_type t , const StateOut &out , time_type dt )
{
do_step_impl( system , in , t , out , dt );
}
template< class StateType >
void adjust_size( const StateType &x )
{
resize_impl( x );
}
const step_storage_type& step_storage( void ) const
{
return m_step_storage;
}
step_storage_type& step_storage( void )
{
return m_step_storage;
}
template< class ExplicitStepper , class System , class StateIn >
void initialize( ExplicitStepper explicit_stepper , System system , StateIn &x , time_type &t , time_type dt )
{
typename odeint::unwrap_reference< ExplicitStepper >::type &stepper = explicit_stepper;
typename odeint::unwrap_reference< System >::type &sys = system;
m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
for( size_t i=0 ; i+1<steps ; ++i )
{
if( i != 0 ) m_step_storage.rotate();
sys( x , m_step_storage[0].m_v , t );
stepper.do_step_dxdt_impl( system, x, m_step_storage[0].m_v, t,
dt );
t += dt;
}
m_steps_initialized = steps;
}
template< class System , class StateIn >
void initialize( System system , StateIn &x , time_type &t , time_type dt )
{
initialize( std::ref( m_initializing_stepper ) , system , x , t , dt );
}
void reset( void )
{
m_steps_initialized = 0;
}
bool is_initialized( void ) const
{
return m_steps_initialized >= ( steps - 1 );
}
const initializing_stepper_type& initializing_stepper( void ) const { return m_initializing_stepper; }
initializing_stepper_type& initializing_stepper( void ) { return m_initializing_stepper; }
private:
template< class System , class StateIn , class StateOut >
void do_step_impl( System system , const StateIn &in , time_type t , StateOut &out , time_type dt )
{
typename odeint::unwrap_reference< System >::type &sys = system;
if( m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); } ) )
{
m_steps_initialized = 0;
}
if( m_steps_initialized + 1 < steps )
{
if( m_steps_initialized != 0 ) m_step_storage.rotate();
sys( in , m_step_storage[0].m_v , t );
m_initializing_stepper.do_step_dxdt_impl(
system, in, m_step_storage[0].m_v, t, out, dt );
++m_steps_initialized;
}
else
{
m_step_storage.rotate();
sys( in , m_step_storage[0].m_v , t );
detail::adams_bashforth_call_algebra< steps , algebra_type , operations_type >()( this->m_algebra , in , out , m_step_storage , m_coefficients , dt );
}
}
template< class StateIn >
bool resize_impl( const StateIn &x )
{
bool resized( false );
for( size_t i=0 ; i<steps ; ++i )
{
resized |= adjust_size_by_resizeability( m_step_storage[i] , x , typename is_resizeable<deriv_type>::type() );
}
return resized;
}
step_storage_type m_step_storage;
resizer_type m_resizer;
detail::adams_bashforth_coefficients< value_type , steps > m_coefficients;
size_t m_steps_initialized;
initializing_stepper_type m_initializing_stepper;
};
/***** DOXYGEN *****/
/**
* \class adams_bashforth
* \brief The Adams-Bashforth multistep algorithm.
*
* The Adams-Bashforth method is a multi-step algorithm with configurable step
* number. The step number is specified as template parameter Steps and it
* then uses the result from the previous Steps steps. See also
* <a href="http://en.wikipedia.org/wiki/Linear_multistep_method">en.wikipedia.org/wiki/Linear_multistep_method</a>.
* Currently, a maximum of Steps=8 is supported.
* The method is explicit and fulfills the Stepper concept. Step size control
* or continuous output are not provided.
*
* This class derives from algebra_base and inherits its interface via
* CRTP (current recurring template pattern). For more details see
* algebra_stepper_base.
*
* \tparam Steps The number of steps (maximal 8).
* \tparam State The state type.
* \tparam Value The value type.
* \tparam Deriv The type representing the time derivative of the state.
* \tparam Time The time representing the independent variable - the time.
* \tparam Algebra The algebra type.
* \tparam Operations The operations type.
* \tparam Resizer The resizer policy type.
* \tparam InitializingStepper The stepper for the first two steps.
*/
/**
* \fn adams_bashforth::adams_bashforth( const algebra_type &algebra )
* \brief Constructs the adams_bashforth class. This constructor can be used as a default
* constructor if the algebra has a default constructor.
* \param algebra A copy of algebra is made and stored.
*/
/**
* \fn order_type adams_bashforth::order( void ) const
* \brief Returns the order of the algorithm, which is equal to the number of steps.
* \return order of the method.
*/
/**
* \fn void adams_bashforth::do_step( System system , StateInOut &x , time_type t , time_type dt )
* \brief This method performs one step. It transforms the result in-place.
*
* \param system The system function to solve, hence the r.h.s. of the ordinary differential equation. It must fulfill the
* Simple System concept.
* \param x The state of the ODE which should be solved. After calling do_step the result is updated in x.
* \param t The value of the time, at which the step should be performed.
* \param dt The step size.
*/
/**
* \fn void adams_bashforth::do_step( System system , const StateIn &in , time_type t , StateOut &out , time_type dt )
* \brief The method performs one step with the stepper passed by Stepper. The state of the ODE is updated out-of-place.
*
* \param system The system function to solve, hence the r.h.s. of the ODE. It must fulfill the
* Simple System concept.
* \param in The state of the ODE which should be solved. in is not modified in this method
* \param t The value of the time, at which the step should be performed.
* \param out The result of the step is written in out.
* \param dt The step size.
*/
/**
* \fn void adams_bashforth::adjust_size( const StateType &x )
* \brief Adjust the size of all temporaries in the stepper manually.
* \param x A state from which the size of the temporaries to be resized is deduced.
*/
/**
* \fn const step_storage_type& adams_bashforth::step_storage( void ) const
* \brief Returns the storage of intermediate results.
* \return The storage of intermediate results.
*/
/**
* \fn step_storage_type& adams_bashforth::step_storage( void )
* \brief Returns the storage of intermediate results.
* \return The storage of intermediate results.
*/
/**
* \fn void adams_bashforth::initialize( ExplicitStepper explicit_stepper , System system , StateIn &x , time_type &t , time_type dt )
* \brief Initialized the stepper. Does Steps-1 steps with the explicit_stepper to fill the buffer.
* \param explicit_stepper the stepper used to fill the buffer of previous step results
* \param system The system function to solve, hence the r.h.s. of the ordinary differential equation. It must fulfill the
* Simple System concept.
* \param x The state of the ODE which should be solved. After calling do_step the result is updated in x.
* \param t The value of the time, at which the step should be performed.
* \param dt The step size.
*/
/**
* \fn void adams_bashforth::initialize( System system , StateIn &x , time_type &t , time_type dt )
* \brief Initialized the stepper. Does Steps-1 steps with an internal instance of InitializingStepper to fill the buffer.
* \note The state x and time t are updated to the values after Steps-1 initial steps.
* \param system The system function to solve, hence the r.h.s. of the ordinary differential equation. It must fulfill the
* Simple System concept.
* \param x The initial state of the ODE which should be solved, updated in this method.
* \param t The initial value of the time, updated in this method.
* \param dt The step size.
*/
/**
* \fn void adams_bashforth::reset( void )
* \brief Resets the internal buffer of the stepper.
*/
/**
* \fn bool adams_bashforth::is_initialized( void ) const
* \brief Returns true if the stepper has been initialized.
* \return bool true if stepper is initialized, false otherwise
*/
/**
* \fn const initializing_stepper_type& adams_bashforth::initializing_stepper( void ) const
* \brief Returns the internal initializing stepper instance.
* \return initializing_stepper
*/
/**
* \fn const initializing_stepper_type& adams_bashforth::initializing_stepper( void ) const
* \brief Returns the internal initializing stepper instance.
* \return initializing_stepper
*/
/**
* \fn initializing_stepper_type& adams_bashforth::initializing_stepper( void )
* \brief Returns the internal initializing stepper instance.
* \return initializing_stepper
*/
} // odeint
} // numeric
} // boost
#endif // BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_BASHFORTH_HPP_INCLUDED

Some files were not shown because too many files have changed in this diff Show More