This commit is contained in:
2026-03-23 20:54:41 +08:00
commit e13b3650e9
4596 changed files with 1015768 additions and 0 deletions

View File

@@ -0,0 +1,183 @@
/*
[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 2012-2013 Karsten Ahnert
Copyright 2012 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the adaptive_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class adaptive_iterator : public adaptive_iterator_impl<
adaptive_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef adaptive_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
adaptive_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
: adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
adaptive_iterator( Stepper stepper , System sys , State &s )
: adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
template< class Stepper , class System , class State >
adaptive_iterator< Stepper , System , State > make_adaptive_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return adaptive_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
}
template< class Stepper , class System , class State >
adaptive_iterator< Stepper , System , State > make_adaptive_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return adaptive_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< adaptive_iterator< Stepper , System , State > , adaptive_iterator< Stepper , System , State > >
make_adaptive_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
adaptive_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
adaptive_iterator< Stepper , System , State >( stepper , system , x )
);
}
/**
* \class adaptive_iterator
*
* \brief ODE Iterator with adaptive step size. The value type of this iterator is the state type of the stepper.
*
* Implements an iterator representing the solution of an ODE from t_start
* to t_end evaluated at steps with an adaptive step size dt.
* After each iteration the iterator dereferences to the state x at the next
* time t+dt where dt is controlled by the stepper.
* This iterator can be used with ControlledSteppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_adaptive routine.
*
* 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.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_adaptive_iterator_begin( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::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_start 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 , State &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 , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::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_start 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

View File

@@ -0,0 +1,175 @@
/*
[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 2012-2013 Karsten Ahnert
Copyright 2012-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_TIME_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the adaptive_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class adaptive_time_iterator : public adaptive_iterator_impl<
adaptive_time_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef adaptive_time_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
adaptive_time_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
: adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
adaptive_time_iterator( Stepper stepper , System sys , State &s )
: adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
template< class Stepper , class System , class State >
adaptive_time_iterator< Stepper , System , State > make_adaptive_time_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return adaptive_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
}
template< class Stepper , class System , class State >
adaptive_time_iterator< Stepper , System , State > make_adaptive_time_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return adaptive_time_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< adaptive_time_iterator< Stepper , System , State > , adaptive_time_iterator< Stepper , System , State > >
make_adaptive_time_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
adaptive_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
adaptive_time_iterator< Stepper , System , State >( stepper , system , x ) );
}
/**
* \class adaptive_time_iterator
*
* \brief ODE Iterator with adaptive step size. The value type of this iterator is a std::pair containing state and time.
*
* Implements an iterator representing the solution of an ODE from t_start
* to t_end evaluated at steps with an adaptive step size dt.
* After each iteration the iterator dereferences to a pair containing state
* and time at the next time point t+dt where dt is controlled by the stepper.
* This iterator can be used with ControlledSteppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_adaptive routine.
*
* adaptive_iterator is a model of single-pass iterator.
*
* The value type of this iterator is a std::pair of state and time 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.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_adaptive_time_iterator_begin( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::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_start 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_time_iterator_end( Stepper stepper , System system , State &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_time_range( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::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_start 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

View File

@@ -0,0 +1,180 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/const_step_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with constant step size.
[end_description]
Copyright 2012-2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/const_step_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the const_step_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class const_step_iterator : public const_step_iterator_impl<
const_step_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef const_step_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
const_step_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
: const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
const_step_iterator( Stepper stepper , System sys , State &s )
: const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State >
const_step_iterator< Stepper , System, State > make_const_step_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return const_step_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
}
template< class Stepper , class System , class State >
const_step_iterator< Stepper , System , State > make_const_step_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return const_step_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< const_step_iterator< Stepper , System , State > , const_step_iterator< Stepper , System , State > >
make_const_step_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
const_step_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
const_step_iterator< Stepper , System , State >( stepper , system , x )
);
}
/**
* \class const_step_iterator
*
* \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper.
*
* Implements an iterator representing the solution of an ODE from t_start
* to t_end evaluated at steps with constant step size dt.
* After each iteration the iterator dereferences to the state x at the next
* time t+dt.
* This iterator can be used with Steppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_const routine.
*
* 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.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_const_step_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::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_start 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 , State &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 , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::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_start 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
//#include <boost/numeric/odeint/iterator/impl/const_step_iterator_dense_output_impl.hpp>
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,173 @@
/*
[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 2012-2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/const_step_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the const_step_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class const_step_time_iterator : public const_step_iterator_impl<
const_step_time_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef const_step_time_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
const_step_time_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
: const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
const_step_time_iterator( Stepper stepper , System sys , State &s )
: const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
template< class Stepper , class System , class State >
const_step_time_iterator< Stepper , System , State > make_const_step_time_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return const_step_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
}
template< class Stepper , class System , class State >
const_step_time_iterator< Stepper , System , State > make_const_step_time_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return const_step_time_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< const_step_time_iterator< Stepper , System , State > , const_step_time_iterator< Stepper , System , State > >
make_const_step_time_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
const_step_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
const_step_time_iterator< Stepper , System , State >( stepper , system , x ) );
}
/**
* \class const_step_time_iterator
*
* \brief ODE Iterator with constant step size. The value type of this iterator is a std::pair containing state and time.
*
* Implements an iterator representing the solution of an ODE from t_start
* to t_end evaluated at steps with constant step size dt.
* After each iteration the iterator dereferences to a pair containing
* state and time at the next time point t+dt..
* This iterator can be used with Steppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_const routine.
*
* const_step_time_iterator is a model of single-pass iterator.
*
* The value type of this iterator is a pair with the 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.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_const_step_time_iterator_begin( Stepper stepper , System system , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::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_start 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 , State &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 , State &x ,
typename traits::time_type< Stepper >::type t_start ,
typename traits::time_type< Stepper >::type t_end ,
typename traits::time_type< Stepper >::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

View File

@@ -0,0 +1,199 @@
/*
[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 2012-2013 Karsten Ahnert
Copyright 2012-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_ITERATOR_BASE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_ITERATOR_BASE_HPP_INCLUDED
#include <boost/iterator/iterator_facade.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
struct ode_state_iterator_tag {};
struct ode_state_time_iterator_tag {};
template< class Iterator , class Stepper , class System , class State , typename Tag >
class ode_iterator_base;
/* Specialization for the state iterator that has only state_type as its value_type */
template< class Iterator , class Stepper , class System , class State >
class ode_iterator_base< Iterator , Stepper , System , State , ode_state_iterator_tag >
: public boost::iterator_facade
<
Iterator ,
typename traits::state_type< Stepper >::type const ,
boost::single_pass_traversal_tag
>
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename unwrapped_stepper_type::time_type time_type;
typedef typename unwrapped_stepper_type::value_type ode_value_type;
public:
ode_iterator_base( stepper_type stepper , system_type sys , time_type t , time_type dt )
: m_stepper( stepper ) , m_system( sys ) ,
m_t( t ) , m_dt( dt ) , m_at_end( false )
{ }
ode_iterator_base( stepper_type stepper , system_type sys )
: m_stepper( stepper ) , m_system( sys ) ,
m_t() , m_dt() , m_at_end( true )
{ }
// this function is only for testing
bool same( const ode_iterator_base &iter ) const
{
return (
//( static_cast<Iterator>(*this).get_state() ==
// static_cast<Iterator>(iter).get_state ) &&
( m_t == iter.m_t ) &&
( m_dt == iter.m_dt ) &&
( m_at_end == iter.m_at_end )
);
}
protected:
friend class boost::iterator_core_access;
bool equal( ode_iterator_base const& other ) const
{
if( m_at_end == other.m_at_end )
{
return true;
}
else
{
return false;
}
}
const state_type& dereference() const
{
return static_cast<const Iterator*>(this)->get_state();
}
protected:
stepper_type m_stepper;
system_type m_system;
time_type m_t;
time_type m_dt;
bool m_at_end;
};
/* Specialization for the state-time iterator that has pair<state_type,time_type> as its value_type */
template< class Iterator , class Stepper , class System , class State >
class ode_iterator_base< Iterator , Stepper , System , State , ode_state_time_iterator_tag >
: public boost::iterator_facade
<
Iterator ,
std::pair< const State , const typename traits::time_type< Stepper >::type > ,
boost::single_pass_traversal_tag ,
std::pair< const State& , const typename traits::time_type< Stepper >::type& >
>
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef typename unwrapped_stepper_type::time_type time_type;
typedef typename unwrapped_stepper_type::value_type ode_value_type;
public:
ode_iterator_base( stepper_type stepper , system_type sys ,
time_type t , time_type dt )
: m_stepper( stepper ) , m_system( sys ) ,
m_t( t ) , m_dt( dt ) , m_at_end( false )
{ }
ode_iterator_base( stepper_type stepper , system_type sys )
: m_stepper( stepper ) , m_system( sys ) , m_at_end( true )
{ }
bool same( ode_iterator_base const& iter )
{
return (
//( static_cast<Iterator>(*this).get_state() ==
// static_cast<Iterator>(iter).get_state ) &&
( m_t == iter.m_t ) &&
( m_dt == iter.m_dt ) &&
( m_at_end == iter.m_at_end )
);
}
protected:
friend class boost::iterator_core_access;
bool equal( ode_iterator_base const& other ) const
{
if( m_at_end == other.m_at_end )
{
return true;
}
else
{
return false;
}
}
std::pair< const state_type& , const time_type& > dereference() const
{
return std::pair< const state_type & , const time_type & >(
static_cast<const Iterator*>(this)->get_state() , m_t );
}
stepper_type m_stepper;
system_type m_system;
time_type m_t;
time_type m_dt;
bool m_at_end;
};
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ODE_ITERATOR_BASE_HPP_INCLUDED

