From 042c7259443b59bd4740a29ae565e6555b2cf0ce Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Fri, 7 Dec 2012 12:36:53 +0100 Subject: [PATCH] removed iterators from master --- boost/numeric/odeint.hpp | 4 - .../odeint/iterator/adaptive_iterator.hpp | 313 --------------- .../iterator/adaptive_time_iterator.hpp | 305 --------------- .../odeint/iterator/const_step_iterator.hpp | 293 -------------- .../iterator/const_step_time_iterator.hpp | 293 -------------- .../iterator/detail/ode_iterator_base.hpp | 127 ------ .../detail/ode_time_iterator_base.hpp | 126 ------ libs/numeric/odeint/doc/details.qbk | 2 - libs/numeric/odeint/doc/details_iterators.qbk | 106 ----- .../doc/tutorial_harmonic_oscillator.qbk | 8 - libs/numeric/odeint/examples/Jamfile.v2 | 2 - .../odeint/examples/adaptive_iterator.cpp | 361 ------------------ .../odeint/examples/const_step_iterator.cpp | 294 -------------- .../odeint/examples/harmonic_oscillator.cpp | 6 - libs/numeric/odeint/performance/Jamfile.v2 | 4 - .../performance/const_step_iterator.cpp | 164 -------- libs/numeric/odeint/test/Jamfile.v2 | 4 - .../numeric/odeint/test/adaptive_iterator.cpp | 116 ------ .../odeint/test/adaptive_time_iterator.cpp | 136 ------- .../odeint/test/const_step_iterator.cpp | 141 ------- .../odeint/test/const_step_time_iterator.cpp | 133 ------- 21 files changed, 2938 deletions(-) delete mode 100644 boost/numeric/odeint/iterator/adaptive_iterator.hpp delete mode 100644 boost/numeric/odeint/iterator/adaptive_time_iterator.hpp delete mode 100644 boost/numeric/odeint/iterator/const_step_iterator.hpp delete mode 100644 boost/numeric/odeint/iterator/const_step_time_iterator.hpp delete mode 100644 boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp delete mode 100644 boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp delete mode 100644 libs/numeric/odeint/doc/details_iterators.qbk delete mode 100644 libs/numeric/odeint/examples/adaptive_iterator.cpp delete mode 100644 libs/numeric/odeint/examples/const_step_iterator.cpp delete mode 100644 libs/numeric/odeint/performance/const_step_iterator.cpp delete mode 100644 libs/numeric/odeint/test/adaptive_iterator.cpp delete mode 100644 libs/numeric/odeint/test/adaptive_time_iterator.cpp delete mode 100644 libs/numeric/odeint/test/const_step_iterator.cpp delete mode 100644 libs/numeric/odeint/test/const_step_time_iterator.cpp diff --git a/boost/numeric/odeint.hpp b/boost/numeric/odeint.hpp index 939008cf..3200fbe1 100644 --- a/boost/numeric/odeint.hpp +++ b/boost/numeric/odeint.hpp @@ -71,9 +71,5 @@ #include -#include -#include -#include -#include #endif // BOOST_NUMERIC_ODEINT_HPP_INCLUDED diff --git a/boost/numeric/odeint/iterator/adaptive_iterator.hpp b/boost/numeric/odeint/iterator/adaptive_iterator.hpp deleted file mode 100644 index 169da4f1..00000000 --- a/boost/numeric/odeint/iterator/adaptive_iterator.hpp +++ /dev/null @@ -1,313 +0,0 @@ - -/* - [auto_generated] - boost/numeric/odeint/iterator/adaptive_iterator.hpp - - [begin_description] - Iterator for iterating throught the solution of an ODE with adaptive step size. The dereferenced types containes also the time. - [end_description] - - Copyright 2009-2011 Karsten Ahnert - Copyright 2009-2011 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED -#define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED - -#include - -#include -#include -#include - -namespace boost { -namespace numeric { -namespace odeint { - - - template< class Stepper , class System , class StepperTag = typename base_tag< typename Stepper::stepper_category >::type > - class adaptive_iterator; - - - /* - * Specilization for controlled steppers - */ - /** - * \brief ODE Iterator with adaptive step size control. The value type of this iterator is the state type of the stepper. - * - * Implements an ODE iterator with adaptive step size control. Uses controlled steppers. adaptive_iterator is a model - * of single-pass iterator. - * - * The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time. - * - * \tparam Stepper The stepper type which should be used during the iteration. - * \tparam System The type of the system function (ODE) which should be solved. - */ - template< class Stepper , class System > - 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 - > - { - 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 , controlled_stepper_tag > , - Stepper , System , controlled_stepper_tag - > base_type; - #endif - - public: - - /** - * \brief Constructs an adaptive_iterator. This constructor should be used to construct the begin iterator. - * - * \param stepper The stepper to use during the iteration. - * \param sys The system function (ODE) to solve. - * \param s The initial state. adaptive_iterator stores a reference of s and changes its value during the iteration. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - */ - adaptive_iterator( 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 ) { } - - /** - * \brief Constructs an adaptive_iterator. This constructor should be used to construct the end iterator. - * - * \param stepper The stepper to use during the iteration. - * \param sys The system function (ODE) to solve. - * \param s The initial state. adaptive_iterator store a reference of s and changes its value during the iteration. - */ - adaptive_iterator( stepper_type stepper , system_type sys , state_type &s ) - : base_type( stepper , sys , s ) { } - - protected: - - friend class boost::iterator_core_access; - - void increment() - { - const size_t max_attempts = 1000; - size_t trials = 0; - controlled_step_result res = success; - do - { - res = this->m_stepper.try_step( this->m_system , *( this->m_state ) , this->m_t , this->m_dt ); - ++trials; - } - while( ( res == fail ) && ( trials < max_attempts ) ); - if( trials == max_attempts ) - { - throw std::overflow_error( "Adaptive iterator : Maximal number of iterations reached. A step size could not be found." ); - } - this->check_end(); - } - }; - - - - - - - /* - * 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: - - - /** - * \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(); - } - - - }; - - - - - - - - - template< class Stepper , class System > - adaptive_iterator< Stepper , System > make_adaptive_iterator_begin( - Stepper stepper , - System system , - typename Stepper::state_type &x , - typename Stepper::time_type t , - typename Stepper::time_type t_end , - typename Stepper::time_type dt ) - { - return adaptive_iterator< Stepper , System >( stepper , system , x , t , t_end , dt ); - } - - - template< class Stepper , class System > - adaptive_iterator< Stepper , System > make_adaptive_iterator_end( - Stepper stepper , - System system , - typename Stepper::state_type &x ) - { - return adaptive_iterator< Stepper , System >( stepper , system , x ); - } - - - template< class Stepper , class System > - std::pair< adaptive_iterator< Stepper , System > , adaptive_iterator< Stepper , System > > - make_adaptive_range( - Stepper stepper , - System system , - typename Stepper::state_type &x , - typename Stepper::time_type t_start , - typename Stepper::time_type t_end , - typename Stepper::time_type dt ) - { - return std::make_pair( - adaptive_iterator< Stepper , System >( stepper , system , x , t_start , t_end , dt ) , - adaptive_iterator< Stepper , System >( stepper , system , x ) - ); - } - - - - - - - - /** - * \fn make_adaptive_iterator_begin( Stepper stepper , System system , typename Stepper::state_type &x , typename Stepper::time_type t , typename Stepper::time_type t_end , typename Stepper::time_type dt ) - * - * \brief Factory function for adaptive_iterator. Constructs a begin iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - * \returns The adaptive iterator. - */ - - - /** - * \fn make_adaptive_iterator_end( Stepper stepper , System system , typename Stepper::state_type &x ) - * \brief Factory function for adaptive_iterator. Constructs a end iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. - * \returns The adaptive iterator. - */ - - - /** - * \fn make_adaptive_range( Stepper stepper , System system , typename Stepper::state_type &x , typename Stepper::time_type t_start , typename Stepper::time_type t_end , typename Stepper::time_type dt ) - * - * \brief Factory function to construct a single pass range of adaptive iterators. A range is here a pair of adaptive_iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - * \returns The adaptive range. - */ - - - - - - -} // namespace odeint -} // namespace numeric -} // namespace boost - - - -#endif // BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED diff --git a/boost/numeric/odeint/iterator/adaptive_time_iterator.hpp b/boost/numeric/odeint/iterator/adaptive_time_iterator.hpp deleted file mode 100644 index f5279685..00000000 --- a/boost/numeric/odeint/iterator/adaptive_time_iterator.hpp +++ /dev/null @@ -1,305 +0,0 @@ - -/* - [auto_generated] - boost/numeric/odeint/iterator/adaptive_time_iterator.hpp - - [begin_description] - Iterator for iterating throught the solution of an ODE with adaptive step size. The dereferenced types containes also the time. - [end_description] - - Copyright 2009-2011 Karsten Ahnert - Copyright 2009-2011 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED -#define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED - - -#include -#include -#include -#include - - -namespace boost { -namespace numeric { -namespace odeint { - - - template< class Stepper , class System , class StepperTag = typename base_tag< typename Stepper::stepper_category >::type > - class adaptive_time_iterator; - - - - /* - * Specilization for controlled 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 iterator with adaptive step size control. Uses controlled steppers. adaptive_iterator is a model - * of single-pass iterator. - * - * The value type of this iterator is 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 , controlled_stepper_tag > : public detail::ode_time_iterator_base - < - adaptive_time_iterator< Stepper , System , controlled_stepper_tag > , - Stepper , System , controlled_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; - typedef detail::ode_time_iterator_base< - adaptive_time_iterator< Stepper , System , controlled_stepper_tag > , - Stepper , System , controlled_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 ) {} - - /** - * \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; - - void increment() - { - const size_t max_attempts = 1000; - size_t trials = 0; - controlled_step_result res = success; - do - { - res = this->m_stepper.try_step( this->m_system , this->m_state.first , this->m_state.second , this->m_dt ); - ++trials; - } - while( ( res == fail ) && ( trials < max_attempts ) ); - if( trials == max_attempts ) - { - throw std::overflow_error( "Adaptive iterator : Maximal number of iterations reached. A step size could not be found." ); - } - this->check_end(); - } - }; - - - - - - - /* - * 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: - - 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 ) - { - } - - - private: - - friend class boost::iterator_core_access; - - 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(); - } - }; - - - - - - - - - template< class Stepper , class System > - adaptive_time_iterator< Stepper , System > make_adaptive_time_iterator_begin( - Stepper stepper , - System system , - typename Stepper::state_type &x , - typename Stepper::time_type t , - typename Stepper::time_type t_end , - typename Stepper::time_type dt ) - { - return adaptive_time_iterator< Stepper , System >( stepper , system , x , t , t_end , dt ); - } - - template< class Stepper , class System > - adaptive_time_iterator< Stepper , System > make_adaptive_time_iterator_end( - Stepper stepper , - System system , - typename Stepper::state_type &x ) - { - return adaptive_time_iterator< Stepper , System >( stepper , system , x ); - } - - - template< class Stepper , class System > - std::pair< adaptive_time_iterator< Stepper , System > , adaptive_time_iterator< Stepper , System > > - make_adaptive_time_range( - Stepper stepper , - System system , - typename Stepper::state_type &x , - typename Stepper::time_type t_start , - typename Stepper::time_type t_end , - typename Stepper::time_type dt ) - { - return std::make_pair( - adaptive_time_iterator< Stepper , System >( stepper , system , x , t_start , t_end , dt ) , - adaptive_time_iterator< Stepper , System >( stepper , system , x ) ); - } - - - - - - - /** - * \fn make_adaptive_time_iterator_begin( Stepper stepper , System system , typename Stepper::state_type &x , typename Stepper::time_type t , typename Stepper::time_type t_end , typename Stepper::time_type dt ) - * - * \brief Factory function for adaptive_time_iterator. Constructs a begin iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - * \returns The adaptive time iterator. - */ - - - /** - * \fn make_adaptive_iterator_end( Stepper stepper , System system , typename Stepper::state_type &x ) - * \brief Factory function for adaptive_time_iterator. Constructs a end iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration. - * \returns The adaptive time iterator. - */ - - - /** - * \fn make_adaptive_range( Stepper stepper , System system , typename Stepper::state_type &x , typename Stepper::time_type t_start , typename Stepper::time_type t_end , typename Stepper::time_type dt ) - * - * \brief Factory function to construct a single pass range of adaptive time iterators. A range is here a pair of adaptive_time_iterators. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - * \returns The adaptive time range. - */ - - - - - - - - - - -} // namespace odeint -} // namespace numeric -} // namespace boost - - - -#endif // BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED diff --git a/boost/numeric/odeint/iterator/const_step_iterator.hpp b/boost/numeric/odeint/iterator/const_step_iterator.hpp deleted file mode 100644 index a53f4eef..00000000 --- a/boost/numeric/odeint/iterator/const_step_iterator.hpp +++ /dev/null @@ -1,293 +0,0 @@ - -/* - [auto_generated] - boost/numeric/odeint/iterator/const_step_ode_iterator.hpp - - [begin_description] - Iterator for iterating throught the solution of an ODE with constant step size. - [end_description] - - Copyright 2009-2011 Karsten Ahnert - Copyright 2009-2011 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED -#define BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED - -#include - -#include -#include - -namespace boost { -namespace numeric { -namespace odeint { - - - template< class Stepper , class System , class StepperTag = typename base_tag< typename Stepper::stepper_category >::type > - class const_step_iterator; - - - - - - /* - * Specilization for steppers and error steppers - */ - /** - * \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 steppers fulfilling the Stepper concept. - * 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 , stepper_tag > - : public detail::ode_iterator_base< - const_step_iterator< Stepper , System , stepper_tag > , - Stepper , System , 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< - const_step_iterator< Stepper , System , stepper_tag > , - Stepper , System , stepper_tag > base_type; - #endif - - public: - - /** - * \brief Constructs a const_step_iterator. This constructor should be used to construct the begin iterator. - * - * \param stepper The stepper to use during the iteration. - * \param sys The system function (ODE) to solve. - * \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - */ - const_step_iterator( 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 ) { } - - /** - * \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; - - void increment() - { - this->m_stepper.do_step( this->m_system , *( this->m_state ) , this->m_t , this->m_dt ); - this->m_t += this->m_dt; - this->check_end(); - } - }; - - - - /* - * 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: - - 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; - - 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 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; - - 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(); - } - }; - - - - - - template< class Stepper , class System > - const_step_iterator< Stepper , System > make_const_step_iterator_begin( - Stepper stepper , - System system , - typename Stepper::state_type &x , - typename Stepper::time_type t , - typename Stepper::time_type t_end , - typename Stepper::time_type dt ) - { - return const_step_iterator< Stepper , System >( stepper , system , x , t , t_end , dt ); - } - - template< class Stepper , class System > - const_step_iterator< Stepper , System > make_const_step_iterator_end( - Stepper stepper , - System system , - typename Stepper::state_type &x ) - { - return const_step_iterator< Stepper , System >( stepper , system , x ); - } - - - template< class Stepper , class System > - std::pair< const_step_iterator< Stepper , System > , const_step_iterator< Stepper , System > > - make_const_step_range( - Stepper stepper , - System system , - typename Stepper::state_type &x , - typename Stepper::time_type t_start , - typename Stepper::time_type t_end , - typename Stepper::time_type dt ) - { - return std::make_pair( - const_step_iterator< Stepper , System >( stepper , system , x , t_start , t_end , dt ) , - const_step_iterator< Stepper , System >( stepper , system , x ) - ); - } - - - - - - /** - * \fn make_const_step_iterator_begin( Stepper stepper , System system , typename Stepper::state_type &x , typename Stepper::time_type t , typename Stepper::time_type t_end , typename Stepper::time_type dt ) - * - * \brief Factory function for const_step_iterator. Constructs a begin iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - * \returns The const step iterator. - */ - - - /** - * \fn make_const_step_iterator_end( Stepper stepper , System system , typename Stepper::state_type &x ) - * \brief Factory function for const_step_iterator. Constructs a end iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration. - * \returns The const_step_iterator. - */ - - - /** - * \fn make_const_step_range( Stepper stepper , System system , typename Stepper::state_type &x , typename Stepper::time_type t_start , typename Stepper::time_type t_end , typename Stepper::time_type dt ) - * - * \brief Factory function to construct a single pass range of const step iterators. A range is here a pair - * of const_step_iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - * \returns The const step range. - */ - - - - - - - - -} // namespace odeint -} // namespace numeric -} // namespace boost - - - -#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED diff --git a/boost/numeric/odeint/iterator/const_step_time_iterator.hpp b/boost/numeric/odeint/iterator/const_step_time_iterator.hpp deleted file mode 100644 index 3891f5a5..00000000 --- a/boost/numeric/odeint/iterator/const_step_time_iterator.hpp +++ /dev/null @@ -1,293 +0,0 @@ - -/* - [auto_generated] - boost/numeric/odeint/iterator/const_step_time_iterator.hpp - - [begin_description] - Iterator for iterating throught the solution of an ODE with constant step size. The dereferences types containes also the time. - [end_description] - - Copyright 2009-2011 Karsten Ahnert - Copyright 2009-2011 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED -#define BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED - -#include -#include -#include - -namespace boost { -namespace numeric { -namespace odeint { - - - template< class Stepper , class System , class StepperTag = typename base_tag< typename Stepper::stepper_category >::type > - class const_step_time_iterator; - - - /* - * Specilization for steppers and error 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. The stepper must fulfill the Stepper - * concept. 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 , stepper_tag > : public detail::ode_time_iterator_base - < - const_step_time_iterator< Stepper , System , stepper_tag > , - Stepper , System , 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; - typedef detail::ode_time_iterator_base< - const_step_time_iterator< Stepper , System , stepper_tag > , - Stepper , System , stepper_tag > base_type; - - 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 ) {} - - /** - * \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: - - friend class boost::iterator_core_access; - - void increment() - { - this->m_stepper.do_step( this->m_system , this->m_state.first , this->m_state.second , this->m_dt ); - this->m_state.second += this->m_dt; - this->check_end(); - } - - }; - - - - - - - /* - * Specilization for steppers and error 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: - - 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; - - - 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 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: - - 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(); - } - }; - - - - - - - - - template< class Stepper , class System > - const_step_time_iterator< Stepper , System > make_const_step_time_iterator_begin( - Stepper stepper , - System system , - typename Stepper::state_type &x , - typename Stepper::time_type t , - typename Stepper::time_type t_end , - typename Stepper::time_type dt ) - { - return const_step_time_iterator< Stepper , System >( stepper , system , x , t , t_end , dt ); - } - - template< class Stepper , class System > - const_step_time_iterator< Stepper , System > make_const_step_time_iterator_end( - Stepper stepper , - System system , - typename Stepper::state_type &x ) - { - return const_step_time_iterator< Stepper , System >( stepper , system , x ); - } - - - template< class Stepper , class System > - std::pair< const_step_time_iterator< Stepper , System > , const_step_time_iterator< Stepper , System > > - make_const_step_time_range( - Stepper stepper , - System system , - typename Stepper::state_type &x , - typename Stepper::time_type t_start , - typename Stepper::time_type t_end , - typename Stepper::time_type dt ) - { - return std::make_pair( - const_step_time_iterator< Stepper , System >( stepper , system , x , t_start , t_end , dt ) , - const_step_time_iterator< Stepper , System >( stepper , system , x ) ); - } - - - - /** - * \fn make_const_step_time_iterator_begin( Stepper stepper , System system , typename Stepper::state_type &x , typename Stepper::time_type t , typename Stepper::time_type t_end , typename Stepper::time_type dt ) - * - * \brief Factory function for const_step_time_iterator. Constructs a begin iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. const_step_time_iterator stores a reference of s and changes its value during the iteration. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - * \returns The const step time iterator. - */ - - - /** - * \fn make_const_step_time_iterator_end( Stepper stepper , System system , typename Stepper::state_type &x ) - * \brief Factory function for const_step_time_iterator. Constructs a end iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. const_step_time_iterator store a reference of s and changes its value during the iteration. - * \returns The const step time iterator. - */ - - - /** - * \fn make_const_step_time_range( Stepper stepper , System system , typename Stepper::state_type &x , typename Stepper::time_type t_start , typename Stepper::time_type t_end , typename Stepper::time_type dt ) - * - * \brief Factory function to construct a single pass range of const_step_time_iterator. A range is here a pair of const_step_time_iterator. - * - * \param stepper The stepper to use during the iteration. - * \param system The system function (ODE) to solve. - * \param x The initial state. const_step_time_iterator stores a reference of s and changes its value during the iteration. - * \param t The initial time. - * \param t_end The end time, at which the iteration should stop. - * \param dt The initial time step. - * \returns The const step time range. - */ - - - - - - - -} // namespace odeint -} // namespace numeric -} // namespace boost - - - -#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED diff --git a/boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp b/boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp deleted file mode 100644 index 61c8fef4..00000000 --- a/boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp +++ /dev/null @@ -1,127 +0,0 @@ - -/* - [auto_generated] - boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp - - [begin_description] - Base class for const_step_iterator and adaptive_iterator. - [end_description] - - Copyright 2009-2011 Karsten Ahnert - Copyright 2009-2011 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_ITERATOR_BASE_HPP_INCLUDED -#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_ITERATOR_BASE_HPP_INCLUDED - -#include - -#include - - -namespace boost { -namespace numeric { -namespace odeint { -namespace detail { - - - - - template< class Iterator , class Stepper , class System , class StepperTag > - class ode_iterator_base : public boost::iterator_facade - < - Iterator , - typename Stepper::state_type const , - boost::single_pass_traversal_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; - - public: - - ode_iterator_base( stepper_type stepper , system_type sys , state_type &s , - time_type t , time_type t_end , time_type dt ) - : m_stepper( stepper ) , m_system( sys ) , m_state( &s ) , m_t( t ) , m_t_end( t_end ) , m_dt( dt ) , m_first( true ) - { - check_end(); - } - - ode_iterator_base( stepper_type stepper , system_type sys , state_type &s ) - : m_stepper( stepper ) , m_system( sys ) , m_state( &s ) , m_t() , m_t_end() , m_dt() , m_first( false ) - { - } - - - protected: - - friend class boost::iterator_core_access; - - bool equal( ode_iterator_base const& other ) const - { - if( m_first == other.m_first ) - { - return true; - } - else - { - return false; - } - } - - const state_type& dereference() const - { - return *m_state; - } - - void check_end( void ) - { - if( get_unit_value( m_dt ) > static_cast< ode_value_type >( 0.0 ) ) - { - if( m_t > m_t_end ) - { - m_first = false; - } - } - else - { - if( m_t < m_t_end ) - { - m_first = false; - } - } - } - - stepper_type m_stepper; - system_type m_system; - state_type *m_state; - time_type m_t; - time_type m_t_end; - time_type m_dt; - bool m_first; - }; - - - - - - - -} // namespace detail -} // namespace odeint -} // namespace numeric -} // namespace boost - - - -#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_ITERATOR_BASE_HPP_INCLUDED diff --git a/boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp b/boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp deleted file mode 100644 index ac9d86e2..00000000 --- a/boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp +++ /dev/null @@ -1,126 +0,0 @@ - -/* - [auto_generated] - boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp - - [begin_description] - Base class for const_step_time_iterator and adaptive_time_iterator. - [end_description] - - Copyright 2009-2011 Karsten Ahnert - Copyright 2009-2011 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_TIME_ITERATOR_BASE_HPP_INCLUDED -#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_TIME_ITERATOR_BASE_HPP_INCLUDED - -#include - -#include - - -namespace boost { -namespace numeric { -namespace odeint { -namespace detail { - - - - - template< class Iterator , class Stepper , class System , class StepperTag > - class ode_time_iterator_base : public boost::iterator_facade - < - Iterator , - std::pair< typename Stepper::state_type& , typename Stepper::time_type > const , - boost::single_pass_traversal_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; - - public: - - ode_time_iterator_base( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt ) - : m_stepper( stepper ) , m_system( sys ) , m_state( s , t ) , m_t_end( t_end ) , m_dt( dt ) , m_first( true ) - { - check_end(); - } - - ode_time_iterator_base( stepper_type stepper , system_type sys , state_type &s ) - : m_stepper( stepper ) , m_system( sys ) , m_state( s , 0.0 ) , m_t_end() , m_dt() , m_first( false ) - { - } - - - protected: - - friend class boost::iterator_core_access; - - bool equal( ode_time_iterator_base const& other ) const - { - if( m_first == other.m_first ) - { - return true; - } - else - { - return false; - } - } - - const std::pair< state_type& , time_type >& dereference() const - { - return m_state; - } - - void check_end( void ) - { - if( get_unit_value( m_dt ) > static_cast< ode_value_type >( 0.0 ) ) - { - if( m_state.second > m_t_end ) - { - m_first = false; - } - } - else - { - if( m_state.second < m_t_end ) - { - m_first = false; - } - } - } - - stepper_type m_stepper; - system_type m_system; - std::pair< state_type& , time_type > m_state; - time_type m_t_end; - time_type m_dt; - bool m_first; - - }; - - - - - - - -} // namespace detail -} // namespace odeint -} // namespace numeric -} // namespace boost - - - -#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_TIME_ITERATOR_BASE_HPP_INCLUDED diff --git a/libs/numeric/odeint/doc/details.qbk b/libs/numeric/odeint/doc/details.qbk index cb5cfc82..9bc0ff00 100644 --- a/libs/numeric/odeint/doc/details.qbk +++ b/libs/numeric/odeint/doc/details.qbk @@ -17,8 +17,6 @@ [include details_integrate_functions.qbk] -[include details_iterators.qbk] - [include details_state_types_algebras_operations.qbk] [include details_boost_ref.qbk] diff --git a/libs/numeric/odeint/doc/details_iterators.qbk b/libs/numeric/odeint/doc/details_iterators.qbk deleted file mode 100644 index 212c2cb4..00000000 --- a/libs/numeric/odeint/doc/details_iterators.qbk +++ /dev/null @@ -1,106 +0,0 @@ -[/============================================================================ - Boost.odeint - - Copyright (c) 2009-2012 Karsten Ahnert - Copyright (c) 2009-2012 Mario Mulansky - - Use, modification and distribution is subject to the Boost Software License, - Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================/] - - -[section Iterators and Ranges] - - - -odeint supports iterators for iterating through an ordinary differential equation. They offer you an alternative to the integrate functions. Furthermore, many of the standard algorithms in the C++ standard library and Boost.Range can be used with the odeint's iterators. - -[import ../examples/const_step_iterator.cpp] - -Four iterators are provided. They are all single pass iterators. The first one is a iterator which solves the odeint with constant step size. An example is - -[const_step_iterator_accumulate] - -In this example all x-values of the solution are accumulated. The iterator itself does not occur directly in this example but it is generated by the factory functions `make_const_step_iterator_begin` and `make_const_step_iterator_end`. odeint also supports Boost.Range, that is you write the above example in a more succinct form with the factory function `make_const_step_range` - -[const_step_iterator_accumulate_range] - -The second iterator type is also a iterator with const step size. But the value type of this iterator consists here of a pair of the time and the state of the solution of the ODE. An example is - -[const_step_time_iterator_accumulate_range] - -The factory functions are now `make_const_step_time_iterator_begin`, `make_const_step_time_iterator_end` and `make_const_step_time_range`. - - -[import ../examples/adaptive_iterator.cpp] - -The other two iterator types adaptive iterators which are completely analogous to the const step iterators. Examples are - -[adaptive_iterator_accumulate_range] - -[adaptive_time_iterator_accumulate_range] - - -[section const_step_iterator] - -* Definition: `const_step_iterator< Stepper , System >` -* `value_type` is `Stepper::state_type` -* Factory functions - * `make_const_step_iterator_begin( stepper , system , state , t_start , t_end , dt )` - * `make_const_step_iterator_end( stepper , system , state )` - * `make_const_step_range( stepper , system , state , t_start , t_end , dt )` -* This stepper works with all steppers fulfilling the Stepper concept or the DenseOutputStepper concept. -* This stepper updates the value of `state`. The value of `state` is the current state of the ODE during the iteration. - -[endsect] - -[section const_step_time_iterator] - -* Definition: `const_step_iterator< Stepper , System >` -* `value_type` is `std::pair< Stepper::state_type& , Stepper::time_type >` -* Factory functions - * `make_const_step_time_iterator_begin( stepper , system , state , t_start , t_end , dt )` - * `make_const_step_time_iterator_end( stepper , system , state )` - * `make_const_step_time_range( stepper , system , state , t_start , t_end , dt )` -* This stepper works with all steppers fulfilling the Stepper concept or the DenseOutputStepper concept. -* This stepper updates the value of `state`. The value of `state` is the current state of the ODE during the iteration. - - -[endsect] - - -[section adaptive_step_iterator] - -* Definition: `adaptive_iterator< Stepper , System >` -* `value_type` is `Stepper::state_type` -* Factory functions - * `make_adaptive_iterator_begin( stepper , system , state , t_start , t_end , dt )` - * `make_adaptive_iterator_end( stepper , system , state )` - * `make_adaptive_range( stepper , system , state , t_start , t_end , dt )` -* This stepper works with all steppers fulfilling the ControlledStepper concept or the DenseOutputStepper concept. -* For steppers fulfilling the ControlledStepper concept `state` is modified according to the current state of the ODE. For DenseOutputStepper the state is not modified due to performance optimizations. - - -[endsect] - -[section adaptive_step_time_iterator] - -* Definition: `adaptive_iterator< Stepper , System >` -* `value_type` is `std::pair< Stepper::state_type& , Stepper::time_type >` -* Factory functions - * `make_adaptive_time_iterator_begin( stepper , system , state , t_start , t_end , dt )` - * `make_adaptive_time_iterator_end( stepper , system , state )` - * `make_adaptive_time_range( stepper , system , state , t_start , t_end , dt )` -* This stepper works with all steppers fulfilling the ControlledStepper concept or the DenseOutputStepper concept. -* This stepper updates the value of `state`. The value of `state` is the current state of the ODE during the iteration. - - -[endsect] - - - - - - -[endsect] diff --git a/libs/numeric/odeint/doc/tutorial_harmonic_oscillator.qbk b/libs/numeric/odeint/doc/tutorial_harmonic_oscillator.qbk index 93dee8f6..89a4d540 100644 --- a/libs/numeric/odeint/doc/tutorial_harmonic_oscillator.qbk +++ b/libs/numeric/odeint/doc/tutorial_harmonic_oscillator.qbk @@ -108,14 +108,6 @@ When using `make_controlled` or `make_dense_output` one should be aware which ex [endsect] -[section Using iterators] - -odeint supports iterators for solving ODEs. That is you instantiate a pair of iterators and instead of using the integrate routines with an appropriate observer you put the iterators in one of the algorithm from the C++ standard library or from Boost.Range. An example is - -[harm_iterator_const_step] - -[endsect] - The full source file for this example can be found here: [github_link libs/numeric/odeint/examples/harmonic_oscillator.cpp harmonic_oscillator.cpp] diff --git a/libs/numeric/odeint/examples/Jamfile.v2 b/libs/numeric/odeint/examples/Jamfile.v2 index 946faa0e..bad21735 100644 --- a/libs/numeric/odeint/examples/Jamfile.v2 +++ b/libs/numeric/odeint/examples/Jamfile.v2 @@ -33,8 +33,6 @@ 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 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 deleted file mode 100644 index 4ba61aa1..00000000 --- a/libs/numeric/odeint/examples/adaptive_iterator.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/* - * adaptive_iterator.cpp - * - * Copyright 2009-2012 Karsten Ahnert - * Copyright 2009-2012 Mario Mulansky - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#define tab "\t" - -using namespace std; -using namespace boost::numeric::odeint; - -const double sigma = 10.0; -const double R = 28.0; -const double b = 8.0 / 3.0; - -struct lorenz -{ - template< class State , class Deriv > - void operator()( const State &x , Deriv &dxdt , double t ) const - { - dxdt[0] = sigma * ( x[1] - x[0] ); - dxdt[1] = R * x[0] - x[1] - x[0] * x[2]; - dxdt[2] = -b * x[2] + x[0] * x[1]; - } -}; - -#include - -int main( int argc , char **argv ) -{ - typedef boost::array< double , 3 > state_type; - - /* - * Controlled steppers with time iterator - */ - - // std::for_each - { - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - 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 ) { - std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); - } - - // std::copy_if - { - std::vector< pair< state_type , double > > res; - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - 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 ) { - return ( x.first[0] > 0.0 ) ? true : false; } ); - for( size_t i=0 ; i() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - double res = std::accumulate( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - make_adaptive_time_iterator_end( stepper , lorenz() , x ) , - 0.0 , - []( double sum , const pair< state_type& , double > &x ) { - return sum + x.first[0]; } ); - cout << res << endl; - } - - - // std::transform - { - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - vector< double > weights; - 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 ) { - 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 ) { - std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); - } - - - // boost::range::copy with filtered adaptor (simulating std::copy_if) - { - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - 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 ); } ) , - 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 ) { - return sum + x.first[0]; } ); - cout << res << endl; - //] - } - - - // boost::range::transform - { - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - 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 ) { - 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 ) { - return ( x.first[0] < 0.0 ); } ); - cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n"; - } - - - - - - - - - - - - - // /* - // * Boost.Range versions for dense output steppers - // */ - - // // boost::range::for_each - // { - // runge_kutta_dopri5< state_type > stepper; - // state_type x = {{ 10.0 , 10.0 , 10.0 }}; - // boost::range::for_each( make_adaptive_range( make_dense_output( 1.0e-6 , 1.0e-6 , stepper ) , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - // []( const state_type &x ) { - // std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } ); - // } - - - // // boost::range::for_each with time iterator - // { - // runge_kutta_dopri5< state_type > stepper; - // state_type x = {{ 10.0 , 10.0 , 10.0 }}; - // boost::range::for_each( make_adaptive_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 ) { - // std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); - - // } - - - - - - /* - * Pure iterators for controlled stepper without time iterator - */ - - // std::for_each - { - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - std::for_each( make_adaptive_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - make_adaptive_iterator_end( stepper , lorenz() , x ) , - []( const state_type& x ) { - std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } ); - } - - // std::copy_if - { - std::vector< state_type > res; - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - std::copy_if( make_adaptive_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - make_adaptive_iterator_end( stepper , lorenz() , x ) , - std::back_inserter( res ) , - []( const state_type& x ) { - return ( x[0] > 0.0 ) ? true : false; } ); - for( size_t i=0 ; i() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - double res = std::accumulate( make_adaptive_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - make_adaptive_iterator_end( stepper , lorenz() , x ) , - 0.0 , - []( double sum , const state_type& x ) { - return sum + x[0]; } ); - cout << res << endl; - } - - - // std::transform - { - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - vector< double > weights; - std::transform( make_adaptive_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - make_adaptive_iterator_end( stepper , lorenz() , x ) , - back_inserter( weights ) , - []( const state_type& x ) { - return sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] ); } ); - for( size_t i=0 ; i() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - boost::range::for_each( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - []( const state_type &x ) { - std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } ); - } - - - // boost::range::copy with filtered adaptor (simulating std::copy_if) - { - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - std::vector< state_type > res; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - boost::range::copy( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) | - boost::adaptors::filtered( [] ( const state_type& x ) { return ( x[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_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 , - []( double sum , const state_type& x ) { - return sum + x[0]; } ); - cout << res << endl; - //] - } - - - // boost::range::transform - { - auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - vector< double > weights; - boost::transform( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , back_inserter( weights ) , - []( const state_type& x ) { - return sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] ); } ); - for( size_t i=0 ; i() ); - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - auto iter = boost::find_if( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - []( const state_type &x ) { - return ( x[0] < 0.0 ); } ); - cout << (*iter)[0] << "\t" << (*iter)[1] << "\t" << (*iter)[2] << "\n"; - } - - - - - - return 0; -} diff --git a/libs/numeric/odeint/examples/const_step_iterator.cpp b/libs/numeric/odeint/examples/const_step_iterator.cpp deleted file mode 100644 index e2dda4f4..00000000 --- a/libs/numeric/odeint/examples/const_step_iterator.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * const_step_iterator.cpp - * - * Copyright 2009-2012 Karsten Ahnert - * Copyright 2009-2012 Mario Mulansky - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#define tab "\t" - -using namespace std; -using namespace boost::numeric::odeint; - -const double sigma = 10.0; -const double R = 28.0; -const double b = 8.0 / 3.0; - -struct lorenz -{ - template< class State , class Deriv > - void operator()( const State &x , Deriv &dxdt , double t ) const - { - dxdt[0] = sigma * ( x[1] - x[0] ); - dxdt[1] = R * x[0] - x[1] - x[0] * x[2]; - dxdt[2] = -b * x[2] + x[0] * x[1]; - } -}; - - - -int main( int argc , char **argv ) -{ - typedef std::array< double , 3 > state_type; - - // std::for_each - { - runge_kutta4< state_type > stepper; - 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 ) { - std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); - } - - // std::copy_if - { - std::vector< state_type > res; - runge_kutta4< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - std::copy_if( make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - make_const_step_iterator_end( stepper , lorenz() , x ) , - std::back_inserter( res ) , - []( const state_type& x ) { - return ( x[0] > 0.0 ) ? true : false; } ); - for( size_t i=0 ; i stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - double res = std::accumulate( make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - make_const_step_iterator_end( stepper , lorenz() , x ) , - 0.0 , - []( double sum , const state_type &x ) { - return sum + x[0]; } ); - cout << res << endl; - //] - } - - - // std::transform - { - runge_kutta4< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - vector< double > weights; - std::transform( make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - make_const_step_iterator_end( stepper , lorenz() , x ) , - back_inserter( weights ) , - []( const state_type &x ) { - return sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] ); } ); - for( size_t i=0 ; i stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - vector< double > weights; - 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 ) { - 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_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - []( const state_type &x ) { - std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } ); - } - - // boost::range::for_each with time iterator - { - runge_kutta4< state_type > 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 ) { - std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); - } - - - // boost::range::copy with filtered adaptor (simulating std::copy_if) - { - std::vector< state_type > res; - runge_kutta4< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - boost::range::copy( make_const_step_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) | - boost::adaptors::filtered( [] ( const state_type &x ) { return ( x[0] > 0.0 ); } ) , - std::back_inserter( res ) ); - for( size_t i=0 ; i stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - double res = boost::accumulate( make_const_step_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 , - []( double sum , const state_type &x ) { - return sum + x[0]; } ); - cout << res << endl; - //] - } - - // boost::range::accumulate with time iterator - { - //[const_step_time_iterator_accumulate_range - 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 ) { - return sum + x.first[0]; } ); - cout << res << endl; - //] - } - - - // boost::range::transform - { - runge_kutta4< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - vector< double > weights; - boost::transform( make_const_step_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , back_inserter( weights ) , - []( const state_type &x ) { - return sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] ); } ); - for( size_t i=0 ; i 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 ) { - return ( x.first[0] < 0.0 ); } ); - cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n"; - - } - - - - - - - - - - - - - /* - * Boost.Range versions for dense output steppers - */ - - // boost::range::for_each - { - runge_kutta_dopri5< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - boost::range::for_each( make_const_step_range( make_dense_output( 1.0e-6 , 1.0e-6 , stepper ) , lorenz() , x , 0.0 , 1.0 , 0.01 ) , - []( const state_type &x ) { - std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } ); - } - - - // boost::range::for_each with time iterator - { - 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 ) { - std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } ); - - } - - - - - - /* - * Pure iterators - */ - { - runge_kutta4< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - auto first = make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ); - auto last = make_const_step_iterator_end( stepper , lorenz() , x ); - while( first != last ) - { - assert( last != first ); - cout << (*first)[0] << tab << (*first)[1] << tab << (*first)[2] << "\n"; - ++first; - } - } - - { - runge_kutta4< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - auto first = make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ); - auto last = make_const_step_time_iterator_end( stepper , lorenz() , x ); - while( first != last ) - { - assert( last != first ); - cout << first->second << tab << first->first[0] << tab << first->first[1] << tab << first->first[2] << "\n"; - ++first; - } - } - - - - - - - - return 0; -} diff --git a/libs/numeric/odeint/examples/harmonic_oscillator.cpp b/libs/numeric/odeint/examples/harmonic_oscillator.cpp index 29038b00..7fdbca88 100644 --- a/libs/numeric/odeint/examples/harmonic_oscillator.cpp +++ b/libs/numeric/odeint/examples/harmonic_oscillator.cpp @@ -194,10 +194,4 @@ int main(int /* argc */ , char** /* argv */ ) #endif - //[harm_iterator_const_step - std::for_each( make_adaptive_iterator_begin( controlled_stepper , harmonic_oscillator , x , 0.0 , 10.0 , 0.01 ) , - make_adaptive_iterator_end( controlled_stepper , harmonic_oscillator , x ) , - write_state() ); - //] - } diff --git a/libs/numeric/odeint/performance/Jamfile.v2 b/libs/numeric/odeint/performance/Jamfile.v2 index f100415f..34892f77 100644 --- a/libs/numeric/odeint/performance/Jamfile.v2 +++ b/libs/numeric/odeint/performance/Jamfile.v2 @@ -69,7 +69,3 @@ exe rt_generic_rk4_phase_lattice ; -exe const_step_iterator - : const_step_iterator.cpp - : -std=c++0x - ; \ No newline at end of file diff --git a/libs/numeric/odeint/performance/const_step_iterator.cpp b/libs/numeric/odeint/performance/const_step_iterator.cpp deleted file mode 100644 index 9163d3f0..00000000 --- a/libs/numeric/odeint/performance/const_step_iterator.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * odeint_rk4_lorenz.cpp - * - * Copyright 2009-2012 Karsten Ahnert - * Copyright 2009-2012 Mario Mulansky - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace boost::numeric::odeint; - -typedef std::array< double , 3 > state_type; -typedef std::vector< double > state_type2; - -std::ostream& operator<<( std::ostream &out , const state_type &x ) -{ - out << x[0] << "\t" << x[1] << "\t" << x[2]; - return out; -} - -std::ostream& operator<<( std::ostream &out , const state_type2 &x ) -{ - if( !x.empty() ) out << x[0]; - for( size_t i=1 ; i - void operator()( const State &x , Deriv &dxdt , double t ) const - { - dxdt[0] = sigma * ( x[1] - x[0] ); - dxdt[1] = R * x[0] - x[1] - x[0] * x[2]; - dxdt[2] = -b * x[2] + x[0] * x[1]; - } -}; - -boost::timer timer; - -void test1_iterator( double t_end = 1000000.0 , double dt = 0.01 ) -{ - cout << "Test 1 Iterator with array : "; - timer.restart(); - - runge_kutta4< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - auto first = make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , t_end , dt ); - auto last = make_const_step_iterator_end( stepper , lorenz() , x ); - for( ; first != last ; ) - ++first; - - cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl; -} - -void test1_time_iterator( double t_end = 1000000.0 , double dt = 0.01 ) -{ - cout << "Test 1 Time iterator with array : "; - timer.restart(); - - runge_kutta4< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - auto first = make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , t_end , dt ); - auto last = make_const_step_time_iterator_end( stepper , lorenz() , x ); - for( ; first != last ; ) - ++first; - - cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl; -} - -void test1_integrate( double t_end = 1000000.0 , double dt = 0.01 ) -{ - cout << "Test 1 Integrate with array : "; - timer.restart(); - - runge_kutta4< state_type > stepper; - state_type x = {{ 10.0 , 10.0 , 10.0 }}; - integrate_const( stepper , lorenz() , x , 0.0 , t_end , dt ); - - cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl; -} - - - - -void test2_iterator( double t_end = 1000000.0 , double dt = 0.01 ) -{ - cout << "Test 2 Iterator with vector : "; - timer.restart(); - - runge_kutta4< state_type2 > stepper; - state_type2 x = { 10.0 , 10.0 , 10.0 }; - auto first = make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , t_end , dt ); - auto last = make_const_step_iterator_end( stepper , lorenz() , x ); - for( ; first != last ; ) - ++first; - - cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl; -} - -void test2_time_iterator( double t_end = 1000000.0 , double dt = 0.01 ) -{ - cout << "Test 2 Time iterator with vector : "; - timer.restart(); - - runge_kutta4< state_type2 > stepper; - state_type2 x = { 10.0 , 10.0 , 10.0 }; - auto first = make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , t_end , dt ); - auto last = make_const_step_time_iterator_end( stepper , lorenz() , x ); - for( ; first != last ; ) - ++first; - - cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl; -} - -void test2_integrate( double t_end = 1000000.0 , double dt = 0.01 ) -{ - cout << "Test 2 Integrate with vector : "; - timer.restart(); - runge_kutta4< state_type2 > stepper; - state_type2 x = { 10.0 , 10.0 , 10.0 }; - integrate_const( stepper , lorenz() , x , 0.0 , t_end , dt ); - cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl; -} - - - -int main( int argc , char **argv ) -{ - test1_iterator( 1000000.0 ); - test1_time_iterator( 1000000.0 ); - test1_integrate( 1000000.0 ); - - test2_iterator( 1000000.0 ); - test2_time_iterator( 1000000.0 ); - test2_integrate( 1000000.0 ); - - - - return 0; -} diff --git a/libs/numeric/odeint/test/Jamfile.v2 b/libs/numeric/odeint/test/Jamfile.v2 index 362d1f3f..9e35a512 100644 --- a/libs/numeric/odeint/test/Jamfile.v2 +++ b/libs/numeric/odeint/test/Jamfile.v2 @@ -47,10 +47,6 @@ test-suite "odeint" [ run integrate_implicit.cpp ] [ run generation.cpp ] [ run trivial_state.cpp ] - [ run const_step_iterator.cpp ] - [ run const_step_time_iterator.cpp ] - [ run adaptive_iterator.cpp ] - [ run adaptive_time_iterator.cpp ] [ run is_resizeable.cpp ] [ run resize.cpp ] [ run same_size.cpp ] diff --git a/libs/numeric/odeint/test/adaptive_iterator.cpp b/libs/numeric/odeint/test/adaptive_iterator.cpp deleted file mode 100644 index 11be1b28..00000000 --- a/libs/numeric/odeint/test/adaptive_iterator.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - [auto_generated] - libs/numeric/odeint/test/adaptive_iterator.cpp - - [begin_description] - This file tests the adaptive iterators. - [end_description] - - Copyright 2009-2012 Karsten Ahnert - Copyright 2009-2012 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#define BOOST_TEST_MODULE odeint_adaptive_iterator - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include "dummy_steppers.hpp" - -namespace mpl = boost::mpl; -using namespace boost::numeric::odeint; - -struct dummy_system { }; - -typedef dummy_stepper::state_type state_type; -typedef dummy_stepper::value_type value_type; - -BOOST_AUTO_TEST_SUITE( adaptive_iterator_test ) - -typedef mpl::vector< - dummy_controlled_stepper - , dummy_dense_output_stepper - > dummy_steppers; - - -BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers ) -{ - typedef adaptive_iterator< Stepper , dummy_system > stepper_iterator; - - state_type x = {{ 1.0 }}; - stepper_iterator first1( Stepper() , dummy_system() , x , 2.5 , 2.0 , 0.1 ); - stepper_iterator last1( Stepper() , dummy_system() , x ); - stepper_iterator last2( Stepper() , dummy_system() , x ); - - BOOST_CHECK( first1 == last1 ); - BOOST_CHECK( first1 == last2 ); - BOOST_CHECK( last1 == last2 ); -} - - - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers ) -{ - typedef adaptive_iterator< Stepper , dummy_system > stepper_iterator; - state_type x = {{ 1.0 }}; - std::vector< state_type > res; - stepper_iterator first( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ); - stepper_iterator last( Stepper() , dummy_system() , x ); - - std::copy( first , last , std::back_insert_iterator< std::vector< state_type > >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 ); -} - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers ) -{ - state_type x = {{ 1.0 }}; - std::vector< state_type > res; - std::copy( make_adaptive_iterator_begin( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) , - make_adaptive_iterator_end( Stepper() , dummy_system() , x ) , - std::back_insert_iterator< std::vector< state_type > >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 ); -} - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers ) -{ - state_type x = {{ 1.0 }}; - std::vector< state_type > res; - boost::range::copy( make_adaptive_range( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) , - std::back_insert_iterator< std::vector< state_type > >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 ); -} - - - - -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 deleted file mode 100644 index 2a8251c8..00000000 --- a/libs/numeric/odeint/test/adaptive_time_iterator.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - [auto_generated] - libs/numeric/odeint/test/adaptive_time_iterator.cpp - - [begin_description] - This file tests the adaptive time iterator. - [end_description] - - Copyright 2009-2012 Karsten Ahnert - Copyright 2009-2012 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#define BOOST_TEST_MODULE odeint_adaptive_time_iterator - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include "dummy_steppers.hpp" - -namespace mpl = boost::mpl; -using namespace boost::numeric::odeint; - -struct dummy_system { }; - -typedef dummy_stepper::state_type state_type; -typedef dummy_stepper::value_type value_type; -typedef dummy_stepper::time_type time_type; -typedef std::vector< std::pair< state_type , time_type > > result_vector; - -BOOST_AUTO_TEST_SUITE( adaptive_time_iterator_test ) - -typedef mpl::vector< -// dummy_controlled_stepper - dummy_dense_output_stepper - > dummy_steppers; - - -BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers ) -{ - typedef adaptive_time_iterator< Stepper , dummy_system > stepper_iterator; - - state_type x = {{ 1.0 }}; - stepper_iterator first1( Stepper() , dummy_system() , x , 1.5 , 1.0 , 0.1 ); - stepper_iterator last1( Stepper() , dummy_system() , x ); - stepper_iterator last2( Stepper() , dummy_system() , x ); - - BOOST_CHECK( first1 == last1 ); - BOOST_CHECK( first1 == last2 ); - BOOST_CHECK( last1 == last2 ); -} - - - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers ) -{ - typedef adaptive_time_iterator< Stepper , dummy_system > stepper_iterator; - state_type x = {{ 1.0 }}; - result_vector res; - stepper_iterator first( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ); - stepper_iterator last( Stepper() , dummy_system() , x ); - - std::copy( first , last , std::back_insert_iterator< result_vector >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 ); - 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 ) -// { -// state_type x = {{ 1.0 }}; -// result_vector res; -// std::copy( make_adaptive_time_iterator_begin( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) , -// make_adaptive_time_iterator_end( Stepper() , dummy_system() , x ) , -// std::back_insert_iterator< result_vector >( res ) ); - -// BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); -// BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 ); -// BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 ); -// BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 ); -// BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 ); -// BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 ); -// 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 ) -// { -// state_type x = {{ 1.0 }}; -// result_vector res; -// boost::range::copy( make_adaptive_time_range( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) , -// std::back_insert_iterator< result_vector >( res ) ); - -// BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); -// BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 ); -// BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 ); -// BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 ); -// BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 ); -// BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 ); -// 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_SUITE_END() diff --git a/libs/numeric/odeint/test/const_step_iterator.cpp b/libs/numeric/odeint/test/const_step_iterator.cpp deleted file mode 100644 index 49b6e0a2..00000000 --- a/libs/numeric/odeint/test/const_step_iterator.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - [auto_generated] - libs/numeric/odeint/test/const_step_iterator.cpp - - [begin_description] - This file tests the const step iterator. - [end_description] - - Copyright 2009-2012 Karsten Ahnert - Copyright 2009-2012 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#define BOOST_TEST_MODULE odeint_const_step_iterator - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include "dummy_steppers.hpp" - -namespace mpl = boost::mpl; -using namespace boost::numeric::odeint; - -struct dummy_system { }; - -typedef dummy_stepper::state_type state_type; -typedef dummy_stepper::value_type value_type; - -BOOST_AUTO_TEST_SUITE( const_step_iterator_test ) - -typedef mpl::vector< - dummy_stepper - , dummy_dense_output_stepper - > dummy_steppers; - - -BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers ) -{ - typedef const_step_iterator< Stepper , dummy_system > stepper_iterator; - - state_type x = {{ 1.0 }}; - stepper_iterator first1( Stepper() , dummy_system() , x , 2.5 , 2.0 , 0.1 ); - stepper_iterator last1( Stepper() , dummy_system() , x ); - stepper_iterator last2( Stepper() , dummy_system() , x ); - - BOOST_CHECK( first1 == last1 ); - BOOST_CHECK( first1 == last2 ); - BOOST_CHECK( last1 == last2 ); -} - - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers ) -{ - typedef const_step_iterator< Stepper , dummy_system > stepper_iterator; - state_type x = {{ 1.0 }}; - std::vector< state_type > res; - stepper_iterator first( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ); - stepper_iterator last( Stepper() , dummy_system() , x ); - - std::copy( first , last , std::back_insert_iterator< std::vector< state_type > >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 ); - - BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 ); -} - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_negative_time_step , Stepper , dummy_steppers ) -{ - typedef const_step_iterator< Stepper , dummy_system > stepper_iterator; - state_type x = {{ 1.0 }}; - std::vector< state_type > res; - stepper_iterator first( Stepper() , dummy_system() , x , 0.3 , -0.05 , -0.1 ); - stepper_iterator last( Stepper() , dummy_system() , x ); - - std::copy( first , last , std::back_insert_iterator< std::vector< state_type > >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 ); - - BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 ); -} - - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers ) -{ - state_type x = {{ 1.0 }}; - std::vector< state_type > res; - std::copy( make_const_step_iterator_begin( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) , - make_const_step_iterator_end( Stepper() , dummy_system() , x ) , - std::back_insert_iterator< std::vector< state_type > >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 ); - - BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 ); -} - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers ) -{ - state_type x = {{ 1.0 }}; - std::vector< state_type > res; - boost::range::copy( make_const_step_range( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) , - std::back_insert_iterator< std::vector< state_type > >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 ); - BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 ); - - BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 ); -} - - - - -BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/numeric/odeint/test/const_step_time_iterator.cpp b/libs/numeric/odeint/test/const_step_time_iterator.cpp deleted file mode 100644 index fd9bde5a..00000000 --- a/libs/numeric/odeint/test/const_step_time_iterator.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - [auto_generated] - libs/numeric/odeint/test/const_step_time_iterator.cpp - - [begin_description] - This file tests the const step time iterator. - [end_description] - - Copyright 2009-2012 Karsten Ahnert - Copyright 2009-2012 Mario Mulansky - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#define BOOST_TEST_MODULE odeint_const_step_time_iterator - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include "dummy_steppers.hpp" - -namespace mpl = boost::mpl; -using namespace boost::numeric::odeint; - -struct dummy_system { }; - -typedef dummy_stepper::state_type state_type; -typedef dummy_stepper::value_type value_type; -typedef dummy_stepper::time_type time_type; -typedef std::vector< std::pair< state_type , time_type > > result_vector; - -BOOST_AUTO_TEST_SUITE( const_step_time_iterator_test ) - -typedef mpl::vector< - dummy_stepper - , dummy_dense_output_stepper - > dummy_steppers; - - -BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers ) -{ - typedef const_step_time_iterator< Stepper , dummy_system > stepper_iterator; - - state_type x = {{ 1.0 }}; - stepper_iterator first1( Stepper() , dummy_system() , x , 1.5 , 1.0 , 0.1 ); - stepper_iterator last1( Stepper() , dummy_system() , x ); - stepper_iterator last2( Stepper() , dummy_system() , x ); - - BOOST_CHECK( first1 == last1 ); - BOOST_CHECK( first1 == last2 ); - BOOST_CHECK( last1 == last2 ); -} - - - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers ) -{ - typedef const_step_time_iterator< Stepper , dummy_system > stepper_iterator; - state_type x = {{ 1.0 }}; - result_vector res; - stepper_iterator first( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ); - stepper_iterator last( Stepper() , dummy_system() , x ); - - std::copy( first , last , std::back_insert_iterator< result_vector >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 ); - 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-13 ); -} - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers ) -{ - state_type x = {{ 1.0 }}; - result_vector res; - std::copy( make_const_step_time_iterator_begin( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) , - make_const_step_time_iterator_end( Stepper() , dummy_system() , x ) , - std::back_insert_iterator< result_vector >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 ); - 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-13 ); -} - -BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers ) -{ - state_type x = {{ 1.0 }}; - result_vector res; - boost::range::copy( make_const_step_time_range( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) , - std::back_insert_iterator< result_vector >( res ) ); - - BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) ); - BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 ); - BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 ); - 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-13 ); -} - - - - -BOOST_AUTO_TEST_SUITE_END()