Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57458 - in sandbox/odeint: boost/numeric/odeint libs/numeric/odeint/stuff/iterator_algebra
From: mario.mulansky_at_[hidden]
Date: 2009-11-07 12:47:52


Author: mariomulansky
Date: 2009-11-07 12:47:51 EST (Sat, 07 Nov 2009)
New Revision: 57458
URL: http://svn.boost.org/trac/boost/changeset/57458

Log:
added some comments when using iterator algebra

Text files modified:
   sandbox/odeint/boost/numeric/odeint/euler.hpp | 10 +++++-----
   sandbox/odeint/boost/numeric/odeint/runge_kutta_4.hpp | 30 +++++++++++++++++-------------
   sandbox/odeint/boost/numeric/odeint/stepper_half_step.hpp | 8 ++++----
   sandbox/odeint/libs/numeric/odeint/stuff/iterator_algebra/increment_decrement.cc | 18 +++++++++---------
   4 files changed, 35 insertions(+), 31 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-11-07 12:47:51 EST (Sat, 07 Nov 2009)
@@ -118,11 +118,11 @@
             next_step( system , m_xtemp , dxdt , t , dt2 );
             next_step( system , m_xtemp , t+dt2 , dt2 );
 
- detail::it_algebra::assign_diff(
- xerr.begin() ,
- xerr.end() ,
- x.begin() ,
- m_xtemp.begin() );
+ //xerr = x - m_xtemp
+ detail::it_algebra::assign_diff(xerr.begin() ,
+ xerr.end() ,
+ x.begin() ,
+ m_xtemp.begin() );
         }
 
 

Modified: sandbox/odeint/boost/numeric/odeint/runge_kutta_4.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/runge_kutta_4.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/runge_kutta_4.hpp 2009-11-07 12:47:51 EST (Sat, 07 Nov 2009)
@@ -30,7 +30,7 @@
 
     template<
         class Container ,
- class Time = double ,
+ class Time = double ,
         class Resizer = resizer< Container >
>
     class ode_step_runge_kutta_4
@@ -53,7 +53,7 @@
     private:
 
         BOOST_CLASS_REQUIRE( container_type ,
- boost::numeric::odeint, StateType );
+ boost::numeric::odeint, StateType );
 
 
 
@@ -71,7 +71,7 @@
 
 
 
- // public interface
+ // public interface
     public:
 
         template< class DynamicalSystem >
@@ -80,30 +80,34 @@
                         time_type t ,
                         time_type dt )
         {
- using namespace detail::it_algebra;
+ using namespace detail::it_algebra;
 
             const time_type val2 = time_type( 2.0 );
 
- m_resizer.adjust_size( x , m_dxdt );
- m_resizer.adjust_size( x , m_dxt );
- m_resizer.adjust_size( x , m_dxm );
- m_resizer.adjust_size( x , m_xt );
+ m_resizer.adjust_size( x , m_dxdt );
+ m_resizer.adjust_size( x , m_dxt );
+ m_resizer.adjust_size( x , m_dxm );
+ m_resizer.adjust_size( x , m_xt );
 
             time_type dh = time_type( 0.5 ) * dt;
             time_type th = t + dh;
 
             system( x , m_dxdt , t );
- assign_sum( m_xt.begin() , m_xt.end() , x.begin() , m_dxdt.begin() , dh );
+ //m_xt = x + dh*m_dxdt
+ assign_sum( m_xt.begin() , m_xt.end() , x.begin() , m_dxdt.begin() , dh );
 
             system( m_xt , m_dxt , th );
- assign_sum( m_xt.begin() , m_xt.end() , x.begin() , m_dxt.begin() , dh );
+ //m_xt = x + dh*m_dxdt
+ assign_sum( m_xt.begin() , m_xt.end() , x.begin() , m_dxt.begin() , dh );
 
             system( m_xt , m_dxm , th );
- assign_sum_increment( m_xt.begin() , m_xt.end() , x.begin() , m_dxm.begin() , m_dxt.begin() , dt );
+ //m_xt = x + dt*m_dxm ; m_dxm += m_dxt
+ assign_sum_increment( m_xt.begin() , m_xt.end() , x.begin() , m_dxm.begin() , m_dxt.begin() , dt );
 
             system( m_xt , m_dxt , value_type( t + dt ) );
- increment_sum_sum( x.begin() , x.end() , m_dxdt.begin() , m_dxt.begin() , m_dxm.begin() , dt / time_type( 6.0 ) , val2
- );
+ //x = dt/6 * ( m_dxdt + m_dxt + val2*m_dxm )
+ increment_sum_sum( x.begin() , x.end() , m_dxdt.begin() , m_dxt.begin() , m_dxm.begin() , dt / time_type( 6.0 ) , val2
+ );
         }
 
 

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 2009-11-07 12:47:51 EST (Sat, 07 Nov 2009)
@@ -37,7 +37,7 @@
         // provide basic typedefs
     public:
 