View File

@@ -0,0 +1,251 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/detail/adaptive_iterator_impl.hpp
[begin_description]
tba.
[end_description]
Copyright 2009-2012 Karsten Ahnert
Copyright 2009-2012 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ADAPTIVE_ITERATOR_IMPL_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ADAPTIVE_ITERATOR_IMPL_HPP_DEFINED
#include <boost/throw_exception.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template< class Iterator , class Stepper , class System , class State , typename Tag , typename StepperTag >
class adaptive_iterator_impl;
/*
* 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 Iterator , class Stepper , class System , class State , typename Tag >
class adaptive_iterator_impl< Iterator , Stepper , System , State , Tag , controlled_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State 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< Iterator , Stepper , System , State , 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_impl( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , t , dt ) , m_t_end( t_end ) , m_state( &s )
{
if( detail::less_with_sign( this->m_t_end , this->m_t , this->m_dt ) )
this->m_at_end = true;
}
/**
* \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_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
if( detail::less_with_sign( this->m_t , this->m_t_end , this->m_dt) )
{
if( detail::less_with_sign( this->m_t_end ,
static_cast<time_type>(this->m_t + this->m_dt) ,
this->m_dt ) )
{
this->m_dt = this->m_t_end - this->m_t;
}
unwrapped_stepper_type &stepper = this->m_stepper;
const size_t max_attempts = 1000;
size_t trials = 0;
controlled_step_result res = success;
do
{
res = 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 )
{
BOOST_THROW_EXCEPTION( std::overflow_error( "Adaptive iterator : Maximal number of iterations reached. A step size could not be found." ));
}
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *this->m_state;
}
private:
time_type m_t_end;
state_type* m_state;
};
/*
* 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 Iterator , class Stepper , class System , class State , typename Tag >
class adaptive_iterator_impl< Iterator , Stepper , System , State , Tag , dense_output_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State 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< Iterator , Stepper , System , State , 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_impl( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , t , dt ) , m_t_end( t_end )
{
if( detail::less_eq_with_sign( this->m_t , this->m_t_end , this->m_dt ) )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( s , this->m_t , this->m_dt );
} else {
this->m_at_end = true;
}
}
/**
* \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_impl( stepper_type stepper , system_type sys , state_type& /* s */ )
: base_type( stepper , sys ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
unwrapped_stepper_type &stepper = this->m_stepper;
if( detail::less_with_sign( this->m_t ,
this->m_t_end ,
stepper.current_time_step() ) )
{
if( detail::less_with_sign( this->m_t_end ,
static_cast<time_type>(this->m_t + stepper.current_time_step()) ,
stepper.current_time_step() ) )
{
// make stpper to end exactly at t_end
stepper.initialize( stepper.current_state() , stepper.current_time() ,
static_cast<time_type>(this->m_t_end-this->m_t) );
}
stepper.do_step( this->m_system );
this->m_t = stepper.current_time();
} else { // we have reached t_end
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
const unwrapped_stepper_type &stepper = this->m_stepper;
return stepper.current_state();
}
private:
time_type m_t_end;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_ADAPTIVE_ITERATOR_IMPL_HPP_DEFINED

View File

@@ -0,0 +1,228 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/detail/const_step_iterator_impl.hpp
[begin_description]
tba.
[end_description]
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_CONST_STEP_ITERATOR_IMPL_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_CONST_STEP_ITERATOR_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 {
template< class Iterator , class Stepper , class System , class State , typename Tag , class StepperTag >
class const_step_iterator_impl;
/*
* Specilization for steppers and error steppers
*/
template< class Iterator , class Stepper , class System , class State , typename Tag >
class const_step_iterator_impl< Iterator , Stepper , System , State , Tag , stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State 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< Iterator , Stepper , System , State , 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_impl( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , t , dt ) , m_t_start( t ) , m_t_end( t_end ) , m_state( &s ) , m_step( 0 )
{
if( detail::less_with_sign( this->m_t_end , this->m_t , this->m_dt ) )
this->m_at_end = true;
}
/**
* \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_impl( stepper_type stepper , system_type sys , state_type& /* s */ )
: base_type( stepper , sys ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
if( detail::less_eq_with_sign( static_cast<time_type>(this->m_t+this->m_dt) ,
this->m_t_end , this->m_dt ) )
{
unwrapped_stepper_type &stepper = this->m_stepper;
stepper.do_step( this->m_system , *this->m_state , this->m_t , this->m_dt );
// use integer to compute current time to reduce roundoff errors
this->m_step++;
this->m_t = this->m_t_start + static_cast< typename unit_value_type<time_type>::type >(this->m_step)*this->m_dt;
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_type m_t_start;
time_type m_t_end;
state_type* m_state;
size_t m_step;
};
/*
* 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 Iterator , class Stepper , class System , class State , typename Tag >
class const_step_iterator_impl< Iterator , Stepper , System , State , Tag , dense_output_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State 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< Iterator , Stepper , System , State , 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_impl( stepper_type stepper , system_type sys , state_type &s , time_type t , time_type t_end , time_type dt )
: base_type( stepper , sys , t , dt ) , m_t_start( t ) , m_t_end( t_end ) , m_state( &s ) , m_step( 0 )
{
if( detail::less_eq_with_sign( this->m_t , this->m_t_end , this->m_dt ) )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( * ( this->m_state ) , this->m_t , this->m_dt );
} else {
this->m_at_end = true;
}
}
/**
* \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_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s )
{
}
protected:
friend class boost::iterator_core_access;
void increment( void )
{
if( detail::less_eq_with_sign( static_cast<time_type>(this->m_t+this->m_dt) ,
this->m_t_end , this->m_dt ) )
{
unwrapped_stepper_type &stepper = this->m_stepper;
// use integer to compute current time to reduce roundoff errors
this->m_step++;
this->m_t = this->m_t_start + static_cast< typename unit_value_type<time_type>::type >(this->m_step)*this->m_dt;
while( detail::less_with_sign( stepper.current_time() , this->m_t ,
stepper.current_time_step() ) )
{
stepper.do_step( this->m_system );
}
stepper.calc_state( this->m_t , *( this->m_state ) );
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_type m_t_start;
time_type m_t_end;
state_type* m_state;
size_t m_step;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_CONST_STEP_ITERATOR_IMPL_HPP_DEFINED

View File

@@ -0,0 +1,239 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/detail/n_step_iterator_impl.hpp
[begin_description]
tba.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_N_STEP_ITERATOR_IMPL_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_N_STEP_ITERATOR_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 {
template< class Iterator , class Stepper , class System , class State , typename Tag , class StepperTag >
class n_step_iterator_impl;
/*
* Specilization for steppers and error steppers
*/
/**
* \brief ODE Iterator performing exactly n steps 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 step size. Uses steppers fulfilling the Stepper concept.
* n_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 Iterator , class Stepper , class System , class State , typename Tag >
class n_step_iterator_impl< Iterator , Stepper , System , State , Tag , stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State 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< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a n_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 dt The initial time step.
* \param num_of_steps the number of steps to be executed.
*/
n_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_type t , time_type dt , size_t num_of_steps )
: base_type( stepper , sys , t , dt ) , m_t_start( t ) , m_state( &s ) ,
m_steps(num_of_steps) , m_step( 0 )
{ }
/**
* \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.
*/
n_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
if( this->m_step < this->m_steps )
{
unwrapped_stepper_type &stepper = this->m_stepper;
stepper.do_step( this->m_system , *this->m_state , this->m_t , this->m_dt );
// use integer to compute current time to reduce roundoff errors
this->m_step++;
this->m_t = this->m_t_start + static_cast< typename unit_value_type<time_type>::type >(this->m_step)*this->m_dt;
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_type m_t_start;
time_type m_t_end;
state_type* m_state;
size_t m_steps;
size_t m_step;
};
/*
* Specilization for dense output stepper
*/
/**
* \brief ODE Iterator with step-size control and dense output.
*
* Implements an ODE iterator solving the ODE with constant steps. Uses dense-output steppers.
* n_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 Iterator , class Stepper , class System , class State , typename Tag >
class n_step_iterator_impl< Iterator , Stepper , System , State , Tag , dense_output_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State 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< Iterator , Stepper , System , State , 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 dt The initial time step.
* \param num_of_steps the number of steps to be executed.
*/
n_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_type t , time_type dt , size_t num_of_steps )
: base_type( stepper , sys , t , dt ) , m_t_start( t ) , m_state( &s ) ,
m_steps( num_of_steps ) , m_step( 0 )
{
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.
*/
n_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s )
{
}
protected:
friend class boost::iterator_core_access;
void increment( void )
{
if( this->m_step < this->m_steps )
{
unwrapped_stepper_type &stepper = this->m_stepper;
// use integer to compute current time to reduce roundoff errors
this->m_step++;
this->m_t = this->m_t_start + static_cast< typename unit_value_type<time_type>::type >(this->m_step)*this->m_dt;
while( detail::less_with_sign( stepper.current_time() , this->m_t ,
stepper.current_time_step() ) )
{
stepper.do_step( this->m_system );
}
stepper.calc_state( this->m_t , *( this->m_state ) );
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_type m_t_start;
time_type m_t_end;
state_type* m_state;
size_t m_steps;
size_t m_step;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_N_STEP_ITERATOR_IMPL_HPP_DEFINED

View File

@@ -0,0 +1,369 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/detail/times_iterator_impl.hpp
[begin_description]
tba.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_TIMES_ITERATOR_IMPL_HPP_DEFINED
#define BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_TIMES_ITERATOR_IMPL_HPP_DEFINED
#include <boost/throw_exception.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
namespace boost {
namespace numeric {
namespace odeint {
template< class Iterator , class Stepper , class System , class State , class TimeIterator ,
typename Tag , typename StepperTag >
class times_iterator_impl;
/*
* Specilization for basic steppers
*/
/**
* \brief ODE Iterator with constant step size.
*
* Implements an ODE iterator with observer calls at predefined times.
* Uses controlled steppers. times_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 Iterator , class Stepper , class System , class State , class TimeIterator , typename Tag >
class times_iterator_impl< Iterator , Stepper , System , State , TimeIterator , Tag , stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef TimeIterator time_iterator_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< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a times_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_start Iterator to the begin of a sequence of time values.
* \param t_end Iterator to the begin of a sequence of time values.
* \param dt The (initial) time step.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_iterator_type t_start , time_iterator_type t_end , time_type dt )
: base_type( stepper , sys , *t_start , dt ) ,
m_t_start( t_start ) , m_t_end( t_end ) , m_state( &s )
{
if( t_start == t_end )
this->m_at_end = true;
}
/**
* \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.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
unwrapped_stepper_type &stepper = this->m_stepper;
if( ++m_t_start != m_t_end )
{
while( detail::less_with_sign( this->m_t , static_cast<time_type>(*m_t_start) , this->m_dt ) )
{
const time_type current_dt = detail::min_abs( this->m_dt , static_cast<time_type>(*m_t_start) - this->m_t );
stepper.do_step( this->m_system , *( this->m_state ) , this->m_t , current_dt );
this->m_t += current_dt;
}
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_iterator_type m_t_start;
time_iterator_type m_t_end;
state_type* m_state;
};
/*
* 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 observer calls at predefined times.
* Uses controlled steppers. times_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 Iterator , class Stepper , class System , class State , class TimeIterator , typename Tag >
class times_iterator_impl< Iterator , Stepper , System , State , TimeIterator , Tag , controlled_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef TimeIterator time_iterator_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< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a times_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_start Iterator to the begin of a sequence of time values.
* \param t_end Iterator to the begin of a sequence of time values.
* \param dt The (initial) time step.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_iterator_type t_start , time_iterator_type t_end , time_type dt )
: base_type( stepper , sys , *t_start , dt ) ,
m_t_start( t_start ) , m_t_end( t_end ) , m_state( &s )
{
if( t_start == t_end )
this->m_at_end = true;
}
/**
* \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.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
if( ++m_t_start != m_t_end )
{
while( detail::less_with_sign( this->m_t , static_cast<time_type>(*m_t_start) , this->m_dt ) )
{
if( detail::less_with_sign( static_cast<time_type>(*m_t_start) - this->m_t , this->m_dt , this->m_dt ) )
{
// we want to end exactly at the time point
time_type current_dt = static_cast<time_type>(*m_t_start) - this->m_t;
step_loop( current_dt );
} else {
step_loop( this->m_dt );
}
}
} else {
this->m_at_end = true;
}
}
private:
void step_loop( time_type &dt )
{
unwrapped_stepper_type &stepper = this->m_stepper;
const size_t max_attempts = 1000;
size_t trials = 0;
controlled_step_result res = success;
do
{
res = stepper.try_step( this->m_system , *( this->m_state ) , this->m_t , dt );
++trials;
}
while( ( res == fail ) && ( trials < max_attempts ) );
if( trials == max_attempts )
{
BOOST_THROW_EXCEPTION( std::overflow_error( "Adaptive iterator : Maximal number of iterations reached. A step size could not be found." ) );
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_iterator_type m_t_start;
time_iterator_type m_t_end;
state_type* m_state;
};
/*
* Specilization for dense outputer steppers
*/
/**
* \brief ODE Iterator with step size control and dense output.
* Implements an ODE iterator with adaptive step size control. Uses dense-output steppers.
* times_iterator is a model of single-pass iterator.
*
* \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 Iterator , class Stepper , class System , class State , class TimeIterator , typename Tag >
class times_iterator_impl< Iterator , Stepper , System , State , TimeIterator , Tag , dense_output_stepper_tag >
: public detail::ode_iterator_base< Iterator , Stepper , System , State , Tag >
{
private:
typedef Stepper stepper_type;
typedef System system_type;
typedef typename boost::numeric::odeint::unwrap_reference< stepper_type >::type unwrapped_stepper_type;
typedef State state_type;
typedef TimeIterator time_iterator_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< Iterator , Stepper , System , State , Tag > base_type;
#endif
public:
/**
* \brief Constructs a times_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_start Iterator to the begin of a sequence of time values.
* \param t_end Iterator to the begin of a sequence of time values.
* \param dt The (initial) time step.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s ,
time_iterator_type t_start , time_iterator_type t_end , time_type dt )
: base_type( stepper , sys , *t_start , dt ) ,
m_t_start( t_start ) , m_t_end( t_end ) , m_final_time( *(t_end-1) ) ,
m_state( &s )
{
if( t_start != t_end )
{
unwrapped_stepper_type &st = this->m_stepper;
st.initialize( *( this->m_state ) , this->m_t , this->m_dt );
} else {
this->m_at_end = true;
}
}
/**
* \brief Constructs a times_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.
*/
times_iterator_impl( stepper_type stepper , system_type sys , state_type &s )
: base_type( stepper , sys ) , m_state( &s ) { }
protected:
friend class boost::iterator_core_access;
void increment()
{
unwrapped_stepper_type &st = this->m_stepper;
if( ++m_t_start != m_t_end )
{
this->m_t = static_cast<time_type>(*m_t_start);
while( detail::less_with_sign( st.current_time() , this->m_t , this->m_dt ) )
{
// make sure we don't go beyond the last point
if( detail::less_with_sign( m_final_time-st.current_time() , st.current_time_step() , st.current_time_step() ) )
{
st.initialize( st.current_state() , st.current_time() , m_final_time-st.current_time() );
}
st.do_step( this->m_system );
}
st.calc_state( this->m_t , *( this->m_state ) );
} else {
this->m_at_end = true;
}
}
public:
const state_type& get_state() const
{
return *m_state;
}
private:
time_iterator_type m_t_start;
time_iterator_type m_t_end;
time_type m_final_time;
state_type* m_state;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_DETAIL_TIMES_ITERATOR_IMPL_HPP_DEFINED

View File

@@ -0,0 +1,70 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/functors.hpp
[begin_description]
some functors for the iterator based integrate routines
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED
#include <utility>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template< class Observer >
struct obs_caller {
size_t &m_n;
Observer m_obs;
obs_caller( size_t &m , Observer &obs ) : m_n(m) , m_obs( obs ) {}
template< class State , class Time >
void operator()( std::pair< const State & , const Time & > x )
{
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
observer_type &obs = m_obs;
obs( x.first , x.second );
m_n++;
}
};
template< class Observer , class Time >
struct obs_caller_time {
Time &m_t;
Observer m_obs;
obs_caller_time( Time &t , Observer &obs ) : m_t(t) , m_obs( obs ) {}
template< class State >
void operator()( std::pair< const State & , const Time & > x )
{
typedef typename odeint::unwrap_reference< Observer >::type observer_type;
observer_type &obs = m_obs;
obs( x.first , x.second );
m_t = x.second;
}
};
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED

View File

@@ -0,0 +1,121 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp
[begin_description]
Default Integrate adaptive implementation.
[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_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#include <stdexcept>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_const.hpp>
#include <boost/numeric/odeint/iterator/adaptive_time_iterator.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
#include <boost/numeric/odeint/util/bind.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/util/copy.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer>
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , stepper_tag );
/*
* integrate_adaptive for simple stepper is basically an integrate_const + some last step
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , stepper_tag
)
{
size_t steps = detail::integrate_const( stepper , system , start_state , start_time ,
end_time , dt , observer , stepper_tag() );
typename odeint::unwrap_reference< Observer >::type &obs = observer;
typename odeint::unwrap_reference< Stepper >::type &st = stepper;
Time end = start_time + dt*steps;
if( less_with_sign( end , end_time , dt ) )
{ //make a last step to end exactly at end_time
st.do_step( system , start_state , end , end_time - end );
steps++;
obs( start_state , end_time );
}
return steps;
}
/*
* classical integrate adaptive
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
Observer observer , controlled_stepper_tag
)
{
size_t obs_calls = 0;
boost::for_each( make_adaptive_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
obs_caller< Observer >( obs_calls , observer ) );
return obs_calls-1;
}
/*
* integrate adaptive for dense output steppers
*
* step size control is used if the stepper supports it
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , dense_output_stepper_tag )
{
size_t obs_calls = 0;
boost::for_each( make_adaptive_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
obs_caller< Observer >( obs_calls , observer ) );
return obs_calls-1;
}
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED

View File

@@ -0,0 +1,111 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_const.hpp
[begin_description]
integrate const implementation
[end_description]
Copyright 2009-2012 Karsten Ahnert
Copyright 2009-2012 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_INCLUDED
#include <boost/range/algorithm/for_each.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/iterator/const_step_time_iterator.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_adaptive.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
Observer observer , controlled_stepper_tag
);
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , stepper_tag
)
{
size_t obs_calls = 0;
boost::for_each( make_const_step_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
// should we use traits<Stepper>::state_type here instead of State? NO!
obs_caller< Observer >( obs_calls , observer ) );
// step integration steps gives step+1 observer calls
return obs_calls-1;
}
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , controlled_stepper_tag
)
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
Time time = start_time;
const Time time_step = dt;
int step = 0;
while( less_eq_with_sign( static_cast<Time>(time+time_step) , end_time , dt ) )
{
obs( start_state , time );
detail::integrate_adaptive( stepper , system , start_state , time , time+time_step , dt ,
null_observer() , controlled_stepper_tag() );
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
++step;
time = start_time + static_cast< typename unit_value_type<Time>::type >(step) * time_step;
}
obs( start_state , time );
return step;
}
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer , dense_output_stepper_tag
)
{
size_t obs_calls = 0;
boost::for_each( make_const_step_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
obs_caller< Observer >( obs_calls , observer ) );
return obs_calls-1;
}
} } } }
#endif

View File

@@ -0,0 +1,107 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp
[begin_description]
integrate steps implementation
[end_description]
Copyright 2009-2012 Karsten Ahnert
Copyright 2009-2012 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_adaptive.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
#include <boost/numeric/odeint/iterator/n_step_time_iterator.hpp>
#include <boost/numeric/odeint/util/unit_helper.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
Observer observer , controlled_stepper_tag
);
/* basic version */
template< class Stepper , class System , class State , class Time , class Observer>
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , stepper_tag )
{
// ToDo: is there a better way to extract the final time?
Time t = start_time; // Assignment is only here to avoid warnings.
boost::for_each( make_n_step_time_range( stepper , system , start_state ,
start_time , dt , num_of_steps ) ,
obs_caller_time< Observer , Time >( t , observer ) );
return t;
}
/* controlled version */
template< class Stepper , class System , class State , class Time , class Observer>
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , controlled_stepper_tag )
{
typename odeint::unwrap_reference< Observer >::type &obs = observer;
Time time = start_time;
Time time_step = dt;
for( size_t step = 0; step < num_of_steps ; ++step )
{
obs( start_state , time );
detail::integrate_adaptive( stepper , system , start_state , time , static_cast<Time>(time+time_step) , dt ,
null_observer() , controlled_stepper_tag() );
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
time = start_time + static_cast< typename unit_value_type<Time>::type >(step+1) * time_step;
}
obs( start_state , time );
return time;
}
/* dense output version */
template< class Stepper , class System , class State , class Time , class Observer>
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer , dense_output_stepper_tag )
{
// ToDo: is there a better way to extract the final time?
Time t = start_time; // Assignment is only here to avoid warnings.
boost::for_each( make_n_step_time_range( stepper , system , start_state ,
start_time , dt , num_of_steps ) ,
obs_caller_time< Observer , Time >( t , observer ) );
return t;
}
}
}
}
}
#endif /* BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED */

