Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60381 - in sandbox/odeint: . boost/numeric/odeint libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2010-03-09 10:07:27


Author: karsten
Date: 2010-03-09 10:07:26 EST (Tue, 09 Mar 2010)
New Revision: 60381
URL: http://svn.boost.org/trac/boost/changeset/60381

Log:
rk5 ck und rk78 updated
Binary files modified:
   sandbox/odeint/boost/numeric/odeint/stepper_rk5_ck.hpp
Text files modified:
   sandbox/odeint/ToDo | 2
   sandbox/odeint/boost/numeric/odeint/stepper_half_step.hpp | 43 +++++++++++++++-------------
   sandbox/odeint/boost/numeric/odeint/stepper_rk78_fehlberg.hpp | 58 +++++++++++++++++++++++++--------------
   sandbox/odeint/libs/numeric/odeint/test/check_stepper_concepts.cpp | 30 ++++++++++++++++----
   4 files changed, 85 insertions(+), 48 deletions(-)

Modified: sandbox/odeint/ToDo
==============================================================================
--- sandbox/odeint/ToDo (original)
+++ sandbox/odeint/ToDo 2010-03-09 10:07:26 EST (Tue, 09 Mar 2010)
@@ -22,7 +22,7 @@
   * stepper_midpoint.hpp - DONE, changed stepcount -> step_number
   * stepper_rk4_classical.hpp - DONE
   * stepper_rk4.hpp - DONE
- * stepper_rk5_ck.hpp
+ * stepper_rk5_ck.hpp - DONE
   * stepper_rk78_fehlberg.hpp
   * stepper_rk_generic.hpp
 * die auskommentierten Iteratoren typedefs entfernen

Modified: sandbox/odeint/boost/numeric/odeint/stepper_half_step.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/stepper_half_step.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/stepper_half_step.hpp 2010-03-09 10:07:26 EST (Tue, 09 Mar 2010)
@@ -60,17 +60,40 @@
     public:
 
 
+ // the order of the step if a normal step is performed
+ order_type order_step( void ) const
+ {
+ return m_stepper.order_step();
+ }
+
+
+ // the order of the step if an error step is performed
+ order_type order_error_step( void ) const
+ {
+ return m_stepper.order_step();
+ }
+
+
+ // the order of the error term if the error step is performed
+ order_type order_error( void ) const
+ {
+ return m_stepper.order_step() + 1;
+ }
+
+
         // standard constructor
         stepper_half_step( void )
         {
         }
 
+
         // contructor, which adjust the size of internal containers
         stepper_half_step( const container_type &x )
         {
             adjust_size( x );
         }
 
+
         // adjust the size of m_dxdt , m_xtemp und m_stepper
         void adjust_size( const container_type &x )
         {
@@ -79,26 +102,6 @@
             traits_type::adjust_size( x , m_xtemp );
         }
 
- // the order of the step if a normal step is performed
- order_type order_step( void ) const
- {
-
- return m_stepper.order_step();
- }
-
- // the order of the step if an error step is performed
- order_type order_error_step( void ) const
- {
-
- return m_stepper.order_step();
- }
-
- // the order of the error term if the error step is performed
- order_type order_error( void ) const
- {
-
- return m_stepper.order_step() + 1;
- }
 
 
         // performs a normal step, without error calculation

Modified: sandbox/odeint/boost/numeric/odeint/stepper_rk5_ck.hpp
==============================================================================
Binary files. No diff available.

Modified: sandbox/odeint/boost/numeric/odeint/stepper_rk78_fehlberg.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/stepper_rk78_fehlberg.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/stepper_rk78_fehlberg.hpp 2010-03-09 10:07:26 EST (Tue, 09 Mar 2010)
@@ -34,8 +34,8 @@
         typedef Traits traits_type;
         typedef typename traits_type::container_type container_type;
         typedef typename traits_type::value_type value_type;
- typedef typename traits_type::iterator iterator;
- typedef typename traits_type::const_iterator const_iterator;
+// typedef typename traits_type::iterator iterator;
+// typedef typename traits_type::const_iterator const_iterator;
 
 
 
@@ -59,9 +59,42 @@
         // public interface
     public:
 
- order_type order() const { return 7; }
+ order_type order_step( void ) const { return 8; }
 
