|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r68408 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/algebra boost/numeric/odeint/stepper libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2011-01-23 18:37:37
Author: karsten
Date: 2011-01-23 18:37:36 EST (Sun, 23 Jan 2011)
New Revision: 68408
URL: http://svn.boost.org/trac/boost/changeset/68408
Log:
finished implementing support for units
Text files modified:
sandbox/odeint/branches/karsten/TODO | 5 +++--
sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_operations.hpp | 19 ++++++++++++-------
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/error_checker.hpp | 12 ++++++------
sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_units.cpp | 6 +++---
4 files changed, 24 insertions(+), 18 deletions(-)
Modified: sandbox/odeint/branches/karsten/TODO
==============================================================================
--- sandbox/odeint/branches/karsten/TODO (original)
+++ sandbox/odeint/branches/karsten/TODO 2011-01-23 18:37:36 EST (Sun, 23 Jan 2011)
@@ -4,19 +4,20 @@
OK * test fusion_algebra
* test vector_space_algebra
* test copying
-* change standard_operations::rel_error in order to word with units and test it
+OK * change standard_operations::rel_error in order to word with units and test it
* include implicit euler
* call via std::pair< deriv , jacobi >
* resizing
+* include rosenbrock4 in trunk
OK * operations that fit units
OK * operations that fit result_of
* include test/thrust in jam system, use system from
OK * change stepper to stepper_units
OK * change error_stepper to error_stepper_units
DIFFICULT * finishing change of controlled_stepper to units
- * DO THIS WHEN INCLUDING ROSENBROCK INTO TRUNK
* check if rosenbrock controller and controlled_stepper can both be used with the explicit steppers
* move error_checker into controlled_stepper
+ * rename controlled_stepper to a more specific name
DIFICULT * change dense_output to units
* roll out dense_output_explicit_euler::calc_state() to explicit_euler::dense_output()
* roll out dense_output_dopri5::calc_state() to explicit_error_dopri5::dense_output()
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_operations.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_operations.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_operations.hpp 2011-01-23 18:37:36 EST (Sun, 23 Jan 2011)
@@ -24,7 +24,7 @@
namespace odeint {
/*
- * Conversion of boost::units for use in standard_operations::rel_error
+ * Conversion of boost::units for use in standard_operations::rel_error and standard_operations::maximum
*/
namespace detail
{
@@ -251,24 +251,29 @@
using detail::set_value;
set_value( t3 , abs( get_value( t3 ) ) / ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_value( t1 ) ) + m_a_dxdt * abs( get_value( t2 ) ) ) ) );
}
+
+ typedef void result_type;
};
/*
* for usage in reduce
- *
- * ToDo : check if T1, T2 are units and if so convert them to normal floats
*/
- template< class Fac1 = double >
+
+ template< class Value >
struct maximum
{
- template< class T1 , class T2 >
- Fac1 operator()( const T1 &t1 , const T2 &t2 ) const
+ template< class Fac1 , class Fac2 >
+ Value operator()( const Fac1 &t1 , const Fac2 &t2 ) const
{
using std::max;
using std::abs;
- return max( abs( t1 ) , abs( t2 ) );
+ using detail::get_value;
+ Value a1 = abs( get_value( t1 ) ) , a2 = abs( get_value( t2 ) );
+ return ( a1 < a2 ) ? a2 : a1 ;
}
+
+ typedef Value result_type;
};
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/error_checker.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/error_checker.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/error_checker.hpp 2011-01-23 18:37:36 EST (Sun, 23 Jan 2011)
@@ -21,6 +21,9 @@
namespace odeint {
+/*
+ * ToDo: implement constructor with epsilons
+ */
template
<
class Value ,
@@ -40,15 +43,12 @@
{}
- /*
- * ToDo: implement constructor with epsilons
- */
- template< class State , class Deriv , class Err >
- value_type error( const State &x_old , const Deriv &dxdt_old , Err &x_err , const value_type &dt )
+ template< class State , class Deriv , class Err , class Time >
+ value_type error( const State &x_old , const Deriv &dxdt_old , Err &x_err , const Time &dt )
{
// this overwrites x_err !
typename algebra_type::for_each3()( x_old , dxdt_old , x_err ,
- typename operations_type::template rel_error< value_type >( m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt*dt ) );
+ typename operations_type::template rel_error< value_type >( m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt * detail::get_value( dt ) ) );
value_type res = typename algebra_type::reduce()( x_err , typename operations_type::template maximum< value_type >() , 0.0 );
return res;
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_units.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_units.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_units.cpp 2011-01-23 18:37:36 EST (Sun, 23 Jan 2011)
@@ -188,12 +188,12 @@
// typedef typename stepper_type::algebra_type algebra_type;
// typedef typename stepper_type::operations_type operations_type;
- const time_type t( 0.0 * si::second );
+ time_type t( 0.0 * si::second );
time_type dt( 0.1 * si::second );
- state_type x( 1.0 * si::meter , 0.0 * si::meter_per_second ) , xerr;
+ state_type x( 1.0 * si::meter , 0.0 * si::meter_per_second );
// test call method one
-// stepper.try_step( oscillator , x , t , dt );
+ stepper.try_step( oscillator , x , 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