View File

@@ -0,0 +1,67 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/detail/integrate_times.hpp
[begin_description]
Default integrate times implementation.
[end_description]
Copyright 2009-2012 Karsten Ahnert
Copyright 2009-2012 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_TIMES_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_TIMES_HPP_INCLUDED
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/range/algorithm/for_each.hpp>
#include <boost/numeric/odeint/util/unwrap_reference.hpp>
#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
#include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
#include <boost/numeric/odeint/iterator/times_time_iterator.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
/*
* integrate_times for all steppers
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer , class StepperTag >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
TimeIterator start_time , TimeIterator end_time , Time dt ,
Observer observer , StepperTag
)
{
size_t obs_calls = 0;
boost::for_each( make_times_time_range( stepper , system , start_state ,
start_time , end_time , dt ) ,
// should we use traits<Stepper>::state_type here instead of State? NO!
obs_caller< Observer >( obs_calls , observer ) );
// step integration steps gives step+1 observer calls
return obs_calls-1;
}
} // namespace detail
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED

View File

@@ -0,0 +1,111 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate.hpp
[begin_description]
Convenience methods which choose the stepper for the current ODE.
[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_INTEGRATE_INTEGRATE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_HPP_INCLUDED
#include <boost/utility/enable_if.hpp>
#include <boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp>
#include <boost/numeric/odeint/stepper/controlled_runge_kutta.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/integrate_adaptive.hpp>
// for has_value_type trait
#include <boost/numeric/odeint/algebra/detail/extract_value_type.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* ToDo :
*
* determine type of dxdt for units
*
*/
template< class System , class State , class Time , class Observer >
typename boost::enable_if< typename has_value_type<State>::type , size_t >::type
integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
{
typedef controlled_runge_kutta< runge_kutta_dopri5< State , typename State::value_type , State , Time > > stepper_type;
return integrate_adaptive( stepper_type() , system , start_state , start_time , end_time , dt , observer );
}
/*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class System , class State , class Time >
size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
{
return integrate( system , start_state , start_time , end_time , dt , null_observer() );
}
/**
* \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
* \brief Integrates the ODE.
*
* Integrates the ODE given by system from start_time to end_time starting
* with start_state as initial condition and dt as initial time step.
* This function uses a dense output dopri5 stepper and performs an adaptive
* integration with step size control, thus dt changes during the integration.
* This method uses standard error bounds of 1E-6.
* After each step, the observer is called.
*
* \param system The system function to solve, hence the r.h.s. of the
* ordinary differential equation.
* \param start_state The initial state.
* \param start_time Start time of the integration.
* \param end_time End time of the integration.
* \param dt Initial step size, will be adjusted during the integration.
* \param observer Observer that will be called after each time step.
* \return The number of steps performed.
*/
/**
* \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
* \brief Integrates the ODE without observer calls.
*
* Integrates the ODE given by system from start_time to end_time starting
* with start_state as initial condition and dt as initial time step.
* This function uses a dense output dopri5 stepper and performs an adaptive
* integration with step size control, thus dt changes during the integration.
* This method uses standard error bounds of 1E-6.
* No observer is called.
*
* \param system The system function to solve, hence the r.h.s. of the
* ordinary differential equation.
* \param start_state The initial state.
* \param start_time Start time of the integration.
* \param end_time End time of the integration.
* \param dt Initial step size, will be adjusted during the integration.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_HPP_INCLUDED

View File

@@ -0,0 +1,127 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_adaptive.hpp
[begin_description]
Adaptive integration of ODEs.
[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_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_adaptive.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
/*
* Suggestion for a new extendable version:
*
* integrator_adaptive< Stepper , System, State , Time , Observer , typename Stepper::stepper_category > integrator;
* return integrator.run( stepper , system , start_state , start_time , end_time , dt , observer );
*/
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_adaptive(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
/**
* \brief integrate_adaptive without an observer.
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_adaptive(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt )
{
return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_adaptive(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt )
{
return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/************* DOXYGEN ************/
/**
* \fn integrate_adaptive( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
* \brief Integrates the ODE with adaptive step size.
*
* This function integrates the ODE given by system with the given stepper.
* The observer is called after each step. If the stepper has no error
* control, the step size remains constant and the observer is called at
* equidistant time points t0+n*dt. If the stepper is a ControlledStepper,
* the step size is adjusted and the observer is called in non-equidistant
* intervals.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param start_time The initial time t0.
* \param end_time The final integration time tend.
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param observer Function/Functor called at equidistant time intervals.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED

View File

@@ -0,0 +1,158 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_const.hpp
[begin_description]
Constant integration of ODEs, meaning that the state of the ODE is observed on constant time intervals.
The routines makes full use of adaptive and dense-output methods.
[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_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED
#include <type_traits>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_const.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_adaptive.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* Integrates with constant time step dt.
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer
)
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
// we want to get as fast as possible to the end
BOOST_IF_CONSTEXPR ( std::is_same< null_observer , Observer >::value )
{
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
else
{
return detail::integrate_const( stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time , class Observer >
size_t integrate_const(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt ,
Observer observer
)
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
// we want to get as fast as possible to the end
BOOST_IF_CONSTEXPR ( std::is_same< null_observer , Observer >::value )
{
return detail::integrate_adaptive(
stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
else
{
return detail::integrate_const( stepper , system , start_state ,
start_time , end_time , dt ,
observer , stepper_category() );
}
}
/**
* \brief integrate_const without observer calls
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_const(
Stepper stepper , System system , State &start_state ,
Time start_time , Time end_time , Time dt
)
{
return integrate_const( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/**
* \brief Second version to solve the forwarding problem,
* can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time >
size_t integrate_const(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time end_time , Time dt
)
{
return integrate_const( stepper , system , start_state , start_time , end_time , dt , null_observer() );
}
/********* DOXYGEN *********/
/**
* \fn integrate_const( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
* \brief Integrates the ODE with constant step size.
*
* Integrates the ODE defined by system using the given stepper.
* This method ensures that the observer is called at constant intervals dt.
* If the Stepper is a normal stepper without step size control, dt is also
* used for the numerical scheme. If a ControlledStepper is provided, the
* algorithm might reduce the step size to meet the error bounds, but it is
* ensured that the observer is always called at equidistant time points
* t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
* and the dense output is used to call the observer at equidistant time
* points.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param start_time The initial time t0.
* \param end_time The final integration time tend.
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param observer Function/Functor called at equidistant time intervals.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_CONST_HPP_INCLUDED

View File

@@ -0,0 +1,123 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_n_steps.hpp
[begin_description]
Integration of n steps with constant time size. Adaptive and dense-output methods are fully supported.
[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_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_n_steps.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* Integrates n steps
*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class Stepper , class System , class State , class Time , class Observer>
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_n_steps(
stepper , system , start_state ,
start_time , dt , num_of_steps ,
observer , stepper_category() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time , class Observer >
Time integrate_n_steps(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_n_steps(
stepper , system , start_state ,
start_time , dt , num_of_steps ,
observer , stepper_category() );
}
/**
* \brief The same function as above, but without observer calls.
*/
template< class Stepper , class System , class State , class Time >
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps )
{
return integrate_n_steps( stepper , system , start_state , start_time , dt , num_of_steps , null_observer() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class Time >
Time integrate_n_steps(
Stepper stepper , System system , const State &start_state ,
Time start_time , Time dt , size_t num_of_steps )
{
return integrate_n_steps( stepper , system , start_state , start_time , dt , num_of_steps , null_observer() );
}
/************* DOXYGEN *************/
/**
* \fn Time integrate_n_steps( Stepper stepper , System system , State &start_state , Time start_time , Time dt , size_t num_of_steps , Observer observer )
* \brief Integrates the ODE with constant step size.
*
* This function is similar to integrate_const. The observer is called at
* equidistant time intervals t0 + n*dt.
* If the Stepper is a normal stepper without step size control, dt is also
* used for the numerical scheme. If a ControlledStepper is provided, the
* algorithm might reduce the step size to meet the error bounds, but it is
* ensured that the observer is always called at equidistant time points
* t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
* and the dense output is used to call the observer at equidistant time
* points. The final integration time is always t0 + num_of_steps*dt.
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param start_time The initial time t0.
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param num_of_steps Number of steps to be performed
* \param observer Function/Functor called at equidistant time intervals.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED

View File

@@ -0,0 +1,131 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/integrate_times.hpp
[begin_description]
Integration of ODEs with observation at user defined points
[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_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED
#include <boost/range.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
#include <boost/numeric/odeint/iterator/integrate/detail/integrate_times.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/*
* the two overloads are needed in order to solve the forwarding problem
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
TimeIterator times_start , TimeIterator times_end , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_times(
stepper , system , start_state ,
times_start , times_end , dt ,
observer , stepper_category() );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , const State &start_state ,
TimeIterator times_start , TimeIterator times_end , Time dt ,
Observer observer )
{
typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
return detail::integrate_times(
stepper , system , start_state ,
times_start , times_end , dt ,
observer , stepper_category() );
}
/**
* \brief The same function as above, but without observer calls.
*/
template< class Stepper , class System , class State , class TimeRange , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , State &start_state ,
const TimeRange &times , Time dt ,
Observer observer )
{
return integrate_times(
stepper , system , start_state ,
boost::begin( times ) , boost::end( times ) , dt , observer );
}
/**
* \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
*/
template< class Stepper , class System , class State , class TimeRange , class Time , class Observer >
size_t integrate_times(
Stepper stepper , System system , const State &start_state ,
const TimeRange &times , Time dt ,
Observer observer )
{
return integrate_times(
stepper , system , start_state ,
boost::begin( times ) , boost::end( times ) , dt , observer );
}
/********* DOXYGEN ***********/
/**
* \fn size_t integrate_times( Stepper stepper , System system , State &start_state , TimeIterator times_start , TimeIterator times_end , Time dt , Observer observer )
* \brief Integrates the ODE with observer calls at given time points.
*
* Integrates the ODE given by system using the given stepper. This function
* does observer calls at the subsequent time points given by the range
* times_start, times_end. If the stepper has not step size control, the
* step size might be reduced occasionally to ensure observer calls exactly
* at the time points from the given sequence. If the stepper is a
* ControlledStepper, the step size is adjusted to meet the error bounds,
* but also might be reduced occasionally to ensure correct observer calls.
* If a DenseOutputStepper is provided, the dense output functionality is
* used to call the observer at the given times. The end time of the
* integration is always *(end_time-1).
*
* \param stepper The stepper to be used for numerical integration.
* \param system Function/Functor defining the rhs of the ODE.
* \param start_state The initial condition x0.
* \param times_start Iterator to the start time
* \param times_end Iterator to the end time
* \param dt The time step between observer calls, _not_ necessarily the
* time step of the integration.
* \param observer Function/Functor called at equidistant time intervals.
* \return The number of steps performed.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED

View File

@@ -0,0 +1,38 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/null_observer.hpp
[begin_description]
null_observer
[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_INTEGRATE_NULL_OBSERVER_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_NULL_OBSERVER_HPP_INCLUDED
namespace boost {
namespace numeric {
namespace odeint {
struct null_observer
{
template< class State , class Time >
void operator()( const State& /* x */ , Time /* t */ ) const
{
}
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_NULL_OBSERVER_HPP_INCLUDED