- order_type order_error() const { return 8; }
+ order_type order_error_step( void ) const { return 7; }
+
+ order_type order_error( void ) const { return 8; }
+
+ // standard constructor, leaves the internal containers uninitialized
+ stepper_rk78_fehlberg( void )
+ {
+ }
+
+
+ // constructor, which adjusts the internal containers
+ stepper_rk78_fehlberg( const container_type &x )
+ {
+ adjust_size( x );
+ }
+
+
+ void adjust_size( const container_type &x )
+ {
+ traits_type::adjust_size( x , m_dxdt );
+ traits_type::adjust_size( x , m_xt );
+ traits_type::adjust_size( x , m_k02 );
+ traits_type::adjust_size( x , m_k03 );
+ traits_type::adjust_size( x , m_k04 );
+ traits_type::adjust_size( x , m_k05 );
+ traits_type::adjust_size( x , m_k06 );
+ traits_type::adjust_size( x , m_k07 );
+ traits_type::adjust_size( x , m_k08 );
+ traits_type::adjust_size( x , m_k09 );
+ traits_type::adjust_size( x , m_k10 );
+ traits_type::adjust_size( x , m_k11 );
+ traits_type::adjust_size( x , m_k12 );
+ traits_type::adjust_size( x , m_k13 );
+ }
 
         template< class DynamicalSystem >
         void do_step( DynamicalSystem &system ,
@@ -176,22 +209,6 @@
             m_t12 = t;
             m_t13 = t + dt;
 
- // resize
- traits_type::adjust_size( x , m_xt );
- traits_type::adjust_size( x , m_k02 );
- traits_type::adjust_size( x , m_k03 );
- traits_type::adjust_size( x , m_k04 );
- traits_type::adjust_size( x , m_k05 );
- traits_type::adjust_size( x , m_k06 );
- traits_type::adjust_size( x , m_k07 );
- traits_type::adjust_size( x , m_k08 );
- traits_type::adjust_size( x , m_k09 );
- traits_type::adjust_size( x , m_k10 );
- traits_type::adjust_size( x , m_k11 );
- traits_type::adjust_size( x , m_k12 );
- traits_type::adjust_size( x , m_k13 );
-
-
             // k1, the first system call has allready been evaluated
 
             // k2 step
@@ -337,7 +354,6 @@
                       time_type t ,
                       time_type dt )
         {
- traits_type::adjust_size( x , m_dxdt );
             system( x , m_dxdt , t );
             do_step( system , x , m_dxdt , t , dt );
         }

Modified: sandbox/odeint/libs/numeric/odeint/test/check_stepper_concepts.cpp
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/test/check_stepper_concepts.cpp (original)
+++ sandbox/odeint/libs/numeric/odeint/test/check_stepper_concepts.cpp 2010-03-09 10:07:26 EST (Tue, 09 Mar 2010)
@@ -20,6 +20,8 @@
 #include <boost/numeric/odeint/stepper_midpoint.hpp>
 #include <boost/numeric/odeint/stepper_rk4_classical.hpp>
 #include <boost/numeric/odeint/stepper_rk4.hpp>
+#include <boost/numeric/odeint/stepper_rk5_ck.hpp>
+#include <boost/numeric/odeint/stepper_rk78_fehlberg.hpp>
 
 using namespace boost::unit_test;
 using namespace boost::numeric::odeint;
@@ -37,6 +39,7 @@
 };
 
 
+const double eps = 1.0e-14;
 
 template< class Stepper >
 void check_stepper_concept( Stepper &stepper ,
@@ -56,11 +59,11 @@
     container_type x( 1 , 0.0 ) ;
     stepper.adjust_size( x );
     stepper.do_step( con , x , 0.0 , 0.1 );
- BOOST_CHECK_CLOSE( x[0] , 0.1 , 1.0e-14 );
+ BOOST_CHECK_SMALL( fabs( x[0] - 0.1 ) , eps );
 
     container_type dxdt( 1 , 1.0 );
     stepper.do_step( con , x , dxdt , 0.0 , 0.1 );
- BOOST_CHECK_CLOSE( x[0] , 0.2 , 1.0e-14 );
+ BOOST_CHECK_SMALL( fabs( x[0] - 0.2 ) , eps );
 
     stepper_type stepper2( x );
     stepper_type stepper3;
@@ -91,13 +94,13 @@
     stepper.adjust_size( x );
 
     stepper.do_step( con , x , 0.0 , 0.1 , xerr );
- BOOST_CHECK_CLOSE( x[0] , 0.1 , 1.0e-14 );
- BOOST_CHECK_CLOSE( xerr[0] , 0.0 , 1.0e-14 );
+ BOOST_CHECK_SMALL( fabs( x[0] - 0.1 ) , eps );
+ BOOST_CHECK_SMALL( fabs( xerr[0] ) , eps );
 
     container_type dxdt( 1 , 1.0 );
     stepper.do_step( con , x , dxdt , 0.0 , 0.1 , xerr );
- BOOST_CHECK_CLOSE( x[0] , 0.2 , 1.0e-14 );
- BOOST_CHECK_CLOSE( xerr[0] , 0.0 , 1.0e-14 );
+ BOOST_CHECK_SMALL( fabs( x[0] - 0.2 ) , eps );
+ BOOST_CHECK_SMALL( fabs( xerr[0] ) , eps );
 
     stepper_type stepper2( x );
     stepper_type stepper3;
@@ -143,6 +146,19 @@
     check_stepper_concept( stepper , 4 );
 }
 
+void test_rk5_ck_concept()
+{
+ stepper_rk5_ck< std::vector<double> > stepper;
+ check_error_stepper_concept( stepper , 5 , 5 );
+}
+
+void test_rk78_fehlberg_concept()
+{
+ stepper_rk78_fehlberg< std::vector<double> > stepper;
+ check_stepper_concept( stepper , 8 );
+// check_error_stepper_concept( stepper , 7 , 8 );
+}
+
 
 
 
@@ -155,6 +171,8 @@
     test->add( BOOST_TEST_CASE( &test_midpoint_concept ) );
     test->add( BOOST_TEST_CASE( &test_rk4_classical_concept ) );
     test->add( BOOST_TEST_CASE( &test_rk4_concept ) );
+ test->add( BOOST_TEST_CASE( &test_rk5_ck_concept ) );
+ test->add( BOOST_TEST_CASE( &test_rk78_fehlberg_concept ) );
 
     return test;
 }


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