2
0
mirror of https://github.com/boostorg/odeint.git synced 2026-01-26 06:42:23 +00:00

finalized redesign iterators

This commit is contained in:
Karsten Ahnert
2013-02-01 14:55:41 +01:00
parent a64b3f65f2
commit 94de59c54a
19 changed files with 640 additions and 394 deletions

Binary file not shown.

View File

@@ -19,8 +19,6 @@
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>

View File

@@ -20,7 +20,7 @@
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_time_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
namespace boost {
@@ -47,7 +47,7 @@ namespace odeint {
class adaptive_iterator< Stepper , System , controlled_stepper_tag > : public detail::ode_iterator_base
<
adaptive_iterator< Stepper , System , controlled_stepper_tag > ,
Stepper , System , controlled_stepper_tag
Stepper , System
>
{
private:
@@ -62,7 +62,7 @@ namespace odeint {
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base<
adaptive_iterator< Stepper , System , controlled_stepper_tag > ,
Stepper , System , controlled_stepper_tag
Stepper , System
> base_type;
#endif

View File

@@ -19,95 +19,105 @@
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ADAPTIVE_ITERATOR_DENSE_OUTPUT_IMPL_HPP_DEFINED
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
namespace boost {
namespace numeric {
namespace odeint {
// /*
// * Specilization for dense outputer steppers
// */
// /**
// * \brief ODE Iterator with adaptive step size control. The value type of this iterator is the state type of the stepper.
// *
// * Implements an ODE iterator with adaptive step size control. Uses dense-output steppers. adaptive_iterator is a model
// * of single-pass iterator.
// *
// * The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
// *
// * \tparam Stepper The stepper type which should be used during the iteration.
// * \tparam System The type of the system function (ODE) which should be solved.
// */
// template< class Stepper , class System >
// class adaptive_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_iterator_base
// <
// adaptive_iterator< Stepper , System , dense_output_stepper_tag > ,
// Stepper , System , dense_output_stepper_tag
// >
// {
// private:
// typedef Stepper stepper_type;
// typedef System system_type;
// typedef typename stepper_type::state_type state_type;
// typedef typename stepper_type::time_type time_type;
// typedef typename stepper_type::value_type ode_value_type;
// #ifndef DOXYGEN_SKIP
// typedef detail::ode_iterator_base<
// adaptive_iterator< Stepper , System , dense_output_stepper_tag > ,
// Stepper , System , dense_output_stepper_tag
// > base_type;
// #endif
// public:
/*
* Specilization for dense outputer steppers
*/
/**
* \brief ODE Iterator with adaptive step size control. The value type of this iterator is the state type of the stepper.
*
* Implements an ODE iterator with adaptive step size control. Uses dense-output steppers. adaptive_iterator is a model
* of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Stepper , class System >
class adaptive_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_iterator_base
<
adaptive_iterator< Stepper , System , dense_output_stepper_tag > ,
Stepper , System
>
{
private:
// /**
// * \brief Constructs an adaptive_iterator. This constructor should be used to construct the begin iterator.
// *
// * \param stepper The stepper to use during the iteration.
// * \param sys The system function (ODE) to solve.
// * \param s The initial state.
// * \param t The initial time.
// * \param t_end The end time, at which the iteration should stop.
// * \param dt The initial time step.
// */
// adaptive_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
// : base_type( stepper , sys , s , t , t_end , dt )
// {
// this->m_stepper.initialize( *( this->m_state ) , this->m_t , this->m_dt );
// }
// /**
// * \brief Constructs an adaptive_iterator. This constructor should be used to construct the end iterator.
// *
// * \param stepper The stepper to use during the iteration.
// * \param sys The system function (ODE) to solve.
// * \param s The initial state.
// */
// adaptive_iterator( stepper_type stepper , system_type sys , state_type &s )
// : base_type( stepper , sys , s ) { }
// protected:
// friend class boost::iterator_core_access;
// void increment()
// {
// this->m_stepper.do_step( this->m_system );
// this->m_t = this->m_stepper.current_time();
// this->check_end();
// }
// // overwrite dereference from ode_iterator_base
// const state_type& dereference() const
// {
// return this->m_stepper.current_state();
// }
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef typename traits::state_type< stepper_type >::type state_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base<
adaptive_iterator< Stepper , System , dense_output_stepper_tag > ,
Stepper , System
> base_type;
#endif
// };
public:
/**
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state.
* \param t The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
*/
adaptive_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , s , t , t_end , dt )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( *( this->m_state ) , this->m_t , this->m_dt );
}
/**
* \brief Constructs an adaptive_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state.
*/
adaptive_iterator( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys , s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
unwrapped_stepper_type &stepper = this->m_stepper;
stepper.do_step( this->m_system );
this->m_t = stepper.current_time();
this->check_end();
}
// overwrite dereference from ode_iterator_base
const state_type& dereference() const
{
const unwrapped_stepper_type &stepper = this->m_stepper;
return stepper.current_state();
}
};

View File

@@ -46,7 +46,7 @@ namespace odeint {
class adaptive_time_iterator< Stepper , System , controlled_stepper_tag > : public detail::ode_time_iterator_base
<
adaptive_time_iterator< Stepper , System , controlled_stepper_tag > ,
Stepper , System , controlled_stepper_tag
Stepper , System
>
{
private:
@@ -59,7 +59,7 @@ namespace odeint {
typedef typename unwrapped_stepper_type::value_type ode_value_type;
typedef detail::ode_time_iterator_base<
adaptive_time_iterator< Stepper , System , controlled_stepper_tag > ,
Stepper , System , controlled_stepper_tag > base_type;
Stepper , System > base_type;
public:

View File

@@ -23,81 +23,91 @@ namespace boost {
namespace numeric {
namespace odeint {
// /*
// * Specilization for steppers and error steppers
// */
// /**
// * \brief ODE Iterator with adaptive step size control. The value type of this iterator is a pair of state type and time type of the stepper.
// *
// * Implements an ODE with adaptive step size control. Uses dense-output steppers. adaptive_iterator is a model
// * of single-pass iterator.
// *
// * The value type of this iterator is a pair of state type and time type of the stepper.
// *
// * \tparam Stepper The stepper type which should be used during the iteration.
// * \tparam System The type of the system function (ODE) which should be solved.
// */
// template< class Stepper , class System >
// class adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_time_iterator_base
// <
// adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > ,
// Stepper , System , dense_output_stepper_tag
// >
// {
// private:
/*
* Specilization for steppers and error steppers
*/
/**
* \brief ODE Iterator with adaptive step size control. The value type of this iterator is a pair of state type and time type of the stepper.
*
* Implements an ODE with adaptive step size control. Uses dense-output steppers. adaptive_iterator is a model
* of single-pass iterator.
*
* The value type of this iterator is a pair of state type and time type of the stepper.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Stepper , class System >
class adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_time_iterator_base
<
adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > ,
Stepper , System
>
{
private:
// typedef Stepper stepper_type;
// typedef System system_type;
// typedef typename stepper_type::state_type state_type;
// typedef typename stepper_type::time_type time_type;
// typedef typename stepper_type::value_type ode_value_type;
// typedef detail::ode_time_iterator_base<
// adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > ,
// Stepper , System , dense_output_stepper_tag > base_type;
// public:
// /**
// * \brief Constructs an adaptive_time_iterator. This constructor should be used to construct the begin iterator.
// *
// * \param stepper The stepper to use during the iteration.
// * \param sys The system function (ODE) to solve.
// * \param s The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
// * \param t The initial time.
// * \param t_end The end time, at which the iteration should stop.
// * \param dt The initial time step.
// */
// adaptive_time_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
// : base_type( stepper , sys , s , t , t_end , dt )
// {
// this->m_stepper.initialize( this->m_state.first , this->m_state.second , this->m_dt );
// }
// /**
// * \brief Constructs an adaptive_time_iterator. This constructor should be used to construct the end iterator.
// *
// * \param stepper The stepper to use during the iteration.
// * \param sys The system function (ODE) to solve.
// * \param s The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
// */
// adaptive_time_iterator( stepper_type stepper , system_type sys , state_type &s )
// : base_type( stepper , sys , s )
// {
// }
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef typename unwrapped_stepper_type::state_type state_type;
typedef typename unwrapped_stepper_type::time_type time_type;
typedef typename unwrapped_stepper_type::value_type ode_value_type;
typedef detail::ode_time_iterator_base<
adaptive_time_iterator< Stepper , System , dense_output_stepper_tag > ,
Stepper , System > base_type;
// private:
public:
// friend class boost::iterator_core_access;
/**
* \brief Constructs an adaptive_time_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
*/
adaptive_time_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , s , t , t_end , dt )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( *(this->m_state) , this->m_t , this->m_dt );
}
// void increment()
// {
// this->m_stepper.do_step( this->m_system );
// this->m_state.second = this->m_stepper.current_time();
// this->m_stepper.calc_state( this->m_state.second , this->m_state.first );
// this->check_end();
// }
// };
/**
* \brief Constructs an adaptive_time_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. adaptive_time_iterator stores a reference of s and changes its value during the iteration.
*/
adaptive_time_iterator( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys , s )
{
}
private:
friend class boost::iterator_core_access;
std::pair< const state_type& , const time_type& > dereference() const
{
const unwrapped_stepper_type &stepper = this->m_stepper;
return std::pair< const state_type & , const time_type & >( stepper.current_state() , this->m_t );
}
void increment()
{
unwrapped_stepper_type &stepper = this->m_stepper;
stepper.do_step( this->m_system );
this->m_t = stepper.current_time();
this->check_end();
}
};

View File

@@ -19,92 +19,104 @@
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_CONST_STEP_ITERATOR_DENSE_OUTPUT_IMPL_HPP_DEFINED
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
namespace boost {
namespace numeric {
namespace odeint {
// /*
// * Specilization for dense output stepper
// */
// /**
// * \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper.
// *
// * Implements an ODE iterator solving the ODE with constant steps. Uses dense-output steppers.
// * const_step_iterator is a model of single-pass iterator.
// *
// * The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
// *
// * \tparam Stepper The stepper type which should be used during the iteration.
// * \tparam System The type of the system function (ODE) which should be solved.
// */
// template< class Stepper , class System >
// class const_step_iterator< Stepper , System , dense_output_stepper_tag >
// : public detail::ode_iterator_base<
// const_step_iterator< Stepper , System , dense_output_stepper_tag > ,
// Stepper , System , dense_output_stepper_tag >
// {
// private:
/*
* Specilization for dense output stepper
*/
/**
* \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper.
*
* Implements an ODE iterator solving the ODE with constant steps. Uses dense-output steppers.
* const_step_iterator is a model of single-pass iterator.
*
* The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Stepper , class System >
class const_step_iterator< Stepper , System , dense_output_stepper_tag >
: public detail::ode_iterator_base<
const_step_iterator< Stepper , System , dense_output_stepper_tag > ,
Stepper , System >
{
private:
// typedef Stepper stepper_type;
// typedef System system_type;
// typedef typename stepper_type::state_type state_type;
// typedef typename stepper_type::time_type time_type;
// typedef typename stepper_type::value_type ode_value_type;
// typedef detail::ode_iterator_base<
// const_step_iterator< Stepper , System , dense_output_stepper_tag > ,
// Stepper , System , dense_output_stepper_tag > base_type;
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef typename traits::state_type< stepper_type >::type state_type;
typedef typename traits::time_type< stepper_type >::type time_type;
typedef typename traits::value_type< stepper_type >::type ode_value_type;
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base<
const_step_iterator< Stepper , System , dense_output_stepper_tag > ,
Stepper , System > base_type;
#endif
// public:
public:
// /**
// * \brief Constructs a const_step_iterator. This constructor should be used to construct the begin iterator.
// *
// * \param stepper The stepper to use during the iteration.
// * \param sys The system function (ODE) to solve.
// * \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
// * \param t The initial time.
// * \param t_end The end time, at which the iteration should stop.
// * \param dt The initial time step.
// */
// const_step_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
// : base_type( stepper , sys , s , t , t_end , dt )
// {
// this->m_stepper.initialize( * ( this->m_state ) , this->m_t , this->m_dt );
// }
/**
* \brief Constructs a const_step_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
*/
const_step_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , s , t , t_end , dt )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( * ( this->m_state ) , this->m_t , this->m_dt );
}
// /**
// * \brief Constructs a const_step_iterator. This constructor should be used to construct the end iterator.
// *
// * \param stepper The stepper to use during the iteration.
// * \param sys The system function (ODE) to solve.
// * \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
// */
// const_step_iterator( stepper_type stepper , system_type sys , state_type &s )
// : base_type( stepper , sys , s ) { }
/**
* \brief Constructs a const_step_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
*/
const_step_iterator( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys , s )
{
}
// protected:
// friend class boost::iterator_core_access;
protected:
// void increment( void )
// {
// this->m_t += this->m_dt;
// if( get_unit_value( this->m_dt ) > static_cast< ode_value_type >( 0.0 ) )
// {
// while( this->m_stepper.current_time() < this->m_t )
// this->m_stepper.do_step( this->m_system );
// }
// else
// {
// while( this->m_stepper.current_time() > this->m_t )
// this->m_stepper.do_step( this->m_system );
// }
// this->m_stepper.calc_state( this->m_t , *( this->m_state ) );
// this->check_end();
// }
// };
friend class boost::iterator_core_access;
void increment( void )
{
unwrapped_stepper_type &stepper = this->m_stepper;
this->m_t += this->m_dt;
if( get_unit_value( this->m_dt ) > static_cast< ode_value_type >( 0.0 ) )
{
while( stepper.current_time() < this->m_t )
stepper.do_step( this->m_system );
}
else
{
while( stepper.current_time() > this->m_t )
stepper.do_step( this->m_system );
}
stepper.calc_state( this->m_t , *( this->m_state ) );
this->check_end();
}
};

View File

@@ -47,7 +47,7 @@ namespace odeint {
class const_step_iterator< Stepper , System , stepper_tag >
: public detail::ode_iterator_base<
const_step_iterator< Stepper , System , stepper_tag > ,
Stepper , System , stepper_tag >
Stepper , System >
{
private:
@@ -60,7 +60,7 @@ namespace odeint {
#ifndef DOXYGEN_SKIP
typedef detail::ode_iterator_base<
const_step_iterator< Stepper , System , stepper_tag > ,
Stepper , System , stepper_tag > base_type;
Stepper , System > base_type;
#endif
public:

View File

@@ -24,89 +24,93 @@ namespace numeric {
namespace odeint {
// /*
// * Specilization for dense output steppers
// */
// /**
// * \brief ODE Iterator with constant step size. The value type of this iterator is a pair of state type and
// * time type of the stepper.
// *
// * Implements an ODE iterator which solves the ODE with constant step size. Uses dense-output steppers.
// * const_step_time_iterator is a model of single-pass iterator.
// *
// * The value type of this iterator is a pair of state type and time type of the stepper.
// *
// * \tparam Stepper The stepper type which should be used during the iteration.
// * \tparam System The type of the system function (ODE) which should be solved.
// */
// template< class Stepper , class System >
// class const_step_time_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_time_iterator_base
// <
// const_step_time_iterator< Stepper , System , dense_output_stepper_tag > ,
// Stepper , System , dense_output_stepper_tag
// >
// {
// private:
/*
* Specilization for dense output steppers
*/
/**
* \brief ODE Iterator with constant step size. The value type of this iterator is a pair of state type and
* time type of the stepper.
*
* Implements an ODE iterator which solves the ODE with constant step size. Uses dense-output steppers.
* const_step_time_iterator is a model of single-pass iterator.
*
* The value type of this iterator is a pair of state type and time type of the stepper.
*
* \tparam Stepper The stepper type which should be used during the iteration.
* \tparam System The type of the system function (ODE) which should be solved.
*/
template< class Stepper , class System >
class const_step_time_iterator< Stepper , System , dense_output_stepper_tag > : public detail::ode_time_iterator_base
<
const_step_time_iterator< Stepper , System , dense_output_stepper_tag > ,
Stepper , System
>
{
private:
// typedef Stepper stepper_type;
// typedef System system_type;
// typedef typename stepper_type::state_type state_type;
// typedef typename stepper_type::time_type time_type;
// typedef typename stepper_type::value_type ode_value_type;
// typedef detail::ode_time_iterator_base<
// const_step_time_iterator< Stepper , System , dense_output_stepper_tag > ,
// Stepper , System , dense_output_stepper_tag > base_type;
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef typename unwrapped_stepper_type::state_type state_type;
typedef typename unwrapped_stepper_type::time_type time_type;
typedef typename unwrapped_stepper_type::value_type ode_value_type;
typedef detail::ode_time_iterator_base<
const_step_time_iterator< Stepper , System , dense_output_stepper_tag > ,
Stepper , System > base_type;
// public:
public:
// /**
// * \brief Constructs a const_step_time_iterator. This constructor should be used to construct the begin iterator.
// *
// * \param stepper The stepper to use during the iteration.
// * \param sys The system function (ODE) to solve.
// * \param s The initial state. const_step_time_iterator stores a reference of s and changes its value during the iteration.
// * \param t The initial time.
// * \param t_end The end time, at which the iteration should stop.
// * \param dt The initial time step.
// */
// const_step_time_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
// : base_type( stepper , sys , s , t , t_end , dt )
// {
// this->m_stepper.initialize( this->m_state.first , this->m_state.second , this->m_dt );
// }
/**
* \brief Constructs a const_step_time_iterator. This constructor should be used to construct the begin iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_time_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param t_end The end time, at which the iteration should stop.
* \param dt The initial time step.
*/
const_step_time_iterator( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , s , t , t_end , dt )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( *(this->m_state) , this->m_t , this->m_dt );
}
// /**
// * \brief Constructs a const_step_time_iterator. This constructor should be used to construct the end iterator.
// *
// * \param stepper The stepper to use during the iteration.
// * \param sys The system function (ODE) to solve.
// * \param s The initial state. const_step_time_iterator stores a reference of s and changes its value during the iteration.
// */
// const_step_time_iterator( stepper_type stepper , system_type sys , state_type &s )
// : base_type( stepper , sys , s ) {}
/**
* \brief Constructs a const_step_time_iterator. This constructor should be used to construct the end iterator.
*
* \param stepper The stepper to use during the iteration.
* \param sys The system function (ODE) to solve.
* \param s The initial state. const_step_time_iterator stores a reference of s and changes its value during the iteration.
*/
const_step_time_iterator( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys , s ) {}
// protected:
protected:
// friend class boost::iterator_core_access;
friend class boost::iterator_core_access;
// void increment()
// {
// this->m_state.second += this->m_dt;
// if( get_unit_value( this->m_dt ) > static_cast< ode_value_type >( 0.0 ) )
// {
// while( this->m_stepper.current_time() < this->m_state.second )
// this->m_stepper.do_step( this->m_system );
// }
// else
// {
// while( this->m_stepper.current_time() > this->m_state.second )
// this->m_stepper.do_step( this->m_system );
// }
// this->m_stepper.calc_state( this->m_state.second , this->m_state.first );
// this->check_end();
// }
// };
void increment()
{
unwrapped_stepper_type &stepper = this->m_stepper;
this->m_t += this->m_dt;
if( get_unit_value( this->m_dt ) > static_cast< ode_value_type >( 0.0 ) )
{
while( stepper.current_time() < this->m_t )
stepper.do_step( this->m_system );
}
else
{
while( stepper.current_time() > this->m_t )
stepper.do_step( this->m_system );
}
stepper.calc_state( this->m_t , *(this->m_state) );
this->check_end();
}
};

View File

@@ -47,7 +47,7 @@ namespace odeint {
class const_step_time_iterator< Stepper , System , stepper_tag > : public detail::ode_time_iterator_base
<
const_step_time_iterator< Stepper , System , stepper_tag > ,
Stepper , System , stepper_tag
Stepper , System
>
{
private:
@@ -60,7 +60,7 @@ namespace odeint {
typedef typename unwrapped_stepper_type::value_type ode_value_type;
typedef detail::ode_time_iterator_base<
const_step_time_iterator< Stepper , System , stepper_tag > ,
Stepper , System , stepper_tag > base_type;
Stepper , System > base_type;
public:

View File

@@ -33,12 +33,12 @@ namespace detail {
template< class Iterator , class Stepper , class System , class StepperTag >
template< class Iterator , class Stepper , class System >
class ode_iterator_base : public boost::iterator_facade
<
Iterator ,
typename traits::state_type< Stepper >::type const ,
boost::single_pass_traversal_tag
boost::single_pass_traversal_tag
>
{
private:

View File

@@ -32,7 +32,7 @@ namespace detail {
template< class Iterator , class Stepper , class System , class StepperTag >
template< class Iterator , class Stepper , class System >
class ode_time_iterator_base : public boost::iterator_facade
<
Iterator ,

View File

@@ -33,8 +33,8 @@ exe simple1d : simple1d.cpp ;
exe stochastic_euler : stochastic_euler.cpp ;
exe generation_functions : generation_functions.cpp ;
exe heun : heun.cpp ;
# exe const_step_iterator : const_step_iterator.cpp : <cxxflags>-std=c++0x ;
# exe adaptive_iterator : adaptive_iterator.cpp : <cxxflags>-std=c++0x ;
exe const_step_iterator : const_step_iterator.cpp : <cxxflags>-std=c++0x ;
exe adaptive_iterator : adaptive_iterator.cpp : <cxxflags>-std=c++0x ;
exe bind_member_functions : bind_member_functions.cpp ;
exe bind_member_functions_cpp11 : bind_member_functions_cpp11.cpp : <cxxflags>-std=c++0x ;

View File

@@ -67,7 +67,7 @@ int main( int argc , char **argv )
state_type x = {{ 10.0 , 10.0 , 10.0 }};
std::for_each( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
[]( const std::pair< state_type&, double > &x ) {
[]( const std::pair< const state_type&, double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}
@@ -79,7 +79,7 @@ int main( int argc , char **argv )
std::copy_if( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
std::back_inserter( res ) ,
[]( const pair< state_type& , double > &x ) {
[]( const pair< const state_type& , double > &x ) {
return ( x.first[0] > 0.0 ) ? true : false; } );
for( size_t i=0 ; i<res.size() ; ++i )
cout << res[i].first[0] << tab << res[i].first[1] << tab << res[i].first[2] << "\n";
@@ -92,7 +92,7 @@ int main( int argc , char **argv )
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 ) {
[]( double sum , const pair< const state_type& , double > &x ) {
return sum + x.first[0]; } );
cout << res << endl;
}
@@ -106,7 +106,7 @@ int main( int argc , char **argv )
std::transform( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
back_inserter( weights ) ,
[]( const pair< state_type& , double > &x ) {
[]( const pair< const state_type& , double > &x ) {
return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } );
for( size_t i=0 ; i<weights.size() ; ++i )
cout << weights[i] << "\n";
@@ -134,7 +134,7 @@ int main( int argc , char **argv )
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 }};
boost::range::for_each( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
[]( const std::pair< state_type& , double > &x ) {
[]( const std::pair< const state_type& , double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}
@@ -145,7 +145,7 @@ int main( int argc , char **argv )
std::vector< std::pair< state_type , double > > res;
state_type x = {{ 10.0 , 10.0 , 10.0 }};
boost::range::copy( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) |
boost::adaptors::filtered( [] ( const pair< state_type& , double > &x ) { return ( x.first[0] > 0.0 ); } ) ,
boost::adaptors::filtered( [] ( const pair< const state_type& , double > &x ) { return ( x.first[0] > 0.0 ); } ) ,
std::back_inserter( res ) );
for( size_t i=0 ; i<res.size() ; ++i )
cout << res[i].first[0] << tab << res[i].first[1] << tab << res[i].first[2] << "\n";
@@ -157,7 +157,7 @@ int main( int argc , char **argv )
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 }};
double res = boost::accumulate( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 ,
[]( double sum , const pair< state_type& , double > &x ) {
[]( double sum , const pair< const state_type& , double > &x ) {
return sum + x.first[0]; } );
cout << res << endl;
//]
@@ -170,7 +170,7 @@ int main( int argc , char **argv )
state_type x = {{ 10.0 , 10.0 , 10.0 }};
vector< double > weights;
boost::transform( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , back_inserter( weights ) ,
[]( const pair< state_type& , double > &x ) {
[]( const pair< const state_type& , double > &x ) {
return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } );
for( size_t i=0 ; i<weights.size() ; ++i )
cout << weights[i] << "\n";
@@ -182,7 +182,7 @@ int main( int argc , char **argv )
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 }};
auto iter = boost::find_if( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
[]( const std::pair< state_type & , double > &x ) {
[]( const std::pair< const state_type & , double > &x ) {
return ( x.first[0] < 0.0 ); } );
cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n";
}

View File

@@ -59,7 +59,7 @@ int main( int argc , char **argv )
state_type x = {{ 10.0 , 10.0 , 10.0 }};
std::for_each( make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_const_step_time_iterator_end( stepper , lorenz() , x ) ,
[]( const std::pair< state_type&, double > &x ) {
[]( const std::pair< const state_type&, double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}
@@ -116,7 +116,7 @@ int main( int argc , char **argv )
std::transform( make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
make_const_step_time_iterator_end( stepper , lorenz() , x ) ,
back_inserter( weights ) ,
[]( const std::pair< state_type &, double > &x ) {
[]( const std::pair< const state_type &, double > &x ) {
return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } );
for( size_t i=0 ; i<weights.size() ; ++i )
cout << weights[i] << "\n";
@@ -150,7 +150,7 @@ int main( int argc , char **argv )
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 ) {
[]( const std::pair< const state_type& , double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}
@@ -185,7 +185,7 @@ int main( int argc , char **argv )
runge_kutta4< state_type > stepper;
state_type x = {{ 10.0 , 10.0 , 10.0 }};
double res = boost::accumulate( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 ,
[]( double sum , const std::pair< state_type &, double > &x ) {
[]( double sum , const std::pair< const state_type &, double > &x ) {
return sum + x.first[0]; } );
cout << res << endl;
//]
@@ -210,7 +210,7 @@ int main( int argc , char **argv )
runge_kutta4< state_type > stepper;
state_type x = {{ 10.0 , 10.0 , 10.0 }};
auto iter = boost::find_if( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
[]( const std::pair< state_type & , double > &x ) {
[]( const std::pair< const state_type & , double > &x ) {
return ( x.first[0] < 0.0 ); } );
cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n";
@@ -246,7 +246,7 @@ int main( int argc , char **argv )
runge_kutta_dopri5< state_type > stepper;
state_type x = {{ 10.0 , 10.0 , 10.0 }};
boost::range::for_each( make_const_step_time_range( make_dense_output( 1.0e-6 , 1.0e-6 , stepper ) , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
[]( const std::pair< state_type& , double > &x ) {
[]( const std::pair< const state_type& , double > &x ) {
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
}

View File

@@ -45,7 +45,7 @@ BOOST_AUTO_TEST_SUITE( adaptive_iterator_test )
typedef mpl::vector<
dummy_controlled_stepper
// , dummy_dense_output_stepper
, dummy_dense_output_stepper
> dummy_steppers;
@@ -72,6 +72,45 @@ BOOST_AUTO_TEST_CASE( copy_controlled_stepper_iterator )
}
BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator )
{
typedef adaptive_iterator< dummy_dense_output_stepper , empty_system > iterator_type;
state_type x = {{ 1.0 }};
iterator_type iter1( dummy_dense_output_stepper() , empty_system() , x );
iterator_type iter2( iter1 );
BOOST_CHECK_NE( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
++iter1;
++iter2;
BOOST_CHECK_NE( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator_with_reference_wrapper )
{
typedef adaptive_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type;
state_type x = {{ 1.0 }};
dummy_dense_output_stepper stepper;
iterator_type iter1( boost::ref( stepper ) , empty_system() , x );
iterator_type iter2( iter1 );
BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
++iter1;
++iter2;
BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_controlled_stepper_iterator )
{
typedef adaptive_iterator< dummy_controlled_stepper , empty_system > iterator_type;
@@ -87,6 +126,44 @@ BOOST_AUTO_TEST_CASE( assignment_controlled_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator )
{
typedef adaptive_iterator< dummy_dense_output_stepper , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( dummy_dense_output_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_NE( & (*iter1) , & (*iter2) );
BOOST_CHECK( !iter1.same( iter2 ) );
iter2 = iter1;
BOOST_CHECK_NE( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator_with_reference_wrapper )
{
typedef adaptive_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
dummy_dense_output_stepper stepper;
iterator_type iter1 = iterator_type( boost::ref( stepper ) , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( boost::ref( stepper ) , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );
BOOST_CHECK( !iter1.same( iter2 ) );
iter2 = iter1;
BOOST_CHECK_EQUAL( & (*iter1) , & (*iter2) );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_factory )
{
dummy_controlled_stepper stepper;
@@ -101,6 +178,21 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_factory )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
std::for_each(
make_adaptive_iterator_begin( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
make_adaptive_iterator_end( stepper , boost::ref( system ) , x ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( controlled_stepper_range )
{
dummy_controlled_stepper stepper;
@@ -113,6 +205,18 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_range )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_range )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
boost::for_each( make_adaptive_range( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_with_reference_wrapper_factory )
{
dummy_controlled_stepper stepper;
@@ -127,6 +231,19 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_iterator_with_reference_wrapper_factory
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_with_reference_wrapper_factory )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
std::for_each(
make_adaptive_iterator_begin( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
make_adaptive_iterator_end( boost::ref( stepper ) , boost::ref( system ) , x ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( controlled_stepper_range_with_reference_wrapper )
{
dummy_controlled_stepper stepper;
@@ -139,6 +256,18 @@ BOOST_AUTO_TEST_CASE( controlled_stepper_range_with_reference_wrapper )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_range_with_reference_wrapper )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
boost::for_each( make_adaptive_range( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers )
{
@@ -203,32 +332,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dum
}
// BOOST_AUTO_TEST_CASE( copy_constructor_iterator_dense_output_stepper )
// {
// state_type x = {{ 1.0 }};
// dummy_dense_output_stepper stepper;
// adaptive_iterator< dummy_dense_output_stepper , empty_system > iter1( stepper , empty_system() , x , 0.0 , 10.0 , 0.01 );
// adaptive_iterator< dummy_dense_output_stepper , empty_system > iter2( iter1 );
// const state_type &p1 = *iter1;
// const state_type &p2 = *iter2;
// BOOST_CHECK_EQUAL( p1[0] , p2[0] );
// BOOST_CHECK_EQUAL( p1[0] , x[0] );
// ++iter1;
// ++iter2;
// BOOST_CHECK_EQUAL( p1[0] , p2[0] );
// const state_type &p3 = *iter1;
// const state_type &p4 = *iter2;
// BOOST_CHECK_EQUAL( p3[0] , p4[0] );
// BOOST_CHECK_EQUAL( p3[0] , p1[0] );
// }
BOOST_AUTO_TEST_SUITE_END()

View File

@@ -49,7 +49,7 @@ BOOST_AUTO_TEST_SUITE( adaptive_time_iterator_test )
typedef mpl::vector<
dummy_controlled_stepper
// , dummy_dense_output_stepper
, dummy_dense_output_stepper
> dummy_steppers;
@@ -64,6 +64,30 @@ BOOST_AUTO_TEST_CASE( copy_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator )
{
typedef adaptive_time_iterator< dummy_dense_output_stepper , empty_system > iterator_type;
state_type x = {{ 1.0 }};
iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iter1;
BOOST_CHECK_NE( &( iter1->first ) , &( iter2->first ) );
BOOST_CHECK_NE( &( iter1->first ) , &x );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( copy_dense_output_stepper_iterator_with_reference_wrapper )
{
typedef adaptive_time_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type;
state_type x = {{ 1.0 }};
dummy_dense_output_stepper stepper;
iterator_type iter1 = iterator_type( boost::ref( stepper ) , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iter1;
BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) );
BOOST_CHECK_NE( &( iter1->first ) , &x );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
{
typedef adaptive_time_iterator< dummy_controlled_stepper , empty_system > iterator_type;
@@ -79,6 +103,42 @@ BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator )
{
typedef adaptive_time_iterator< dummy_dense_output_stepper , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
iterator_type iter1 = iterator_type( dummy_dense_output_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( dummy_dense_output_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_NE( &( iter1->first ) , &x1 );
BOOST_CHECK_NE( &( iter2->first ) , &x2 );
BOOST_CHECK( !iter1.same( iter2 ) );
iter2 = iter1;
BOOST_CHECK_NE( &( iter1->first ) , &x1 );
BOOST_CHECK_NE( &( iter2->first ) , &x1 );
BOOST_CHECK( iter1.same( iter2 ) );
BOOST_CHECK_EQUAL( (iter1->first)[0] , (iter1->first)[0] );
}
BOOST_AUTO_TEST_CASE( assignment_dense_output_stepper_iterator_with_reference_wrapper )
{
typedef adaptive_time_iterator< boost::reference_wrapper< dummy_dense_output_stepper > , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
dummy_dense_output_stepper stepper;
iterator_type iter1 = iterator_type( boost::ref( stepper ) , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( boost::ref( stepper ) , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_NE( &( iter1->first ) , &x1 );
BOOST_CHECK_NE( &( iter2->first ) , &x2 );
BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) );
BOOST_CHECK( !iter1.same( iter2 ) );
iter2 = iter1;
BOOST_CHECK_NE( &( iter1->first ) , &x1 );
BOOST_CHECK_NE( &( iter2->first ) , &x1 );
BOOST_CHECK( iter1.same( iter2 ) );
BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
{
dummy_controlled_stepper stepper;
@@ -93,6 +153,20 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_factory )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
std::for_each(
make_adaptive_time_iterator_begin( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
make_adaptive_time_iterator_end( stepper , boost::ref( system ) , x ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( stepper_range )
{
dummy_controlled_stepper stepper;
@@ -105,6 +179,18 @@ BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_range )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
boost::for_each( make_adaptive_time_range( stepper , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
{
dummy_controlled_stepper stepper;
@@ -119,6 +205,21 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_iterator_with_reference_wrapper_factory )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
std::for_each(
make_adaptive_time_iterator_begin( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
make_adaptive_time_iterator_end( boost::ref( stepper ) , boost::ref( system ) , x ) ,
dummy_observer() );
}
BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper )
{
dummy_controlled_stepper stepper;
@@ -131,6 +232,17 @@ BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
// just test if it compiles
BOOST_AUTO_TEST_CASE( dense_output_stepper_range_with_reference_wrapper )
{
dummy_dense_output_stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
boost::for_each( make_adaptive_time_range( boost::ref( stepper ) , boost::ref( system ) , x , 0.0 , 0.999 , 0.1 ) ,
dummy_observer() );
}
@@ -170,8 +282,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers )
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers )
@@ -191,8 +301,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_ste
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers )
@@ -211,8 +319,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dum
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
}

View File

@@ -46,27 +46,28 @@ BOOST_AUTO_TEST_SUITE( const_step_iterator_test )
typedef mpl::vector<
dummy_stepper
// , dummy_dense_output_stepper
, dummy_dense_output_stepper
> dummy_steppers;
BOOST_AUTO_TEST_CASE( copy_stepper_iterator )
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_stepper_iterator , Stepper , dummy_steppers )
{
typedef const_step_iterator< dummy_stepper , empty_system > iterator_type;
typedef const_step_iterator< Stepper , empty_system > iterator_type;
state_type x = {{ 1.0 }};
iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter1 = iterator_type( Stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iter1;
BOOST_CHECK_EQUAL( &(*iter1) , &(*iter2) );
BOOST_CHECK_EQUAL( &(*iter1) , &x );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_AUTO_TEST_CASE_TEMPLATE( assignment_stepper_iterator , Stepper , dummy_steppers )
{
typedef const_step_iterator< dummy_stepper , empty_system > iterator_type;
typedef const_step_iterator< Stepper , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( dummy_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
iterator_type iter1 = iterator_type( Stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( Stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_EQUAL( &(*iter1) , &x1 );
BOOST_CHECK_EQUAL( &(*iter2) , &x2 );
BOOST_CHECK( !iter1.same( iter2 ) );
@@ -76,9 +77,11 @@ BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_factory , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -90,9 +93,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -102,9 +105,9 @@ BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_with_reference_wrapper_factory , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -116,9 +119,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range_with_reference_wrapper , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};

View File

@@ -47,28 +47,28 @@ BOOST_AUTO_TEST_SUITE( const_step_time_iterator_test )
typedef mpl::vector<
dummy_stepper
// , dummy_dense_output_stepper
, dummy_dense_output_stepper
> dummy_steppers;
BOOST_AUTO_TEST_CASE( copy_stepper_iterator )
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_stepper_iterator , Stepper , dummy_steppers )
{
typedef const_step_time_iterator< dummy_stepper , empty_system > iterator_type;
typedef const_step_time_iterator< Stepper , empty_system > iterator_type;
state_type x = {{ 1.0 }};
iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter1 = iterator_type( Stepper() , empty_system() , x , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iter1;
BOOST_CHECK_EQUAL( &( iter1->first ) , &( iter2->first ) );
BOOST_CHECK_EQUAL( &( iter1->first ) , &x );
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_AUTO_TEST_CASE_TEMPLATE( assignment_stepper_iterator , Stepper , dummy_steppers )
{
typedef const_step_time_iterator< dummy_stepper , empty_system > iterator_type;
typedef const_step_time_iterator< Stepper , empty_system > iterator_type;
state_type x1 = {{ 1.0 }} , x2 = {{ 2.0 }};
iterator_type iter1 = iterator_type( dummy_stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( dummy_stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
iterator_type iter1 = iterator_type( Stepper() , empty_system() , x1 , 0.0 , 0.999 , 0.1 );
iterator_type iter2 = iterator_type( Stepper() , empty_system() , x2 , 0.0 , 0.999 , 0.1 );
BOOST_CHECK_EQUAL( &( iter1->first ) , &x1 );
BOOST_CHECK_EQUAL( &( iter2->first ) , &x2 );
BOOST_CHECK( !iter1.same( iter2 ) );
@@ -78,9 +78,9 @@ BOOST_AUTO_TEST_CASE( assignment_stepper_iterator )
BOOST_CHECK( iter1.same( iter2 ) );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_factory , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -92,9 +92,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -104,9 +104,9 @@ BOOST_AUTO_TEST_CASE( stepper_range )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_iterator_with_reference_wrapper_factory , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};
@@ -118,9 +118,9 @@ BOOST_AUTO_TEST_CASE( stepper_iterator_with_reference_wrapper_factory )
BOOST_CHECK_CLOSE( x[0] , 3.5 , 1.0e-14 );
}
BOOST_AUTO_TEST_CASE( stepper_range_with_reference_wrapper )
BOOST_AUTO_TEST_CASE_TEMPLATE( stepper_range_with_reference_wrapper , Stepper , dummy_steppers )
{
dummy_stepper stepper;
Stepper stepper;
empty_system system;
state_type x = {{ 1.0 }};