diff --git a/Iteratoren.ods b/Iteratoren.ods index 9cbb24ca..31efa41b 100644 Binary files a/Iteratoren.ods and b/Iteratoren.ods differ 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 }};