Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68317 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/algebra boost/numeric/odeint/stepper libs/numeric/odeint/ideas/units libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2011-01-20 04:09:48


Author: karsten
Date: 2011-01-20 04:09:44 EST (Thu, 20 Jan 2011)
New Revision: 68317
URL: http://svn.boost.org/trac/boost/changeset/68317

Log:
* changing dense output in order to word with units
* introducing operations unit test
Added:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_operations.cpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/TODO | 15 +++++++++++----
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_operations.hpp | 13 ++++++-------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/vector_space_reduce.hpp | 7 +++++--
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_dopri5.hpp | 12 +++++++-----
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/dense_output_explicit_euler.hpp | 10 +++++++---
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp | 4 ++--
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/Jamfile | 6 +++---
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile | 17 +++++++++--------
   8 files changed, 50 insertions(+), 34 deletions(-)

Modified: sandbox/odeint/branches/karsten/TODO
==============================================================================
--- sandbox/odeint/branches/karsten/TODO (original)
+++ sandbox/odeint/branches/karsten/TODO 2011-01-20 04:09:44 EST (Thu, 20 Jan 2011)
@@ -6,10 +6,17 @@
 * include test/thrust in jam system, use system from
 OK * change stepper to stepper_units
 OK * change error_stepper to error_stepper_units
-* finishing change of controlled_stepper to units
-* change error_checker to units
-* change dense_output to units
-* include fusion_algebra in tests
+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
+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()
+ * create dense_output_explicit
+ * create dense_output_explicit_controlled
+ * create dense_output_explicit_controlled_fsal
+ * maybe remove dense_output_explicit
 * split check_concepts into check_stepper_concept, check_error_stepper_concept, check_controlled_stepper_concept
 
 * Integrate functions

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-20 04:09:44 EST (Thu, 20 Jan 2011)
@@ -13,7 +13,8 @@
 #ifndef BOOST_BOOST_NUMERIC_ODEINT_STANDARD_OPERATIONS_HPP_INCLUDED
 #define BOOST_BOOST_NUMERIC_ODEINT_STANDARD_OPERATIONS_HPP_INCLUDED
 
-#include <algorithm> // for std::max
+#include <algorithm>
+#include <cmath> // for std::max
 
 namespace boost {
 namespace numeric {
@@ -143,11 +144,6 @@
         };
 
 
- template< class Fac1 , class Fac2 >
- static scale_sum2< Fac1 , Fac2 > make_scale_sum2( const Fac1 &alpha1 , const Fac2 &alpha2 )
- {
- return scale_sum2< Fac1 , Fac2 >( alpha1 , alpha2 );
- }
 
 
 
@@ -158,6 +154,8 @@
 
         /*
          * for usage in for_each2
+ *
+ * ToDo : check if T1, T2, T3 are units and if so convert them to normal floats
          */
         template< class Fac1 >
         struct rel_error
@@ -174,12 +172,13 @@
                         using std::abs;
                         t3 = abs( t3 ) / ( m_eps_abs + m_eps_rel * ( m_a_x * abs( t1 ) + m_a_dxdt * abs( t2 ) ) );
                 }
-
         };
 
 
         /*
          * for usage in reduce
+ *
+ * ToDo : check if T1, T2 are units and if so convert them to normal floats
          */
         template< class Fac1 >
         struct maximum

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/vector_space_reduce.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/vector_space_reduce.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/vector_space_reduce.hpp 2011-01-20 04:09:44 EST (Thu, 20 Jan 2011)
@@ -18,9 +18,12 @@
 //class vector_space_reduce
 //{
 // template< class Value , class Op >
-// Value operator()( const State & , Op op , Value init ) const
+// Value operator()( const LorenzState &s , Op op , Value init ) const
 // {
-// // ...
+// init = op( init , s.x );
+// init = op( init , s.y );
+// init = op( init , s.z );
+// return init;
 // }
 //};
 

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-20 04:09:44 EST (Thu, 20 Jan 2011)
@@ -41,6 +41,8 @@
 
         typedef typename stepper_type::stepper_type dopri5_type;
         typedef typename dopri5_type::state_type state_type;
+ typedef typename dopri5_type::value_type value_type;
+ typedef typename dopri5_type::deriv_type deriv_type;
         typedef typename dopri5_type::time_type time_type;
         typedef typename dopri5_type::algebra_type algebra_type;
         typedef typename dopri5_type::operations_type operations_type;
@@ -48,7 +50,7 @@
 
         BOOST_STATIC_ASSERT(( boost::is_same<
                                 dopri5_type ,
- explicit_error_dopri5< state_type , time_type , algebra_type , operations_type , adjust_size_policy >
+ explicit_error_dopri5< state_type , value_type , deriv_type , time_type , algebra_type , operations_type , adjust_size_policy >
>::value ));
 
         dense_output_dopri5( stepper_type &stepper )
@@ -175,10 +177,10 @@
                 time_type b7_theta = B + C * X7;
 
                 const state_type &k1 = *m_old_deriv;
