|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65667 - in sandbox/odeint/branches/karsten: boost/numeric/odeint/algebra boost/numeric/odeint/stepper boost/numeric/odeint/stepper/base libs/numeric/odeint/test
From: mario.mulansky_at_[hidden]
Date: 2010-09-29 08:21:41
Author: mariomulansky
Date: 2010-09-29 08:21:38 EDT (Wed, 29 Sep 2010)
New Revision: 65667
URL: http://svn.boost.org/trac/boost/changeset/65667
Log:
changed adjust_size to return bool
Added:
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp (contents, props changed)
Text files modified:
sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_resize.hpp | 9 +++++++--
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adjust_size.hpp | 32 ++++++++++++++++++++------------
sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_resize.cpp | 3 ++-
3 files changed, 29 insertions(+), 15 deletions(-)
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_resize.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_resize.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_resize.hpp 2010-09-29 08:21:38 EDT (Wed, 29 Sep 2010)
@@ -80,9 +80,14 @@
}
template< class Container >
-void adjust_size( const Container &x1 , Container &x2 )
+bool adjust_size( const Container &x1 , Container &x2 )
{
- if( !same_size( x1 , x2 ) ) resize( x1 , x2 );
+ if( !same_size( x1 , x2 ) )
+ {
+ resize( x1 , x2 );
+ return true;
+ } else
+ return false;
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adjust_size.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adjust_size.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adjust_size.hpp 2010-09-29 08:21:38 EDT (Wed, 29 Sep 2010)
@@ -47,27 +47,29 @@
size_adjuster() : m_is_initialized( false ) { }
- void adjust_size( const State &x )
+ bool adjust_size( const State &x )
{
- adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
}
- void adjust_size_by_policy( const State &x , adjust_size_manually_tag )
+ bool adjust_size_by_policy( const State &x , adjust_size_manually_tag )
{
+ return false;
}
- void adjust_size_by_policy( const State &x , adjust_size_initially_tag )
+ bool adjust_size_by_policy( const State &x , adjust_size_initially_tag )
{
if( !m_is_initialized )
{
- adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
m_is_initialized = true;
- }
+ return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ } else
+ return false;
}
- void adjust_size_by_policy( const State &x , adjust_size_always_tag )
+ bool adjust_size_by_policy( const State &x , adjust_size_always_tag )
{
- adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
}
void register_state( size_t idx , State &x )
@@ -78,14 +80,20 @@
private:
- void adjust_size_by_resizeability( const State &x , boost::true_type )
+ bool adjust_size_by_resizeability( const State &x , boost::true_type )
{
- for( size_t i=0 ; i<Dim ; ++i ) boost::numeric::odeint::adjust_size( x , m_states[i] );
- // adjust_size_impl( x );
+ bool changed = false;
+ for( size_t i=0 ; i<Dim ; ++i )
+ {
+ boost::numeric::odeint::adjust_size( x , m_states[i] );
+ changed = true;
+ }
+ return changed;
}
- void adjust_size_by_resizeability( const State &x , boost::false_type )
+ bool adjust_size_by_resizeability( const State &x , boost::false_type )
{
+ return false;
}
Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp 2010-09-29 08:21:38 EDT (Wed, 29 Sep 2010)
@@ -0,0 +1,163 @@
+/*
+ boost header: numeric/odeint/explicit_stepper_and_error_stepper_fsal_base.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_EXPLICIT_STEPPER_AND_ERROR_STEPPER_FSAL_BASE_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_AND_ERROR_STEPPER_FSAL_BASE_HPP_INCLUDED
+
+#include <boost/noncopyable.hpp>
+
+#include <boost/numeric/odeint/stepper/adjust_size.hpp>
+#include <boost/numeric/odeint/algebra/standard_resize.hpp>
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+/*
+ * base class for explicit stepper and error steppers with the fsal property
+ * models the stepper AND the error stepper fsal concept
+ */
+template<
+ class Stepper ,
+ unsigned short Order ,
+ unsigned short StepperOrder ,
+ unsigned short ErrorOrder ,
+ class State ,
+ class Time ,
+ class Algebra ,
+ class Operations ,
+ class AdjustSizePolicy
+>
+class explicit_stepper_and_error_stepper_fsal_base
+{
+public:
+
+
+ typedef State state_type;
+ typedef Time time_type;
+ typedef Algebra algebra_type;
+ typedef Operations operations_type;
+ typedef AdjustSizePolicy adjust_size_policy;
+ typedef Stepper stepper_type;
+
+ typedef unsigned short order_type;
+ static const order_type order_value = Order;
+ static const order_type stepper_order_value = StepperOrder;
+ static const order_type error_order_value = ErrorOrder;
+
+ order_type order( void ) const { return order_value; }
+ order_type stepper_order( void ) const { return stepper_order_value; }
+ order_type error_order( void ) const { return error_order_value; }
+
+
+ explicit_stepper_and_error_stepper_fsal_base( void ) : m_size_adjuster() , m_dxdt() , m_first_call( true )
+ {
+ boost::numeric::odeint::construct( m_dxdt );
+ m_size_adjuster.register_state( 0 , m_dxdt );
+ }
+
+ ~explicit_stepper_and_error_stepper_base( void )
+ {
+ boost::numeric::odeint::destruct( m_dxdt );
+ }
+
+
+
+ stepper_type& stepper( void ) { return *static_cast< stepper_type* >( this ); }
+ const stepper_type& stepper( void ) const {return *static_cast< const stepper_type* >( this );}
+
+
+ template< class System >
+ void do_step( System &system , state_type &x , time_type t , time_type dt )
+ {
+ m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ system( x , m_dxdt ,t );
+ this->stepper().do_step_impl( system , x , m_dxdt , x , t , dt );
+ }
+
+ template< class System >
+ void do_step( System &system , state_type &x , const state_type &dxdt , time_type t , time_type dt )
+ {
+ this->stepper().do_step_impl( system , x , dxdt , x , t , dt );
+ }
+
+ template< class System >
+ void do_step( System &system , const state_type &in , state_type &out , time_type t , time_type dt )
+ {
+ m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ system( in , m_dxdt ,t );
+ this->stepper().do_step_impl( system , in , m_dxdt , out , t , dt );
+ }
+
+ template< class System >
+ void do_step( System &system , const state_type &in , const state_type &dxdt , state_type &out , time_type t , time_type dt )
+ {
+ this->stepper().do_step_impl( system , in , dxdt , out , t , dt );
+ }
+
+
+
+ template< class System >
+ void do_step( System &system , state_type &x , time_type t , time_type dt , state_type &xerr )
+ {
+ if( m_first_call || m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) )
+ {
+ system( in , m_dxdt ,t );
+ m_first_call = false;
+ }
+ this->stepper().do_step_impl( system , x , m_dxdt , x , t , dt , xerr );
+ }
+
+ template< class System >
+ void do_step( System &system , state_type &x , state_type &dxdt , time_type t , time_type dt , state_type &xerr )
+ {
+ this->stepper().do_step_impl( system , x , dxdt , x , t , dt , xerr );
+ }
+
+ template< class System >
+ void do_step( System &system , state_type &in , state_type &out , time_type t , time_type dt , state_type &xerr )
+ {
+ if( m_first_call || m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) )
+ {
+ system( in , m_dxdt ,t );
+ m_first_call = false;
+ }
+ this->stepper().do_step_impl( system , in , m_dxdt , out , t , dt , xerr );
+ }
+
+ template< class System >
+ void do_step( System &system , state_type &in , state_type &dxdt , state_type &out , time_type t , time_type dt , state_type &xerr )
+ {
+ this->stepper().do_step_impl( system , in , dxdt , out , t , dt , xerr );
+ }
+
+ void adjust_size( const state_type &x )
+ {
+ m_size_adjuster.adjust_size( x );
+ }
+
+
+private:
+
+ size_adjuster< state_type , 1 > m_size_adjuster;
+ state_type m_dxdt;
+ bool m_first_call;
+
+};
+
+
+} // odeint
+} // numeric
+} // boost
+
+#endif //BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_AND_ERROR_STEPPER_FSAL_BASE_HPP_INCLUDED
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_resize.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_resize.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_resize.cpp 2010-09-29 08:21:38 EDT (Wed, 29 Sep 2010)
@@ -45,9 +45,10 @@
};
- template<> void adjust_size( const test_array_type &x1 , test_array_type &x2 )
+ template<> bool adjust_size( const test_array_type &x1 , test_array_type &x2 )
{
adjust_size_count++;
+ return false;
}
} } }
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