|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57074 - sandbox/odeint/boost/numeric/odeint
From: karsten.ahnert_at_[hidden]
Date: 2009-10-22 14:38:11
Author: karsten
Date: 2009-10-22 14:38:11 EDT (Thu, 22 Oct 2009)
New Revision: 57074
URL: http://svn.boost.org/trac/boost/changeset/57074
Log:
added std::tr1::array support
Text files modified:
sandbox/odeint/boost/numeric/odeint/euler.hpp | 49 ++++++++++++++++++++++++++++++++++-----
1 files changed, 42 insertions(+), 7 deletions(-)
Modified: sandbox/odeint/boost/numeric/odeint/euler.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/euler.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/euler.hpp 2009-10-22 14:38:11 EDT (Thu, 22 Oct 2009)
@@ -18,34 +18,69 @@
#define BOOST_NUMERIC_ODEINT_EULER_HPP
#include <boost/concept_check.hpp>
+#include <tr1/array>
namespace boost {
namespace numeric {
namespace odeint {
+
template< class ContainerType >
+ class container_resizer
+ {
+ public:
+
+ void resize( const ContainerType &x , ContainerType &dxdt ) const
+ {
+ if( x.size() != dxdt.size() )
+ dxdt.resize( x.size() );
+ }
+ };
+
+
+
+ template< class T , int N >
+ class array_resizer
+ {
+ public:
+ void resize( const std::tr1::array<T,N> &x , std::tr1::array<T,N> &dxdt ) const
+ {
+ }
+ };
+
+
+
+ template<
+ class ContainerType ,
+ class ResizerType = container_resizer<ContainerType>
+ >
class ode_step_euler
{
- BOOST_CLASS_REQUIRE( ContainerType , boost , SequenceConcept );
+ // BOOST_CLASS_REQUIRE( ContainerType , boost , SequenceConcept );
ContainerType dxdt;
+ ResizerType resizer;
+
+ typedef typename ContainerType::iterator iterator;
public:
template< class DynamicalSystem , class TimeType>
- void next_step( DynamicalSystem system , ContainerType &x , TimeType t , TimeType dt )
+ void next_step( DynamicalSystem system ,
+ ContainerType &x ,
+ TimeType t ,
+ TimeType dt )
{
- if( x.size() != dxdt.size() ) dxdt.resize( x.size() );
+ resizer.resize( x , dxdt );
system( x , dxdt , t );
- typename ContainerType::iterator state_begin = x.begin();
- typename ContainerType::iterator state_end = x.end();
- typename ContainerType::iterator derivative_begin = dxdt.begin();
+ iterator state_begin = x.begin();
+ iterator state_end = x.end();
+ iterator derivative_begin = dxdt.begin();
while( state_begin != state_end )
(*state_begin++) += dt * (*derivative_begin++);
}
};
-
/* ToDo:
Write stepper for
* fixed size systems
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