- const state_type &k3 = dopri5().m_x3;
- const state_type &k4 = dopri5().m_x4;
- const state_type &k5 = dopri5().m_x5;
- const state_type &k6 = dopri5().m_x6;
+ const state_type &k3 = dopri5().m_k3;
+ const state_type &k4 = dopri5().m_k4;
+ const state_type &k5 = dopri5().m_k5;
+ const state_type &k6 = dopri5().m_k6;
                 const state_type &k7 = *m_current_deriv;
 
                 algebra_type::for_each8( x , *m_old_state , k1 , k3 , k4 , k5 , k6 , k7 ,

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-20 04:09:44 EST (Thu, 20 Jan 2011)
@@ -22,7 +22,9 @@
 
 template<
     class State ,
- class Time = double ,
+ class Value = double ,
+ class Deriv = State ,
+ class Time = Value ,
         class Algebra = standard_algebra ,
         class Operations = standard_operations ,
         class AdjustSizePolicy = adjust_size_initially_tag
@@ -32,11 +34,13 @@
 public:
 
         typedef State state_type;
+ typedef Value value_type;
+ typedef Deriv deriv_type;
         typedef Time time_type;
         typedef Algebra algebra_type;
         typedef Operations operations_type;
         typedef AdjustSizePolicy adjust_size_policy;
- typedef explicit_euler< state_type , time_type , algebra_type , operations_type , adjust_size_policy > stepper_type;
+ typedef explicit_euler< state_type , value_type , deriv_type , time_type , algebra_type , operations_type , adjust_size_policy > stepper_type;
 
         dense_output_explicit_euler( void )
         : m_euler() , m_size_adjuster() ,
@@ -92,7 +96,7 @@
 
         const state_type& current_state( void ) const { return *m_current_state; }
         const time_type& current_time( void ) const { return m_t; }
- const time_type& previous_state( void ) const { return *m_old_state; }
+ const time_type& previous_state( void ) const { return *m_old_state; }
         const time_type& previous_time( void ) const { return m_t_old; }
 
 private:

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-20 04:09:44 EST (Thu, 20 Jan 2011)
@@ -23,7 +23,7 @@
 namespace numeric {
 namespace odeint {
 
-template< class State , class Time , class Algebra , class Operations , class AdjustSizePolicy >
+template< class State , class Value , class Deriv , class Time , class Algebra , class Operations , class AdjustSizePolicy >
 class dense_output_explicit_euler;
 
 template<
@@ -42,7 +42,7 @@
 {
 public :
 
- friend class dense_output_explicit_euler< Deriv , Time , Algebra , Operations , AdjustSizePolicy >;
+ friend class dense_output_explicit_euler< State , Value , Deriv , Time , Algebra , Operations , AdjustSizePolicy >;
 
         BOOST_ODEINT_EXPLICIT_STEPPERS_TYPEDEFS( explicit_euler , 1 );
 

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-20 04:09:44 EST (Thu, 20 Jan 2011)
@@ -20,6 +20,6 @@
     : test_units.cpp
     ;
     
-exe test_ranges
- : test_ranges.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/test/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile 2011-01-20 04:09:44 EST (Thu, 20 Jan 2011)
@@ -19,18 +19,19 @@
 unit-test basic_test
         : check_stepper_concepts.cpp
           check_resize.cpp
+ check_operations.cpp
           check_implicit_euler.cpp
-# check_dense_output_explicit_euler.cpp
-# check_dense_output_dopri5.cpp
+ check_dense_output_explicit_euler.cpp
+ check_dense_output_dopri5.cpp
         :
         : <library>/boost/test//boost_unit_test_framework
           <link>static
         ;
         
-# exe controlled_stepper_evolution
-# : controlled_stepper_evolution.cpp
-# ;
+exe controlled_stepper_evolution
+ : controlled_stepper_evolution.cpp
+ ;
         
-# exe dense_output_stepper_evolution
-# : dense_output_stepper_evolution.cpp
-# ;
\ No newline at end of file
+exe dense_output_stepper_evolution
+ : dense_output_stepper_evolution.cpp
+ ;
\ No newline at end of file

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_operations.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_operations.cpp 2011-01-20 04:09:44 EST (Thu, 20 Jan 2011)
@@ -0,0 +1,140 @@
+/*
+ * check_operations.cpp
+ *
+ * Created on: Jan 20, 2011
+ * Author: karsten
+ */
+
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+
+#include <boost/numeric/odeint/algebra/standard_operations.hpp>
+
+using boost::numeric::odeint::standard_operations;
+
+const double eps = 1.0e-13;
+
+struct double_fixture
+{
+ double_fixture( void )
+ : res( 0.0 ) , x1( 1.0 ) , x2( 2.0 ) , x3( 3.0 ) , x4( 4.0 ) , x5( 5.0 ) , x6( 6.0 ) , x7( 7.0 ) , x8( 8.0 )
+ {}
+ ~double_fixture( void )
+ {
+ BOOST_CHECK_CLOSE( x1 , double( 1.0 ) , eps );
+ BOOST_CHECK_CLOSE( x2 , double( 2.0 ) , eps );
+ BOOST_CHECK_CLOSE( x3 , double( 3.0 ) , eps );
+ BOOST_CHECK_CLOSE( x4 , double( 4.0 ) , eps );
+ BOOST_CHECK_CLOSE( x5 , double( 5.0 ) , eps );
+ BOOST_CHECK_CLOSE( x6 , double( 6.0 ) , eps );
+ BOOST_CHECK_CLOSE( x7 , double( 7.0 ) , eps );
+ BOOST_CHECK_CLOSE( x8 , double( 8.0 ) , eps );
+ }
+ double res;
+ double x1 , x2 , x3 , x4 , x5 , x6 , x7 , x8;
+};
+
+struct unit_fixture
+{
+ unit_fixture( void )
+ {}
+ ~unit_fixture( void )
+ {
+
+ }
+
+
+};
+
+
+BOOST_AUTO_TEST_SUITE( check_operations_test )
+
+BOOST_AUTO_TEST_CASE( scale_sum2_with_double )
+{
+ double_fixture f;
+ double res = 0.0;
+ typedef standard_operations::scale_sum2< double , double > Op;
+ Op op( 1.25 , 9.81 );
+ op( res , f.x1 , f.x2 );
+ BOOST_CHECK_CLOSE( res , double( 20.87 ) , eps );
+}
+
+BOOST_AUTO_TEST_CASE( scale_sum3_with_double )
+{
+ double_fixture f;
+ double res = 0.0;
+ typedef standard_operations::scale_sum3< double , double , double > Op;
+ Op op( 1.25 , 9.81 , 0.87 );
+ op( res , f.x1 , f.x2 , f.x3 );
+ BOOST_CHECK_CLOSE( res , double( 23.48 ) , eps );
+}
+
+BOOST_AUTO_TEST_CASE( scale_sum4_with_double )
+{
+ double_fixture f;
+ double res = 0.0;
+ typedef standard_operations::scale_sum4< double , double , double , double > Op;
+ Op op( 1.25 , 9.81 , 0.87 , -0.15 );
+ op( res , f.x1 , f.x2 , f.x3 , f.x4 );
+ BOOST_CHECK_CLOSE( res , double( 22.88 ) , eps );
+}
+
+BOOST_AUTO_TEST_CASE( scale_sum5_with_double )
+{
+ double_fixture f;
+ double res = 0.0;
+ typedef standard_operations::scale_sum5< double , double , double , double , double > Op;
+ Op op( 1.25 , 9.81 , 0.87 , -0.15 , -3.3 );
+ op( res , f.x1 , f.x2 , f.x3 , f.x4 , f.x5 );
+ BOOST_CHECK_CLOSE( res , double( 6.38 ) , eps );
+}
+
+BOOST_AUTO_TEST_CASE( scale_sum6_with_double )
+{
+ double_fixture f;
+ double res = 0.0;
+ typedef standard_operations::scale_sum6< double , double , double , double , double , double > Op;
+ Op op( 1.25 , 9.81 , 0.87 , -0.15 , -3.3 , 4.2 );
+ op( res , f.x1 , f.x2 , f.x3 , f.x4 , f.x5 , f.x6 );
+ BOOST_CHECK_CLOSE( res , double( 31.58 ) , eps );
+}
+
+BOOST_AUTO_TEST_CASE( scale_sum7_with_double )
+{
+ double_fixture f;
+ double res = 0.0;
+ typedef standard_operations::scale_sum7< double , double , double , double , double , double , double > Op;
+ Op op( 1.25 , 9.81 , 0.87 , -0.15 , -3.3 , 4.2 , -0.22 );
+ op( res , f.x1 , f.x2 , f.x3 , f.x4 , f.x5 , f.x6 , f.x7 );
+ BOOST_CHECK_CLOSE( res , double( 30.04 ) , eps );
+}
+
+BOOST_AUTO_TEST_CASE( rel_error_with_double )
+{
+ double_fixture f;
+ double res = -1.1;
+ typedef standard_operations::rel_error< double > Op;
+ Op op( 0.1 , 0.2 , 0.15 , 0.12 );
+ op( -f.x1 , -f.x2 , res );
+ BOOST_CHECK_CLOSE( res , 6.17978 , 1.0e-4 );
+}
+
+BOOST_AUTO_TEST_CASE( maximum )
+{
+ double_fixture f;
+ double res = 0.0;
+ typedef standard_operations::maximum< double > Op;
+ Op op;
+ res = op( f.x1 , f.x2 );
+ BOOST_CHECK_CLOSE( res , 2.0 , eps );
+}
+
+BOOST_AUTO_TEST_CASE( scale_sum2_with_units )
+{
+
+}
+
+
+
+BOOST_AUTO_TEST_SUITE_END()


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