From 94de59c54a75dae2540d5a7d08576df23e32251a Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Fri, 1 Feb 2013 14:55:41 +0100 Subject: [PATCH] finalized redesign iterators --- Iteratoren.ods | Bin 10676 -> 10835 bytes .../odeint/iterator/adaptive_iterator.hpp | 2 - .../adaptive_iterator_controlled_impl.hpp | 6 +- .../adaptive_iterator_dense_output_impl.hpp | 168 ++++++++++-------- ...adaptive_time_iterator_controlled_impl.hpp | 4 +- ...aptive_time_iterator_dense_output_impl.hpp | 150 ++++++++-------- .../const_step_iterator_dense_output_impl.hpp | 158 ++++++++-------- .../detail/const_step_iterator_impl.hpp | 4 +- ...t_step_time_iterator_dense_output_impl.hpp | 154 ++++++++-------- .../detail/const_step_time_iterator_impl.hpp | 4 +- .../iterator/detail/ode_iterator_base.hpp | 4 +- .../detail/ode_time_iterator_base.hpp | 2 +- libs/numeric/odeint/examples/Jamfile.v2 | 4 +- .../odeint/examples/adaptive_iterator.cpp | 18 +- .../odeint/examples/const_step_iterator.cpp | 12 +- .../numeric/odeint/test/adaptive_iterator.cpp | 157 +++++++++++++--- .../odeint/test/adaptive_time_iterator.cpp | 120 ++++++++++++- .../odeint/test/const_step_iterator.cpp | 35 ++-- .../odeint/test/const_step_time_iterator.cpp | 32 ++-- 19 files changed, 640 insertions(+), 394 deletions(-) diff --git a/Iteratoren.ods b/Iteratoren.ods index 9cbb24ca6d861b85079f972928e73170c6c9aeb3..31efa41bb4e158abe3596e9dd983b2e6dd12ccf1 100644 GIT binary patch delta 5292 zcmdlId^vv>P&3aE)FD$hEf1xgWkMv%t2SuK;8)8bB_;+M^2YBsQimtMn z9%f`?!gNqqWs+C7F#nSJr83;L4_=yN|IgJnn`W~!dCGmh-mO9VQfDPf$h97K*9c4d z{^iS+9{0=PvQNBsX=Q6wR^Jy#a{j%;mgXUsSerL87`fl~V843pdVTX0?c^(x zGx`|3$pWb;eucRr?lj-~6#YP-eno1(DKOi_-V_ zGlx8vyZe1VvaOM82Qth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(lE>!IY4QZx7Anjt4&&#r*nGKROlAZis zRtAeihV0~EO^ADIG^Ls5$xe=z)6{|a7aFKe$iWS&eGy*%Dm(d|rUck?oLbUMLMoHb Qs)$dv)e>OKPz9+10H2AHM*si- diff --git a/boost/numeric/odeint/iterator/adaptive_iterator.hpp b/boost/numeric/odeint/iterator/adaptive_iterator.hpp index 30bfd4bb..bc8b78a6 100644 --- a/boost/numeric/odeint/iterator/adaptive_iterator.hpp +++ b/boost/numeric/odeint/iterator/adaptive_iterator.hpp @@ -19,8 +19,6 @@ #ifndef BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED #define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED -#include - #include #include #include diff --git a/boost/numeric/odeint/iterator/detail/adaptive_iterator_controlled_impl.hpp b/boost/numeric/odeint/iterator/detail/adaptive_iterator_controlled_impl.hpp index 6f217506..a15a11a9 100644 --- a/boost/numeric/odeint/iterator/detail/adaptive_iterator_controlled_impl.hpp +++ b/boost/numeric/odeint/iterator/detail/adaptive_iterator_controlled_impl.hpp @@ -20,7 +20,7 @@ #include #include -#include +#include namespace boost { @@ -47,7 +47,7 @@ namespace odeint { class adaptive_iterator< Stepper , System , controlled_stepper_tag > : public detail::ode_iterator_base < adaptive_iterator< Stepper , System , controlled_stepper_tag > , - Stepper , System , controlled_stepper_tag + Stepper , System > { private: @@ -62,7 +62,7 @@ namespace odeint { #ifndef DOXYGEN_SKIP typedef detail::ode_iterator_base< adaptive_iterator< Stepper , System , controlled_stepper_tag > , - Stepper , System , controlled_stepper_tag + Stepper , System > base_type; #endif diff --git a/boost/numeric/odeint/iterator/detail/adaptive_iterator_dense_output_impl.hpp b/boost/numeric/odeint/iterator/detail/adaptive_iterator_dense_output_impl.hpp index 0459471e..348af302 100644 --- a/boost/numeric/odeint/iterator/detail/adaptive_iterator_dense_output_impl.hpp +++ b/boost/numeric/odeint/iterator/detail/adaptive_iterator_dense_output_impl.hpp @@ -19,95 +19,105 @@ #define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ADAPTIVE_ITERATOR_DENSE_OUTPUT_IMPL_HPP_DEFINED +#include +#include + + namespace boost { namespace numeric { namespace odeint { -// /* -// * 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 Stepper , class System > -// class adaptive_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_iterator_base -// < -// adaptive_iterator< Stepper , System , dense_output_stepper_tag > , -// Stepper , System , dense_output_stepper_tag -// > -// { -// private: - -// typedef Stepper stepper_type; -// typedef System system_type; -// typedef typename stepper_type::state_type state_type; -// typedef typename stepper_type::time_type time_type; -// typedef typename stepper_type::value_type ode_value_type; -// #ifndef DOXYGEN_SKIP -// typedef detail::ode_iterator_base< -// adaptive_iterator< Stepper , System , dense_output_stepper_tag > , -// Stepper , System , dense_output_stepper_tag -// > base_type; -// #endif - -// public: + /* + * 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 Stepper , class System > + class adaptive_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_iterator_base + < + adaptive_iterator< Stepper , System , dense_output_stepper_tag > , + Stepper , System + > + { + private: -// /** -// * \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( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt ) -// : base_type( stepper , sys , s , t , t_end , dt ) -// { -// this->m_stepper.initialize( *( this->m_state ) , this->m_t , this->m_dt ); -// } - -// /** -// * \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( stepper_type stepper , system_type sys , state_type &s ) -// : base_type( stepper , sys , s ) { } - -// protected: - -// friend class boost::iterator_core_access; - -// void increment() -// { -// this->m_stepper.do_step( this->m_system ); -// this->m_t = this->m_stepper.current_time(); -// this->check_end(); -// } - -// // overwrite dereference from ode_iterator_base -// const state_type& dereference() const -// { -// return this->m_stepper.current_state(); -// } + typedef Stepper stepper_type; + typedef System system_type; + typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type; + typedef typename traits::state_type< stepper_type >::type 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< + adaptive_iterator< Stepper , System , dense_output_stepper_tag > , + Stepper , System + > 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( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt ) + : base_type( stepper , sys , s , t , t_end , dt ) + { + unwrapped_stepper_type &st = this->m_stepper; + st.initialize( *( this->m_state ) , this->m_t , this->m_dt ); + } + + /** + * \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( stepper_type stepper , system_type sys , state_type &s ) + : base_type( stepper , sys , s ) { } + + protected: + + friend class boost::iterator_core_access; + + void increment() + { + unwrapped_stepper_type &stepper = this->m_stepper; + stepper.do_step( this->m_system ); + this->m_t = stepper.current_time(); + this->check_end(); + } + + // overwrite dereference from ode_iterator_base + const state_type& dereference() const + { + const unwrapped_stepper_type &stepper = this->m_stepper; + return stepper.current_state(); + } + + + }; diff --git a/boost/numeric/odeint/iterator/detail/adaptive_time_iterator_controlled_impl.hpp b/boost/numeric/odeint/iterator/detail/adaptive_time_iterator_controlled_impl.hpp index f59917ac..ca3b9d37 100644 --- a/boost/numeric/odeint/iterator/detail/adaptive_time_iterator_controlled_impl.hpp +++ b/boost/numeric/odeint/iterator/detail/adaptive_time_iterator_controlled_impl.hpp @@ -46,7 +46,7 @@ namespace odeint { class adaptive_time_iterator< Stepper , System , controlled_stepper_tag > : public detail::ode_time_iterator_base < adaptive_time_iterator< Stepper , System , controlled_stepper_tag > , - Stepper , System , controlled_stepper_tag + Stepper , System > { private: @@ -59,7 +59,7 @@ namespace odeint { typedef typename unwrapped_stepper_type::value_type ode_value_type; typedef detail::ode_time_iterator_base< adaptive_time_iterator< Stepper , System , controlled_stepper_tag > , - Stepper , System , controlled_stepper_tag > base_type; + Stepper , System > base_type; public: diff --git a/boost/numeric/odeint/iterator/detail/adaptive_time_iterator_dense_output_impl.hpp b/boost/numeric/odeint/iterator/detail/adaptive_time_iterator_dense_output_impl.hpp index 93ca3330..e4453dd1 100644 --- a/boost/numeric/odeint/iterator/detail/adaptive_time_iterator_dense_output_impl.hpp +++ b/boost/numeric/odeint/iterator/detail/adaptive_time_iterator_dense_output_impl.hpp @@ -23,81 +23,91 @@ namespace boost { namespace numeric { namespace odeint { -// /* -// * Specilization for steppers and error steppers -// */ -// /** -// * \brief ODE Iterator with adaptive step size control. The value type of this iterator is a pair of state type and time type of the stepper. -// * -// * Implements an ODE 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 a pair of 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. -// */ -// template< class Stepper , class System > -// class adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_time_iterator_base -// < -// adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > , -// Stepper , System , dense_output_stepper_tag -// > -// { -// private: + /* + * Specilization for steppers and error steppers + */ + /** + * \brief ODE Iterator with adaptive step size control. The value type of this iterator is a pair of state type and time type of the stepper. + * + * Implements an ODE 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 a pair of 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. + */ + template< class Stepper , class System > + class adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_time_iterator_base + < + adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > , + Stepper , System + > + { + private: -// typedef Stepper stepper_type; -// typedef System system_type; -// typedef typename stepper_type::state_type state_type; -// typedef typename stepper_type::time_type time_type; -// typedef typename stepper_type::value_type ode_value_type; -// typedef detail::ode_time_iterator_base< -// adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > , -// Stepper , System , dense_output_stepper_tag > base_type; - -// public: - -// /** -// * \brief Constructs an adaptive_time_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_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. -// */ -// adaptive_time_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt ) -// : base_type( stepper , sys , s , t , t_end , dt ) -// { -// this->m_stepper.initialize( this->m_state.first , this->m_state.second , this->m_dt ); -// } - -// /** -// * \brief Constructs an adaptive_time_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_time_iterator stores a reference of s and changes its value during the iteration. -// */ -// adaptive_time_iterator( stepper_type stepper , system_type sys , state_type &s ) -// : base_type( stepper , sys , s ) -// { -// } + typedef Stepper stepper_type; + typedef System system_type; + typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type; + typedef typename unwrapped_stepper_type::state_type state_type; + typedef typename unwrapped_stepper_type::time_type time_type; + typedef typename unwrapped_stepper_type::value_type ode_value_type; + typedef detail::ode_time_iterator_base< + adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > , + Stepper , System > base_type; -// private: + public: -// friend class boost::iterator_core_access; + /** + * \brief Constructs an adaptive_time_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_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. + */ + adaptive_time_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt ) + : base_type( stepper , sys , s , t , t_end , dt ) + { + unwrapped_stepper_type &st = this->m_stepper; + st.initialize( *(this->m_state) , this->m_t , this->m_dt ); + } -// void increment() -// { -// this->m_stepper.do_step( this->m_system ); -// this->m_state.second = this->m_stepper.current_time(); -// this->m_stepper.calc_state( this->m_state.second , this->m_state.first ); -// this->check_end(); -// } -// }; + /** + * \brief Constructs an adaptive_time_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_time_iterator stores a reference of s and changes its value during the iteration. + */ + adaptive_time_iterator( stepper_type stepper , system_type sys , state_type &s ) + : base_type( stepper , sys , s ) + { + } + + + private: + + friend class boost::iterator_core_access; + + std::pair< const state_type& , const time_type& > dereference() const + { + const unwrapped_stepper_type &stepper = this->m_stepper; + return std::pair< const state_type & , const time_type & >( stepper.current_state() , this->m_t ); + } + + + void increment() + { + unwrapped_stepper_type &stepper = this->m_stepper; + stepper.do_step( this->m_system ); + this->m_t = stepper.current_time(); + this->check_end(); + } + }; diff --git a/boost/numeric/odeint/iterator/detail/const_step_iterator_dense_output_impl.hpp b/boost/numeric/odeint/iterator/detail/const_step_iterator_dense_output_impl.hpp index 2b0c0e9c..e2504e65 100644 --- a/boost/numeric/odeint/iterator/detail/const_step_iterator_dense_output_impl.hpp +++ b/boost/numeric/odeint/iterator/detail/const_step_iterator_dense_output_impl.hpp @@ -19,92 +19,104 @@ #define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_CONST_STEP_ITERATOR_DENSE_OUTPUT_IMPL_HPP_DEFINED +#include +#include + namespace boost { namespace numeric { namespace odeint { -// /* -// * 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 Stepper , class System > -// class const_step_iterator< Stepper , System , dense_output_stepper_tag > -// : public detail::ode_iterator_base< -// const_step_iterator< Stepper , System , dense_output_stepper_tag > , -// Stepper , System , dense_output_stepper_tag > -// { -// private: + /* + * 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 Stepper , class System > + class const_step_iterator< Stepper , System , dense_output_stepper_tag > + : public detail::ode_iterator_base< + const_step_iterator< Stepper , System , dense_output_stepper_tag > , + Stepper , System > + { + private: -// typedef Stepper stepper_type; -// typedef System system_type; -// typedef typename stepper_type::state_type state_type; -// typedef typename stepper_type::time_type time_type; -// typedef typename stepper_type::value_type ode_value_type; -// typedef detail::ode_iterator_base< -// const_step_iterator< Stepper , System , dense_output_stepper_tag > , -// Stepper , System , dense_output_stepper_tag > base_type; + typedef Stepper stepper_type; + typedef System system_type; + typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type; + typedef typename traits::state_type< stepper_type >::type 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< + const_step_iterator< Stepper , System , dense_output_stepper_tag > , + Stepper , System > base_type; + #endif -// public: + 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( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt ) -// : base_type( stepper , sys , s , t , t_end , dt ) -// { -// this->m_stepper.initialize( * ( this->m_state ) , this->m_t , this->m_dt ); -// } + /** + * \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( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt ) + : base_type( stepper , sys , s , t , t_end , dt ) + { + 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. -// */ -// const_step_iterator( stepper_type stepper , system_type sys , state_type &s ) -// : base_type( stepper , sys , s ) { } + /** + * \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( stepper_type stepper , system_type sys , state_type &s ) + : base_type( stepper , sys , s ) + { + } -// protected: -// friend class boost::iterator_core_access; + protected: -// void increment( void ) -// { -// this->m_t += this->m_dt; -// if( get_unit_value( this->m_dt ) > static_cast< ode_value_type >( 0.0 ) ) -// { -// while( this->m_stepper.current_time() < this->m_t ) -// this->m_stepper.do_step( this->m_system ); -// } -// else -// { -// while( this->m_stepper.current_time() > this->m_t ) -// this->m_stepper.do_step( this->m_system ); -// } -// this->m_stepper.calc_state( this->m_t , *( this->m_state ) ); -// this->check_end(); -// } -// }; + friend class boost::iterator_core_access; + + void increment( void ) + { + unwrapped_stepper_type &stepper = this->m_stepper; + + this->m_t += this->m_dt; + if( get_unit_value( this->m_dt ) > static_cast< ode_value_type >( 0.0 ) ) + { + while( stepper.current_time() < this->m_t ) + stepper.do_step( this->m_system ); + } + else + { + while( stepper.current_time() > this->m_t ) + stepper.do_step( this->m_system ); + } + stepper.calc_state( this->m_t , *( this->m_state ) ); + this->check_end(); + } + }; diff --git a/boost/numeric/odeint/iterator/detail/const_step_iterator_impl.hpp b/boost/numeric/odeint/iterator/detail/const_step_iterator_impl.hpp index 165ba9ed..342b31a2 100644 --- a/boost/numeric/odeint/iterator/detail/const_step_iterator_impl.hpp +++ b/boost/numeric/odeint/iterator/detail/const_step_iterator_impl.hpp @@ -47,7 +47,7 @@ namespace odeint { class const_step_iterator< Stepper , System , stepper_tag > : public detail::ode_iterator_base< const_step_iterator< Stepper , System , stepper_tag > , - Stepper , System , stepper_tag > + Stepper , System > { private: @@ -60,7 +60,7 @@ namespace odeint { #ifndef DOXYGEN_SKIP typedef detail::ode_iterator_base< const_step_iterator< Stepper , System , stepper_tag > , - Stepper , System , stepper_tag > base_type; + Stepper , System > base_type; #endif public: diff --git a/boost/numeric/odeint/iterator/detail/const_step_time_iterator_dense_output_impl.hpp b/boost/numeric/odeint/iterator/detail/const_step_time_iterator_dense_output_impl.hpp index 769a12bd..945b0e09 100644 --- a/boost/numeric/odeint/iterator/detail/const_step_time_iterator_dense_output_impl.hpp +++ b/boost/numeric/odeint/iterator/detail/const_step_time_iterator_dense_output_impl.hpp @@ -24,89 +24,93 @@ namespace numeric { namespace odeint { -// /* -// * Specilization for dense output steppers -// */ -// /** -// * \brief ODE Iterator with constant step size. The value type of this iterator is a pair of state type and -// * time type of the stepper. -// * -// * Implements an ODE iterator which solves the ODE with constant step size. Uses dense-output steppers. -// * const_step_time_iterator is a model of single-pass iterator. -// * -// * The value type of this iterator is a pair of 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. -// */ -// template< class Stepper , class System > -// class const_step_time_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_time_iterator_base -// < -// const_step_time_iterator< Stepper , System , dense_output_stepper_tag > , -// Stepper , System , dense_output_stepper_tag -// > -// { -// private: + /* + * Specilization for dense output steppers + */ + /** + * \brief ODE Iterator with constant step size. The value type of this iterator is a pair of state type and + * time type of the stepper. + * + * Implements an ODE iterator which solves the ODE with constant step size. Uses dense-output steppers. + * const_step_time_iterator is a model of single-pass iterator. + * + * The value type of this iterator is a pair of 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. + */ + template< class Stepper , class System > + class const_step_time_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_time_iterator_base + < + const_step_time_iterator< Stepper , System , dense_output_stepper_tag > , + Stepper , System + > + { + private: -// typedef Stepper stepper_type; -// typedef System system_type; -// typedef typename stepper_type::state_type state_type; -// typedef typename stepper_type::time_type time_type; -// typedef typename stepper_type::value_type ode_value_type; -// typedef detail::ode_time_iterator_base< -// const_step_time_iterator< Stepper , System , dense_output_stepper_tag > , -// Stepper , System , dense_output_stepper_tag > base_type; + typedef Stepper stepper_type; + typedef System system_type; + typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type; + typedef typename unwrapped_stepper_type::state_type state_type; + typedef typename unwrapped_stepper_type::time_type time_type; + typedef typename unwrapped_stepper_type::value_type ode_value_type; + typedef detail::ode_time_iterator_base< + const_step_time_iterator< Stepper , System , dense_output_stepper_tag > , + Stepper , System > base_type; -// public: + public: -// /** -// * \brief Constructs a const_step_time_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_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. -// */ -// const_step_time_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt ) -// : base_type( stepper , sys , s , t , t_end , dt ) -// { -// this->m_stepper.initialize( this->m_state.first , this->m_state.second , this->m_dt ); -// } + /** + * \brief Constructs a const_step_time_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_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. + */ + const_step_time_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt ) + : base_type( stepper , sys , s , t , t_end , dt ) + { + unwrapped_stepper_type &st = this->m_stepper; + st.initialize( *(this->m_state) , this->m_t , this->m_dt ); + } -// /** -// * \brief Constructs a const_step_time_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_time_iterator stores a reference of s and changes its value during the iteration. -// */ -// const_step_time_iterator( stepper_type stepper , system_type sys , state_type &s ) -// : base_type( stepper , sys , s ) {} + /** + * \brief Constructs a const_step_time_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_time_iterator stores a reference of s and changes its value during the iteration. + */ + const_step_time_iterator( stepper_type stepper , system_type sys , state_type &s ) + : base_type( stepper , sys , s ) {} -// protected: + protected: -// friend class boost::iterator_core_access; + friend class boost::iterator_core_access; -// void increment() -// { -// this->m_state.second += this->m_dt; -// if( get_unit_value( this->m_dt ) > static_cast< ode_value_type >( 0.0 ) ) -// { -// while( this->m_stepper.current_time() < this->m_state.second ) -// this->m_stepper.do_step( this->m_system ); -// } -// else -// { -// while( this->m_stepper.current_time() > this->m_state.second ) -// this->m_stepper.do_step( this->m_system ); -// } -// this->m_stepper.calc_state( this->m_state.second , this->m_state.first ); -// this->check_end(); -// } -// }; + void increment() + { + unwrapped_stepper_type &stepper = this->m_stepper; + + this->m_t += this->m_dt; + if( get_unit_value( this->m_dt ) > static_cast< ode_value_type >( 0.0 ) ) + { + while( stepper.current_time() < this->m_t ) + stepper.do_step( this->m_system ); + } + else + { + while( stepper.current_time() > this->m_t ) + stepper.do_step( this->m_system ); + } + stepper.calc_state( this->m_t , *(this->m_state) ); + this->check_end(); + } + }; diff --git a/boost/numeric/odeint/iterator/detail/const_step_time_iterator_impl.hpp b/boost/numeric/odeint/iterator/detail/const_step_time_iterator_impl.hpp index ef90b98c..2791c3d1 100644 --- a/boost/numeric/odeint/iterator/detail/const_step_time_iterator_impl.hpp +++ b/boost/numeric/odeint/iterator/detail/const_step_time_iterator_impl.hpp @@ -47,7 +47,7 @@ namespace odeint { class const_step_time_iterator< Stepper , System , stepper_tag > : public detail::ode_time_iterator_base < const_step_time_iterator< Stepper , System , stepper_tag > , - Stepper , System , stepper_tag + Stepper , System > { private: @@ -60,7 +60,7 @@ namespace odeint { typedef typename unwrapped_stepper_type::value_type ode_value_type; typedef detail::ode_time_iterator_base< const_step_time_iterator< Stepper , System , stepper_tag > , - Stepper , System , stepper_tag > base_type; + Stepper , System > base_type; public: diff --git a/boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp b/boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp index 68cf7381..bdb1ea08 100644 --- a/boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp +++ b/boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp @@ -33,12 +33,12 @@ namespace detail { - template< class Iterator , class Stepper , class System , class StepperTag > + template< class Iterator , class Stepper , class System > class ode_iterator_base : public boost::iterator_facade < Iterator , typename traits::state_type< Stepper >::type const , - boost::single_pass_traversal_tag + boost::single_pass_traversal_tag > { private: diff --git a/boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp b/boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp index 38fca2ba..bcc95a1d 100644 --- a/boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp +++ b/boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp @@ -32,7 +32,7 @@ namespace detail { - template< class Iterator , class Stepper , class System , class StepperTag > + template< class Iterator , class Stepper , class System > class ode_time_iterator_base : public boost::iterator_facade < Iterator , diff --git a/libs/numeric/odeint/examples/Jamfile.v2 b/libs/numeric/odeint/examples/Jamfile.v2 index 41c44df3..1e09d27a 100644 --- a/libs/numeric/odeint/examples/Jamfile.v2 +++ b/libs/numeric/odeint/examples/Jamfile.v2 @@ -33,8 +33,8 @@ exe simple1d : simple1d.cpp ; exe stochastic_euler : stochastic_euler.cpp ; exe generation_functions : generation_functions.cpp ; exe heun : heun.cpp ; -# exe const_step_iterator : const_step_iterator.cpp : -std=c++0x ; -# exe adaptive_iterator : adaptive_iterator.cpp : -std=c++0x ; +exe const_step_iterator : const_step_iterator.cpp : -std=c++0x ; +exe adaptive_iterator : adaptive_iterator.cpp : -std=c++0x ; exe bind_member_functions : bind_member_functions.cpp ; exe bind_member_functions_cpp11 : bind_member_functions_cpp11.cpp : -std=c++0x ; diff --git a/libs/numeric/odeint/examples/adaptive_iterator.cpp b/libs/numeric/odeint/examples/adaptive_iterator.cpp index 4ba61aa1..8bae0424 100644 --- a/libs/numeric/odeint/examples/adaptive_iterator.cpp +++ b/libs/numeric/odeint/examples/adaptive_iterator.cpp @@ -67,7 +67,7 @@ int main( int argc , char **argv ) state_type x = {{ 10.0 , 10.0 , 10.0 }}; std::for_each( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , make_adaptive_time_iterator_end( stepper , lorenz() , x ) , - []( const std::pair< state_type&, double > &x ) { + []( const std::pair< const state_type&, double > &x ) { std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); } @@ -79,7 +79,7 @@ int main( int argc , char **argv ) std::copy_if( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , make_adaptive_time_iterator_end( stepper , lorenz() , x ) , std::back_inserter( res ) , - []( const pair< state_type& , double > &x ) { + []( const pair< const state_type& , double > &x ) { return ( x.first[0] > 0.0 ) ? true : false; } ); for( size_t i=0 ; i &x ) { + []( double sum , const pair< const state_type& , double > &x ) { return sum + x.first[0]; } ); cout << res << endl; } @@ -106,7 +106,7 @@ int main( int argc , char **argv ) std::transform( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , make_adaptive_time_iterator_end( stepper , lorenz() , x ) , back_inserter( weights ) , - []( const pair< state_type& , double > &x ) { + []( const pair< const state_type& , double > &x ) { return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } ); for( size_t i=0 ; i() ); state_type x = {{ 10.0 , 10.0 , 10.0 }}; boost::range::for_each( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - []( const std::pair< state_type& , double > &x ) { + []( const std::pair< const state_type& , double > &x ) { std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); } @@ -145,7 +145,7 @@ int main( int argc , char **argv ) std::vector< std::pair< state_type , double > > res; state_type x = {{ 10.0 , 10.0 , 10.0 }}; boost::range::copy( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) | - boost::adaptors::filtered( [] ( const pair< state_type& , double > &x ) { return ( x.first[0] > 0.0 ); } ) , + boost::adaptors::filtered( [] ( const pair< const state_type& , double > &x ) { return ( x.first[0] > 0.0 ); } ) , std::back_inserter( res ) ); for( size_t i=0 ; i() ); state_type x = {{ 10.0 , 10.0 , 10.0 }}; double res = boost::accumulate( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 , - []( double sum , const pair< state_type& , double > &x ) { + []( double sum , const pair< const state_type& , double > &x ) { return sum + x.first[0]; } ); cout << res << endl; //] @@ -170,7 +170,7 @@ int main( int argc , char **argv ) state_type x = {{ 10.0 , 10.0 , 10.0 }}; vector< double > weights; boost::transform( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , back_inserter( weights ) , - []( const pair< state_type& , double > &x ) { + []( const pair< const state_type& , double > &x ) { return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } ); for( size_t i=0 ; i() ); state_type x = {{ 10.0 , 10.0 , 10.0 }}; auto iter = boost::find_if( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - []( const std::pair< state_type & , double > &x ) { + []( const std::pair< const state_type & , double > &x ) { return ( x.first[0] < 0.0 ); } ); cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n"; } diff --git a/libs/numeric/odeint/examples/const_step_iterator.cpp b/libs/numeric/odeint/examples/const_step_iterator.cpp index e2dda4f4..4c8a8970 100644 --- a/libs/numeric/odeint/examples/const_step_iterator.cpp +++ b/libs/numeric/odeint/examples/const_step_iterator.cpp @@ -59,7 +59,7 @@ int main( int argc , char **argv ) state_type x = {{ 10.0 , 10.0 , 10.0 }}; std::for_each( make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , make_const_step_time_iterator_end( stepper , lorenz() , x ) , - []( const std::pair< state_type&, double > &x ) { + []( const std::pair< const state_type&, double > &x ) { std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); } @@ -116,7 +116,7 @@ int main( int argc , char **argv ) std::transform( make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , make_const_step_time_iterator_end( stepper , lorenz() , x ) , back_inserter( weights ) , - []( const std::pair< state_type &, double > &x ) { + []( const std::pair< const state_type &, double > &x ) { return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } ); for( size_t i=0 ; i stepper; state_type x = {{ 10.0 , 10.0 , 10.0 }}; boost::range::for_each( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - []( const std::pair< state_type& , double > &x ) { + []( const std::pair< const state_type& , double > &x ) { std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); } @@ -185,7 +185,7 @@ int main( int argc , char **argv ) runge_kutta4< state_type > stepper; state_type x = {{ 10.0 , 10.0 , 10.0 }}; double res = boost::accumulate( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 , - []( double sum , const std::pair< state_type &, double > &x ) { + []( double sum , const std::pair< const state_type &, double > &x ) { return sum + x.first[0]; } ); cout << res << endl; //] @@ -210,7 +210,7 @@ int main( int argc , char **argv ) runge_kutta4< state_type > stepper; state_type x = {{ 10.0 , 10.0 , 10.0 }}; auto iter = boost::find_if( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - []( const std::pair< state_type & , double > &x ) { + []( const std::pair< const state_type & , double > &x ) { return ( x.first[0] < 0.0 ); } ); cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n"; @@ -246,7 +246,7 @@ int main( int argc , char **argv ) runge_kutta_dopri5< state_type > stepper; state_type x = {{ 10.0 , 10.0 , 10.0 }}; boost::range::for_each( make_const_step_time_range( make_dense_output( 1.0e-6 , 1.0e-6 , stepper ) , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - []( const std::pair< state_type& , double > &x ) { + []( const std::pair< const state_type& , double > &x ) { std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); } diff --git a/libs/numeric/odeint/test/adaptive_iterator.cpp b/libs/numeric/odeint/test/adaptive_iterator.cpp index 54a794cc..5bc95904 100644 --- a/libs/numeric/odeint/test/adaptive_iterator.cpp +++ b/libs/numeric/odeint/test/adaptive_iterator.cpp @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_SUITE( adaptive_iterator_test ) typedef mpl::vector< dummy_controlled_stepper - // , dummy_dense_output_stepper + , dummy_dense_output_stepper > dummy_steppers; @@ -72,6 +72,45 @@ BOOST_AUTO_TEST_CASE( copy_controlled_stepper_iterator ) } +BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator ) +{ + typedef adaptive_iterator< dummy_dense_output_stepper , empty_system > iterator_type; + + state_type x = {{ 1.0 }}; + iterator_type iter1( dummy_dense_output_stepper() , empty_system() , x ); + iterator_type iter2( iter1 ); + + BOOST_CHECK_NE( & (*iter1) , & (*iter2) ); + BOOST_CHECK( iter1.same( iter2 ) ); + + ++iter1; + ++iter2; + + BOOST_CHECK_NE( & (*iter1) , & (*iter2) ); + BOOST_CHECK( iter1.same( iter2 ) ); +} + +BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator_with_reference_wrapper ) +{ + typedef adaptive_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type; + + state_type x = {{ 1.0 }}; + dummy_dense_output_stepper stepper; + iterator_type iter1( boost::ref( stepper ) , empty_system() , x ); + iterator_type iter2( iter1 ); + + BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) ); + BOOST_CHECK( iter1.same( iter2 ) ); + + ++iter1; + ++iter2; + + BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) ); + BOOST_CHECK( iter1.same( iter2 ) ); +} + + + BOOST_AUTO_TEST_CASE( assignment_controlled_stepper_iterator ) { typedef adaptive_iterator< dummy_controlled_stepper , empty_system > iterator_type; @@ -87,6 +126,44 @@ BOOST_AUTO_TEST_CASE( assignment_controlled_stepper_iterator ) BOOST_CHECK( iter1.same( iter2 ) ); } + + +BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator ) +{ + typedef adaptive_iterator< dummy_dense_output_stepper , empty_system > iterator_type; + state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }}; + iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 ); + iterator_type iter2 = iterator_type( dummy_dense_output_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 ); + + BOOST_CHECK_NE( & (*iter1) , & (*iter2) ); + BOOST_CHECK( !iter1.same( iter2 ) ); + + iter2 = iter1; + + BOOST_CHECK_NE( & (*iter1) , & (*iter2) ); + BOOST_CHECK( iter1.same( iter2 ) ); +} + +BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator_with_reference_wrapper ) +{ + typedef adaptive_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type; + state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }}; + + dummy_dense_output_stepper stepper; + iterator_type iter1 = iterator_type( boost::ref( stepper ) , empty_system() , x1 , 0.0 , 0.999 , 0.1 ); + iterator_type iter2 = iterator_type( boost::ref( stepper ) , empty_system() , x2 , 0.0 , 0.999 , 0.1 ); + + BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) ); + BOOST_CHECK( !iter1.same( iter2 ) ); + + iter2 = iter1; + + BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) ); + BOOST_CHECK( iter1.same( iter2 ) ); +} + + + BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_factory ) { dummy_controlled_stepper stepper; @@ -101,6 +178,21 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_factory ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } +// just test if it compiles +BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_factory ) +{ + dummy_dense_output_stepper stepper; + empty_system system; + state_type x = {{ 1.0 }}; + + std::for_each( + make_adaptive_iterator_begin( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) , + make_adaptive_iterator_end( stepper , boost::ref( system ) , x ) , + dummy_observer() ); +} + + + BOOST_AUTO_TEST_CASE( controlled_stepper_range ) { dummy_controlled_stepper stepper; @@ -113,6 +205,18 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_range ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } +// just test if it compiles +BOOST_AUTO_TEST_CASE( dense_output_stepper_range ) +{ + dummy_dense_output_stepper stepper; + empty_system system; + state_type x = {{ 1.0 }}; + + boost::for_each( make_adaptive_range( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) , + dummy_observer() ); +} + + BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_with_reference_wrapper_factory ) { dummy_controlled_stepper stepper; @@ -127,6 +231,19 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_with_reference_wrapper_factory BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } +// just test if it compiles +BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_with_reference_wrapper_factory ) +{ + dummy_dense_output_stepper stepper; + empty_system system; + state_type x = {{ 1.0 }}; + + std::for_each( + make_adaptive_iterator_begin( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) , + make_adaptive_iterator_end( boost::ref( stepper ) , boost::ref( system ) , x ) , + dummy_observer() ); +} + BOOST_AUTO_TEST_CASE( controlled_stepper_range_with_reference_wrapper ) { dummy_controlled_stepper stepper; @@ -139,6 +256,18 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_range_with_reference_wrapper ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } +// just test if it compiles +BOOST_AUTO_TEST_CASE( dense_output_stepper_range_with_reference_wrapper ) +{ + dummy_dense_output_stepper stepper; + empty_system system; + state_type x = {{ 1.0 }}; + + boost::for_each( make_adaptive_range( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) , + dummy_observer() ); +} + + BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers ) { @@ -203,32 +332,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dum } -// BOOST_AUTO_TEST_CASE( copy_constructor_iterator_dense_output_stepper ) -// { -// state_type x = {{ 1.0 }}; -// dummy_dense_output_stepper stepper; -// adaptive_iterator< dummy_dense_output_stepper , empty_system > iter1( stepper , empty_system() , x , 0.0 , 10.0 , 0.01 ); -// adaptive_iterator< dummy_dense_output_stepper , empty_system > iter2( iter1 ); - -// const state_type &p1 = *iter1; -// const state_type &p2 = *iter2; - -// BOOST_CHECK_EQUAL( p1[0] , p2[0] ); -// BOOST_CHECK_EQUAL( p1[0] , x[0] ); - -// ++iter1; -// ++iter2; - -// BOOST_CHECK_EQUAL( p1[0] , p2[0] ); - -// const state_type &p3 = *iter1; -// const state_type &p4 = *iter2; - -// BOOST_CHECK_EQUAL( p3[0] , p4[0] ); -// BOOST_CHECK_EQUAL( p3[0] , p1[0] ); -// } - - BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/numeric/odeint/test/adaptive_time_iterator.cpp b/libs/numeric/odeint/test/adaptive_time_iterator.cpp index bf142825..902ae3cd 100644 --- a/libs/numeric/odeint/test/adaptive_time_iterator.cpp +++ b/libs/numeric/odeint/test/adaptive_time_iterator.cpp @@ -49,7 +49,7 @@ BOOST_AUTO_TEST_SUITE( adaptive_time_iterator_test ) typedef mpl::vector< dummy_controlled_stepper -// , dummy_dense_output_stepper + , dummy_dense_output_stepper > dummy_steppers; @@ -64,6 +64,30 @@ BOOST_AUTO_TEST_CASE( copy_stepper_iterator ) BOOST_CHECK( iter1.same( iter2 ) ); } +BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator ) +{ + typedef adaptive_time_iterator< dummy_dense_output_stepper , empty_system > iterator_type; + state_type x = {{ 1.0 }}; + iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 ); + iterator_type iter2 = iter1; + BOOST_CHECK_NE( &( iter1->first ) , &( iter2->first ) ); + BOOST_CHECK_NE( &( iter1->first ) , &x ); + BOOST_CHECK( iter1.same( iter2 ) ); +} + +BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator_with_reference_wrapper ) +{ + typedef adaptive_time_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type; + state_type x = {{ 1.0 }}; + dummy_dense_output_stepper stepper; + iterator_type iter1 = iterator_type( boost::ref( stepper ) , empty_system() , x , 0.0 , 0.999 , 0.1 ); + iterator_type iter2 = iter1; + BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) ); + BOOST_CHECK_NE( &( iter1->first ) , &x ); + BOOST_CHECK( iter1.same( iter2 ) ); +} + + BOOST_AUTO_TEST_CASE( assignment_stepper_iterator ) { typedef adaptive_time_iterator< dummy_controlled_stepper , empty_system > iterator_type; @@ -79,6 +103,42 @@ BOOST_AUTO_TEST_CASE( assignment_stepper_iterator ) BOOST_CHECK( iter1.same( iter2 ) ); } +BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator ) +{ + typedef adaptive_time_iterator< dummy_dense_output_stepper , empty_system > iterator_type; + state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }}; + iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 ); + iterator_type iter2 = iterator_type( dummy_dense_output_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 ); + BOOST_CHECK_NE( &( iter1->first ) , &x1 ); + BOOST_CHECK_NE( &( iter2->first ) , &x2 ); + BOOST_CHECK( !iter1.same( iter2 ) ); + iter2 = iter1; + BOOST_CHECK_NE( &( iter1->first ) , &x1 ); + BOOST_CHECK_NE( &( iter2->first ) , &x1 ); + BOOST_CHECK( iter1.same( iter2 ) ); + BOOST_CHECK_EQUAL( (iter1->first)[0] , (iter1->first)[0] ); +} + +BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator_with_reference_wrapper ) +{ + typedef adaptive_time_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type; + state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }}; + dummy_dense_output_stepper stepper; + iterator_type iter1 = iterator_type( boost::ref( stepper ) , empty_system() , x1 , 0.0 , 0.999 , 0.1 ); + iterator_type iter2 = iterator_type( boost::ref( stepper ) , empty_system() , x2 , 0.0 , 0.999 , 0.1 ); + + BOOST_CHECK_NE( &( iter1->first ) , &x1 ); + BOOST_CHECK_NE( &( iter2->first ) , &x2 ); + BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) ); + BOOST_CHECK( !iter1.same( iter2 ) ); + iter2 = iter1; + BOOST_CHECK_NE( &( iter1->first ) , &x1 ); + BOOST_CHECK_NE( &( iter2->first ) , &x1 ); + BOOST_CHECK( iter1.same( iter2 ) ); + BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) ); +} + + BOOST_AUTO_TEST_CASE( stepper_iterator_factory ) { dummy_controlled_stepper stepper; @@ -93,6 +153,20 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_factory ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } +// just test if it compiles +BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_factory ) +{ + dummy_dense_output_stepper stepper; + empty_system system; + state_type x = {{ 1.0 }}; + + std::for_each( + make_adaptive_time_iterator_begin( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) , + make_adaptive_time_iterator_end( stepper , boost::ref( system ) , x ) , + dummy_observer() ); +} + + BOOST_AUTO_TEST_CASE( stepper_range ) { dummy_controlled_stepper stepper; @@ -105,6 +179,18 @@ BOOST_AUTO_TEST_CASE( stepper_range ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } +// just test if it compiles +BOOST_AUTO_TEST_CASE( dense_output_stepper_range ) +{ + dummy_dense_output_stepper stepper; + empty_system system; + state_type x = {{ 1.0 }}; + + boost::for_each( make_adaptive_time_range( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) , + dummy_observer() ); +} + + BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory ) { dummy_controlled_stepper stepper; @@ -119,6 +205,21 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } +// just test if it compiles +BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_with_reference_wrapper_factory ) +{ + dummy_dense_output_stepper stepper; + empty_system system; + state_type x = {{ 1.0 }}; + + std::for_each( + make_adaptive_time_iterator_begin( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) , + make_adaptive_time_iterator_end( boost::ref( stepper ) , boost::ref( system ) , x ) , + dummy_observer() ); +} + + + BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper ) { dummy_controlled_stepper stepper; @@ -131,6 +232,17 @@ BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } +// just test if it compiles +BOOST_AUTO_TEST_CASE( dense_output_stepper_range_with_reference_wrapper ) +{ + dummy_dense_output_stepper stepper; + empty_system system; + state_type x = {{ 1.0 }}; + + boost::for_each( make_adaptive_time_range( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) , + dummy_observer() ); +} + @@ -170,8 +282,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers ) BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 ); BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 ); BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 ); - - BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 ); } BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers ) @@ -191,8 +301,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_ste BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 ); BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 ); BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 ); - - BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 ); } BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers ) @@ -211,8 +319,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dum BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 ); BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 ); BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 ); - - BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 ); } diff --git a/libs/numeric/odeint/test/const_step_iterator.cpp b/libs/numeric/odeint/test/const_step_iterator.cpp index 0116a033..e8951008 100644 --- a/libs/numeric/odeint/test/const_step_iterator.cpp +++ b/libs/numeric/odeint/test/const_step_iterator.cpp @@ -46,27 +46,28 @@ BOOST_AUTO_TEST_SUITE( const_step_iterator_test ) typedef mpl::vector< dummy_stepper -// , dummy_dense_output_stepper + , dummy_dense_output_stepper > dummy_steppers; -BOOST_AUTO_TEST_CASE( copy_stepper_iterator ) +BOOST_AUTO_TEST_CASE_TEMPLATE( copy_stepper_iterator , Stepper , dummy_steppers ) { - typedef const_step_iterator< dummy_stepper , empty_system > iterator_type; + typedef const_step_iterator< Stepper , empty_system > iterator_type; state_type x = {{ 1.0 }}; - iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 ); + iterator_type iter1 = iterator_type( Stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 ); iterator_type iter2 = iter1; BOOST_CHECK_EQUAL( &(*iter1) , &(*iter2) ); BOOST_CHECK_EQUAL( &(*iter1) , &x ); BOOST_CHECK( iter1.same( iter2 ) ); } -BOOST_AUTO_TEST_CASE( assignment_stepper_iterator ) + +BOOST_AUTO_TEST_CASE_TEMPLATE( assignment_stepper_iterator , Stepper , dummy_steppers ) { - typedef const_step_iterator< dummy_stepper , empty_system > iterator_type; + typedef const_step_iterator< Stepper , empty_system > iterator_type; state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }}; - iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 ); - iterator_type iter2 = iterator_type( dummy_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 ); + iterator_type iter1 = iterator_type( Stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 ); + iterator_type iter2 = iterator_type( Stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 ); BOOST_CHECK_EQUAL( &(*iter1) , &x1 ); BOOST_CHECK_EQUAL( &(*iter2) , &x2 ); BOOST_CHECK( !iter1.same( iter2 ) ); @@ -76,9 +77,11 @@ BOOST_AUTO_TEST_CASE( assignment_stepper_iterator ) BOOST_CHECK( iter1.same( iter2 ) ); } -BOOST_AUTO_TEST_CASE( stepper_iterator_factory ) + + +BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_factory , Stepper , dummy_steppers ) { - dummy_stepper stepper; + Stepper stepper; empty_system system; state_type x = {{ 1.0 }}; @@ -90,9 +93,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_factory ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } -BOOST_AUTO_TEST_CASE( stepper_range ) +BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range , Stepper , dummy_steppers ) { - dummy_stepper stepper; + Stepper stepper; empty_system system; state_type x = {{ 1.0 }}; @@ -102,9 +105,9 @@ BOOST_AUTO_TEST_CASE( stepper_range ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } -BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory ) +BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_with_reference_wrapper_factory , Stepper , dummy_steppers ) { - dummy_stepper stepper; + Stepper stepper; empty_system system; state_type x = {{ 1.0 }}; @@ -116,9 +119,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } -BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper ) +BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range_with_reference_wrapper , Stepper , dummy_steppers ) { - dummy_stepper stepper; + Stepper stepper; empty_system system; state_type x = {{ 1.0 }}; diff --git a/libs/numeric/odeint/test/const_step_time_iterator.cpp b/libs/numeric/odeint/test/const_step_time_iterator.cpp index a85b4029..6cb00446 100644 --- a/libs/numeric/odeint/test/const_step_time_iterator.cpp +++ b/libs/numeric/odeint/test/const_step_time_iterator.cpp @@ -47,28 +47,28 @@ BOOST_AUTO_TEST_SUITE( const_step_time_iterator_test ) typedef mpl::vector< dummy_stepper -// , dummy_dense_output_stepper + , dummy_dense_output_stepper > dummy_steppers; -BOOST_AUTO_TEST_CASE( copy_stepper_iterator ) +BOOST_AUTO_TEST_CASE_TEMPLATE( copy_stepper_iterator , Stepper , dummy_steppers ) { - typedef const_step_time_iterator< dummy_stepper , empty_system > iterator_type; + typedef const_step_time_iterator< Stepper , empty_system > iterator_type; state_type x = {{ 1.0 }}; - iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 ); + iterator_type iter1 = iterator_type( Stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 ); iterator_type iter2 = iter1; BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) ); BOOST_CHECK_EQUAL( &( iter1->first ) , &x ); BOOST_CHECK( iter1.same( iter2 ) ); } -BOOST_AUTO_TEST_CASE( assignment_stepper_iterator ) +BOOST_AUTO_TEST_CASE_TEMPLATE( assignment_stepper_iterator , Stepper , dummy_steppers ) { - typedef const_step_time_iterator< dummy_stepper , empty_system > iterator_type; + typedef const_step_time_iterator< Stepper , empty_system > iterator_type; state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }}; - iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 ); - iterator_type iter2 = iterator_type( dummy_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 ); + iterator_type iter1 = iterator_type( Stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 ); + iterator_type iter2 = iterator_type( Stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 ); BOOST_CHECK_EQUAL( &( iter1->first ) , &x1 ); BOOST_CHECK_EQUAL( &( iter2->first ) , &x2 ); BOOST_CHECK( !iter1.same( iter2 ) ); @@ -78,9 +78,9 @@ BOOST_AUTO_TEST_CASE( assignment_stepper_iterator ) BOOST_CHECK( iter1.same( iter2 ) ); } -BOOST_AUTO_TEST_CASE( stepper_iterator_factory ) +BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_factory , Stepper , dummy_steppers ) { - dummy_stepper stepper; + Stepper stepper; empty_system system; state_type x = {{ 1.0 }}; @@ -92,9 +92,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_factory ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } -BOOST_AUTO_TEST_CASE( stepper_range ) +BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range , Stepper , dummy_steppers ) { - dummy_stepper stepper; + Stepper stepper; empty_system system; state_type x = {{ 1.0 }}; @@ -104,9 +104,9 @@ BOOST_AUTO_TEST_CASE( stepper_range ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } -BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory ) +BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_with_reference_wrapper_factory , Stepper , dummy_steppers ) { - dummy_stepper stepper; + Stepper stepper; empty_system system; state_type x = {{ 1.0 }}; @@ -118,9 +118,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory ) BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 ); } -BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper ) +BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range_with_reference_wrapper , Stepper , dummy_steppers ) { - dummy_stepper stepper; + Stepper stepper; empty_system system; state_type x = {{ 1.0 }};