- typedef Stepper stepper_type;
+ typedef Stepper stepper_type;
         typedef typename Stepper::container_type container_type;
         typedef typename Stepper::resizer_type resizer_type;
         typedef typename Stepper::time_type time_type;
@@ -56,7 +56,7 @@
         container_type m_dxdt;
         container_type m_xtemp;
         resizer_type m_resizer;
- stepper_type m_stepper;
+ stepper_type m_stepper;
         
 
         const unsigned int order() { return m_stepper.order(); }
@@ -70,7 +70,7 @@
                         time_type t ,
                         time_type dt )
         {
- m_stepper.next_step( system , x , dxdt , t , dt );
+ m_stepper.next_step( system , x , dxdt , t , dt );
         }
 
 
@@ -81,7 +81,7 @@
                         time_type t ,
                         time_type dt )
         {
- m_stepper.next_step( system , x , t , dt );
+ m_stepper.next_step( system , x , t , dt );
         }
 
         /*

Modified: sandbox/odeint/libs/numeric/odeint/stuff/iterator_algebra/increment_decrement.cc
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/stuff/iterator_algebra/increment_decrement.cc (original)
+++ sandbox/odeint/libs/numeric/odeint/stuff/iterator_algebra/increment_decrement.cc 2009-11-07 12:47:51 EST (Sat, 07 Nov 2009)
@@ -202,17 +202,17 @@
 
 
     cout << endl << endl;
- cout << "Berechne a += 0.25*b, mit " << endl;
- cout << "1. a += 0.25 * b" << endl;
- cout << "2. a -= (-0.25)*b" << endl;
- cout << "3. a += lambda( 0.25 *_1)" << endl;
- cout << "4. a -= lambda( -0.25 *_1)" << endl;
+ cout << "Berechne a += 0.33*b, mit " << endl;
+ cout << "1. a += 0.33 * b" << endl;
+ cout << "2. a -= (-0.33)*b" << endl;
+ cout << "3. a += lambda( 0.33 *_1)" << endl;
+ cout << "4. a -= lambda( -0.33 *_1)" << endl;
 
     eins1 = eins;
     zwei1 = zwei;
     st1 = clock();
     for( size_t i=0 ; i<cycles ; ++i )
- increment( eins1.begin() , eins1.end() , zwei1.begin() , 0.25 );
+ increment( eins1.begin() , eins1.end() , zwei1.begin() , 0.33 );
     et1 = clock();
     time1 = double( et1 - st1 ) / double( CLOCKS_PER_SEC );
     cout << "1." << tab << time1 << endl;
@@ -221,7 +221,7 @@
     zwei1 = zwei;
     st2 = clock();
     for( size_t i=0 ; i<cycles ; ++i )
- decrement( eins1.begin() , eins1.end() , zwei1.begin() , -0.25 );
+ decrement( eins1.begin() , eins1.end() , zwei1.begin() , -0.33 );
     et2 = clock();
     time2 = double( et2 - st2 ) / double( CLOCKS_PER_SEC );
     cout << "2." << tab << time2 << endl;
@@ -231,7 +231,7 @@
     zwei1 = zwei;
     st3 = clock();
     for( size_t i=0 ; i<cycles ; ++i )
- increment_op( eins1.begin() , eins1.end() , zwei1.begin() , 0.25 * _1 );
+ increment_op( eins1.begin() , eins1.end() , zwei1.begin() , 0.33 * _1 );
     et3 = clock();
     time3 = double( et3 - st3 ) / double( CLOCKS_PER_SEC );
     cout << "3." << tab << time3 << endl;
@@ -240,7 +240,7 @@
     zwei1 = zwei;
     st4 = clock();
     for( size_t i=0 ; i<cycles ; ++i )
- decrement_op( eins1.begin() , eins1.end() , zwei1.begin() , -0.25 * _1 );
+ decrement_op( eins1.begin() , eins1.end() , zwei1.begin() , -0.33 * _1 );
     et4 = clock();
     time4 = double( et4 - st4 ) / double( CLOCKS_PER_SEC );
     cout << "4." << tab << time4 << endl;


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