diff options
Diffstat (limited to 'boost/numeric/odeint/external')
6 files changed, 350 insertions, 85 deletions
diff --git a/boost/numeric/odeint/external/eigen/eigen.hpp b/boost/numeric/odeint/external/eigen/eigen.hpp new file mode 100644 index 0000000000..620acae51f --- /dev/null +++ b/boost/numeric/odeint/external/eigen/eigen.hpp @@ -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 diff --git a/boost/numeric/odeint/external/eigen/eigen_algebra.hpp b/boost/numeric/odeint/external/eigen/eigen_algebra.hpp index 6ca2026b9f..b4ee5c3b1f 100644 --- a/boost/numeric/odeint/external/eigen/eigen_algebra.hpp +++ b/boost/numeric/odeint/external/eigen/eigen_algebra.hpp @@ -71,6 +71,19 @@ 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 diff --git a/boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.hpp b/boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.hpp new file mode 100644 index 0000000000..6c8a3a276f --- /dev/null +++ b/boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.hpp @@ -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 diff --git a/boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp b/boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp index 5deba2cb57..0961346350 100644 --- a/boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp +++ b/boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp @@ -24,6 +24,7 @@ #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 { @@ -48,5 +49,59 @@ struct algebra_dispatcher< thrust::device_vector< T , A > > } // namespace boost +// add support for thrust backend vectors, if available + +#include <thrust/version.h> + +#if 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 diff --git a/boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp b/boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp index 0105a4e344..e9b3a64234 100644 --- a/boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp +++ b/boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp @@ -6,8 +6,8 @@ operations_dispatcher specialization for thrust [end_description] - Copyright 2013 Karsten Ahnert - Copyright 2013 Mario Mulansky + 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 @@ -24,6 +24,7 @@ #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 { @@ -47,6 +48,60 @@ struct operations_dispatcher< thrust::device_vector< T , A > > } // namespace numeric } // namespace boost +// add support for thrust backend vectors, if available -#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_DISPATCHER_HPP_DEFINED +#include <thrust/version.h> + +#if 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 diff --git a/boost/numeric/odeint/external/thrust/thrust_resize.hpp b/boost/numeric/odeint/external/thrust/thrust_resize.hpp index 8f1b181e25..2f7f7b23b1 100644 --- a/boost/numeric/odeint/external/thrust/thrust_resize.hpp +++ b/boost/numeric/odeint/external/thrust/thrust_resize.hpp @@ -6,7 +6,7 @@ Enable resizing for thrusts device and host_vector. [end_description] - Copyright 2010-2012 Mario Mulansky + Copyright 2010-2014 Mario Mulansky Copyright 2010-2011 Karsten Ahnert Distributed under the Boost Software License, Version 1.0. @@ -18,102 +18,168 @@ #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED #define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED +#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 { -template< class T > -struct is_resizeable< thrust::device_vector< T > > -{ - struct type : public boost::true_type { }; - const static bool value = type::value; -}; - -template< class T > -struct same_size_impl< thrust::device_vector< T > , thrust::device_vector< T > > -{ - static bool same_size( const thrust::device_vector< T > &x , const thrust::device_vector< T > &y ) - { - return x.size() == y.size(); - } -}; - -template< class T > -struct resize_impl< thrust::device_vector< T > , thrust::device_vector< T > > -{ - static void resize( thrust::device_vector< T > &x , const thrust::device_vector< T > &y ) - { - x.resize( y.size() ); - } -}; - - -template< class T > -struct is_resizeable< thrust::host_vector< T > > -{ - struct type : public boost::true_type { }; - const static bool value = type::value; -}; - -template< class T > -struct same_size_impl< thrust::host_vector< T > , thrust::host_vector< T > > -{ - static bool same_size( const thrust::host_vector< T > &x , const thrust::host_vector< T > &y ) - { - return x.size() == y.size(); - } -}; - -template< class T > -struct resize_impl< thrust::host_vector< T > , thrust::host_vector< T > > -{ - static void resize( thrust::host_vector< T > &x , const thrust::host_vector< T > &y ) - { - x.resize( y.size() ); - } -}; - - - -template< class Container1, class Value > -struct copy_impl< Container1 , thrust::device_vector< Value > > -{ - static void copy( const Container1 &from , thrust::device_vector< Value > &to ) - { - thrust::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) ); - } -}; - -template< class Value , class Container2 > -struct copy_impl< thrust::device_vector< Value > , Container2 > -{ - static void copy( const thrust::device_vector< Value > &from , Container2 &to ) - { - thrust::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) ); - } -}; - -template< class Value > -struct copy_impl< thrust::device_vector< Value > , thrust::device_vector< Value > > -{ - static void copy( const thrust::device_vector< Value > &from , thrust::device_vector< Value > &to ) - { - thrust::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) ); - } -}; - - +// 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 boost::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 >= 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 |