|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57725 - in sandbox/odeint: boost/numeric boost/numeric/odeint boost/numeric/odeint/detail libs/numeric/odeint/examples
From: karsten.ahnert_at_[hidden]
Date: 2009-11-17 09:02:11
Author: karsten
Date: 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
New Revision: 57725
URL: http://svn.boost.org/trac/boost/changeset/57725
Log:
small changes and bugfixing
Added:
sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp (contents, props changed)
- copied, changed from r57721, /sandbox/odeint/boost/numeric/odeint/integrator.hpp
sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp (contents, props changed)
- copied, changed from r57721, /sandbox/odeint/boost/numeric/odeint/integrator_constant_step.hpp
Removed:
sandbox/odeint/boost/numeric/odeint/integrator.hpp
sandbox/odeint/boost/numeric/odeint/integrator_constant_step.hpp
Text files modified:
sandbox/odeint/boost/numeric/odeint.hpp | 4 +-
sandbox/odeint/boost/numeric/odeint/detail/iterator_algebra.hpp | 6 ++-
sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp | 78 ++++++++++++++++++++++++++++-----------
sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp | 18 ++++----
sandbox/odeint/boost/numeric/odeint/observer.hpp | 27 +++++++++----
sandbox/odeint/boost/numeric/odeint/resizer.hpp | 1
sandbox/odeint/boost/numeric/odeint/stepper_euler.hpp | 2 -
sandbox/odeint/boost/numeric/odeint/stepper_half_step.hpp | 4 +-
sandbox/odeint/boost/numeric/odeint/stepper_rk4.hpp | 30 +++++++-------
sandbox/odeint/boost/numeric/odeint/stepper_rk_generic.hpp | 27 +++++++++++--
sandbox/odeint/boost/numeric/odeint/stepsize_controller_standard.hpp | 2
sandbox/odeint/libs/numeric/odeint/examples/lorenz_controlled.cpp | 2
sandbox/odeint/libs/numeric/odeint/examples/lorenz_integrate_constant_step.cpp | 8 ++--
13 files changed, 135 insertions(+), 74 deletions(-)
Modified: sandbox/odeint/boost/numeric/odeint.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -24,7 +24,7 @@
#include <boost/numeric/odeint/stepsize_controller_standard.hpp>
-#include <boost/numeric/odeint/integrator.hpp>
-#include <boost/numeric/odeint/integrator_constant_step.hpp>
+#include <boost/numeric/odeint/integrator_adaptive_stepsize.hpp>
+#include <boost/numeric/odeint/integrator_constant_stepsize.hpp>
#endif // BOOST_NUMERIC_ODEINT_HPP
Modified: sandbox/odeint/boost/numeric/odeint/detail/iterator_algebra.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/detail/iterator_algebra.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/detail/iterator_algebra.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -242,12 +242,14 @@
{
FactorIterator alpha_iter;
InputIteratorIterator x_iter_iter;
- while( y_begin != y_end ) {
+ while( y_begin != y_end )
+ {
x_iter_iter = x_iter_begin;
alpha_iter = alpha_begin;
*y_begin = *x_begin++;
//std::clog<<(*y_begin);
- while( alpha_iter != alpha_end ) {
+ while( alpha_iter != alpha_end )
+ {
//std::clog<< " + " <<beta<<" * "<<*alpha_iter<<"*"<<(*(*(x_iter_iter)));
(*y_begin) += beta * (*alpha_iter++) * (*(*x_iter_iter++)++);
}
Deleted: sandbox/odeint/boost/numeric/odeint/integrator.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/integrator.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
+++ (empty file)
@@ -1,172 +0,0 @@
-/* Boost odeint/integrator.hpp header file
-
- Copyright 2009 Karsten Ahnert
- Copyright 2009 Mario Mulansky
-
- This file includes integration methods with adaptive stepsize.
-
- 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_INTEGRATOR_HPP
-#define BOOST_NUMERIC_ODEINT_INTEGRATOR_HPP
-
-#include <boost/numeric/odeint/stepsize_controller_standard.hpp>
-#include <boost/numeric/odeint/resizer.hpp>
-#include <boost/numeric/odeint/observer.hpp>
-#include <vector>
-#include <limits>
-
-namespace boost {
-namespace numeric {
-namespace odeint {
-
-
- template<
- class Stepper,
- class DynamicalSystem,
- class StepController,
- class Observer
- >
- size_t integrate( Stepper &stepper,
- DynamicalSystem &system,
- StepController &controller,
- typename Stepper::time_type start_time,
- typename Stepper::time_type dt,
- typename Stepper::container_type &state,
- typename Stepper::time_type end_time,
- Observer &observer )
- {
- controlled_step_result result;
- size_t iterations = 0;
- typename Stepper::time_type t = start_time;
- typename Stepper::time_type dt_ = dt;
-
- observer(t, state, system);
-
- while( t < end_time )
- {
- // do a controlled step
- result = controller.controlled_step( stepper, system, state, t, dt_ );
- if( result != STEP_SIZE_DECREASED )
- { // we actually did a step forward (dt was small enough)
- observer(t, state, system);
- iterations++;
- }
- while( result != SUCCESS ) // as long as dt is too large/small
- {
- // do the controlled step
- result = controller.controlled_step( stepper, system, state, t, dt_ );
- if( result != STEP_SIZE_DECREASED )
- { // we did a step
- observer(t, state, system);
- iterations++;
- }
- if( !( t+dt_ > t) )
- throw; // we've reached machine precision with dt - no advancing in t
- }
- }
- return iterations;
- }
-
-
-
- /* Integration of an ode with adaptive stepsize methods.
- Integrates an ode give by system using the integration scheme stepper and the
- step-size controller controller.
- The initial state is given in x.
- t is an vector including the times at which the state will be written into
- the vector x_vec.
- x_vec must provide enough space to hold times.size() states.
- dt is the initial step size (will be adjusted according to the controller).
- This function returns the total number of steps required to integrate the
- whole intervale times.begin() - times.end().
- Note that the values in times don't influence the stepsize, but only the
- time points at which the state is stored into x_vec.
- */
- template<
- class Stepper,
- class DynamicalSystem,
- class StepController,
- class TimeContainer,
- class InsertIterator
- >
- size_t integrate(Stepper &stepper,
- DynamicalSystem &system,
- StepController &controller,
- typename Stepper::container_type &state,
- TimeContainer ×,
- InsertIterator state_inserter,
- typename Stepper::time_type &dt)
- {
- state_copy_observer<InsertIterator, TimeContainer> observer(times, state_inserter);
- return integrate(stepper, system, controller, *(times.begin()),
- dt, state, *(times.end()-1), observer);
- }
-
-
- /*
- Integration of an ode with adaptive stepsize methods.
- Integrates an ode give by system using the integration scheme stepper and the
- a standard step-size controller that ensures the error being below the values
- given below.
- The initial state is given in x.
- t is an vector including the times at which the state will be written into
- the vector x_vec.
- x_vec must provide enough space to hold times.size() states.
- dt is the initial step size (will be adjusted according to the errors).
- This function returns the total number of steps required to integrate the
- whole intervale times.begin() - times.end().
- Note that the values in times don't influence the stepsize, but only the
- time points at which the state is stored into x_vec.
-
- The stepsize is adjust such that the following maximal relative error is
- small enough for each step:
- R = max( x_err_n / [eps_abs + eps_rel*( a_x * |x_n| + a_dxdt * |dxdt_n| )] )
- where the max refers to the componentwise maximum the expression.
-
- if R > 1.1 the stepsize is decreased:
- dt = dt*S*R^(-1/q)
-
- if R < 0.5 the stepsize is increased:
- dt = dt*S*R^(-1/(q+1))
-
- q is the order of the stepper (e.g. 1 for simple euler) and S is a safety
- factor set to S = 0.9.
-
- To avoid extensive chages in dt, the decrease factor is limited to 0.2 and
- the increase factor to 5.0.
- */
- template< class Stepper,
- class DynamicalSystem,
- class InsertIterator
- >
- size_t integrate(Stepper &stepper,
- DynamicalSystem &system,
- typename Stepper::container_type &x,
- std::vector<typename Stepper::time_type> ×,
- InsertIterator state_inserter,
- typename Stepper::time_type dt = 1E-4,
- typename Stepper::time_type eps_abs = 1E-6,
- typename Stepper::time_type eps_rel = 1E-7,
- typename Stepper::time_type a_x = 1.0 ,
- typename Stepper::time_type a_dxdt = 1.0)
- {
- // we use the standard controller for this adaptive integrator
- step_controller_standard< typename Stepper::container_type,
- typename Stepper::time_type,
- typename Stepper::resizer_type > controller(eps_abs, eps_rel, a_x, a_dxdt );
- // initialized with values from above
-
- // call the normal integrator
- return integrate(stepper, system, controller, x, times, state_inserter, dt);
- }
-
-
-} // namespace odeint
-} // namespace numeric
-} // namespace boost
-
-#endif
Copied: sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp (from r57721, /sandbox/odeint/boost/numeric/odeint/integrator.hpp)
==============================================================================
--- /sandbox/odeint/boost/numeric/odeint/integrator.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -10,8 +10,8 @@
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
-#ifndef BOOST_NUMERIC_ODEINT_INTEGRATOR_HPP
-#define BOOST_NUMERIC_ODEINT_INTEGRATOR_HPP
+#ifndef BOOST_NUMERIC_ODEINT_INTEGRATOR_ADAPTIVE_STEPSIZE_HPP
+#define BOOST_NUMERIC_ODEINT_INTEGRATOR_ADAPTIVE_STEPSIZE_HPP
#include <boost/numeric/odeint/stepsize_controller_standard.hpp>
#include <boost/numeric/odeint/resizer.hpp>
@@ -30,14 +30,15 @@
class StepController,
class Observer
>
- size_t integrate( Stepper &stepper,
- DynamicalSystem &system,
- StepController &controller,
- typename Stepper::time_type start_time,
- typename Stepper::time_type dt,
- typename Stepper::container_type &state,
- typename Stepper::time_type end_time,
- Observer &observer )
+ size_t integrate_adaptive(
+ Stepper &stepper,
+ DynamicalSystem &system,
+ StepController &controller,
+ typename Stepper::time_type start_time,
+ typename Stepper::time_type dt,
+ typename Stepper::container_type &state,
+ typename Stepper::time_type end_time,
+ Observer &observer )
{
controlled_step_result result;
size_t iterations = 0;
@@ -50,12 +51,14 @@
{
// do a controlled step
result = controller.controlled_step( stepper, system, state, t, dt_ );
+
if( result != STEP_SIZE_DECREASED )
{ // we actually did a step forward (dt was small enough)
observer(t, state, system);
iterations++;
}
- while( result != SUCCESS ) // as long as dt is too large/small
+
+/* while( result != SUCCESS ) // as long as dt is too large/small
{
// do the controlled step
result = controller.controlled_step( stepper, system, state, t, dt_ );
@@ -63,14 +66,40 @@
{ // we did a step
observer(t, state, system);
iterations++;
- }
- if( !( t+dt_ > t) )
- throw; // we've reached machine precision with dt - no advancing in t
- }
+ }*/
+ if( !( t+dt_ > t) )
+ throw; // we've reached machine precision with dt - no advancing in t
+ //}
}
return iterations;
}
+ template<
+ class Stepper,
+ class DynamicalSystem,
+ class StepController
+ >
+ size_t integrate_adaptive(
+ Stepper &stepper,
+ DynamicalSystem &system,
+ StepController &controller,
+ typename Stepper::time_type start_time,
+ typename Stepper::time_type dt,
+ typename Stepper::container_type &state,
+ typename Stepper::time_type end_time
+ )
+ {
+ return integrate_adaptive(
+ stepper , system , controller ,
+ start_time , dt , state , end_time ,
+ do_nothing_observer<
+ typename Stepper::time_type ,
+ typename Stepper::container_type ,
+ DynamicalSystem >
+ );
+ }
+
+
/* Integration of an ode with adaptive stepsize methods.
@@ -90,20 +119,24 @@
class Stepper,
class DynamicalSystem,
class StepController,
- class TimeContainer,
+ class TimeSequence,
class InsertIterator
>
size_t integrate(Stepper &stepper,
DynamicalSystem &system,
StepController &controller,
typename Stepper::container_type &state,
- TimeContainer ×,
+ TimeSequence ×,
InsertIterator state_inserter,
typename Stepper::time_type &dt)
{
- state_copy_observer<InsertIterator, TimeContainer> observer(times, state_inserter);
- return integrate(stepper, system, controller, *(times.begin()),
- dt, state, *(times.end()-1), observer);
+ if( times.empty() ) return 0;
+ else
+ {
+ state_copy_observer<InsertIterator, TimeSequence> observer(times, state_inserter);
+ return integrate_adaptive(stepper, system, controller, times.front() ,
+ dt, state, times.back() , observer);
+ }
}
@@ -141,12 +174,13 @@
*/
template< class Stepper,
class DynamicalSystem,
- class InsertIterator
+ class InsertIterator ,
+ class TimeSequence
>
size_t integrate(Stepper &stepper,
DynamicalSystem &system,
typename Stepper::container_type &x,
- std::vector<typename Stepper::time_type> ×,
+ TimeSequence ×,
InsertIterator state_inserter,
typename Stepper::time_type dt = 1E-4,
typename Stepper::time_type eps_abs = 1E-6,
Deleted: sandbox/odeint/boost/numeric/odeint/integrator_constant_step.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/integrator_constant_step.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
+++ (empty file)
@@ -1,136 +0,0 @@
-/*
- boost header: numeric/odeint/integrator_constant_step.hpp
-
- Copyright 2009 Karsten Ahnert
- Copyright 2009 Mario Mulansky
- Copyright 2009 Andre Bergner
-
- 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_INTEGRATOR_CONSTANT_STEP_HPP_INCLUDED
-#define BOOST_NUMERIC_ODEINT_INTEGRATOR_CONSTANT_STEP_HPP_INCLUDED
-
-#include <boost/numeric/odeint/observer.hpp>
-
-namespace boost {
-namespace numeric {
-namespace odeint {
-
-
- template<
- class Stepper ,
- class DynamicalSystem ,
- class Observer
- >
- size_t integrate(
- Stepper &stepper ,
- DynamicalSystem &system ,
- typename Stepper::time_type start_time ,
- typename Stepper::time_type dt ,
- typename Stepper::container_type &state ,
- typename Stepper::time_type end_time ,
- Observer &observer
- )
- {
- size_t iteration = 0;
- while( start_time < end_time )
- {
- observer( start_time , state , system );
- stepper.next_step( system , state , start_time , dt );
- start_time += dt;
- ++iteration;
- }
- observer( start_time , state , system );
-
- return iteration;
- }
-
-
-
- template<
- class Stepper ,
- class DynamicalSystem
- >
- size_t integrate(
- Stepper &stepper ,
- DynamicalSystem &system ,
- typename Stepper::time_type start_time ,
- typename Stepper::time_type dt ,
- typename Stepper::container_type &state ,
- typename Stepper::time_type end_time
- )
- {
- return integrate(
- stepper , system , start_time , dt , state , end_time ,
- do_nothing_observer<
- typename Stepper::time_type ,
- typename Stepper::container_type ,
- DynamicalSystem >
- );
- }
-
-
-
- template<
- class Stepper ,
- class DynamicalSystem ,
- class Observer
- >
- typename Stepper::time_type integrate_steps(
- Stepper &stepper ,
- DynamicalSystem &system ,
- typename Stepper::time_type start_time ,
- typename Stepper::time_type dt ,
- typename Stepper::container_type &state ,
- size_t num_of_steps ,
- Observer &observer
- )
- {
- size_t iteration = 0;
- while( iteration < num_of_steps )
- {
- observer( start_time , state , system );
- stepper.next_step( system , state , start_time , dt );
- start_time += dt;
- ++iteration;
- }
- observer( start_time , state , system );
-
- return start_time;
- }
-
-
- template<
- class Stepper ,
- class DynamicalSystem
- >
- typename Stepper::time_type integrate_steps(
- Stepper &stepper ,
- DynamicalSystem &system ,
- typename Stepper::time_type start_time ,
- typename Stepper::time_type dt ,
- typename Stepper::container_type &state ,
- size_t num_of_steps
- )
- {
- return integrate_steps(
- stepper , system , start_time , dt , state , num_of_steps ,
- do_nothing_observer<
- typename Stepper::time_type ,
- typename Stepper::container_type ,
- DynamicalSystem >
- );
- }
-
-
-
-
-
-} // odeint
-} // numeric
-} // boost
-
-#endif //BOOST_NUMERIC_ODEINT_INTEGRATOR_CONSTANT_STEP_HPP_INCLUDED
Copied: sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp (from r57721, /sandbox/odeint/boost/numeric/odeint/integrator_constant_step.hpp)
==============================================================================
--- /sandbox/odeint/boost/numeric/odeint/integrator_constant_step.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -10,8 +10,8 @@
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
-#ifndef BOOST_NUMERIC_ODEINT_INTEGRATOR_CONSTANT_STEP_HPP_INCLUDED
-#define BOOST_NUMERIC_ODEINT_INTEGRATOR_CONSTANT_STEP_HPP_INCLUDED
+#ifndef BOOST_NUMERIC_ODEINT_INTEGRATOR_CONSTANT_STEPSIZE_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_INTEGRATOR_CONSTANT_STEPSIZE_HPP_INCLUDED
#include <boost/numeric/odeint/observer.hpp>
@@ -25,7 +25,7 @@
class DynamicalSystem ,
class Observer
>
- size_t integrate(
+ size_t integrate_const(
Stepper &stepper ,
DynamicalSystem &system ,
typename Stepper::time_type start_time ,
@@ -54,7 +54,7 @@
class Stepper ,
class DynamicalSystem
>
- size_t integrate(
+ size_t integrate_const(
Stepper &stepper ,
DynamicalSystem &system ,
typename Stepper::time_type start_time ,
@@ -63,7 +63,7 @@
typename Stepper::time_type end_time
)
{
- return integrate(
+ return integrate_const(
stepper , system , start_time , dt , state , end_time ,
do_nothing_observer<
typename Stepper::time_type ,
@@ -79,7 +79,7 @@
class DynamicalSystem ,
class Observer
>
- typename Stepper::time_type integrate_steps(
+ typename Stepper::time_type integrate_const_steps(
Stepper &stepper ,
DynamicalSystem &system ,
typename Stepper::time_type start_time ,
@@ -107,7 +107,7 @@
class Stepper ,
class DynamicalSystem
>
- typename Stepper::time_type integrate_steps(
+ typename Stepper::time_type integrate_const_steps(
Stepper &stepper ,
DynamicalSystem &system ,
typename Stepper::time_type start_time ,
@@ -116,7 +116,7 @@
size_t num_of_steps
)
{
- return integrate_steps(
+ return integrate_const_steps(
stepper , system , start_time , dt , state , num_of_steps ,
do_nothing_observer<
typename Stepper::time_type ,
@@ -133,4 +133,4 @@
} // numeric
} // boost
-#endif //BOOST_NUMERIC_ODEINT_INTEGRATOR_CONSTANT_STEP_HPP_INCLUDED
+#endif //BOOST_NUMERIC_ODEINT_INTEGRATOR_CONSTANT_STEPSIZE_HPP_INCLUDED
Modified: sandbox/odeint/boost/numeric/odeint/observer.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/observer.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/observer.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -27,28 +27,37 @@
- template< class InsertIterator, class TimeContainer = std::vector<double> >
+ template< class InsertIterator, class TimeSequence = std::vector<double> >
class state_copy_observer
{
private:
- TimeContainer *m_times;
+
+ TimeSequence &m_times;
InsertIterator m_state_inserter;
- typename TimeContainer::iterator m_time_iter;
+ typename TimeSequence::iterator m_time_iter;
+
+ typedef typename TimeSequence::value_type time_type;
- typedef typename TimeContainer::value_type time_type;
public:
- state_copy_observer( TimeContainer × ,
+
+ state_copy_observer( TimeSequence × ,
InsertIterator state_inserter )
- : m_times(×),
+ : m_times(times),
m_state_inserter(state_inserter),
- m_time_iter(m_times->begin())
+ m_time_iter(m_times.begin())
{ }
+
+ void reset( void ) { m_time_iter = m_times.begin(); }
template< class Container, class System >
- void operator () (time_type t, Container &state, System &system ) {
- if( t >= *m_time_iter ) { // we've reached the next time point
+ void operator () (time_type t, Container &state, System &system )
+ {
+ if( ( m_time_iter != m_times.end() ) &&
+ ( t >= *m_time_iter ) )
+ {
+ // we've reached the next time point
*m_state_inserter++ = state; // insert the state
m_time_iter++; // next time point
}
Modified: sandbox/odeint/boost/numeric/odeint/resizer.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/resizer.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/resizer.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -33,6 +33,7 @@
public:
+
void resize( const container_type &x , container_type &dxdt ) const
{
dxdt.resize( x.size() );
Modified: sandbox/odeint/boost/numeric/odeint/stepper_euler.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/stepper_euler.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/stepper_euler.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -37,8 +37,6 @@
>
class stepper_euler
{
-
-
// provide basic typedefs
public:
Modified: sandbox/odeint/boost/numeric/odeint/stepper_half_step.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/stepper_half_step.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/stepper_half_step.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -70,7 +70,7 @@
template< class DynamicalSystem >
void next_step( DynamicalSystem &system ,
container_type &x ,
- const container_type &dxdt ,
+ container_type &dxdt ,
time_type t ,
time_type dt )
{
@@ -91,7 +91,7 @@
template< class DynamicalSystem >
void next_step( DynamicalSystem &system ,
container_type &x ,
- const container_type &dxdt ,
+ container_type &dxdt ,
time_type t ,
time_type dt ,
container_type &xerr )
Modified: sandbox/odeint/boost/numeric/odeint/stepper_rk4.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/stepper_rk4.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/stepper_rk4.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -67,13 +67,19 @@
container_type m_xt;
resizer_type m_resizer;
-
+ // private member functions
+ private:
// public interface
public:
+ stepper_rk4( void )
+ : current_size(0)
+ {
+ }
+
order_type order() const { return 4; }
template< class DynamicalSystem >
@@ -85,7 +91,6 @@
{
using namespace detail::it_algebra;
- //const time_type val2 = time_type( 2.0 );
const time_type val1 = time_type( 1.0 );
m_resizer.adjust_size( x , m_dxt );
@@ -97,33 +102,28 @@
time_type th = t + dh;
// dt * dxdt = k1
-
- //m_xt = x + dh*dxdt
- // old: assign_sum( m_xt.begin() , m_xt.end() , x.begin() , dxdt.begin() , dh );
+ // m_xt = x + dh*dxdt
scale_sum( m_xt.begin(), m_xt.end(),
val1, x.begin(),
dh, dxdt.begin() );
- system( m_xt , m_dxt , th ); // dt * m_dxt = k2
+ // dt * m_dxt = k2
+ system( m_xt , m_dxt , th );
//m_xt = x + dh*m_dxt
- // old: assign_sum( m_xt.begin() , m_xt.end() , x.begin() , m_dxt.begin() , dh );
scale_sum( m_xt.begin(), m_xt.end(),
val1, x.begin(),
dh, m_dxt.begin() );
- system( m_xt , m_dxm , th ); // dt * m_dxm = k3
- //m_xt = x + dt*m_dxm ; m_dxm += m_dxt
- // old: assign_sum_increment( m_xt.begin() , m_xt.end() , x.begin() ,
- // m_dxm.begin() , m_dxt.begin() , dt );
+ // dt * m_dxm = k3
+ system( m_xt , m_dxm , th );
+ //m_xt = x + dt*m_dxm
scale_sum( m_xt.begin(), m_xt.end(),
val1, x.begin(),
dt, m_dxm.begin() );
- system( m_xt , m_dxh , value_type( t + dt ) ); // dt * m_dxh = k4
+ // dt * m_dxh = k4
+ system( m_xt , m_dxh , value_type( t + dt ) );
//x += dt/6 * ( m_dxdt + m_dxt + val2*m_dxm )
- // old: increment_sum_sum( x.begin() , x.end() , dxdt.begin() ,
- // m_dxt.begin() , m_dxm.begin() ,
- // dt / time_type( 6.0 ) , val2 );
scale_sum( x.begin(), x.end(),
val1, x.begin(),
dt / time_type( 6.0 ), dxdt.begin(),
Modified: sandbox/odeint/boost/numeric/odeint/stepper_rk_generic.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/stepper_rk_generic.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/stepper_rk_generic.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -55,7 +55,9 @@
class Time = double ,
class Resizer = resizer< Container >
>
- class stepper_rk_generic {
+ class stepper_rk_generic
+ {
+
// provide basic typedefs
public:
@@ -68,14 +70,19 @@
typedef typename container_type::iterator iterator;
+
+
// check the concept of the ContainerType
private:
BOOST_CLASS_REQUIRE( container_type ,
boost::numeric::odeint, Container );
+
+
// private variables
private:
+
typedef std::vector< container_type > container_vector;
typedef std::vector< iterator > container_iterator_vector;
@@ -90,7 +97,10 @@
resizer_type m_resizer;
+
+ // private member functions
private:
+
void reset_iter(typename container_iterator_vector::iterator xiter_iter)
{
typename container_vector::iterator x_iter = m_xvec.begin();
@@ -143,6 +153,8 @@
public:
+
+
/* Constructor
a,b,c are vectors providing the butcher tableau for the Runge Kutta scheme
@@ -185,6 +197,7 @@
order_type order() const { return m_q; }
+
template< class DynamicalSystem >
void next_step( DynamicalSystem &system ,
container_type &x ,
@@ -199,7 +212,8 @@
(*x_iter) = dxdt;
(*xiter_iter++) = (*x_iter++).begin();
- while( x_iter != m_xvec.end() ) {
+ while( x_iter != m_xvec.end() )
+ {
m_resizer.adjust_size(x, (*x_iter));
(*xiter_iter++) = (*x_iter++).begin();
}
@@ -209,7 +223,8 @@
typename std::vector< time_type >::const_iterator a_iter = m_a.begin();
typename std::vector< std::vector<time_type> >::const_iterator b_iter = m_b.begin();
- while( x_iter != m_xvec.end() ) {
+ while( x_iter != m_xvec.end() )
+ {
reset_iter(m_xiter_vec.begin());
scale_sum_generic( m_xtmp.begin(), m_xtmp.end(),
(*b_iter).begin(), (*b_iter).end(), dt,
@@ -381,7 +396,8 @@
(*x_iter) = dxdt;
(*xiter_iter++) = (*x_iter++).begin();
- while( x_iter != m_xvec.end() ) {
+ while( x_iter != m_xvec.end() )
+ {
m_resizer.adjust_size(x, (*x_iter));
(*xiter_iter++) = (*x_iter++).begin();
}
@@ -392,7 +408,8 @@
const time_type* a_iter = &m_a[0];
const time_type* b_iter = &m_b[0];
unsigned short b_len= 1;
- while( x_iter != m_xvec.end() ) {
+ while( x_iter != m_xvec.end() )
+ {
reset_iter(m_xiter_vec.begin());
const time_type* b_end = b_iter + b_len;
scale_sum_generic( m_xtmp.begin(), m_xtmp.end(),
Modified: sandbox/odeint/boost/numeric/odeint/stepsize_controller_standard.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/stepsize_controller_standard.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/stepsize_controller_standard.hpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -26,7 +26,7 @@
namespace numeric {
namespace odeint {
-typedef enum{SUCCESS, STEP_SIZE_DECREASED, STEP_SIZE_INCREASED} controlled_step_result;
+ typedef enum{SUCCESS, STEP_SIZE_DECREASED, STEP_SIZE_INCREASED} controlled_step_result;
template<
class ContainerType,
Modified: sandbox/odeint/libs/numeric/odeint/examples/lorenz_controlled.cpp
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/examples/lorenz_controlled.cpp (original)
+++ sandbox/odeint/libs/numeric/odeint/examples/lorenz_controlled.cpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -66,7 +66,7 @@
cout.precision(5);
cout.setf(ios::fixed,ios::floatfield);
- size_t steps = integrate( euler, lorenz, controller, 0.0, 1E-4, x, 10.0, print_state );
+ size_t steps = integrate_adaptive( euler, lorenz, controller, 0.0, 1E-4, x, 10.0, print_state );
clog << "Number of steps: " << steps << endl;
Modified: sandbox/odeint/libs/numeric/odeint/examples/lorenz_integrate_constant_step.cpp
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/examples/lorenz_integrate_constant_step.cpp (original)
+++ sandbox/odeint/libs/numeric/odeint/examples/lorenz_integrate_constant_step.cpp 2009-11-17 09:02:10 EST (Tue, 17 Nov 2009)
@@ -65,14 +65,14 @@
stepper_rk4< state_type , double > rk4;
stepper_euler< state_type , double > euler;
- integrate( rk4 , lorenz , 0.0 , 0.01 , x , 100.0 ,
+ integrate_const( rk4 , lorenz , 0.0 , 0.01 , x , 100.0 ,
cout << _1 << tab << _2[0] << "\n" );
- integrate_steps( rk4 , lorenz , 0.0 , 0.01 , x , 100 ,
+ integrate_const_steps( rk4 , lorenz , 0.0 , 0.01 , x , 100 ,
cout << _1 << tab << _2[0] << "\n" );
- integrate( rk4 , lorenz , 0.0 , 0.01 , x , 100.0 );
- integrate_steps( rk4 , lorenz , 0.0 , 0.01 , x , 1000 );
+ integrate_const( rk4 , lorenz , 0.0 , 0.01 , x , 100.0 );
+ integrate_const_steps( rk4 , lorenz , 0.0 , 0.01 , x , 1000 );
/* integrate( euler , lorenz , 0.0 , 0.01 , x , 100.0 ,
cout << _1 << tab << _2[0] << "\n" );*/
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk