|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r68228 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/algebra boost/numeric/odeint/stepper boost/numeric/odeint/stepper/base libs/numeric/odeint/ideas libs/numeric/odeint/ideas/units libs/numeric/odeint/test libs/numeric/odeint/test/thrust
From: karsten.ahnert_at_[hidden]
Date: 2011-01-18 08:14:23
Author: karsten
Date: 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
New Revision: 68228
URL: http://svn.boost.org/trac/boost/changeset/68228
Log:
* making the system call compatible with boost::ref
* introducing ideas/units
Added:
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/Jamfile (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/explicit_euler_units.hpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/explicit_stepper_base_units.hpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/standard_operations_units.hpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_units.cpp (contents, props changed)
Text files modified:
sandbox/odeint/branches/karsten/Jamroot | 5 ++-
sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_resize.hpp | 21 +++++++++------
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp | 18 +++++++------
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp | 29 ++++++++++++---------
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp | 31 +++++++++++++---------
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp | 15 ++++++----
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp | 39 ++++++++++++++++------------
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_dopri5.hpp | 6 +++-
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp | 2
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_dopri5.hpp | 20 +++++++++------
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_rk54_ck.hpp | 18 +++++++------
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp | 2
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_rk4.hpp | 14 ++++++---
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/implicit_euler.hpp | 11 +++++---
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/odeint_ref_problem.cpp | 2
sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp | 53 +++++++++++++++++++++++++++++++++------
sandbox/odeint/branches/karsten/libs/numeric/odeint/test/thrust/Makefile | 2
17 files changed, 181 insertions(+), 107 deletions(-)
Modified: sandbox/odeint/branches/karsten/Jamroot
==============================================================================
--- sandbox/odeint/branches/karsten/Jamroot (original)
+++ sandbox/odeint/branches/karsten/Jamroot 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -20,9 +20,10 @@
# ideas
-build-project libs/numeric/odeint/ideas/butcher ;
-build-project libs/numeric/odeint/ideas/generic_stepper ;
+# build-project libs/numeric/odeint/ideas/butcher ;
+# build-project libs/numeric/odeint/ideas/generic_stepper ;
build-project libs/numeric/odeint/ideas/rosenbrock4 ;
+build-project libs/numeric/odeint/ideas/units ;
# additional tests with external libraries :
build-project libs/numeric/odeint/test/gmp ;
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 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -67,32 +67,35 @@
{
}
-template< class Container >
-void resize( const Container &x , Container &dxdt )
+template< class Container , class Deriv >
+void resize( const Container &x , Deriv &dxdt )
{
dxdt.resize( x.size() );
}
-template< class Container >
-bool same_size( const Container &x1 , const Container &x2 )
+template< class Container , class Deriv >
+bool same_size( const Container &x1 , const Deriv &x2 )
{
return ( x1.size() == x2.size() );
}
-template< class Container >
-bool adjust_size( const Container &x1 , Container &x2 )
+template< class Container , class Deriv >
+bool adjust_size( const Container &x1 , Deriv &x2 )
{
if( !same_size( x1 , x2 ) )
{
resize( x1 , x2 );
return true;
- } else
+ }
+ else
+ {
return false;
+ }
}
-template< class Container >
-void copy( const Container &from , Container &to )
+template< class Container , class Deriv >
+void copy( const Container &from , Deriv &to )
{
to = from;
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -14,6 +14,7 @@
#define BOOST_NUMERIC_ODEINT_EXPLICIT_ERROR_STEPPER_BASE_HPP_INCLUDED
#include <boost/noncopyable.hpp>
+#include <boost/ref.hpp>
#include <boost/numeric/odeint/stepper/adjust_size.hpp>
#include <boost/numeric/odeint/algebra/standard_resize.hpp>
@@ -61,8 +62,7 @@
order_type error_order( void ) const
{
- return error_order_value;
- }
+ return error_order_value; }
@@ -83,32 +83,34 @@
// do_step( system , x , t , dt , xerr )
template< class System >
- void do_step( System &system , state_type &x , const time_type t , const time_type dt , state_type &xerr )
+ void do_step( System system , state_type &x , const time_type t , const time_type dt , state_type &xerr )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
- system( x , m_dxdt ,t );
+ sys( x , m_dxdt ,t );
this->stepper().do_step_impl( system , x , m_dxdt , t , x , dt , xerr );
}
// do_step( system , x , dxdt , t , dt , xerr )
template< class System >
- void do_step( System &system , state_type &x , const state_type &dxdt , const time_type t , const time_type dt , state_type &xerr )
+ void do_step( System system , state_type &x , const state_type &dxdt , const time_type t , const time_type dt , state_type &xerr )
{
this->stepper().do_step_impl( system , x , dxdt , t , x , dt , xerr );
}
// do_step( system , in , t , out , dt , xerr )
template< class System >
- void do_step( System &system , const state_type &in , const time_type t , state_type &out , const time_type dt , state_type &xerr )
+ void do_step( System system , const state_type &in , const time_type t , state_type &out , const time_type dt , state_type &xerr )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
- system( in , m_dxdt ,t );
+ sys( in , m_dxdt ,t );
this->stepper().do_step_impl( system , in , m_dxdt , t , out , dt , xerr );
}
// do_step( system , in , dxdt , t , out , dt , xerr )
template< class System >
- void do_step( System &system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt , state_type &xerr )
+ void do_step( System system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt , state_type &xerr )
{
this->stepper().do_step_impl( system , in , dxdt , t , out , dt , xerr );
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -14,6 +14,7 @@
#define BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_AND_ERROR_STEPPER_BASE_HPP_INCLUDED
#include <boost/noncopyable.hpp>
+#include <boost/ref.hpp>
#include <boost/numeric/odeint/stepper/adjust_size.hpp>
#include <boost/numeric/odeint/algebra/standard_resize.hpp>
@@ -93,32 +94,34 @@
// do_step( sys , x , t , dt )
template< class System >
- void do_step( System &system , state_type &x , const time_type t , const time_type dt )
+ void do_step( System system , state_type &x , const time_type t , const time_type dt )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
- system( x , m_dxdt ,t );
+ sys( x , m_dxdt ,t );
this->stepper().do_step_impl( system , x , m_dxdt , t , x , dt );
}
// do_step( sys , x , dxdt , t , dt )
template< class System >
- void do_step( System &system , state_type &x , const state_type &dxdt , const time_type t , const time_type dt )
+ void do_step( System system , state_type &x , const state_type &dxdt , const time_type t , const time_type dt )
{
this->stepper().do_step_impl( system , x , dxdt , t , x , dt );
}
// do_step( sys , in , t , out , dt )
template< class System >
- void do_step( System &system , const state_type &in , const time_type t , state_type &out , const time_type dt )
+ void do_step( System system , const state_type &in , const time_type t , state_type &out , const time_type dt )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
- system( in , m_dxdt ,t );
+ sys( in , m_dxdt ,t );
this->stepper().do_step_impl( system , in , m_dxdt , t , out , dt );
}
// do_step( sys , in , dxdt , t , out , dt )
template< class System >
- void do_step( System &system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt )
+ void do_step( System system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt )
{
this->stepper().do_step_impl( system , in , dxdt , t , out , dt );
}
@@ -130,32 +133,34 @@
// do_step( sys , x , t , dt , xerr )
template< class System >
- void do_step( System &system , state_type &x , const time_type t , const time_type dt , state_type &xerr )
+ void do_step( System system , state_type &x , const time_type t , const time_type dt , state_type &xerr )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
- system( x , m_dxdt ,t );
+ sys( x , m_dxdt ,t );
this->stepper().do_step_impl( system , x , m_dxdt , t , x , dt , xerr );
}
// do_step( sys , x , dxdt , t , dt , xerr )
template< class System >
- void do_step( System &system , state_type &x , const state_type &dxdt , const time_type t , const time_type dt , state_type &xerr )
+ void do_step( System system , state_type &x , const state_type &dxdt , const time_type t , const time_type dt , state_type &xerr )
{
this->stepper().do_step_impl( system , x , dxdt , t , x , dt , xerr );
}
// do_step( sys , in , t , out , dt , xerr )
template< class System >
- void do_step( System &system , const state_type &in , const time_type t , state_type &out , const time_type dt , state_type &xerr )
+ void do_step( System system , const state_type &in , const time_type t , state_type &out , const time_type dt , state_type &xerr )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
- system( in , m_dxdt ,t );
+ sys( in , m_dxdt ,t );
this->stepper().do_step_impl( system , in , m_dxdt , t , out , dt , xerr );
}
// do_step( sys , in , dxdt , t , out , dt , xerr )
template< class System >
- void do_step( System &system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt , state_type &xerr )
+ void do_step( System system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt , state_type &xerr )
{
this->stepper().do_step_impl( system , in , dxdt , t , out , dt , xerr );
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -14,6 +14,7 @@
#define BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_AND_ERROR_STEPPER_FSAL_BASE_HPP_INCLUDED
#include <boost/noncopyable.hpp>
+#include <boost/ref.hpp>
#include <boost/numeric/odeint/stepper/adjust_size.hpp>
#include <boost/numeric/odeint/algebra/standard_resize.hpp>
@@ -93,11 +94,12 @@
// do_step( sys , x , t , dt )
template< class System >
- void do_step( System &system , state_type &x , const time_type t , const time_type dt )
+ void do_step( System system , state_type &x , const time_type t , const time_type dt )
{
- if( m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) || m_first_call )
+ if( m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) || m_first_call )
{
- system( x , m_dxdt ,t );
+ typename boost::unwrap_reference< System >::type &sys = system;
+ sys( x , m_dxdt ,t );
m_first_call = false;
}
this->stepper().do_step_impl( system , x , m_dxdt , t , x , m_dxdt , dt );
@@ -105,7 +107,7 @@
// do_step( sys , x , dxdt , t , dt )
template< class System >
- void do_step( System &system , state_type &x , state_type &dxdt , const time_type t , const time_type dt )
+ void do_step( System system , state_type &x , state_type &dxdt , const time_type t , const time_type dt )
{
m_first_call = true;
this->stepper().do_step_impl( system , x , dxdt , t , x , dxdt , dt );
@@ -113,11 +115,12 @@
// do_step( sys , in , t , out , dt )
template< class System >
- void do_step( System &system , const state_type &in , const time_type t , state_type &out , const time_type dt )
+ void do_step( System system , const state_type &in , const time_type t , state_type &out , const time_type dt )
{
if( m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() ) || m_first_call )
{
- system( in , m_dxdt ,t );
+ typename boost::unwrap_reference< System >::type &sys = system;
+ sys( in , m_dxdt ,t );
m_first_call = false;
}
this->stepper().do_step_impl( system , in , m_dxdt , t , out , m_dxdt , dt );
@@ -125,7 +128,7 @@
// do_step( sys , in , dxdt_in , t , out , dxdt_out , dt )
template< class System >
- void do_step( System &system , const state_type &in , const state_type &dxdt_in , const time_type t ,
+ void do_step( System system , const state_type &in , const state_type &dxdt_in , const time_type t ,
state_type &out , state_type &dxdt_out , const time_type dt )
{
m_first_call = true;
@@ -139,11 +142,12 @@
// do_step( sys , x , t , dt , xerr )
template< class System >
- void do_step( System &system , state_type &x , const time_type t , const time_type dt , state_type &xerr )
+ void do_step( System system , state_type &x , const time_type t , const time_type dt , state_type &xerr )
{
if( m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) || m_first_call )
{
- system( x , m_dxdt ,t );
+ typename boost::unwrap_reference< System >::type &sys = system;
+ sys( x , m_dxdt ,t );
m_first_call = false;
}
this->stepper().do_step_impl( system , x , m_dxdt , t , x , m_dxdt , dt , xerr );
@@ -151,7 +155,7 @@
// do_step( sys , x , dxdt , t , dt , xerr )
template< class System >
- void do_step( System &system , state_type &x , state_type &dxdt , const time_type t , const time_type dt , state_type &xerr )
+ void do_step( System system , state_type &x , state_type &dxdt , const time_type t , const time_type dt , state_type &xerr )
{
m_first_call = true;
this->stepper().do_step_impl( system , x , dxdt , t , x , dxdt , dt , xerr );
@@ -159,11 +163,12 @@
// do_step( sys , in , t , out , dt , xerr )
template< class System >
- void do_step( System &system , const state_type &in , const time_type t , state_type &out , const time_type dt , state_type &xerr )
+ void do_step( System system , const state_type &in , const time_type t , state_type &out , const time_type dt , state_type &xerr )
{
if( m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() ) || m_first_call )
{
- system( in , m_dxdt ,t );
+ typename boost::unwrap_reference< System >::type &sys = system;
+ sys( in , m_dxdt ,t );
m_first_call = false;
}
this->stepper().do_step_impl( system , in , m_dxdt , t , out , m_dxdt , dt , xerr );
@@ -171,7 +176,7 @@
// do_step( sys , in , dxdt_in , t , out , dxdt_out , dt )
template< class System >
- void do_step( System &system , const state_type &in , const state_type &dxdt_in , const time_type t ,
+ void do_step( System system , const state_type &in , const state_type &dxdt_in , const time_type t ,
state_type &out , state_type &dxdt_out , const time_type dt , state_type &xerr )
{
m_first_call = true;
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -14,6 +14,7 @@
#define BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_BASE_HPP_INCLUDED
#include <boost/noncopyable.hpp>
+#include <boost/ref.hpp>
#include <boost/numeric/odeint/stepper/adjust_size.hpp>
#include <boost/numeric/odeint/algebra/standard_resize.hpp>
@@ -76,32 +77,34 @@
// do_step( sys , x , t , dt )
template< class System >
- void do_step( System &system , state_type &x , const time_type t , const time_type dt )
+ void do_step( System system , state_type &x , const time_type t , const time_type dt )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
- system( x , m_dxdt ,t );
+ sys( x , m_dxdt ,t );
this->stepper().do_step_impl( system , x , m_dxdt , t , x , dt );
}
// do_step( sys , x , dxdt , t , dt )
template< class System >
- void do_step( System &system , state_type &x , const state_type dxdt , const time_type t , const time_type dt )
+ void do_step( System system , state_type &x , const state_type dxdt , const time_type t , const time_type dt )
{
this->stepper().do_step_impl( system , x , dxdt , t , x , dt );
}
// do_step( sys , in , t , out , dt )
template< class System >
- void do_step( System &system , const state_type &in , const time_type t , state_type &out , const time_type dt )
+ void do_step( System system , const state_type &in , const time_type t , state_type &out , const time_type dt )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
- system( in , m_dxdt ,t );
+ sys( in , m_dxdt ,t );
this->stepper().do_step_impl( system , in , m_dxdt , t , out , dt );
}
// do_step( sys , in , dxdt , t , out , dt )
template< class System >
- void do_step( System &system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt )
+ void do_step( System system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt )
{
this->stepper().do_step_impl( system , in , dxdt , t , out , dt );
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -16,6 +16,7 @@
#include <cmath>
#include <boost/noncopyable.hpp>
+#include <boost/ref.hpp>
#include <boost/numeric/odeint/stepper/adjust_size.hpp>
#include <boost/numeric/odeint/stepper/error_checker.hpp>
@@ -99,19 +100,20 @@
// try_step( sys , x , t , dt )
template< class System >
- controlled_step_result try_step( System &sys , state_type &x , time_type &t , time_type &dt )
+ controlled_step_result try_step( System system , state_type &x , time_type &t , time_type &dt )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_dxdt_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
sys( x , m_dxdt ,t );
- return try_step( sys , x , m_dxdt , t , dt );
+ return try_step( system , x , m_dxdt , t , dt );
}
// try_step( sys , x , dxdt , t , dt )
template< class System >
- controlled_step_result try_step( System &sys , state_type &x , const state_type &dxdt , time_type &t , time_type &dt )
+ controlled_step_result try_step( System system , state_type &x , const state_type &dxdt , time_type &t , time_type &dt )
{
m_xnew_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
- controlled_step_result res = try_step( sys , x , dxdt , t , m_xnew , dt );
+ controlled_step_result res = try_step( system , x , dxdt , t , m_xnew , dt );
if( ( res == success_step_size_increased ) || ( res == success_step_size_unchanged ) )
{
boost::numeric::odeint::copy( m_xnew , x );
@@ -121,17 +123,18 @@
// try_step( sys , in , t , out , dt )
template< class System >
- controlled_step_result try_step( System &sys , const state_type &in , time_type &t , state_type &out , time_type &dt )
+ controlled_step_result try_step( System system , const state_type &in , time_type &t , state_type &out , time_type &dt )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
m_dxdt_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
- sys( in , m_dxdt , t );
- return try_step( sys , in , m_dxdt , t , out , dt );
+ system( in , m_dxdt , t );
+ return try_step( system , in , m_dxdt , t , out , dt );
}
// try_step( sys , in , dxdt , t , out , dt )
template< class System >
- controlled_step_result try_step( System &sys , const state_type &in , const state_type &dxdt , time_type &t , state_type &out , time_type &dt )
+ controlled_step_result try_step( System system , const state_type &in , const state_type &dxdt , time_type &t , state_type &out , time_type &dt )
{
using std::max;
using std::min;
@@ -140,7 +143,7 @@
m_xerr_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
// do one step with error calculation
- m_stepper.do_step( sys , in , dxdt , t , out , dt , m_xerr );
+ m_stepper.do_step( system , in , dxdt , t , out , dt , m_xerr );
m_max_rel_error = m_error_checker.error( in , dxdt , m_xerr , dt );
@@ -275,34 +278,36 @@
// try_step( sys , x , t , dt )
template< class System >
- controlled_step_result try_step( System &sys , state_type &x , time_type &t , time_type &dt )
+ controlled_step_result try_step( System system , state_type &x , time_type &t , time_type &dt )
{
if( m_dxdt_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) || m_first_call )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
sys( x , m_dxdt ,t );
m_first_call = false;
}
- return try_step( sys , x , m_dxdt , t , dt );
+ return try_step( system , x , m_dxdt , t , dt );
}
// try_step( sys , in , t , out , dt );
template< class System >
- controlled_step_result try_step( System &sys , const state_type &in , time_type &t , state_type &out , time_type &dt )
+ controlled_step_result try_step( System system , const state_type &in , time_type &t , state_type &out , time_type &dt )
{
if( m_dxdt_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() ) || m_first_call )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
sys( in , m_dxdt ,t );
m_first_call = false;
}
- return try_step( sys , in , m_dxdt , t , out , dt );
+ return try_step( system , in , m_dxdt , t , out , dt );
}
// try_step( sys , x , dxdt , t , dt )
template< class System >
- controlled_step_result try_step( System &sys , state_type &x , state_type &dxdt , time_type &t , time_type &dt )
+ controlled_step_result try_step( System system , state_type &x , state_type &dxdt , time_type &t , time_type &dt )
{
m_new_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
- controlled_step_result res = try_step( sys , x , dxdt , t , m_xnew , m_dxdtnew , dt );
+ controlled_step_result res = try_step( system , x , dxdt , t , m_xnew , m_dxdtnew , dt );
if( ( res == success_step_size_increased ) || ( res == success_step_size_unchanged) )
{
boost::numeric::odeint::copy( m_xnew , x );
@@ -313,7 +318,7 @@
// try_step( sys , in , dxdt , t , out , dt )
template< class System >
- controlled_step_result try_step( System &sys , const state_type &in , const state_type &dxdt_in , time_type &t ,
+ controlled_step_result try_step( System system , const state_type &in , const state_type &dxdt_in , time_type &t ,
state_type &out , state_type &dxdt_out , time_type &dt )
{
using std::max;
@@ -324,7 +329,7 @@
//fsal: m_stepper.get_dxdt( dxdt );
//fsal: m_stepper.do_step( sys , x , dxdt , t , dt , m_x_err );
- m_stepper.do_step( sys , in , dxdt_in , t , out , dxdt_out , dt , m_xerr );
+ m_stepper.do_step( system , in , dxdt_in , t , out , dxdt_out , dt , m_xerr );
// this potentially overwrites m_x_err! (standard_error_checker does, at least)
time_type max_rel_err = m_error_checker.error( in , dxdt_in , m_xerr , dt );
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_dopri5.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_dopri5.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_dopri5.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -23,6 +23,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
+#include <boost/ref.hpp>
#include <boost/numeric/odeint/stepper/explicit_error_dopri5.hpp>
@@ -92,13 +93,14 @@
}
template< class System >
- std::pair< time_type , time_type > do_step( System &system )
+ std::pair< time_type , time_type > do_step( System system )
{
const size_t max_count = 1000;
if( !m_is_deriv_initialized )
{
- system( *m_current_state , *m_current_deriv , m_t );
+ typename boost::unwrap_reference< System >::type &sys = system;
+ sys( *m_current_state , *m_current_deriv , m_t );
m_is_deriv_initialized = true;
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -68,7 +68,7 @@
template< class System >
- std::pair< time_type , time_type > do_step( System &system )
+ std::pair< time_type , time_type > do_step( System system )
{
m_euler.do_step( system , *m_current_state , m_t , *m_old_state , m_dt );
m_t_old = m_t;
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_dopri5.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_dopri5.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_dopri5.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -12,6 +12,8 @@
#ifndef BOOST_BOOST_NUMERIC_ODEINT_STEPPER_EXPLICIT_ERROR_DOPRI5_HPP_INCLUDED
#define BOOST_BOOST_NUMERIC_ODEINT_STEPPER_EXPLICIT_ERROR_DOPRI5_HPP_INCLUDED
+#include <boost/ref.hpp>
+
#include <boost/numeric/odeint/algebra/standard_algebra.hpp>
#include <boost/numeric/odeint/algebra/standard_operations.hpp>
#include <boost/numeric/odeint/algebra/standard_resize.hpp>
@@ -84,8 +86,6 @@
void do_step_impl( System system , const state_type &in , const state_type &dxdt_in , const time_type t ,
state_type &out , state_type &dxdt_out , const time_type dt )
{
- m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
-
const time_type a2 = static_cast<time_type> ( 0.2 );
const time_type a3 = static_cast<time_type> ( 0.3 );
const time_type a4 = static_cast<time_type> ( 0.8 );
@@ -117,34 +117,38 @@
const time_type c5 = static_cast<time_type> ( -2187.0 ) / static_cast<time_type>( 6784.0 );
const time_type c6 = static_cast<time_type> ( 11.0 ) / static_cast<time_type>( 84.0 );
+ m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
+
+ typename boost::unwrap_reference< System >::type &sys = system;
+
//m_x1 = x + dt*b21*dxdt
algebra_type::for_each3( m_x1 , in , dxdt_in ,
typename operations_type::scale_sum2( 1.0 , dt*b21 ) );
- system( m_x1 , m_x2 , t + dt*a2 );
+ sys( m_x1 , m_x2 , t + dt*a2 );
// m_x1 = x + dt*b31*dxdt + dt*b32*m_x2
algebra_type::for_each4( m_x1 , in , dxdt_in , m_x2 ,
typename operations_type::scale_sum3( 1.0 , dt*b31 , dt*b32 ));
- system( m_x1 , m_x3 , t + dt*a3 );
+ sys( m_x1 , m_x3 , t + dt*a3 );
// m_x1 = x + dt * (b41*dxdt + b42*m_x2 + b43*m_x3)
algebra_type::for_each5( m_x1 , in , dxdt_in , m_x2 , m_x3 ,
typename operations_type::scale_sum4( 1.0 , dt*b41 , dt*b42 , dt*b43 ));
- system( m_x1, m_x4 , t + dt*a4 );
+ sys( m_x1, m_x4 , t + dt*a4 );
algebra_type::for_each6( m_x1 , in , dxdt_in , m_x2 , m_x3 , m_x4 ,
typename operations_type::scale_sum5( 1.0 , dt*b51 , dt*b52 , dt*b53 , dt*b54 ));
- system( m_x1 , m_x5 , t + dt*a5 );
+ sys( m_x1 , m_x5 , t + dt*a5 );
algebra_type::for_each7( m_x1 , in , dxdt_in , m_x2 , m_x3 , m_x4 , m_x5 ,
typename operations_type::scale_sum6( 1.0 , dt*b61 , dt*b62 , dt*b63 , dt*b64 , dt*b65 ));
- system( m_x1 , m_x6 , t + dt );
+ sys( m_x1 , m_x6 , t + dt );
algebra_type::for_each7( out , in , dxdt_in , m_x3 , m_x4 , m_x5 , m_x6 ,
typename operations_type::scale_sum6( 1.0 , dt*c1 , dt*c3 , dt*c4 , dt*c5 , dt*c6 ));
// the new derivative
- system( out , dxdt_out , t + dt );
+ sys( out , dxdt_out , t + dt );
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_rk54_ck.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_rk54_ck.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_error_rk54_ck.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -13,6 +13,7 @@
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_EXPLICIT_ERROR_RK54_CK_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_EXPLICIT_ERROR_RK54_CK_HPP_INCLUDED
+#include <boost/ref.hpp>
#include <boost/numeric/odeint/algebra/standard_algebra.hpp>
#include <boost/numeric/odeint/algebra/standard_operations.hpp>
@@ -82,7 +83,6 @@
template< class System >
void do_step_impl( System system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt , state_type &xerr )
{
-
const time_type c1 = static_cast<time_type> ( 37.0 ) / static_cast<time_type>( 378.0 );
const time_type c3 = static_cast<time_type> ( 250.0 ) / static_cast<time_type>( 621.0 );
const time_type c4 = static_cast<time_type> ( 125.0 ) / static_cast<time_type>( 594.0 );
@@ -107,8 +107,6 @@
template< class System >
void do_step_impl( System system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt )
{
- m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
-
const time_type a2 = static_cast<time_type> ( 0.2 );
const time_type a3 = static_cast<time_type> ( 0.3 );
const time_type a4 = static_cast<time_type> ( 0.6 );
@@ -136,29 +134,33 @@
const time_type c4 = static_cast<time_type> ( 125.0 ) / static_cast<time_type>( 594.0 );
const time_type c6 = static_cast<time_type> ( 512.0 ) / static_cast<time_type>( 1771.0 );
+ m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
+
+ typename boost::unwrap_reference< System >::type &sys = system;
+
//m_x1 = x + dt*b21*dxdt
algebra_type::for_each3( m_x1 , in , dxdt ,
typename operations_type::scale_sum2( 1.0 , dt*b21 ) );
- system( m_x1 , m_x2 , t + dt*a2 );
+ sys( m_x1 , m_x2 , t + dt*a2 );
// m_x1 = x + dt*b31*dxdt + dt*b32*m_x2
algebra_type::for_each4( m_x1 , in , dxdt , m_x2 ,
typename operations_type::scale_sum3( 1.0 , dt*b31 , dt*b32 ));
- system( m_x1 , m_x3 , t + dt*a3 );
+ sys( m_x1 , m_x3 , t + dt*a3 );
// m_x1 = x + dt * (b41*dxdt + b42*m_x2 + b43*m_x3)
algebra_type::for_each5( m_x1 , in , dxdt , m_x2 , m_x3 ,
typename operations_type::scale_sum4( 1.0 , dt*b41 , dt*b42 , dt*b43 ));
- system( m_x1, m_x4 , t + dt*a4 );
+ sys( m_x1, m_x4 , t + dt*a4 );
algebra_type::for_each6( m_x1 , in , dxdt , m_x2 , m_x3 , m_x4 ,
typename operations_type::scale_sum5( 1.0 , dt*b51 , dt*b52 , dt*b53 , dt*b54 ));
- system( m_x1 , m_x5 , t + dt*a5 );
+ sys( m_x1 , m_x5 , t + dt*a5 );
algebra_type::for_each7( m_x1 , in , dxdt , m_x2 , m_x3 , m_x4 , m_x5 ,
typename operations_type::scale_sum6( 1.0 , dt*b61 , dt*b62 , dt*b63 , dt*b64 , dt*b65 ));
- system( m_x1 , m_x6 , t + dt*a6 );
+ sys( m_x1 , m_x6 , t + dt*a6 );
algebra_type::for_each6( out , in , dxdt , m_x3 , m_x4 , m_x6 ,
typename operations_type::scale_sum5( 1.0 , dt*c1 , dt*c3 , dt*c4 , dt*c6 ));
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -45,7 +45,7 @@
BOOST_ODEINT_EXPLICIT_STEPPERS_TYPEDEFS( explicit_euler , 1 );
template< class System >
- void do_step_impl( System &system , const state_type &in , const state_type &dxdt , const time_type t , state_type & out , const time_type dt )
+ void do_step_impl( System system , const state_type &in , const state_type &dxdt , const time_type t , state_type & out , const time_type dt )
{
algebra_type::for_each3( out , in , dxdt , typename operations_type::scale_sum2( 1.0 , dt ) );
}
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_rk4.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_rk4.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_rk4.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -13,6 +13,7 @@
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_EXPLICIT_RK4_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_EXPLICIT_RK4_HPP_INCLUDED
+#include <boost/ref.hpp>
#include <boost/numeric/odeint/algebra/standard_algebra.hpp>
#include <boost/numeric/odeint/algebra/standard_operations.hpp>
@@ -65,13 +66,16 @@
}
template< class System >
- void do_step_impl( System &system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt )
+ void do_step_impl( System system , const state_type &in , const state_type &dxdt , const time_type t , state_type &out , const time_type dt )
{
- m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
// ToDo : check if size of in,dxdt,out are equal?
const time_type val1 = static_cast<time_type>( 1.0 );
+ m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
+
+ typename boost::unwrap_reference< System >::type &sys = system;
+
time_type dh = static_cast<time_type>( 0.5 ) * dt;
time_type th = t + dh;
@@ -81,20 +85,20 @@
// dt * m_dxt = k2
- system( m_xt , m_dxt , th );
+ sys( m_xt , m_dxt , th );
// m_xt = x + dh*m_dxt
algebra_type::for_each3( m_xt , in , m_dxt , typename operations_type::scale_sum2( val1 , dh ) );
// dt * m_dxm = k3
- system( m_xt , m_dxm , th );
+ sys( m_xt , m_dxm , th );
//m_xt = x + dt*m_dxm
algebra_type::for_each3( m_xt , in , m_dxm , typename operations_type::scale_sum2( val1 , dt ) );
// dt * m_dxh = k4
- system( m_xt , m_dxh , t + dt );
+ sys( m_xt , m_dxh , t + dt );
//x += dt/6 * ( m_dxdt + m_dxt + val2*m_dxm )
time_type dt6 = dt / static_cast<time_type>( 6.0 );
time_type dt3 = dt / static_cast<time_type>( 3.0 );
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/implicit_euler.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/implicit_euler.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/implicit_euler.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -36,8 +36,11 @@
{ }
template< class System , class Jacobi >
- void do_step( System &system , Jacobi &jacobi , state_type &x , value_type t , value_type dt )
+ void do_step( System system , Jacobi jacobi , state_type &x , value_type t , value_type dt )
{
+ typename boost::unwrap_reference< System >::type &sys = system;
+ typename boost::unwrap_reference< Jacobi >::type &jac = jacobi;
+
m_dxdt.resize( x.size() );
m_x.resize( x.size() );
m_b.resize( x.size() );
@@ -47,11 +50,11 @@
t += dt;
// apply first Newton step
- system( x , m_dxdt , t );
+ sys( x , m_dxdt , t );
m_b = dt * m_dxdt;
- jacobi( x , m_jacobi , t );
+ jac( x , m_jacobi , t );
m_jacobi *= dt;
m_jacobi -= boost::numeric::ublas::identity_matrix< value_type >( x.size() );
@@ -65,7 +68,7 @@
// ToDo: maybe we should apply only one Newton step -> linear implicit one-step scheme
while( boost::numeric::ublas::norm_2( m_b ) > m_epsilon )
{
- system( m_x , m_dxdt , t );
+ sys( m_x , m_dxdt , t );
m_b = x - m_x + dt*m_dxdt;
/* we use simplified newton where the jacobi matrix is evaluated only once
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/odeint_ref_problem.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/odeint_ref_problem.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/odeint_ref_problem.cpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -76,7 +76,7 @@
template< class System >
void do_step( System system , state_type &x , value_type t , value_type dt )
{
- typename boost::unwrap_reference< System >::type sys = system;
+ typename boost::unwrap_reference< System >::type &sys = system;
sys( x , m_dxdt , t );
// x = x + dt*dxdt
boost::numeric::odeint::detail::it_algebra::increment(
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/Jamfile 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -0,0 +1,21 @@
+# (C) Copyright 2010 : Karsten Ahnert, 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)
+
+import os ;
+import modules ;
+import path ;
+
+path-constant HOME : [ os.environ HOME ] ;
+path-constant CHRONO_ROOT : [ os.environ CHRONO_ROOT ] ;
+
+project
+ : requirements
+ <define>BOOST_ALL_NO_LIB=1
+ <include>../../../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+exe test_units
+ : test_units.cpp
+ ;
\ No newline at end of file
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -0,0 +1,197 @@
+/*
+ boost header: NUMERIC_ODEINT/adjust_size.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_ADJUST_SIZE_UNITS_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_ADJUST_SIZE_UNITS_HPP_INCLUDED
+
+#include <algorithm>
+
+#include <boost/noncopyable.hpp>
+#include <boost/array.hpp>
+
+#include <boost/numeric/odeint/algebra/standard_resize.hpp>
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+
+/*
+ * Tags to specify resize behavior of steppers
+ */
+struct adjust_size_manually_tag {};
+struct adjust_size_initially_tag {};
+struct adjust_size_always_tag {};
+
+
+
+
+
+
+/*
+ * Adjust size functionality with policies and resizeability
+ */
+template< class Deriv , size_t Dim >
+class size_adjuster_units : boost::noncopyable
+{
+public:
+
+ size_adjuster_units() : m_is_initialized( false ) , m_states()
+ {
+ std::fill( m_states.begin() , m_states.end() , static_cast< Deriv* >( 0 ) );
+ }
+
+ template< class State >
+ bool adjust_size( const State &x )
+ {
+ return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ }
+
+ template< class State >
+ bool adjust_size_by_policy( const State &x , adjust_size_manually_tag )
+ {
+ return false;
+ }
+
+ template< class State >
+ bool adjust_size_by_policy( const State &x , adjust_size_initially_tag )
+ {
+ if( !m_is_initialized )
+ {
+ m_is_initialized = true;
+ return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ template< class State >
+ bool adjust_size_by_policy( const State &x , adjust_size_always_tag )
+ {
+ return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ }
+
+ void register_state( size_t idx , Deriv &x )
+ {
+ m_states[idx] = &x;
+ }
+
+
+private:
+
+ template< class State >
+ bool adjust_size_by_resizeability( const State &x , boost::true_type )
+ {
+ bool changed = ( Dim > 0 );
+ for( size_t i=0 ; i<Dim ; ++i )
+ {
+ boost::numeric::odeint::adjust_size( x , *(m_states[i]) );
+ }
+ return changed;
+ }
+
+ template< class State >
+ bool adjust_size_by_resizeability( const State &x , boost::false_type )
+ {
+ return false;
+ }
+
+
+private :
+
+ bool m_is_initialized;
+ boost::array< Deriv* , Dim > m_states;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+ * really old stuff
+ */
+//template< class State , class AdjustSizeImpl >
+//class size_adjuster
+//{
+//public:
+//
+// size_adjuster( AdjustSizeImpl &adjust_size_impl ) : m_is_initialized( false ) , m_adjust_size_impl( adjust_size_impl ) { }
+//
+// void adjust_size( const State &x )
+// {
+// adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+// }
+//
+// void adjust_size_by_policy( const State &x , adjust_size_manually_tag )
+// {
+// }
+//
+// void 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;
+// }
+// }
+//
+// void adjust_size_by_policy( const State &x , adjust_size_always_tag )
+// {
+// adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+// }
+//
+//
+//private:
+//
+//
+// void adjust_size_by_resizeability( const State &x , boost::true_type )
+// {
+// m_adjust_size_impl( x );
+// }
+//
+// void adjust_size_by_resizeability( const State &x , boost::false_type )
+// {
+// }
+//
+//
+//private :
+//
+// bool m_is_initialized;
+// AdjustSizeImpl &m_adjust_size_impl;
+//};
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_NUMERIC_ODEINT_ADJUST_SIZE_UNITS_HPP_INCLUDED
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/explicit_euler_units.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/explicit_euler_units.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -0,0 +1,67 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/explicit_euler.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_BOOST_NUMERIC_ODEINT_EXPLICIT_EULER_UNITS_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_EXPLICIT_EULER_UNITS_HPP_INCLUDED
+
+#include <boost/numeric/odeint/algebra/standard_algebra.hpp>
+
+#include "explicit_stepper_base_units.hpp"
+#include "standard_operations_units.hpp"
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+template<
+ class Deriv ,
+ class Value = double ,
+ class Time = double ,
+ class Algebra = standard_algebra ,
+ class Operations = standard_operations_units ,
+ class AdjustSizePolicy = adjust_size_initially_tag
+ >
+class explicit_euler_units
+: public explicit_stepper_base_units<
+ explicit_euler_units< Deriv , Value , Time , Algebra , Operations , AdjustSizePolicy > ,
+ 1 , Deriv , Value , Time , Algebra , Operations , AdjustSizePolicy >
+{
+public :
+
+ typedef explicit_stepper_base_units<
+ explicit_euler_units< Deriv , Value , Time , Algebra , Operations , AdjustSizePolicy > ,
+ 1 , Deriv , Value , Time , Algebra , Operations , AdjustSizePolicy > stepper_base_type;
+ typedef typename stepper_base_type::deriv_type deriv_type;
+ typedef typename stepper_base_type::value_type value_type;
+ typedef typename stepper_base_type::time_type time_type;
+ typedef typename stepper_base_type::algebra_type algebra_type;
+ typedef typename stepper_base_type::operations_type operations_type;
+ typedef typename stepper_base_type::adjust_size_policy adjust_size_policy;
+ typedef typename stepper_base_type::stepper_type stepper_type;
+
+
+ template< class System , class State >
+ void do_step_impl( System system , const State &in , const deriv_type &dxdt , const time_type t , State & out , const time_type dt )
+ {
+ algebra_type::for_each3( out , in , dxdt , operations_type::make_scale_sum2( static_cast< value_type >( 1.0 ) , dt ) );
+ }
+};
+
+
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_EXPLICIT_EULER_UNITS_HPP_INCLUDED
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/explicit_stepper_base_units.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/explicit_stepper_base_units.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -0,0 +1,146 @@
+/*
+ boost header: numeric/odeint/explicit_stepper_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_BASE_UNITS_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_BASE_UNITS_HPP_INCLUDED
+
+#include <boost/noncopyable.hpp>
+#include <boost/ref.hpp>
+
+#include <boost/numeric/odeint/algebra/standard_resize.hpp>
+
+#include "adjust_size_units.hpp"
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+/*
+ * base class for explicit steppers
+ * models the stepper concept
+ */
+template<
+ class Stepper ,
+ unsigned short Order ,
+ class Deriv ,
+ class Value ,
+ class Time ,
+ class Algebra ,
+ class Operations ,
+ class AdjustSizePolicy
+>
+class explicit_stepper_base_units : boost::noncopyable
+{
+public:
+
+
+ typedef Deriv deriv_type;
+ typedef Value value_type;
+ typedef Time time_type;
+ typedef Algebra algebra_type;
+ typedef Operations operations_type;
+ typedef AdjustSizePolicy adjust_size_policy;
+ typedef Stepper stepper_type;
+
+ typedef explicit_stepper_base_units< Stepper , Order , Deriv , Value , Time , Algebra , Operations , AdjustSizePolicy > internal_stepper_base_type;
+
+ typedef unsigned short order_type;
+ static const order_type order_value = Order;
+
+
+ order_type order( void ) const
+ {
+ return order_value;
+ }
+
+
+ explicit_stepper_base_units( void ) : m_size_adjuster() , m_dxdt()
+ {
+ boost::numeric::odeint::construct( m_dxdt );
+ m_size_adjuster.register_state( 0 , m_dxdt );
+ }
+
+ ~explicit_stepper_base_units( void )
+ {
+ boost::numeric::odeint::destruct( m_dxdt );
+ }
+
+
+
+
+ // do_step( sys , x , t , dt )
+ template< class System , class State >
+ void do_step( System system , State &x , const time_type &t , const time_type &dt )
+ {
+ typename boost::unwrap_reference< System >::type &sys = system;
+ m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ sys( x , m_dxdt ,t );
+ this->stepper().do_step_impl( system , x , m_dxdt , t , x , dt );
+ }
+
+ // do_step( sys , x , dxdt , t , dt )
+ template< class System , class State >
+ void do_step( System system , State &x , const deriv_type dxdt , const time_type &t , const time_type &dt )
+ {
+ this->stepper().do_step_impl( system , x , dxdt , t , x , dt );
+ }
+
+ // do_step( sys , in , t , out , dt )
+ template< class System , class State >
+ void do_step( System system , const State &in , const time_type &t , State &out , const time_type &dt )
+ {
+ typename boost::unwrap_reference< System >::type &sys = system;
+ m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
+ sys( in , m_dxdt ,t );
+ this->stepper().do_step_impl( system , in , m_dxdt , t , out , dt );
+ }
+
+ // do_step( sys , in , dxdt , t , out , dt )
+ template< class System , class State >
+ void do_step( System system , const State &in , const deriv_type &dxdt , const time_type &t , State &out , const time_type &dt )
+ {
+ this->stepper().do_step_impl( system , in , dxdt , t , out , dt );
+ }
+
+
+
+ template< class State >
+ void adjust_size( const State &x )
+ {
+ m_size_adjuster.adjust_size( x );
+ }
+
+
+protected:
+
+ stepper_type& stepper( void )
+ {
+ return *static_cast< stepper_type* >( this );
+ }
+
+ const stepper_type& stepper( void ) const
+ {
+ return *static_cast< const stepper_type* >( this );
+ }
+
+
+ size_adjuster_units< deriv_type , 1 > m_size_adjuster;
+ deriv_type m_dxdt;
+};
+
+
+} // odeint
+} // numeric
+} // boost
+
+#endif //BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_BASE_UNITS_HPP_INCLUDED
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/standard_operations_units.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/standard_operations_units.hpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -0,0 +1,55 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/standard_operations.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_BOOST_NUMERIC_ODEINT_STANDARD_OPERATIONS_UNITS_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_STANDARD_OPERATIONS_UNITS_HPP_INCLUDED
+
+#include <algorithm> // for std::max
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+
+struct standard_operations_units
+{
+ template< class Fac1 , class Fac2 >
+ struct scale_sum2
+ {
+ const Fac1 m_alpha1;
+ const Fac2 m_alpha2;
+
+ scale_sum2( const Fac1 &alpha1 , const Fac2 &alpha2 ) : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
+
+ template< class T1 , class T2 , class T3 >
+ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3) const
+ {
+ t1 = m_alpha1 * t2 + m_alpha2 * t3;
+ }
+ };
+
+ template< class Fac1 , class Fac2 >
+ scale_sum2< Fac1 , Fac2 > make_scale_sum2( const Fac1 &alpha1 , const Fac2 &alpha2 )
+ {
+ return scale_sum2< Fac1 , Fac2 >( alpha1 , alpha2 );
+ }
+
+};
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_STANDARD_OPERATIONS_UNITS_HPP_INCLUDED
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_units.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_units.cpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -0,0 +1,64 @@
+/*
+ * test.cpp
+ *
+ * Created on: Jan 18, 2011
+ * Author: karsten
+ */
+
+#include <iostream>
+#include <tr1/array>
+
+#include <boost/units/systems/si/energy.hpp>
+#include <boost/units/systems/si/force.hpp>
+#include <boost/units/systems/si/length.hpp>
+#include <boost/units/systems/si/time.hpp>
+#include <boost/units/systems/si/electric_potential.hpp>
+#include <boost/units/systems/si/current.hpp>
+#include <boost/units/systems/si/resistance.hpp>
+#include <boost/units/systems/si/io.hpp>
+
+#include "explicit_euler_units.hpp"
+
+namespace units = boost::units;
+namespace si = boost::units::si;
+
+using std::cout;
+using std::endl;
+
+typedef units::derived_dimension< units::length_base_dimension , 1 , units::time_base_dimension , -1 > vel_type;
+
+typedef std::tr1::array< units::quantity< si::length > , 2 > state_type;
+typedef std::tr1::array< units::quantity< vel_type > , 2 > deriv_type;
+typedef units::quantity< si::time > time_type;
+
+typedef boost::numeric::odeint::explicit_euler_units< deriv_type , double , time_type > stepper_type;
+
+struct lorenz
+{
+ template< class State , class Deriv , class Time >
+ void operator()( const State &x , Deriv &dxdt , const Time &t )
+ {
+ dxdt[0] = ( x[0] / Time( 1.0 * si::second ) );
+ dxdt[0] = ( x[1] / Time( 1.0 * si::second ) );
+ }
+};
+
+
+
+int main( int argc , char **argv )
+{
+ /*
+ * zwei faelle, erstens units, zweitens ranges
+ */
+ state_type x = {{ 1.0 * si::meter , 1.0 * si::meter }};
+ time_type t( 0.0 * si::seconds ) , dt( 0.0 * si::seconds );
+ stepper_type stepper;
+ stepper.do_step( lorenz() , x , t , dt );
+
+// units::quantity< si::length > x( 2.0 * si::meter );
+// units::quantity< si::time > t( 1.0 * si::second );
+
+// cout << x * t << endl;
+
+ return 0;
+}
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -20,6 +20,7 @@
#include <iostream>
#include <tr1/array>
+#include <boost/ref.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/mpl/vector.hpp>
@@ -52,6 +53,8 @@
typedef vector_space_1d< double > vector_space_type;
typedef std::tr1::array< double , 1 > array_type;
+const double result = 2.2;
+
typedef mpl::vector< vector_type , vector_space_type , array_type >::type container_types;
@@ -59,6 +62,29 @@
template<> struct algebra_dispatcher< vector_space_type > { typedef vector_space_algebra type; };
template<> struct algebra_dispatcher< double > { typedef vector_space_algebra type; };
+struct constant_system_vector_class
+{
+ void operator()( const vector_type &x , vector_type &dxdt , double t ) const
+ {
+ dxdt[0] = 1.0;
+ }
+};
+
+struct constant_system_vector_space_class
+{
+ void operator()( const vector_space_type &x , vector_space_type &dxdt , double t ) const
+ {
+ dxdt.m_x = 1.0;
+ }
+};
+
+struct constant_system_array_class
+{
+ void operator()( const array_type &x , array_type &dxdt , double t ) const
+ {
+ dxdt[0] = 1.0;
+ }
+};
void constant_system_vector( const vector_type &x , vector_type &dxdt , double t ) { dxdt[0] = 1.0; }
void constant_system_vector_space( const vector_space_type &x , vector_space_type &dxdt , double t ) { dxdt.m_x = 1.0; }
@@ -115,7 +141,8 @@
vector_type x( 1 , 2.0 );
Stepper stepper;
check_stepper_concept( stepper , constant_system_vector , x );
- BOOST_CHECK_SMALL( fabs( x[0] - 2.1 ) , eps );
+ check_stepper_concept( stepper , boost::cref( constant_system_vector_class() ) , x );
+ BOOST_CHECK_SMALL( fabs( x[0] - result ) , eps );
}
};
@@ -128,7 +155,8 @@
x.m_x = 2.0;
Stepper stepper;
check_stepper_concept( stepper , constant_system_vector_space , x );
- BOOST_CHECK_SMALL( fabs( x.m_x - 2.1 ) , eps );
+ check_stepper_concept( stepper , boost::cref( constant_system_vector_space_class() ) , x );
+ BOOST_CHECK_SMALL( fabs( x.m_x - result ) , eps );
}
};
@@ -141,7 +169,8 @@
x[0] = 2.0;
Stepper stepper;
check_stepper_concept( stepper , constant_system_array , x );
- BOOST_CHECK_SMALL( fabs( x[0] - 2.1 ) , eps );
+ check_stepper_concept( stepper , boost::cref( constant_system_array_class() ) , x );
+ BOOST_CHECK_SMALL( fabs( x[0] - result ) , eps );
}
};
@@ -209,7 +238,8 @@
vector_type x( 1 , 2.0 ) , xerr( 1 );
Stepper stepper;
check_error_stepper_concept( stepper , constant_system_vector , x , xerr );
- BOOST_CHECK_SMALL( fabs( x[0] - 2.1 ) , eps );
+ check_error_stepper_concept( stepper , boost::cref( constant_system_vector_class() ) , x , xerr );
+ BOOST_CHECK_SMALL( fabs( x[0] - result ) , eps );
}
};
@@ -223,7 +253,8 @@
x.m_x = 2.0;
Stepper stepper;
check_error_stepper_concept( stepper , constant_system_vector_space , x , xerr );
- BOOST_CHECK_SMALL( fabs( x.m_x - 2.1 ) , eps );
+ check_error_stepper_concept( stepper , boost::cref( constant_system_vector_space_class() ) , x , xerr );
+ BOOST_CHECK_SMALL( fabs( x.m_x - result ) , eps );
}
};
@@ -236,7 +267,8 @@
x[0] = 2.0;
Stepper stepper;
check_error_stepper_concept( stepper , constant_system_array , x , xerr );
- BOOST_CHECK_SMALL( fabs( x[0] - 2.1 ) , eps );
+ check_error_stepper_concept( stepper , boost::cref( constant_system_array_class() ) , x , xerr );
+ BOOST_CHECK_SMALL( fabs( x[0] - result ) , eps );
}
};
@@ -303,7 +335,8 @@
error_checker_standard< typename ControlledStepper::state_type , typename ControlledStepper::time_type > error_checker;
ControlledStepper controlled_stepper( error_stepper , error_checker );
check_controlled_stepper_concept( controlled_stepper , constant_system_vector , x );
- BOOST_CHECK_SMALL( fabs( x[0] - 2.1 ) , eps );
+ check_controlled_stepper_concept( controlled_stepper , boost::cref( constant_system_vector_class() ) , x );
+ BOOST_CHECK_SMALL( fabs( x[0] - result ) , eps );
}
};
@@ -318,7 +351,8 @@
error_checker_standard< typename ControlledStepper::state_type , typename ControlledStepper::time_type , vector_space_algebra > error_checker;
ControlledStepper controlled_stepper( error_stepper , error_checker );
check_controlled_stepper_concept( controlled_stepper , constant_system_vector_space , x );
- BOOST_CHECK_SMALL( fabs( x.m_x - 2.1 ) , eps );
+ check_controlled_stepper_concept( controlled_stepper , boost::cref( constant_system_vector_space_class() ) , x );
+ BOOST_CHECK_SMALL( fabs( x.m_x - result ) , eps );
}
};
@@ -333,7 +367,8 @@
error_checker_standard< typename ControlledStepper::state_type , typename ControlledStepper::time_type > error_checker;
ControlledStepper controlled_stepper( error_stepper , error_checker );
check_controlled_stepper_concept( controlled_stepper , constant_system_array , x );
- BOOST_CHECK_SMALL( fabs( x[0] - 2.1 ) , eps );
+ check_controlled_stepper_concept( controlled_stepper , boost::cref( constant_system_array_class() ) , x );
+ BOOST_CHECK_SMALL( fabs( x[0] - result ) , eps );
}
};
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/thrust/Makefile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/thrust/Makefile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/thrust/Makefile 2011-01-18 08:14:20 EST (Tue, 18 Jan 2011)
@@ -6,7 +6,7 @@
INCLUDES += -I$(BOOST_ROOT) -I$(THRUST_ROOT) -I$(CUDA_ROOT)/include -I../../../../..
-NVCCFLAGS = -O3 $(INCLUDES) --compiler-bindir=/usr/bin/g++-4.3
+NVCCFLAGS = -O3 $(INCLUDES) --compiler-bindir=/usr/bin/g++-4.4
LDLIBS = -lcudart
LDFLAGS = -L$(CUDA_ROOT)/lib64
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