View File

@@ -0,0 +1,55 @@
/*
[auto_generated]
boost/numeric/odeint/integrate/observer_collection.hpp
[begin_description]
Collection of observers, which are all called during the evolution of the ODE.
[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_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
#include <vector>
#include <functional>
namespace boost {
namespace numeric {
namespace odeint {
template< class State , class Time >
class observer_collection
{
public:
typedef std::function< void( const State& , const Time& ) > observer_type;
typedef std::vector< observer_type > collection_type;
void operator()( const State& x , Time t )
{
for( size_t i=0 ; i<m_observers.size() ; ++i )
m_observers[i]( x , t );
}
collection_type& observers( void ) { return m_observers; }
const collection_type& observers( void ) const { return m_observers; }
private:
collection_type m_observers;
};
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED

View File

@@ -0,0 +1,168 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/n_step_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with constant step size performing exactly n steps.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/n_step_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the n_step_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class n_step_iterator : public n_step_iterator_impl<
n_step_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef n_step_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
n_step_iterator( Stepper stepper , System sys , State &s , time_type t , time_type dt , size_t num_of_steps )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t , dt , num_of_steps )
{}
n_step_iterator( Stepper stepper , System sys , State &s )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State >
n_step_iterator< Stepper , System, State > make_n_step_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return n_step_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps );
}
template< class Stepper , class System , class State >
n_step_iterator< Stepper , System , State > make_n_step_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return n_step_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< n_step_iterator< Stepper , System , State > , n_step_iterator< Stepper , System , State > >
make_n_step_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return std::make_pair(
n_step_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ) ,
n_step_iterator< Stepper , System , State >( stepper , system , x )
);
}
/**
* \class n_step_iterator
*
* \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper.
*
* Implements an iterator representing the solution of an ODE starting from t
* with n steps and a constant step size dt.
* After each iteration the iterator dereferences to the state x at the next
* time t+dt.
* This iterator can be used with Steppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_n_steps routine.
*
* n_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.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_n_step_iterator_begin( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
*
* \brief Factory function for n_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 dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step iterator.
*/
/**
* \fn make_n_step_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for n_step_iterator. Constructs an 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_n_step_range( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , , size_t num_of_steps )
*
* \brief Factory function to construct a single pass range of n-step iterators. A range is here a pair
* of n_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 dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,169 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/n_step_time_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with constant step size performing exactly n steps.
The dereferenced type contains also the time.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/n_step_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the n_step_iterator_impl with the right tags */
template< class Stepper , class System , class State
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class n_step_time_iterator : public n_step_iterator_impl<
n_step_time_iterator< Stepper , System , State , StepperTag > ,
Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef n_step_time_iterator< Stepper , System , State , StepperTag > iterator_type;
public:
n_step_time_iterator( Stepper stepper , System sys , State &s , time_type t , time_type dt , size_t num_of_steps )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t , dt , num_of_steps )
{}
n_step_time_iterator( Stepper stepper , System sys , State &s )
: n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State >
n_step_time_iterator< Stepper , System, State > make_n_step_time_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps );
}
template< class Stepper , class System , class State >
n_step_time_iterator< Stepper , System , State > make_n_step_time_iterator_end(
Stepper stepper ,
System system ,
State &x )
{
return n_step_time_iterator< Stepper , System , State >( stepper , system , x );
}
template< class Stepper , class System , class State >
std::pair< n_step_time_iterator< Stepper , System , State > , n_step_time_iterator< Stepper , System , State > >
make_n_step_time_range(
Stepper stepper ,
System system ,
State &x ,
typename traits::time_type< Stepper >::type t ,
typename traits::time_type< Stepper >::type dt ,
size_t num_of_steps )
{
return std::make_pair(
n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ) ,
n_step_time_iterator< Stepper , System , State >( stepper , system , x )
);
}
/**
* \class n_step_time_iterator
*
* \brief ODE Iterator with constant step size. The value type of this iterator is a std::pair containing state and time.
*
* Implements an iterator representing the solution of an ODE starting from t
* with n steps and a constant step size dt.
* After each iteration the iterator dereferences to a pair of state and time at the next
* time t+dt.
* This iterator can be used with Steppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_n_steps routine.
*
* n_step_time_iterator is a model of single-pass iterator.
*
* The value type of this iterator is pair of state and 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.
* \tparam State The state type of the ODE.
*/
/**
* \fn make_n_step_time_iterator_begin( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
*
* \brief Factory function for n_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_iterator stores a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step iterator.
*/
/**
* \fn make_n_step_time_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for n_step_time_iterator. Constructs an 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_n_step_time_range( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
*
* \brief Factory function to construct a single pass range of n-step iterators. A range is here a pair
* of n_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_iterator store a reference of s and changes its value during the iteration.
* \param t The initial time.
* \param dt The initial time step.
* \param num_of_steps The number of steps to be executed.
* \returns The n-step range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_TIME_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,189 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/times_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with oscillator calls at times from a given sequence.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/times_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the times_iterator_impl with the right tags */
template< class Stepper , class System , class State , class TimeIterator
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class times_iterator : public times_iterator_impl<
times_iterator< Stepper , System , State , TimeIterator , StepperTag > ,
Stepper , System , State , TimeIterator , detail::ode_state_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef times_iterator< Stepper , System , State , TimeIterator , StepperTag > iterator_type;
public:
times_iterator( Stepper stepper , System sys , State &s ,
TimeIterator t_start , TimeIterator t_end , time_type dt )
: times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator, detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
times_iterator( Stepper stepper , System sys , State &s )
: times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State , class TimeIterator >
times_iterator< Stepper , System, State , TimeIterator > make_times_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
{
return times_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt );
}
// ToDo: requires to specifically provide the TimeIterator template parameter, can this be improved?
template< class TimeIterator , class Stepper , class System , class State >
times_iterator< Stepper , System , State , TimeIterator > make_times_iterator_end(
Stepper stepper ,
System system ,
State &x )
//TimeIterator t_end )
{
return times_iterator< Stepper , System , State , TimeIterator >( stepper , system , x );
}
template< class Stepper , class System , class State , class TimeIterator >
std::pair< times_iterator< Stepper , System , State , TimeIterator > ,
times_iterator< Stepper , System , State , TimeIterator > >
make_times_range(
Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
times_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt ) ,
times_iterator< Stepper , System , State , TimeIterator >( stepper , system , x )
);
}
/**
* \class times_iterator
*
* \brief ODE Iterator with given evaluation points. The value type of this iterator is the state type of the stepper.
*
* Implements an iterator representing the solution of an ODE from *t_start
* to *t_end evaluated at time points given by the sequence t_start to t_end.
* t_start and t_end are iterators representing a sequence of time points
* where the solution of the ODE should be evaluated.
* After each iteration the iterator dereferences to the state x at the next
* time *t_start++ until t_end is reached.
* This iterator can be used with Steppers, ControlledSteppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_times routine.
*
* times_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.
* \tparam State The state type of the ODE.
* \tparam TimeIterator The iterator type for the sequence of time points.
*/
/**
* \fn make_times_iterator_begin( Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function for times_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_start Begin iterator of the sequence of evaluation time points.
* \param t_end End iterator of the sequence of evaluation time points.
* \param dt The initial time step.
* \returns The times iterator.
*/
/**
* \fn make_times_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for times_iterator. Constructs an end iterator.
*
* \tparam TimesIterator The iterator type of the time sequence, must be specifically provided.
*
* \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 times iterator.
*
* This function needs the TimeIterator type specifically defined as a
* template parameter.
*/
/**
* \fn make_times_range( Stepper stepper , System system , State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function to construct a single pass range of times iterators. A range is here a pair
* of times_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_start Begin iterator of the sequence of evaluation time points.
* \param t_end End iterator of the sequence of evaluation time points.
* \param dt The initial time step.
* \returns The times iterator range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_ITERATOR_HPP_INCLUDED

View File

@@ -0,0 +1,193 @@
/*
[auto_generated]
boost/numeric/odeint/iterator/times_time_iterator.hpp
[begin_description]
Iterator for iterating through the solution of an ODE with oscillator calls at times from a given sequence.
The dereferenced type contains also the time.
[end_description]
Copyright 2009-2013 Karsten Ahnert
Copyright 2009-2013 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED
#include <boost/numeric/odeint/util/stepper_traits.hpp>
#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
#include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
#include <boost/numeric/odeint/iterator/impl/times_iterator_impl.hpp>
namespace boost {
namespace numeric {
namespace odeint {
/* use the times_iterator_impl with the right tags */
template< class Stepper , class System , class State , class TimeIterator
#ifndef DOXYGEN_SKIP
, class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
#endif
>
class times_time_iterator : public times_iterator_impl<
times_time_iterator< Stepper , System , State , TimeIterator , StepperTag > ,
Stepper , System , State , TimeIterator , detail::ode_state_time_iterator_tag , StepperTag
>
{
typedef typename traits::time_type< Stepper >::type time_type;
typedef times_time_iterator< Stepper , System , State , TimeIterator , StepperTag > iterator_type;
public:
times_time_iterator( Stepper stepper , System sys , State &s ,
TimeIterator t_start , TimeIterator t_end , time_type dt )
: times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator, detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
{}
times_time_iterator( Stepper stepper , System sys , State &s )
: times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
{}
};
/* make functions */
template< class Stepper , class System , class State , class TimeIterator >
times_time_iterator< Stepper , System, State , TimeIterator > make_times_time_iterator_begin(
Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
{
return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt );
}
// ToDo: requires to specifically provide the TimeIterator template parameter, can this be improved?
template< class TimeIterator , class Stepper , class System , class State >
times_time_iterator< Stepper , System , State , TimeIterator > make_times_time_iterator_end(
Stepper stepper ,
System system ,
State &x )
//TimeIterator t_end )
{
return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x );
}
template< class Stepper , class System , class State , class TimeIterator >
std::pair< times_time_iterator< Stepper , System , State , TimeIterator > ,
times_time_iterator< Stepper , System , State , TimeIterator > >
make_times_time_range(
Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
{
return std::make_pair(
times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt ) ,
times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x )
);
}
/**
* \class times_time_iterator
*
* \brief ODE Iterator with given evaluation points. The value type of this iterator is a std::pair containing state and time.
*
* Implements an iterator representing the solution of an ODE from *t_start
* to *t_end evaluated at time points given by the sequence t_start to t_end.
* t_start and t_end are iterators representing a sequence of time points
* where the solution of the ODE should be evaluated.
* After each iteration the iterator dereferences to a pair with the state
* and the time at the next evaluation point *t_start++ until t_end is reached.
* This iterator can be used with Steppers, ControlledSteppers and
* DenseOutputSteppers and it always makes use of the all the given steppers
* capabilities. A for_each over such an iterator range behaves similar to
* the integrate_times routine.
*
* times_time_iterator is a model of single-pass iterator.
*
* The value type of this iterator is a pair of state and time type.
*
* \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.
* \tparam State The state type of the ODE.
* \tparam TimeIterator The iterator type for the sequence of time points.
*/
/**
* \fn make_times_time_iterator_begin( Stepper stepper ,
System system ,
State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function for times_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_iterator stores a reference of s and changes its value during the iteration.
* \param t_start Begin iterator of the sequence of evaluation time points.
* \param t_end End iterator of the sequence of evaluation time points.
* \param dt The initial time step.
* \returns The times_time iterator.
*/
/**
* \fn make_times_time_iterator_end( Stepper stepper , System system , State &x )
* \brief Factory function for times_time_iterator. Constructs an end iterator.
*
* \tparam TimesIterator The iterator type of the time sequence, must be specifically provided.
*
* \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 times_time iterator.
*
* This function needs the TimeIterator type specifically defined as a
* template parameter.
*/
/**
* \fn make_times_time_range( Stepper stepper , System system , State &x ,
TimeIterator t_start ,
TimeIterator t_end ,
typename traits::time_type< Stepper >::type dt )
*
* \brief Factory function to construct a single pass range of times_time iterators. A range is here a pair
* of times_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_start Begin iterator of the sequence of evaluation time points.
* \param t_end End iterator of the sequence of evaluation time points.
* \param dt The initial time step.
* \returns The times_time iterator range.
*/
} // namespace odeint
} // namespace numeric
} // namespace boost
#endif // BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED