Squashed 'third_party/boostorg/odeint/' content from commit 6ff2719
Change-Id: If4892e29c1a5e6cf3a7aa51486a2725c251b0c7d
git-subtree-dir: third_party/boostorg/odeint
git-subtree-split: 6ff2719b6907b86596c3d43e88c1bcfdf29df560
diff --git a/include/boost/numeric/odeint/util/bind.hpp b/include/boost/numeric/odeint/util/bind.hpp
new file mode 100644
index 0000000..1201afa
--- /dev/null
+++ b/include/boost/numeric/odeint/util/bind.hpp
@@ -0,0 +1,101 @@
+/*
+ * [begin_description]
+ * Boost bind pull the placeholders, _1, _2, ... into global
+ * namespace. This can conflict with the C++03 TR1 and C++11
+ * std::placeholders. This header provides a workaround for
+ * this problem.
+ * [end_description]
+ *
+ * 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_UTIL_BIND_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED
+
+
+#include <boost/numeric/odeint/config.hpp>
+
+
+#if BOOST_NUMERIC_ODEINT_CXX11
+ #include <functional>
+#else
+#define BOOST_BIND_NO_PLACEHOLDERS
+#include <boost/bind.hpp>
+#endif
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+namespace detail {
+
+#if BOOST_NUMERIC_ODEINT_CXX11
+
+using ::std::bind;
+using namespace ::std::placeholders;
+
+
+#else
+
+// unnamed namespace to avoid multiple declarations (#138)
+namespace {
+using ::boost::bind;
+boost::arg<1> _1;
+boost::arg<2> _2;
+}
+// using ::boost::bind;
+// using ::_1;
+// using ::_2;
+
+#endif
+
+}
+}
+}
+}
+
+
+
+
+
+/*
+
+// the following is the suggested way. Unfortunately it does not work with all compilers.
+
+#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
+#include <boost/bind.hpp>
+#else
+#include <functional>
+#endif
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+namespace detail {
+
+
+#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
+
+using ::boost::bind;
+using ::_1;
+using ::_2;
+
+#else
+
+using ::std::bind;
+using namespace ::std::placeholders;
+
+#endif
+
+
+}
+}
+}
+}*/
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/copy.hpp b/include/boost/numeric/odeint/util/copy.hpp
new file mode 100644
index 0000000..161f135
--- /dev/null
+++ b/include/boost/numeric/odeint/util/copy.hpp
@@ -0,0 +1,87 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/copy.hpp
+
+ [begin_description]
+ Copy abstraction for the usage in the steppers.
+ [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_UTIL_COPY_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED
+
+
+#include <boost/range/algorithm/copy.hpp>
+
+#include <boost/utility/enable_if.hpp>
+
+#include <boost/numeric/odeint/util/detail/is_range.hpp>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+namespace detail {
+
+ template< class Container1 , class Container2 >
+ void do_copying( const Container1 &from , Container2 &to , boost::mpl::true_ )
+ {
+ boost::range::copy( from , boost::begin( to ) );
+ }
+
+ template< class Container1 , class Container2 >
+ void do_copying( const Container1 &from , Container2 &to , boost::mpl::false_ )
+ {
+ to = from;
+ }
+
+} // namespace detail
+
+
+
+/*
+ * Default implementation of the copy operation used the assign operator
+ * gsl_vector must copied differently
+ */
+template< class Container1 , class Container2 , class Enabler = void >
+struct copy_impl_sfinae
+{
+ static void copy( const Container1 &from , Container2 &to )
+ {
+ typedef typename boost::numeric::odeint::detail::is_range< Container1 >::type is_range_type;
+ detail::do_copying( from , to , is_range_type() );
+ }
+
+};
+
+template< class Container1, class Container2 >
+struct copy_impl
+{
+ static void copy( const Container1 &from , Container2 &to )
+ {
+ copy_impl_sfinae< Container1 , Container2 >::copy( from , to );
+ }
+};
+
+// ToDo: allow also to copy INTO a range, not only from a range! Needs "const Container2 &to"
+template< class Container1 , class Container2 >
+void copy( const Container1 &from , Container2 &to )
+{
+ copy_impl< Container1 , Container2 >::copy( from , to );
+}
+
+
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/detail/is_range.hpp b/include/boost/numeric/odeint/util/detail/is_range.hpp
new file mode 100644
index 0000000..a176855
--- /dev/null
+++ b/include/boost/numeric/odeint/util/detail/is_range.hpp
@@ -0,0 +1,134 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/detail/is_range.hpp
+
+ [begin_description]
+ is_range implementation. Taken from the boost::range library.
+ [end_description]
+
+ Copyright 2011-2013 Karsten Ahnert
+ Copyright 2011-2013 Thorsten Ottosen
+
+
+
+ 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_UTIL_DETAIL_IS_RANGE_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_DETAIL_IS_RANGE_HPP_INCLUDED
+
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <cstddef>
+#include <boost/range/config.hpp>
+#include <boost/mpl/has_xxx.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+
+namespace range_detail
+{
+BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator)
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator)
+}
+
+namespace detail
+{
+
+template< typename Range >
+struct is_range : boost::mpl::and_<range_detail::has_iterator<Range>, range_detail::has_const_iterator<Range> >
+{
+};
+
+//////////////////////////////////////////////////////////////////////////
+// pair
+//////////////////////////////////////////////////////////////////////////
+
+template< typename iteratorT >
+struct is_range< std::pair<iteratorT,iteratorT> > : boost::mpl::true_
+{
+};
+
+template< typename iteratorT >
+struct is_range< const std::pair<iteratorT,iteratorT> > : boost::mpl::true_
+{
+};
+
+//////////////////////////////////////////////////////////////////////////
+// array
+//////////////////////////////////////////////////////////////////////////
+
+template< typename elementT, std::size_t sz >
+struct is_range< elementT[sz] > : boost::mpl::true_
+{
+};
+
+template< typename elementT, std::size_t sz >
+struct is_range< const elementT[sz] > : boost::mpl::true_
+{
+};
+
+//////////////////////////////////////////////////////////////////////////
+// string
+//////////////////////////////////////////////////////////////////////////
+
+template<>
+struct is_range< char* > : boost::mpl::true_
+{
+};
+
+template<>
+struct is_range< wchar_t* > : boost::mpl::true_
+{
+};
+
+template<>
+struct is_range< const char* > : boost::mpl::true_
+{
+};
+
+template<>
+struct is_range< const wchar_t* > : boost::mpl::true_
+{
+};
+
+template<>
+struct is_range< char* const > : boost::mpl::true_
+{
+};
+
+template<>
+struct is_range< wchar_t* const > : boost::mpl::true_
+{
+};
+
+template<>
+struct is_range< const char* const > : boost::mpl::true_
+{
+};
+
+template<>
+struct is_range< const wchar_t* const > : boost::mpl::true_
+{
+};
+
+} // namespace detail
+
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_DETAIL_IS_RANGE_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/detail/less_with_sign.hpp b/include/boost/numeric/odeint/util/detail/less_with_sign.hpp
new file mode 100644
index 0000000..3ffa7ca
--- /dev/null
+++ b/include/boost/numeric/odeint/util/detail/less_with_sign.hpp
@@ -0,0 +1,78 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/detail/less_with_sign.hpp
+
+ [begin_description]
+ Helper function to compare times taking into account the sign of dt
+ [end_description]
+
+ Copyright 2012-2015 Mario Mulansky
+ 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_LESS_WITH_SIGN_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_LESS_WITH_SIGN_HPP_INCLUDED
+
+#include <limits>
+
+#include <boost/numeric/odeint/util/unit_helper.hpp>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+namespace detail {
+
+/**
+ * return t1 < t2 if dt > 0 and t1 > t2 if dt < 0 with epsilon accuracy
+ */
+template< typename T >
+bool less_with_sign( T t1 , T t2 , T dt )
+{
+ if( get_unit_value(dt) > 0 )
+ //return t1 < t2;
+ return t2-t1 > std::numeric_limits<T>::epsilon();
+ else
+ //return t1 > t2;
+ return t1-t2 > std::numeric_limits<T>::epsilon();
+}
+
+/**
+ * return t1 <= t2 if dt > 0 and t1 => t2 if dt < 0 with epsilon accuracy
+ */
+template< typename T >
+bool less_eq_with_sign( T t1 , T t2 , T dt )
+{
+ if( get_unit_value(dt) > 0 )
+ return t1-t2 <= std::numeric_limits<T>::epsilon();
+ else
+ return t2-t1 <= std::numeric_limits<T>::epsilon();
+}
+
+template< typename T >
+T min_abs( T t1 , T t2 )
+{
+ BOOST_USING_STD_MIN();
+ BOOST_USING_STD_MAX();
+ if( get_unit_value(t1)>0 )
+ return min BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 );
+ else
+ return max BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 );
+}
+
+template< typename T >
+T max_abs( T t1 , T t2 )
+{
+ BOOST_USING_STD_MIN();
+ BOOST_USING_STD_MAX();
+ if( get_unit_value(t1)>0 )
+ return max BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 );
+ else
+ return min BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 );
+}
+} } } }
+
+#endif
diff --git a/include/boost/numeric/odeint/util/is_pair.hpp b/include/boost/numeric/odeint/util/is_pair.hpp
new file mode 100644
index 0000000..1827840
--- /dev/null
+++ b/include/boost/numeric/odeint/util/is_pair.hpp
@@ -0,0 +1,45 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/is_pair.hpp
+
+ [begin_description]
+ Metafunction to determine if a type is a std::pair<>.
+ [end_description]
+
+ Copyright 2011 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_UTIL_IS_PAIR_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_IS_PAIR_HPP_INCLUDED
+
+
+#include <boost/mpl/bool.hpp>
+#include <utility>
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+template< class T >
+struct is_pair : public boost::mpl::false_
+{
+};
+
+template< class T1 , class T2 >
+struct is_pair< std::pair< T1 , T2 > > : public boost::mpl::true_
+{
+};
+
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_IS_PAIR_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/is_resizeable.hpp b/include/boost/numeric/odeint/util/is_resizeable.hpp
new file mode 100644
index 0000000..ad7332d
--- /dev/null
+++ b/include/boost/numeric/odeint/util/is_resizeable.hpp
@@ -0,0 +1,83 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/is_resizeable.hpp
+
+ [begin_description]
+ Metafunction to determine if a state type can resized. For usage in the steppers.
+ [end_description]
+
+ Copyright 2011-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_UTIL_IS_RESIZEABLE_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_IS_RESIZEABLE_HPP_INCLUDED
+
+
+#include <vector>
+
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/fusion/include/front.hpp>
+#include <boost/fusion/include/is_sequence.hpp>
+
+#include <boost/mpl/find_if.hpp>
+#include <boost/mpl/end.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+/*
+ * by default any type is not resizable
+ */
+template< typename Container , typename Enabler = void >
+struct is_resizeable_sfinae : boost::false_type {};
+
+template< typename Container >
+struct is_resizeable : is_resizeable_sfinae< Container > {};
+
+
+
+/*
+ * specialization for std::vector
+ */
+template< class V, class A >
+struct is_resizeable< std::vector< V , A > > : boost::true_type {};
+
+
+/*
+ * sfinae specialization for fusion sequences
+ */
+template< typename FusionSequence >
+struct is_resizeable_sfinae<
+ FusionSequence ,
+ typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSequence >::type >::type >
+{
+ typedef typename boost::mpl::find_if< FusionSequence , is_resizeable< boost::mpl::_1 > >::type iter;
+ typedef typename boost::mpl::end< FusionSequence >::type last;
+
+ typedef typename boost::mpl::if_< boost::is_same< iter , last > , boost::false_type , boost::true_type >::type type;
+ const static bool value = type::value;
+};
+
+
+
+
+
+
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_IS_RESIZEABLE_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/multi_array_adaption.hpp b/include/boost/numeric/odeint/util/multi_array_adaption.hpp
new file mode 100644
index 0000000..e2c0a48
--- /dev/null
+++ b/include/boost/numeric/odeint/util/multi_array_adaption.hpp
@@ -0,0 +1,130 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/multi_array_adaption.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_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED
+#define BOOST_NUMERIC_ODEINT_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED
+
+
+
+#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/mpl/and.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/multi_array.hpp>
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+template< typename T >
+struct is_multi_array
+{
+ typedef boost::false_type type;
+ const static bool value = type::value;
+};
+
+template< typename T >
+struct is_resizeable_multi_array
+{
+ typedef boost::false_type type;
+ const static bool value = type::value;
+};
+
+
+
+template< typename V , size_t Dim , typename A >
+struct is_multi_array< boost::multi_array< V , Dim , A > >
+{
+ typedef boost::true_type type;
+ const static bool value = type::value;
+};
+
+template< typename V , size_t Dim , typename A >
+struct is_resizeable_multi_array< boost::multi_array< V , Dim , A > >
+{
+ typedef boost::true_type type;
+ const static bool value = type::value;
+};
+
+
+
+
+template< typename T >
+struct is_resizeable_sfinae< T , typename boost::enable_if< typename is_resizeable_multi_array< T >::type >::type >
+{
+ typedef boost::true_type type;
+ const static bool value = type::value;
+};
+
+
+
+
+
+template< typename T1 , typename T2 >
+struct same_size_impl_sfinae< T1 , T2 ,
+ typename boost::enable_if<
+ typename boost::mpl::and_<
+ is_multi_array< T1 > ,
+ is_multi_array< T2 > ,
+ boost::mpl::bool_< T1::dimensionality == T2::dimensionality >
+ >::type
+ >::type >
+{
+ static bool same_size( T1 const &x1 , T2 const &x2 )
+ {
+ for( size_t i=0 ; i<T1::dimensionality ; ++i )
+ {
+ if( x1.shape()[i] != x2.shape()[i] ) return false;
+ if( x1.index_bases()[i] != x2.index_bases()[i] ) return false;
+ }
+ return true;
+ }
+};
+
+
+template< typename T1 , typename T2 >
+struct resize_impl_sfinae< T1 , T2 ,
+ typename boost::enable_if<
+ typename boost::mpl::and_<
+ is_resizeable_multi_array< T1 > ,
+ is_multi_array< T2 > ,
+ boost::mpl::bool_< T1::dimensionality == T2::dimensionality >
+ >::type
+ >::type >
+{
+ static void resize( T1 &x1 , const T2 &x2 )
+ {
+ boost::array< int , T1::dimensionality > extents;
+ for( size_t i=0 ; i<T1::dimensionality ; ++i ) extents[i] = x2.shape()[i];
+ x1.resize( extents );
+ boost::array< int , T1::dimensionality > origins;
+ for( size_t i=0 ; i<T1::dimensionality ; ++i ) origins[i] = x2.index_bases()[i];
+ x1.reindex( origins );
+ }
+};
+
+
+
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_MULTI_ARRAY_ADAPTION_HPP_DEFINED
diff --git a/include/boost/numeric/odeint/util/n_ary_helper.hpp b/include/boost/numeric/odeint/util/n_ary_helper.hpp
new file mode 100644
index 0000000..6138074
--- /dev/null
+++ b/include/boost/numeric/odeint/util/n_ary_helper.hpp
@@ -0,0 +1,96 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/n_ary_helper.hpp
+
+ Macros to generate scale_sumN and for_eachN functors.
+
+ 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_UTIL_N_ARY_HELPER_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_N_ARY_HELPER_HPP_INCLUDED
+
+#include <boost/preprocessor/repetition.hpp>
+
+// like BOOST_PP_ENUM_SHIFTED but with a comma in front like _TRAILING
+#define BOOST_ODEINT_ENUM_TRAILING_SHIFTED_PARAMS(count, param) \
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(count)) \
+ BOOST_PP_ENUM_SHIFTED_PARAMS(count, param)
+
+#define BOOST_ODEINT_ENUM_TRAILING_SHIFTED_BINARY_PARAMS(count, p1, p2) \
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(count)) \
+ BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(count, p1, p2)
+
+// like BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(n, p1, p2) but p2 is shifted left.
+// generate "p1 ## 0 = p2, p1 ## 1 = p3 ## 0, p1 ## 2 = p3 ## 1"
+#define BOOST_ODEINT_ENUM_LSHIFTED_BINARY_PARAMS(count, p1, p2, p3) \
+ BOOST_PP_ENUM(count, BOOST_ODEINT_ENUM_LSHIFTED_BINARY_PARAMS_, (p1, p2, p3))
+#define BOOST_ODEINT_ENUM_LSHIFTED_BINARY_PARAMS_(z, n, data) \
+ BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 0, data), n) \
+ BOOST_PP_IF(n, \
+ BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 2, data), BOOST_PP_DEC(n)), \
+ BOOST_PP_TUPLE_ELEM(3, 1, data))
+
+// like BOOST_PP_ENUM_BINARY_PARAMS(n, p1, p2) but with statements.
+// "p1 ## 0 p2 ## 0 ; p1 ## 1 p2 ## 1 ; ..."
+#define BOOST_ODEINT_ENUM_BINARY_STATEMENTS(count, p1, p2) \
+ BOOST_PP_REPEAT(count, BOOST_ODEINT_ENUM_BINARY_STATEMENTS_, (p1, p2))
+#define BOOST_ODEINT_ENUM_BINARY_STATEMENTS_(z, n, data) \
+ BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, data), n) \
+ BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, data), n) ;
+
+// like BOOST_PP_ENUM_BINARY_PARAMS(n, p1, p2) but p2 is in parens.
+// "p1 ## 0 (p2 ## 0) , p1 ## 1 (p2 ## 1) , ..."
+#define BOOST_ODEINT_ENUM_UNARY_CALLS(count, p1, p2) \
+ BOOST_PP_ENUM(count, BOOST_ODEINT_ENUM_UNARY_CALLS_, (p1, p2))
+#define BOOST_ODEINT_ENUM_SHIFTED_UNARY_CALLS(count, p1, p2) \
+ BOOST_PP_ENUM_SHIFTED(count, BOOST_ODEINT_ENUM_UNARY_CALLS_, (p1, p2))
+#define BOOST_ODEINT_ENUM_TRAILING_SHIFTED_UNARY_CALLS(count, p1, p2) \
+ BOOST_PP_COMMA_IF(BOOST_PP_DEC(count)) \
+ BOOST_PP_ENUM_SHIFTED(count, BOOST_ODEINT_ENUM_UNARY_CALLS_, (p1, p2))
+#define BOOST_ODEINT_ENUM_UNARY_CALLS_(z, n, data) \
+ BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, data), n) \
+ ( BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, data), n) )
+
+
+// maximum arity + 1 for scale_sum and for_each
+#define BOOST_ODEINT_N_ARY_MAX 16
+
+
+// generate scale_sum1 to scale_sumN, operator body generated by macro(N)
+#define BOOST_ODEINT_GEN_SCALE_SUM(macro) \
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_ODEINT_N_ARY_MAX, BOOST_ODEINT_GEN_SCALE_SUM_, macro)
+#define BOOST_ODEINT_GEN_SCALE_SUM_(z, n, macro) \
+ template< BOOST_ODEINT_ENUM_LSHIFTED_BINARY_PARAMS(n, class Fac, = double, = Fac) > \
+ struct BOOST_PP_CAT(scale_sum, n) \
+ { \
+ BOOST_ODEINT_ENUM_BINARY_STATEMENTS(n, const Fac, m_alpha) \
+ \
+ BOOST_PP_CAT(scale_sum, n) \
+ ( BOOST_PP_ENUM_BINARY_PARAMS(n, Fac, alpha) ) \
+ : BOOST_ODEINT_ENUM_UNARY_CALLS(n, m_alpha, alpha) {} \
+ \
+ template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), class T) > \
+ void operator()( T0 &t0 \
+ BOOST_ODEINT_ENUM_TRAILING_SHIFTED_BINARY_PARAMS(BOOST_PP_INC(n), const T, &t) \
+ ) const \
+ { macro(n) } \
+ typedef void result_type; \
+ };
+
+// generate for_each1 to for_eachN, body generated by macro(N)
+#define BOOST_ODEINT_GEN_FOR_EACH(macro) \
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_ODEINT_N_ARY_MAX, BOOST_ODEINT_GEN_FOR_EACH_, macro)
+#define BOOST_ODEINT_GEN_FOR_EACH_(z, n, macro) \
+ template< BOOST_PP_ENUM_PARAMS(n, class S) , class Op > \
+ static void for_each##n ( BOOST_PP_ENUM_BINARY_PARAMS(n, S, &s) , Op op ) \
+ { macro(n) }
+
+
+#endif
diff --git a/include/boost/numeric/odeint/util/odeint_error.hpp b/include/boost/numeric/odeint/util/odeint_error.hpp
new file mode 100644
index 0000000..312e5b1
--- /dev/null
+++ b/include/boost/numeric/odeint/util/odeint_error.hpp
@@ -0,0 +1,77 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/odeint_error.hpp
+
+ [begin_description]
+ Runtime Exceptions thrown by odeint
+ [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_UTIL_ODEINT_ERROR_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_ODEINT_ERROR_HPP_INCLUDED
+
+#include <stdexcept>
+#include <string>
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+/**
+ * \brief Runtime error thrown by odeint
+ */
+class odeint_error : public std::runtime_error
+{
+public:
+ odeint_error(const std::string &s)
+ : std::runtime_error(s)
+ { }
+};
+
+
+/**
+ * \brief Runtime error thrown from integrate routines
+ *
+ * This Error occures when too many iterations are performed in between two
+ * observer calls in the integrate routines.
+ */
+class no_progress_error : public odeint_error
+{
+public:
+ no_progress_error(const std::string &s)
+ : odeint_error(s)
+ { }
+};
+
+
+/**
+ * \brief Runtime error thrown during stepsize adjustment
+ *
+ * This Error occures when too many iterations are performed without finding
+ * an appropriate new step size. This usually indicates non-continuous points
+ * in the ODE.
+ */
+class step_adjustment_error : public odeint_error
+{
+public:
+ step_adjustment_error(const std::string &s)
+ : odeint_error(s)
+ { }
+};
+
+}
+}
+}
+
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_ODEINT_ERROR_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/resize.hpp b/include/boost/numeric/odeint/util/resize.hpp
new file mode 100644
index 0000000..3645782
--- /dev/null
+++ b/include/boost/numeric/odeint/util/resize.hpp
@@ -0,0 +1,118 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/state_wrapper.hpp
+
+ [begin_description]
+ State wrapper for the state type in all stepper. The state wrappers are responsible for construction,
+ destruction, copying construction, assignment and resizing.
+ [end_description]
+
+ Copyright 2011-2013 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_UTIL_RESIZE_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_RESIZE_HPP_INCLUDED
+
+#include <boost/range.hpp>
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/fusion/include/is_sequence.hpp>
+#include <boost/fusion/include/zip_view.hpp>
+#include <boost/fusion/include/vector.hpp>
+#include <boost/fusion/include/make_fused.hpp>
+#include <boost/fusion/include/for_each.hpp>
+
+#include <boost/numeric/odeint/util/is_resizeable.hpp>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+template< class StateOut , class StateIn , class Enabler = void >
+struct resize_impl_sfinae
+{
+ static void resize( StateOut &x1 , const StateIn &x2 )
+ {
+ x1.resize( boost::size( x2 ) );
+ }
+};
+
+// resize function
+// standard implementation relies on boost.range and resize member function
+template< class StateOut , class StateIn >
+struct resize_impl
+{
+ static void resize( StateOut &x1 , const StateIn &x2 )
+ {
+ resize_impl_sfinae< StateOut , StateIn >::resize( x1 , x2 );
+ }
+};
+
+
+// do not overload or specialize this function, specialize resize_impl<> instead
+template< class StateOut , class StateIn >
+void resize( StateOut &x1 , const StateIn &x2 )
+{
+ resize_impl< StateOut , StateIn >::resize( x1 , x2 );
+}
+
+
+namespace detail {
+
+ struct resizer
+ {
+ typedef void result_type;
+
+ template< class StateOut , class StateIn >
+ void operator()( StateOut &x1 , const StateIn &x2 ) const
+ {
+ resize_op( x1 , x2 , typename is_resizeable< StateOut >::type() );
+ }
+
+ template< class StateOut , class StateIn >
+ void resize_op( StateOut &x1 , const StateIn &x2 , boost::true_type ) const
+ {
+ resize( x1 , x2 );
+ }
+
+ template< class StateOut , class StateIn >
+ void resize_op( StateOut &/*x1*/ , const StateIn &/*x2*/ , boost::false_type ) const
+ {
+ }
+
+ };
+} // namespace detail
+
+
+/*
+ * specialization for fusion sequences
+ */
+template< class FusionSeq >
+struct resize_impl_sfinae< FusionSeq , FusionSeq ,
+ typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSeq >::type >::type >
+{
+ static void resize( FusionSeq &x1 , const FusionSeq &x2 )
+ {
+ typedef boost::fusion::vector< FusionSeq& , const FusionSeq& > Sequences;
+ Sequences sequences( x1 , x2 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( detail::resizer() ) );
+ }
+};
+
+
+
+
+}
+}
+}
+
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_RESIZE_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/resizer.hpp b/include/boost/numeric/odeint/util/resizer.hpp
new file mode 100644
index 0000000..cd27990
--- /dev/null
+++ b/include/boost/numeric/odeint/util/resizer.hpp
@@ -0,0 +1,93 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/resizer.hpp
+
+ [begin_description]
+ Implementation of the resizers.
+ [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_UTIL_RESIZER_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_RESIZER_HPP_INCLUDED
+
+
+#include <boost/numeric/odeint/util/is_resizeable.hpp>
+#include <boost/numeric/odeint/util/same_size.hpp>
+#include <boost/numeric/odeint/util/resize.hpp>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+template< class ResizeWrappedState , class State >
+bool adjust_size_by_resizeability( ResizeWrappedState &x , const State &y , boost::true_type )
+{
+ if ( !same_size( x.m_v , y ) )
+ {
+ resize( x.m_v , y );
+ return true;
+ }
+ else
+ return false;
+}
+
+template< class ResizeWrappedState , class State >
+bool adjust_size_by_resizeability( ResizeWrappedState & /* x */ , const State & /* y */ , boost::false_type )
+{
+ return false;
+}
+
+struct always_resizer
+{
+ template< class State , class ResizeFunction >
+ bool adjust_size( const State &x , ResizeFunction f )
+ {
+ return f( x );
+ }
+};
+
+
+struct initially_resizer
+{
+
+ bool m_initialized;
+
+ initially_resizer() : m_initialized( false )
+ { }
+
+ template< class State , class ResizeFunction >
+ bool adjust_size( const State &x , ResizeFunction f )
+ {
+ if( !m_initialized )
+ {
+ m_initialized = true;
+ return f( x );
+ } else
+ return false;
+ }
+};
+
+
+struct never_resizer
+{
+ template< class State , class ResizeFunction >
+ bool adjust_size( const State &/*x*/ , ResizeFunction /*f*/ )
+ {
+ return false;
+ }
+};
+
+
+}
+}
+}
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_RESIZER_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/same_instance.hpp b/include/boost/numeric/odeint/util/same_instance.hpp
new file mode 100644
index 0000000..a889ee1
--- /dev/null
+++ b/include/boost/numeric/odeint/util/same_instance.hpp
@@ -0,0 +1,56 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/same_instance.hpp
+
+ [begin_description]
+ Basic check if two variables are the same instance
+ [end_description]
+
+ 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_UTIL_SAME_INSTANCE_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_SAME_INSTANCE_HPP_INCLUDED
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+template< class T1 , class T2 , class Enabler=void >
+struct same_instance_impl
+{
+ static bool same_instance( const T1& /* x1 */ , const T2& /* x2 */ )
+ {
+ return false;
+ }
+};
+
+template< class T >
+struct same_instance_impl< T , T >
+{
+ static bool same_instance( const T &x1 , const T &x2 )
+ {
+ // check pointers
+ return (&x1 == &x2);
+ }
+};
+
+
+template< class T1 , class T2 >
+bool same_instance( const T1 &x1 , const T2 &x2 )
+{
+ return same_instance_impl< T1 , T2 >::same_instance( x1 , x2 );
+}
+
+
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+#endif
diff --git a/include/boost/numeric/odeint/util/same_size.hpp b/include/boost/numeric/odeint/util/same_size.hpp
new file mode 100644
index 0000000..81ae249
--- /dev/null
+++ b/include/boost/numeric/odeint/util/same_size.hpp
@@ -0,0 +1,115 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/state_wrapper.hpp
+
+ [begin_description]
+ State wrapper for the state type in all stepper. The state wrappers are responsible for construction,
+ destruction, copying construction, assignment and resizing.
+ [end_description]
+
+ Copyright 2011-2013 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_UTIL_SAME_SIZE_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_SAME_SIZE_HPP_INCLUDED
+
+#include <boost/numeric/odeint/util/is_resizeable.hpp>
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/fusion/include/is_sequence.hpp>
+#include <boost/fusion/include/zip_view.hpp>
+#include <boost/fusion/include/vector.hpp>
+#include <boost/fusion/include/make_fused.hpp>
+#include <boost/fusion/include/all.hpp>
+
+#include <boost/range.hpp>
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+template< typename State1 , typename State2 , class Enabler = void >
+struct same_size_impl_sfinae
+{
+ static bool same_size( const State1 &x1 , const State2 &x2 )
+ {
+ return ( boost::size( x1 ) == boost::size( x2 ) );
+ }
+
+};
+
+// same_size function
+// standard implementation relies on boost.range
+template< class State1 , class State2 >
+struct same_size_impl
+{
+ static bool same_size( const State1 &x1 , const State2 &x2 )
+ {
+ return same_size_impl_sfinae< State1 , State2 >::same_size( x1 , x2 );
+ }
+};
+
+
+// do not overload or specialize this function, specialize resize_impl<> instead
+template< class State1 , class State2 >
+bool same_size( const State1 &x1 , const State2 &x2 )
+{
+ return same_size_impl< State1 , State2 >::same_size( x1 , x2 );
+}
+
+namespace detail {
+
+struct same_size_fusion
+{
+ typedef bool result_type;
+
+ template< class S1 , class S2 >
+ bool operator()( const S1 &x1 , const S2 &x2 ) const
+ {
+ return same_size_op( x1 , x2 , typename is_resizeable< S1 >::type() );
+ }
+
+ template< class S1 , class S2 >
+ bool same_size_op( const S1 &x1 , const S2 &x2 , boost::true_type ) const
+ {
+ return same_size( x1 , x2 );
+ }
+
+ template< class S1 , class S2 >
+ bool same_size_op( const S1 &/*x1*/ , const S2 &/*x2*/ , boost::false_type ) const
+ {
+ return true;
+ }
+};
+
+} // namespace detail
+
+
+
+template< class FusionSeq >
+struct same_size_impl_sfinae< FusionSeq , FusionSeq , typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSeq >::type >::type >
+{
+ static bool same_size( const FusionSeq &x1 , const FusionSeq &x2 )
+ {
+ typedef boost::fusion::vector< const FusionSeq& , const FusionSeq& > Sequences;
+ Sequences sequences( x1 , x2 );
+ return boost::fusion::all( boost::fusion::zip_view< Sequences >( sequences ) ,
+ boost::fusion::make_fused( detail::same_size_fusion() ) );
+ }
+};
+
+
+}
+}
+}
+
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_SAME_SIZE_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/split.hpp b/include/boost/numeric/odeint/util/split.hpp
new file mode 100644
index 0000000..ba9875a
--- /dev/null
+++ b/include/boost/numeric/odeint/util/split.hpp
@@ -0,0 +1,64 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/split.hpp
+
+ [begin_description]
+ Split abstraction for parallel backends.
+ [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_UTIL_SPLIT_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_SPLIT_HPP_INCLUDED
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+/*
+ * No default implementation of the split operation
+ */
+template< class Container1, class Container2 , class Enabler = void >
+struct split_impl
+{
+ static void split( const Container1 &from , Container2 &to );
+};
+
+template< class Container1 , class Container2 >
+void split( const Container1 &from , Container2 &to )
+{
+ split_impl< Container1 , Container2 >::split( from , to );
+}
+
+
+/*
+ * No default implementation of the unsplit operation
+ */
+template< class Container1, class Container2 , class Enabler = void >
+struct unsplit_impl
+{
+ static void unsplit( const Container1 &from , Container2 &to );
+};
+
+template< class Container1 , class Container2 >
+void unsplit( const Container1 &from , Container2 &to )
+{
+ unsplit_impl< Container1 , Container2 >::unsplit( from , to );
+}
+
+
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED
+
diff --git a/include/boost/numeric/odeint/util/split_adaptor.hpp b/include/boost/numeric/odeint/util/split_adaptor.hpp
new file mode 100644
index 0000000..cf0d623
--- /dev/null
+++ b/include/boost/numeric/odeint/util/split_adaptor.hpp
@@ -0,0 +1,102 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/split_adaptor.hpp
+
+ [begin_description]
+ A range adaptor which returns even-sized slices.
+ [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_UTIL_SPLIT_ADAPTOR_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_SPLIT_ADAPTOR_INCLUDED
+
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/size_type.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <algorithm>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+namespace detail {
+
+/** \brief Returns the begin and end offset for a sub-range */
+inline std::pair<std::size_t, std::size_t>
+split_offsets( std::size_t total_length, std::size_t index, std::size_t parts )
+{
+ BOOST_ASSERT( parts > 0 );
+ BOOST_ASSERT( index < parts );
+ const std::size_t
+ slice = total_length / parts,
+ partial = total_length % parts,
+ lo = (std::min)(index, partial),
+ hi = (std::max<std::ptrdiff_t>)(0, index - partial),
+ begin_offset = lo * (slice + 1) + hi * slice,
+ length = slice + (index < partial ? 1 : 0),
+ end_offset = begin_offset + length;
+ return std::make_pair( begin_offset, end_offset );
+}
+
+/** \brief Return the sub-range `index` from a range which is split into `parts`.
+ *
+ * For example, splitting a range into three about equal-sized sub-ranges:
+ * \code
+ * sub0 = make_split_range(rng, 0, 3);
+ * sub1 = rng | split(1, 3);
+ * sub2 = rng | split(2, 3);
+ * \endcode
+ */
+template< class RandomAccessRange >
+inline iterator_range< typename range_iterator<RandomAccessRange>::type >
+make_split_range( RandomAccessRange& rng, std::size_t index, std::size_t parts )
+{
+ const std::pair<std::size_t, std::size_t> off = split_offsets(boost::size(rng), index, parts);
+ return make_iterator_range( boost::begin(rng) + off.first, boost::begin(rng) + off.second );
+}
+
+template< class RandomAccessRange >
+inline iterator_range< typename range_iterator<const RandomAccessRange>::type >
+make_split_range( const RandomAccessRange& rng, std::size_t index, std::size_t parts )
+{
+ const std::pair<std::size_t, std::size_t> off = split_offsets(boost::size(rng), index, parts);
+ return make_iterator_range( boost::begin(rng) + off.first, boost::begin(rng) + off.second );
+}
+
+
+struct split
+{
+ split(std::size_t index, std::size_t parts)
+ : index(index), parts(parts) {}
+ std::size_t index, parts;
+};
+
+template< class RandomAccessRange >
+inline iterator_range< typename range_iterator<RandomAccessRange>::type >
+operator|( RandomAccessRange& rng, const split& f )
+{
+ return make_split_range( rng, f.index, f.parts );
+}
+
+template< class RandomAccessRange >
+inline iterator_range< typename range_iterator<const RandomAccessRange>::type >
+operator|( const RandomAccessRange& rng, const split& f )
+{
+ return make_split_range( rng, f.index, f.parts );
+}
+
+
+}
+}
+}
+}
+
+#endif
diff --git a/include/boost/numeric/odeint/util/state_wrapper.hpp b/include/boost/numeric/odeint/util/state_wrapper.hpp
new file mode 100644
index 0000000..10f8ecd
--- /dev/null
+++ b/include/boost/numeric/odeint/util/state_wrapper.hpp
@@ -0,0 +1,50 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/state_wrapper.hpp
+
+ [begin_description]
+ State wrapper for the state type in all stepper. The state wrappers are responsible for construction,
+ destruction, copying construction, assignment and resizing.
+ [end_description]
+
+ Copyright 2011-2012 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_UTIL_STATE_WRAPPER_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_STATE_WRAPPER_HPP_INCLUDED
+
+
+#include <boost/type_traits/integral_constant.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 {
+
+
+template< class V , class Enabler = void >
+struct state_wrapper
+{
+ typedef state_wrapper< V > state_wrapper_type;
+
+ V m_v;
+};
+
+
+}
+}
+}
+
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_STATE_WRAPPER_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/stepper_traits.hpp b/include/boost/numeric/odeint/util/stepper_traits.hpp
new file mode 100644
index 0000000..5d1d31a
--- /dev/null
+++ b/include/boost/numeric/odeint/util/stepper_traits.hpp
@@ -0,0 +1,63 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/stepper_traits.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_UTIL_STEPPER_TRAITS_HPP_DEFINED
+#define BOOST_NUMERIC_ODEINT_UTIL_STEPPER_TRAITS_HPP_DEFINED
+
+#include <boost/numeric/odeint/util/unwrap_reference.hpp>
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+namespace traits {
+
+template< class Stepper >
+struct state_type
+{
+ typedef typename boost::numeric::odeint::unwrap_reference< Stepper >::type stepper_type;
+ typedef typename stepper_type::state_type type;
+};
+
+template< class Stepper >
+struct time_type
+{
+ typedef typename boost::numeric::odeint::unwrap_reference< Stepper >::type stepper_type;
+ typedef typename stepper_type::time_type type;
+};
+
+template< class Stepper >
+struct stepper_category
+{
+ typedef typename boost::numeric::odeint::unwrap_reference< Stepper >::type stepper_type;
+ typedef typename stepper_type::stepper_category type;
+};
+
+template< class Stepper >
+struct value_type
+{
+ typedef typename boost::numeric::odeint::unwrap_reference< Stepper >::type stepper_type;
+ typedef typename stepper_type::value_type type;
+};
+
+} // namespace traits
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_STEPPER_TRAITS_HPP_DEFINED
diff --git a/include/boost/numeric/odeint/util/ublas_matrix_expression.patch b/include/boost/numeric/odeint/util/ublas_matrix_expression.patch
new file mode 100644
index 0000000..4e8ac6c
--- /dev/null
+++ b/include/boost/numeric/odeint/util/ublas_matrix_expression.patch
@@ -0,0 +1,6 @@
+3390,3392c3390
+< typename enable_if< is_convertible<typename E1::value_type , T2>,
+< typename matrix_binary_scalar2_traits<E1, const T2, scalar_divides<typename E1::value_type, T2> >::result_type
+< > ::result_type
+---
+> typename matrix_binary_scalar2_traits<E1, const T2, scalar_divides<typename E1::value_type, T2> >::result_type
diff --git a/include/boost/numeric/odeint/util/ublas_wrapper.hpp b/include/boost/numeric/odeint/util/ublas_wrapper.hpp
new file mode 100644
index 0000000..c8facfc
--- /dev/null
+++ b/include/boost/numeric/odeint/util/ublas_wrapper.hpp
@@ -0,0 +1,297 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/ublas_wrapper.hpp
+
+ [begin_description]
+ Resizing for ublas::vector and ublas::matrix
+ [end_description]
+
+ Copyright 2011-2013 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_UTIL_UBLAS_WRAPPER_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_UBLAS_WRAPPER_HPP_INCLUDED
+
+
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/lu.hpp>
+#include <boost/numeric/ublas/vector_expression.hpp>
+#include <boost/numeric/ublas/matrix_expression.hpp>
+
+#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
+#include <boost/numeric/odeint/algebra/default_operations.hpp>
+
+#include <boost/numeric/odeint/util/is_resizeable.hpp>
+#include <boost/numeric/odeint/util/state_wrapper.hpp>
+
+
+/* extend ublas by a few operations */
+
+/* map norm_inf onto reduce( v , default_operations::maximum ) */
+namespace boost { namespace numeric { namespace odeint {
+
+ template< typename T , typename A >
+ struct vector_space_norm_inf< boost::numeric::ublas::vector<T,A> >
+ {
+ typedef T result_type;
+
+ result_type operator()( const boost::numeric::ublas::vector<T,A> &x ) const
+ {
+ return boost::numeric::ublas::norm_inf( x );
+ }
+ };
+
+
+ template< class T , class L , class A >
+ struct vector_space_norm_inf< boost::numeric::ublas::matrix<T,L,A> >
+ {
+ typedef T result_type;
+
+ result_type operator()( const boost::numeric::ublas::matrix<T,L,A> &x ) const
+ {
+ return boost::numeric::ublas::norm_inf( x );
+ }
+ };
+} } }
+
+/* additional operations:
+ * abs( v )
+ * v / w
+ * a + v
+ */
+namespace boost { namespace numeric { namespace ublas {
+
+
+ // elementwise abs - calculates absolute values of the elements
+ template<class T>
+ struct scalar_abs: public scalar_unary_functor<T> {
+ typedef typename scalar_unary_functor<T>::value_type value_type;
+ typedef typename scalar_unary_functor<T>::argument_type argument_type;
+ typedef typename scalar_unary_functor<T>::result_type result_type;
+
+ static BOOST_UBLAS_INLINE
+ result_type apply (argument_type t) {
+ using std::abs;
+ return abs (t);
+ }
+ };
+
+
+ // (abs v) [i] = abs (v [i])
+ template<class E>
+ BOOST_UBLAS_INLINE
+ typename vector_unary_traits<E, scalar_abs<typename E::value_type> >::result_type
+ abs (const vector_expression<E> &e) {
+ typedef typename vector_unary_traits<E, scalar_abs<typename E::value_type> >::expression_type expression_type;
+ return expression_type (e ());
+ }
+
+ // (abs m) [i] = abs (m [i])
+ template<class E>
+ BOOST_UBLAS_INLINE
+ typename matrix_unary1_traits<E, scalar_abs<typename E::value_type> >::result_type
+ abs (const matrix_expression<E> &e) {
+ typedef typename matrix_unary1_traits<E, scalar_abs<typename E::value_type> >::expression_type expression_type;
+ return expression_type (e ());
+ }
+
+
+ // elementwise division (v1 / v2) [i] = v1 [i] / v2 [i]
+ template<class E1, class E2>
+ BOOST_UBLAS_INLINE
+ typename vector_binary_traits<E1, E2, scalar_divides<typename E1::value_type,
+ typename E2::value_type> >::result_type
+ operator / (const vector_expression<E1> &e1,
+ const vector_expression<E2> &e2) {
+ typedef typename vector_binary_traits<E1, E2, scalar_divides<typename E1::value_type,
+ typename E2::value_type> >::expression_type expression_type;
+ return expression_type (e1 (), e2 ());
+ }
+
+
+ // elementwise division (m1 / m2) [i] = m1 [i] / m2 [i]
+ template<class E1, class E2>
+ BOOST_UBLAS_INLINE
+ typename matrix_binary_traits<E1, E2, scalar_divides<typename E1::value_type,
+ typename E2::value_type> >::result_type
+ operator / (const matrix_expression<E1> &e1,
+ const matrix_expression<E2> &e2) {
+ typedef typename matrix_binary_traits<E1, E2, scalar_divides<typename E1::value_type,
+ typename E2::value_type> >::expression_type expression_type;
+ return expression_type (e1 (), e2 ());
+ }
+
+ // addition with scalar
+ // (t + v) [i] = t + v [i]
+ template<class T1, class E2>
+ BOOST_UBLAS_INLINE
+ typename enable_if< is_convertible<T1, typename E2::value_type >,
+ typename vector_binary_scalar1_traits<const T1, E2, scalar_plus<T1, typename E2::value_type> >::result_type
+ >::type
+ operator + (const T1 &e1,
+ const vector_expression<E2> &e2) {
+ typedef typename vector_binary_scalar1_traits<const T1, E2, scalar_plus<T1, typename E2::value_type> >::expression_type expression_type;
+ return expression_type (e1, e2 ());
+ }
+
+ // addition with scalar
+ // (t + m) [i] = t + m [i]
+ template<class T1, class E2>
+ BOOST_UBLAS_INLINE
+ typename enable_if< is_convertible<T1, typename E2::value_type >,
+ typename matrix_binary_scalar1_traits<const T1, E2, scalar_plus<T1, typename E2::value_type> >::result_type
+ >::type
+ operator + (const T1 &e1,
+ const matrix_expression<E2> &e2) {
+ typedef typename matrix_binary_scalar1_traits<const T1, E2, scalar_plus<T1, typename E2::value_type> >::expression_type expression_type;
+ return expression_type (e1, e2 ());
+ }
+
+} } }
+
+
+
+
+/* add resize functionality */
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+/*
+ * resizeable specialization for boost::numeric::ublas::vector
+ */
+template< class T , class A >
+struct is_resizeable< boost::numeric::ublas::vector< T , A > >
+{
+ typedef boost::true_type type;
+ const static bool value = type::value;
+};
+
+
+/*
+ * resizeable specialization for boost::numeric::ublas::matrix
+ */
+template< class T , class L , class A >
+struct is_resizeable< boost::numeric::ublas::matrix< T , L , A > >
+{
+ typedef boost::true_type type;
+ const static bool value = type::value;
+};
+
+
+/*
+ * resizeable specialization for boost::numeric::ublas::permutation_matrix
+ */
+template< class T , class A >
+struct is_resizeable< boost::numeric::ublas::permutation_matrix< T , A > >
+{
+ typedef boost::true_type type;
+ const static bool value = type::value;
+};
+
+
+// specialization for ublas::matrix
+// same size and resize specialization for matrix-matrix resizing
+template< class T , class L , class A , class T2 , class L2 , class A2 >
+struct same_size_impl< boost::numeric::ublas::matrix< T , L , A > , boost::numeric::ublas::matrix< T2 , L2 , A2 > >
+{
+ static bool same_size( const boost::numeric::ublas::matrix< T , L , A > &m1 ,
+ const boost::numeric::ublas::matrix< T2 , L2 , A2 > &m2 )
+ {
+ return ( ( m1.size1() == m2.size1() ) && ( m1.size2() == m2.size2() ) );
+ }
+};
+
+template< class T , class L , class A , class T2 , class L2 , class A2 >
+struct resize_impl< boost::numeric::ublas::matrix< T , L , A > , boost::numeric::ublas::matrix< T2 , L2 , A2 > >
+{
+ static void resize( boost::numeric::ublas::matrix< T , L , A > &m1 ,
+ const boost::numeric::ublas::matrix< T2 , L2 , A2 > &m2 )
+ {
+ m1.resize( m2.size1() , m2.size2() );
+ }
+};
+
+
+
+// same size and resize specialization for matrix-vector resizing
+template< class T , class L , class A , class T_V , class A_V >
+struct same_size_impl< boost::numeric::ublas::matrix< T , L , A > , boost::numeric::ublas::vector< T_V , A_V > >
+{
+ static bool same_size( const boost::numeric::ublas::matrix< T , L , A > &m ,
+ const boost::numeric::ublas::vector< T_V , A_V > &v )
+ {
+ return ( ( m.size1() == v.size() ) && ( m.size2() == v.size() ) );
+ }
+};
+
+template< class T , class L , class A , class T_V , class A_V >
+struct resize_impl< boost::numeric::ublas::matrix< T , L , A > , boost::numeric::ublas::vector< T_V , A_V > >
+{
+ static void resize( boost::numeric::ublas::matrix< T , L , A > &m ,
+ const boost::numeric::ublas::vector< T_V , A_V > &v )
+ {
+ m.resize( v.size() , v.size() );
+ }
+};
+
+
+
+// specialization for ublas::permutation_matrix
+// same size and resize specialization for matrix-vector resizing
+template< class T , class A , class T_V , class A_V >
+struct same_size_impl< boost::numeric::ublas::permutation_matrix< T , A > ,
+ boost::numeric::ublas::vector< T_V , A_V > >
+{
+ static bool same_size( const boost::numeric::ublas::permutation_matrix< T , A > &m ,
+ const boost::numeric::ublas::vector< T_V , A_V > &v )
+ {
+ return ( m.size() == v.size() ); // && ( m.size2() == v.size() ) );
+ }
+};
+
+template< class T , class A , class T_V , class A_V >
+struct resize_impl< boost::numeric::ublas::vector< T_V , A_V > ,
+ boost::numeric::ublas::permutation_matrix< T , A > >
+{
+ static void resize( const boost::numeric::ublas::vector< T_V , A_V > &v,
+ boost::numeric::ublas::permutation_matrix< T , A > &m )
+ {
+ m.resize( v.size() , v.size() );
+ }
+};
+
+
+
+
+
+
+
+template< class T , class A >
+struct state_wrapper< boost::numeric::ublas::permutation_matrix< T , A > > // with resizing
+{
+ typedef boost::numeric::ublas::permutation_matrix< T , A > state_type;
+ typedef state_wrapper< state_type > state_wrapper_type;
+
+ state_type m_v;
+
+ state_wrapper() : m_v( 1 ) // permutation matrix constructor requires a size, choose 1 as default
+ { }
+
+};
+
+
+
+
+} } }
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_UBLAS_WRAPPER_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/unit_helper.hpp b/include/boost/numeric/odeint/util/unit_helper.hpp
new file mode 100644
index 0000000..736b3e5
--- /dev/null
+++ b/include/boost/numeric/odeint/util/unit_helper.hpp
@@ -0,0 +1,151 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/unit_helper.hpp
+
+ [begin_description]
+ Get and set the value of a unit.
+ [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_UTIL_UNIT_HELPER_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_UNIT_HELPER_HPP_INCLUDED
+
+
+#ifndef __CUDACC__
+#include <boost/units/quantity.hpp>
+#include <boost/units/get_dimension.hpp>
+#include <boost/units/get_system.hpp>
+#endif
+
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+namespace detail {
+
+ template<class T , class Enabler = void >
+ struct get_unit_value_impl
+ {
+ static T value(const T &t)
+ {
+ return t;
+ }
+ typedef T result_type;
+ };
+
+#ifndef __CUDACC__
+ template<class Unit , class T>
+ struct get_unit_value_impl< boost::units::quantity< Unit , T> >
+ {
+ static T value( const boost::units::quantity< Unit , T> &t )
+ {
+ return t.value();
+ }
+ typedef T result_type;
+ };
+#endif
+
+
+
+
+
+ template<class T , class V , class Enabler = void >
+ struct set_unit_value_impl
+ {
+ static void set_value(T &t , const V &v)
+ {
+ t = v;
+ }
+ };
+
+#ifndef __CUDACC__
+ template<class Unit , class T , class V>
+ struct set_unit_value_impl<boost::units::quantity<Unit , T> , V>
+ {
+ static void set_value(boost::units::quantity<Unit , T> &t , const V &v)
+ {
+ t = boost::units::quantity<Unit , T>::from_value(v);
+ }
+ };
+#endif
+
+
+
+} // namespace detail
+
+
+ template<class T>
+ typename detail::get_unit_value_impl<T>::result_type get_unit_value(const T &t)
+ {
+ return detail::get_unit_value_impl<T>::value(t);
+ }
+
+
+ template<class T , class V>
+ void set_unit_value(T &t , const V &v)
+ {
+ return detail::set_unit_value_impl<T , V>::set_value(t , v);
+ }
+
+
+
+ template< class T >
+ struct unit_value_type
+ {
+ typedef T type;
+ };
+
+#ifndef __CUDACC__
+ template< class Unit , class Y >
+ struct unit_value_type< boost::units::quantity< Unit , Y > >
+ {
+ typedef Y type;
+ };
+#endif
+
+
+
+
+
+
+
+
+
+
+ template< typename Time >
+ struct inverse_time
+ {
+ typedef Time type;
+ };
+
+#ifndef __CUDACC__
+ template< typename Unit , typename Value >
+ struct inverse_time< boost::units::quantity< Unit , Value > >
+ {
+ typedef boost::units::quantity< Unit , Value > time_type;
+ typedef typename boost::units::get_dimension< time_type >::type dimension;
+ typedef typename boost::units::get_system< time_type >::type system;
+ typedef typename boost::mpl::divides< boost::units::dimensionless_type , dimension >::type inv_dimension;
+ typedef boost::units::unit< inv_dimension , system > inv_unit;
+ typedef boost::units::quantity< inv_unit , Value > type;
+ };
+#endif
+
+
+} // namespace odeint
+} // namespace numeric
+} // namespace boost
+
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_UNIT_HELPER_HPP_INCLUDED
diff --git a/include/boost/numeric/odeint/util/unwrap_reference.hpp b/include/boost/numeric/odeint/util/unwrap_reference.hpp
new file mode 100644
index 0000000..e160878
--- /dev/null
+++ b/include/boost/numeric/odeint/util/unwrap_reference.hpp
@@ -0,0 +1,166 @@
+/*
+ [auto_generated]
+ boost/numeric/odeint/util/unwrap_reference.hpp
+
+ [begin_description]
+ unwrap_reference
+ [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_UTIL_UNWRAP_REFERENCE_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_UTIL_UNWRAP_REFERENCE_HPP_INCLUDED
+
+
+#include <boost/numeric/odeint/config.hpp>
+
+
+#if BOOST_NUMERIC_ODEINT_CXX11
+#include <functional>
+#else
+#include <boost/ref.hpp>
+#endif
+
+namespace boost {
+
+#if BOOST_NUMERIC_ODEINT_CXX11
+template<typename T> class reference_wrapper;
+
+template<typename T> struct unwrap_reference;
+#endif
+
+namespace numeric {
+namespace odeint {
+
+
+#if BOOST_NUMERIC_ODEINT_CXX11
+
+template<typename T>
+struct unwrap_reference
+{
+ typedef typename std::remove_reference<T>::type type;
+};
+
+template<typename T>
+struct unwrap_reference< std::reference_wrapper<T> >
+{
+ typedef typename std::remove_reference<T>::type type;
+};
+
+template<typename T>
+struct unwrap_reference< boost::reference_wrapper<T> >
+{
+ typedef typename boost::unwrap_reference<T>::type type;
+};
+
+#else
+
+using ::boost::unwrap_reference;
+
+#endif
+
+namespace detail
+{
+
+#if BOOST_NUMERIC_ODEINT_CXX11
+
+using ::std::ref;
+
+#else
+
+using ::boost::ref;
+
+#endif
+}
+
+}
+}
+}
+
+
+
+/*
+ *
+ * the following is the suggested way, but unfortunately it does not work with all compilers.
+ */
+
+/*
+
+#include <boost/config.hpp>
+
+
+#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
+#include <boost/ref.hpp>
+#else
+#include <functional>
+#endif
+
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+
+template<typename T>
+struct unwrap_reference
+{
+ typedef typename std::remove_reference<T>::type type;
+};
+
+template<typename T>
+struct unwrap_reference< std::reference_wrapper<T> >
+{
+ typedef typename std::remove_reference<T>::type type;
+};
+
+template<typename T>
+struct unwrap_reference< boost::reference_wrapper<T> >
+{
+ typedef typename boost::unwrap_reference<T>::type type;
+};
+
+#else
+
+using ::boost::unwrap_reference;
+
+#endif
+
+}
+}
+}
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+namespace detail {
+
+
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+
+using ::std::ref;
+
+#else
+
+using ::boost::ref;
+
+#endif
+
+
+}
+}
+}
+}
+
+*/
+
+#endif // BOOST_NUMERIC_ODEINT_UTIL_UNWRAP_REFERENCE_HPP_INCLUDED