|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57090 - in sandbox/odeint: boost/numeric/odeint libs/numeric/odeint/examples
From: karsten.ahnert_at_[hidden]
Date: 2009-10-23 10:32:13
Author: karsten
Date: 2009-10-23 10:32:12 EDT (Fri, 23 Oct 2009)
New Revision: 57090
URL: http://svn.boost.org/trac/boost/changeset/57090
Log:
resizer specialisation for arrays added
Text files modified:
sandbox/odeint/boost/numeric/odeint/euler.hpp | 26 +++++++++++---------------
sandbox/odeint/libs/numeric/odeint/examples/lorenz.cpp | 2 +-
sandbox/odeint/libs/numeric/odeint/examples/lorenz_array.cpp | 3 +--
3 files changed, 13 insertions(+), 18 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-23 10:32:12 EDT (Fri, 23 Oct 2009)
@@ -24,32 +24,28 @@
namespace numeric {
namespace odeint {
- struct resizable
+
+ template< class ContainerType > class container_resizer
{
- template< class ContainerType >
+ public:
void resize( const ContainerType &x , ContainerType &dxdt ) const
{
- if( x.size() != dxdt.size() )
- dxdt.resize( x.size() );
+ if( x.size() != dxdt.size() ) dxdt.resize( x.size() );
}
};
-
-
- struct non_resizable
+ template< class T , size_t N >
+ class container_resizer< std::tr1::array< T , N > >
{
- template< class ContainerType >
- void resize( const ContainerType &x , ContainerType &dxdt ) const
- {
- throw; //should not happen
+ public:
+ void resize( const std::tr1::array<T,N> &x , std::tr1::array<T,N> &dxdt ) const
+ {
}
};
-
-
template<
class ContainerType ,
- class ResizeType = resizable
+ class ResizeType = container_resizer< ContainerType >
>
class ode_step_euler
{
@@ -66,7 +62,7 @@
ContainerType &x ,
TimeType t ,
TimeType dt )
- {
+ {
resizer.resize( x , dxdt );
system( x , dxdt , t );
iterator state_begin = x.begin();
Modified: sandbox/odeint/libs/numeric/odeint/examples/lorenz.cpp
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/examples/lorenz.cpp (original)
+++ sandbox/odeint/libs/numeric/odeint/examples/lorenz.cpp 2009-10-23 10:32:12 EDT (Fri, 23 Oct 2009)
@@ -58,7 +58,7 @@
x[1] = 0.0;
x[2] = 0.0;
- ode_step_euler< state_type > euler;
+ ode_step_euler_container< state_type > euler;
double t = 0.0;
for( size_t oi=0 ; oi<olen ; ++oi,t+=dt )
Modified: sandbox/odeint/libs/numeric/odeint/examples/lorenz_array.cpp
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/examples/lorenz_array.cpp (original)
+++ sandbox/odeint/libs/numeric/odeint/examples/lorenz_array.cpp 2009-10-23 10:32:12 EDT (Fri, 23 Oct 2009)
@@ -52,8 +52,7 @@
x[1] = 0.0;
x[2] = 0.0;
- // tr1::array is not resizable, we have to tell this to the stepper!
- ode_step_euler< state_type , non_resizable > euler;
+ ode_step_euler< state_type > euler;
double t = 0.0;
for( size_t oi=0 ; oi<olen ; ++oi,t+=dt )
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