Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68230 - sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units
From: karsten.ahnert_at_[hidden]
Date: 2011-01-18 09:53:23


Author: karsten
Date: 2011-01-18 09:53:19 EST (Tue, 18 Jan 2011)
New Revision: 68230
URL: http://svn.boost.org/trac/boost/changeset/68230

Log:
* finished ideas/units
Added:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_ranges.cpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/Jamfile | 6 ++
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp | 83 +--------------------------------------
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/standard_operations_units.hpp | 2
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_units.cpp | 18 ++++----
   4 files changed, 19 insertions(+), 90 deletions(-)

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/Jamfile 2011-01-18 09:53:19 EST (Tue, 18 Jan 2011)
@@ -18,4 +18,8 @@
 
 exe test_units
     : test_units.cpp
- ;
\ No newline at end of file
+ ;
+
+exe test_ranges
+ : test_ranges.cpp
+ ;
\ No newline at end of file

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp 2011-01-18 09:53:19 EST (Tue, 18 Jan 2011)
@@ -37,8 +37,6 @@
 
 
 
-
-
 /*
  * Adjust size functionality with policies and resizeability
  */
@@ -55,7 +53,7 @@
         template< class State >
         bool adjust_size( const State &x )
         {
- return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ return adjust_size_by_resizeability( x , typename is_resizeable< Deriv >::type() );
         }
 
         template< class State >
@@ -70,7 +68,7 @@
                 if( !m_is_initialized )
                 {
                         m_is_initialized = true;
- return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ return adjust_size_by_resizeability( x , typename is_resizeable< Deriv >::type() );
                 }
                 else
                 {
@@ -81,7 +79,7 @@
         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() );
+ return adjust_size_by_resizeability( x , typename is_resizeable< Deriv >::type() );
         }
 
         void register_state( size_t idx , Deriv &x )
@@ -95,12 +93,11 @@
         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;
+ return ( Dim > 0 );
         }
 
         template< class State >
@@ -117,78 +114,6 @@
 };
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/*
- * 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

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/standard_operations_units.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/standard_operations_units.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/standard_operations_units.hpp 2011-01-18 09:53:19 EST (Tue, 18 Jan 2011)
@@ -39,7 +39,7 @@
         };
 
         template< class Fac1 , class Fac2 >
- scale_sum2< Fac1 , Fac2 > make_scale_sum2( const Fac1 &alpha1 , const Fac2 &alpha2 )
+ static scale_sum2< Fac1 , Fac2 > make_scale_sum2( const Fac1 &alpha1 , const Fac2 &alpha2 )
         {
                 return scale_sum2< Fac1 , Fac2 >( alpha1 , alpha2 );
         }

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_ranges.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_ranges.cpp 2011-01-18 09:53:19 EST (Tue, 18 Jan 2011)
@@ -0,0 +1,33 @@
+/*
+ * test_ranges.cpp
+ *
+ * Created on: Jan 18, 2011
+ * Author: karsten
+ */
+
+#include <iostream>
+#include <vector>
+#include <tr1/array>
+
+#include "explicit_euler_units.hpp"
+
+typedef std::vector< double > deriv_type;
+
+typedef boost::numeric::odeint::explicit_euler_units< deriv_type > stepper_type;
+
+struct harm_osc
+{
+ template< class State , class Deriv >
+ void operator()( const State &x , Deriv &dxdt , double t )
+ {
+ dxdt[0] = x[1];
+ dxdt[1] = -x[0];
+ }
+};
+
+int main( int argc , char **argv )
+{
+ stepper_type stepper;
+ std::tr1::array< double , 2 > x = {{ 1.0 , 0.0 }};
+ stepper.do_step( harm_osc() , x , 0.0 , 0.1 );
+}

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_units.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_units.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/test_units.cpp 2011-01-18 09:53:19 EST (Tue, 18 Jan 2011)
@@ -25,12 +25,14 @@
 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::length > length_type;
+typedef units::quantity< si::velocity > vel_type;
 typedef units::quantity< si::time > time_type;
 
+typedef std::tr1::array< length_type , 2 > state_type;
+typedef std::tr1::array< vel_type , 2 > deriv_type;
+
+
 typedef boost::numeric::odeint::explicit_euler_units< deriv_type , double , time_type > stepper_type;
 
 struct lorenz
@@ -39,7 +41,7 @@
         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 ) );
+ dxdt[1] = ( x[1] / Time( 1.0 * si::second ) );
         }
 };
 
@@ -47,17 +49,15 @@
 
 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 );
 
+ vel_type a( 1.0 * si::meter / si::seconds );
+
 // units::quantity< si::length > x( 2.0 * si::meter );
 // units::quantity< si::time > t( 1.0 * si::second );
-
 // cout << x * t << endl;
 
         return 0;


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