Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68371 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/algebra libs/numeric/odeint/regression_test libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2011-01-22 14:46:22


Author: karsten
Date: 2011-01-22 14:46:19 EST (Sat, 22 Jan 2011)
New Revision: 68371
URL: http://svn.boost.org/trac/boost/changeset/68371

Log:
* finishing fusion_algebra test
Added:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/fusion_algebra.cpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/TODO | 9
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/fusion_algebra.hpp | 243 +++++++++++++++++++++++----------------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp | 32 +++-
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_operations.hpp | 30 ++++
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile | 1
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/standard_algebra.cpp | 2
   6 files changed, 198 insertions(+), 119 deletions(-)

Modified: sandbox/odeint/branches/karsten/TODO
==============================================================================
--- sandbox/odeint/branches/karsten/TODO (original)
+++ sandbox/odeint/branches/karsten/TODO 2011-01-22 14:46:19 EST (Sat, 22 Jan 2011)
@@ -1,8 +1,11 @@
 * Unit test
- * test operations
- * test algebra
+ OK * test operations
+ OK * test standard_algebra
+ OK * test fusion_algebra
+ * test vector_space_algebra
+* change standard_operations::rel_error in order to word with units and test it
 OK * operations that fit units
-* operations that fit result_of
+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

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/fusion_algebra.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/fusion_algebra.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/fusion_algebra.hpp 2011-01-22 14:46:19 EST (Sat, 22 Jan 2011)
@@ -7,125 +7,168 @@
  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE_1_0.txt or
  copy at http://www.boost.org/LICENSE_1_0.txt)
-*/
+ */
 
 #ifndef BOOST_BOOST_NUMERIC_ODEINT_FUSION_ALGEBRA_HPP_INCLUDED
 #define BOOST_BOOST_NUMERIC_ODEINT_FUSION_ALGEBRA_HPP_INCLUDED
 
+
+#define BOOST_FUSION_UNFUSED_MAX_ARITY 10
+#define BOOST_FUSION_UNFUSED_TYPE_MAX_ARITY 10
+#define BOOST_FUSION_INVOKE_MAX_ARITY 10
+#define BOOST_FUSION_INVOKE_PROCEDURE_MAX_ARITY 10
+#define BOOST_FUSION_INVOKE_FUNCTION_OBJECT_MAX_ARITY 10
 #include <boost/fusion/container.hpp>
 #include <boost/fusion/sequence.hpp>
 #include <boost/fusion/algorithm.hpp>
 #include <boost/fusion/view.hpp>
 #include <boost/fusion/functional.hpp>
 
+#define BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY 9
+#include <boost/functional/forward_adapter.hpp>
+
+
 
 namespace boost {
 namespace numeric {
 namespace odeint {
 
 
-/*
- * TODO :
- * 1. testing, include int unit test
- * 2. change the standard operations, using boost::result_of. for example:
- *
- * struct increment
- * {
- * template< class T > struct result;
- *
- * template< class F , class T1 , class T2 >
- * struct result< F( T1 , T2 ) >
- * {
- * typedef void type;
- * };
- *
- * template< class T1 , class T2 >
- * void operator()( T1 &t1 , T2 &t2 ) const
- * {
- * t1 += t2;
- * }
- * };
- *
- *
- */
 struct fusion_algebra
 {
-
- template< class StateType1 , class Operation >
- static void for_each1( StateType1 &s1 , Operation op )
- {
- boost::fusion::for_each( s1 , op );
- }
-
-
- template< class StateType1 , class StateType2 , class Operation >
- static void for_each2( StateType1 &s1 , StateType2 &s2 , Operation op )
- {
- typedef boost::fusion::vector< StateType1& , StateType2& > Sequences;
- Sequences sequences( s1 , s2 );
- boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
- }
-
-
- template< class StateType1 , class StateType2 , class StateType3 , class Operation >
- static void for_each3( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , Operation op )
- {
- typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& > Sequences;
- Sequences sequences( s1 , s2 , s3 );
- boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
- }
-
-
- template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class Operation >
- static void for_each4( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , Operation op )
- {
- typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& > Sequences;
- Sequences sequences( s1 , s2 , s3 , s4 );
- boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
- }
-
-
- template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class StateType5 , class Operation >
- static void for_each5( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , StateType5 &s5 , Operation op )
- {
- typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& , StateType5& > Sequences;
- Sequences sequences( s1 , s2 , s3 , s4 , s5 );
- boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
- }
-
-
- template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class StateType5 , class StateType6 , class Operation >
- static void for_each6( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , StateType5 &s5 , StateType6 &s6 , Operation op )
- {
- typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& , StateType5& , StateType6& > Sequences;
- Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 );
- boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
- }
-
-
- template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class StateType5 , class StateType6 , class StateType7 , class Operation >
- static void for_each7( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , StateType5 &s5 , StateType6 &s6 , StateType7 &s7 , Operation op )
- {
- typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& , StateType5& , StateType6& , StateType7& > Sequences;
- Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 );
- boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
- }
-
-
- template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class StateType5 , class StateType6 , class StateType7 , class StateType8 , class Operation >
- static void for_each8( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , StateType5 &s5 , StateType6 &s6 , StateType7 &s7 , StateType8 &s8 , Operation op )
- {
- typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& , StateType5& , StateType6& , StateType7& , StateType8& > Sequences;
- Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 );
- boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
- }
-
-
- template< class ValueType , class StateType , class Reduction >
- static ValueType reduce( StateType &s , Reduction red , ValueType init)
+ struct for_each1_impl
         {
- return boost::fusion::accumulate( s , init , red );
- }
+ template< class S1 , class Op >
+ void operator()( S1 &s1 , Op op ) const
+ {
+ boost::fusion::for_each( s1 , op );
+ }
+ typedef void result_type;
+ };
+
+
+ struct for_each2_impl
+ {
+ template< class S1 , class S2 , class Op >
+ void operator()( S1 &s1 , S2 &s2 , Op op ) const
+ {
+ typedef boost::fusion::vector< S1& , S2& > Sequences;
+ Sequences sequences( s1 , s2 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+ typedef void result_type;
+ };
+
+
+ struct for_each3_impl
+ {
+ template< class S1 , class S2 , class S3 , class Op >
+ void operator()( S1 &s1 , S2 &s2 , S3 &s3 , Op op ) const
+ {
+ typedef boost::fusion::vector< S1& , S2& , S3& > Sequences;
+ Sequences sequences( s1 , s2 , s3 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+ typedef void result_type;
+ };
+
+ struct for_each4_impl
+ {
+ template< class S1 , class S2 , class S3 , class S4 , class Op >
+ void operator()( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op ) const
+ {
+ typedef boost::fusion::vector< S1& , S2& , S3& , S4& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+ typedef void result_type;
+ };
+
+
+ struct for_each5_impl
+ {
+ template< class S1 , class S2 , class S3 , class S4 , class S5 , class Op >
+ void operator()( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , Op op ) const
+ {
+ typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 , s5 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+ typedef void result_type;
+ };
+
+
+ struct for_each6_impl
+ {
+ template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class Op >
+ void operator()( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , Op op ) const
+ {
+ typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+ typedef void result_type;
+ };
+
+
+ struct for_each7_impl
+ {
+ template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class Op >
+ void operator()( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , Op op ) const
+ {
+ typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+ typedef void result_type;
+ };
+
+
+ struct for_each8_impl
+ {
+ template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class S7 , class S8 , class Op >
+ void operator()( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , Op op ) const
+ {
+ typedef boost::fusion::vector< S1& , S2& , S3& , S4& , S5& , S6& , S7& , S8& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+ typedef void result_type;
+ };
+
+
+ struct reduce_impl
+ {
+ template< class Value , class S , class Reduction >
+ Value operator()( S &s , Reduction red , Value init) const
+ {
+ return boost::fusion::accumulate( s , init , red );
+ }
+
+ template< class T > struct result;
+ template< class F , class T1 , class T2 , class T3 >
+ struct result< F( T1 , T2 , T3 ) >
+ {
+ /*
+ * A Simple
+ * typedef T3 type;
+ * would result in warnings
+ */
+ typedef typename boost::remove_reference< T3 >::type type;
+ };
+ };
+
+
+
+ typedef boost::forward_adapter< for_each1_impl , 2 > for_each1;
+ typedef boost::forward_adapter< for_each2_impl , 3 > for_each2;
+ typedef boost::forward_adapter< for_each3_impl , 4 > for_each3;
+ typedef boost::forward_adapter< for_each4_impl , 5 > for_each4;
+ typedef boost::forward_adapter< for_each5_impl , 6 > for_each5;
+ typedef boost::forward_adapter< for_each6_impl , 7 > for_each6;
+ typedef boost::forward_adapter< for_each7_impl , 8 > for_each7;
+ typedef boost::forward_adapter< for_each8_impl , 9 > for_each8;
+ typedef boost::forward_adapter< reduce_impl , 3 > reduce;
 };
 
 

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp 2011-01-22 14:46:19 EST (Sat, 22 Jan 2011)
@@ -17,6 +17,8 @@
 #define BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY 9
 #include <boost/functional/forward_adapter.hpp>
 
+#include <boost/type_traits.hpp>
+
 #include <boost/numeric/odeint/algebra/detail/macros.hpp>
 #include <boost/numeric/odeint/algebra/detail/for_each.hpp>
 #include <boost/numeric/odeint/algebra/detail/reduce.hpp>
@@ -138,9 +140,16 @@
         };
 
 
+// struct reduce
+// {
+// template< class Value , class S , class Red >
+// Value operator()( const S &s , Red red , Value init) const
+// {
+// return detail::reduce( boost::begin( s ) , boost::end( s ) , red , init );
+// }
+// };
 
-
- struct reduce
+ struct reduce_impl
         {
                 template< class Value , class S , class Red >
                 Value operator()( const S &s , Red red , Value init) const
@@ -148,16 +157,19 @@
                         return detail::reduce( boost::begin( s ) , boost::end( s ) , red , init );
                 }
 
-// template< class T > struct result;
-//
-// template< class F , class T1 , class T2 , class T3 >
-// struct result< F( T1 , T2 , T3 ) >
-// {
-// typedef T3 type;
-// };
+ template< class T > struct result;
+ template< class F , class T1 , class T2 , class T3 >
+ struct result< F( T1 , T2 , T3 ) >
+ {
+ /*
+ * typedef T3 type would result in warnings
+ */
+ typedef typename boost::remove_reference< T3 >::type type;
+ };
         };
 
 
+
         typedef boost::forward_adapter< for_each1_impl , 2 > for_each1;
         typedef boost::forward_adapter< for_each2_impl , 3 > for_each2;
         typedef boost::forward_adapter< for_each3_impl , 4 > for_each3;
@@ -166,7 +178,7 @@
         typedef boost::forward_adapter< for_each6_impl , 7 > for_each6;
         typedef boost::forward_adapter< for_each7_impl , 8 > for_each7;
         typedef boost::forward_adapter< for_each8_impl , 9 > for_each8;
-// typedef boost::forward_adapter< reduce_impl , 3 > reduce;
+ typedef boost::forward_adapter< reduce_impl , 3 > reduce;
 
 };
 

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-22 14:46:19 EST (Sat, 22 Jan 2011)
@@ -16,16 +16,21 @@
 #include <algorithm>
 #include <cmath> // for std::max
 
+#include <boost/utility/result_of.hpp>
+
 namespace boost {
 namespace numeric {
 namespace odeint {
 
 
 /*
- * have to be changed if thrust device_vector or gsl_vector are used
+ * Notes:
+ *
+ * * the results structs are needed in order to work with fusion_algebra
  */
 struct standard_operations
 {
+
         template< class Fac1 = double >
         struct scale_sum1
         {
@@ -38,8 +43,11 @@
                 {
                         t1 = m_alpha1 * t2;
                 }
+
+ typedef void result_type;
         };
 
+
         template< class Fac1 = double , class Fac2 = Fac1 >
         struct scale_sum2
         {
@@ -53,6 +61,8 @@
                 {
                         t1 = m_alpha1 * t2 + m_alpha2 * t3;
                 }
+
+ typedef void result_type;
         };
 
 
@@ -71,10 +81,12 @@
                 {
                         t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4;
                 }
+
+ typedef void result_type;
         };
 
 
- template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac1 , class Fac4 = Fac1 >
+ template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 >
         struct scale_sum4
         {
                 const Fac1 m_alpha1;
@@ -90,10 +102,12 @@
                 {
                         t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5;
                 }
+
+ typedef void result_type;
         };
 
 
- template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac1 , class Fac4 = Fac1 , class Fac5 = Fac1 >
+ template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 >
         struct scale_sum5
         {
                 const Fac1 m_alpha1;
@@ -110,10 +124,12 @@
                 {
                         t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6;
                 }
+
+ typedef void result_type;
         };
 
 
- template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac1 , class Fac4 = Fac1 , class Fac5 = Fac1 , class Fac6 = Fac1 >
+ template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 >
         struct scale_sum6
         {
                 const Fac1 m_alpha1;
@@ -131,10 +147,12 @@
                 {
                         t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7;
                 }
+
+ typedef void result_type;
         };
 
 
- template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac1 , class Fac4 = Fac1 , class Fac5 = Fac1 , class Fac6 = Fac1 , class Fac7 = Fac1 >
+ template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 >
         struct scale_sum7
         {
                 const Fac1 m_alpha1;
@@ -154,6 +172,8 @@
                 {
                         t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8;
                 }
+
+ typedef void result_type;
         };
 
 

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile 2011-01-22 14:46:19 EST (Sat, 22 Jan 2011)
@@ -0,0 +1,26 @@
+# Copyright 2009 Karsten Ahnert and Mario Mulansky.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+
+project
+ : requirements
+ <include>../../../..
+ ;
+
+exe controlled_stepper_evolution
+ : controlled_stepper_evolution.cpp
+ ;
+
+exe dense_output_dopri5
+ : dense_output_dopri5.cpp
+ ;
+
+exe dense_output_explicit_euler
+ : dense_output_explicit_euler.cpp
+ ;
+
+exe dense_output_stepper_evolution
+ : dense_output_stepper_evolution.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-22 14:46:19 EST (Sat, 22 Jan 2011)
@@ -23,4 +23,5 @@
          [ run standard_operations.cpp ]
          [ run standard_algebra.cpp ]
          [ run implicit_euler.cpp ]
+ [ run fusion_algebra.cpp ]
          ;

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/fusion_algebra.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/fusion_algebra.cpp 2011-01-22 14:46:19 EST (Sat, 22 Jan 2011)
@@ -0,0 +1,158 @@
+/*
+ * check_operations.cpp
+ *
+ * Created on: Jan 20, 2011
+ * Author: karsten
+ */
+
+#define BOOST_TEST_MODULE odeint_fusion_algebra
+#include <cmath>
+#include <complex>
+#include <utility>
+#include <functional>
+#include <tr1/array>
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+
+#include <boost/range.hpp>
+
+#include <boost/units/systems/si/length.hpp>
+#include <boost/units/systems/si/time.hpp>
+#include <boost/units/systems/si/velocity.hpp>
+#include <boost/units/systems/si/acceleration.hpp>
+#include <boost/units/systems/si/io.hpp>
+
+#include <boost/fusion/container.hpp>
+
+#include <boost/numeric/odeint/algebra/standard_operations.hpp>
+#include <boost/numeric/odeint/algebra/fusion_algebra.hpp>
+
+namespace units = boost::units;
+namespace si = boost::units::si;
+namespace fusion = boost::fusion;
+
+using boost::numeric::odeint::standard_operations;
+using boost::numeric::odeint::fusion_algebra;
+
+typedef double value_type;
+typedef units::quantity< si::time , value_type > time_type;
+typedef units::quantity< si::length , value_type > length_type;
+typedef units::quantity< si::velocity , value_type > velocity_type;
+typedef units::quantity< si::acceleration , value_type > acceleration_type;
+typedef fusion::vector< length_type , velocity_type > state_type;
+typedef fusion::vector< velocity_type , acceleration_type > deriv_type;
+
+const time_type dt = 0.1 * si::second;
+
+
+struct fusion_fixture
+{
+ fusion_fixture( void )
+ : res( 0.0 * si::meter , 0.0 * si::meter_per_second ) ,
+ x( 1.0 * si::meter , 1.0 * si::meter_per_second ) ,
+ k1( 1.0 * si::meter_per_second , 1.0 * si::meter_per_second_squared ) ,
+ k2( 2.0 * si::meter_per_second , 2.0 * si::meter_per_second_squared ) ,
+ k3( 3.0 * si::meter_per_second , 3.0 * si::meter_per_second_squared ) ,
+ k4( 4.0 * si::meter_per_second , 4.0 * si::meter_per_second_squared ) ,
+ k5( 5.0 * si::meter_per_second , 5.0 * si::meter_per_second_squared ) ,
+ k6( 6.0 * si::meter_per_second , 6.0 * si::meter_per_second_squared ) { }
+
+ ~fusion_fixture( void )
+ {
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( x ).value() , 1.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( x ).value() , 1.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( k1 ).value() , 1.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( k1 ).value() , 1.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( k2 ).value() , 2.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( k2 ).value() , 2.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( k3 ).value() , 3.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( k3 ).value() , 3.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( k4 ).value() , 4.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( k4 ).value() , 4.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( k5 ).value() , 5.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( k5 ).value() , 5.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( k6 ).value() , 6.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( k6 ).value() , 6.0 , 1.0e-10 );
+ }
+
+ state_type res , x;
+ deriv_type k1 , k2 , k3 , k4 , k5 , k6 ;
+};
+
+
+
+BOOST_AUTO_TEST_SUITE( fusion_algebra_test )
+
+BOOST_AUTO_TEST_CASE( for_each2 )
+{
+ fusion_fixture f;
+ fusion_algebra::for_each2()( f.res , f.k1 ,
+ standard_operations::scale_sum1< time_type >( dt ) );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( f.res ).value() , 0.1 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( f.res ).value() , 0.1 , 1.0e-10 );
+}
+
+BOOST_AUTO_TEST_CASE( for_each3 )
+{
+ fusion_fixture f;
+ fusion_algebra::for_each3()( f.res , f.x , f.k1 ,
+ standard_operations::scale_sum2< value_type , time_type >( 1.0 , dt ) );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( f.res ).value() , 1.1 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( f.res ).value() , 1.1 , 1.0e-10 );
+}
+
+BOOST_AUTO_TEST_CASE( for_each4 )
+{
+ fusion_fixture f;
+ fusion_algebra::for_each4()( f.res , f.x , f.k1 , f.k2 ,
+ standard_operations::scale_sum3< value_type , time_type , time_type >( 1.0 , dt , dt ) );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( f.res ).value() , 1.3 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( f.res ).value() , 1.3 , 1.0e-10 );
+}
+
+BOOST_AUTO_TEST_CASE( for_each5 )
+{
+ fusion_fixture f;
+ fusion_algebra::for_each5()( f.res , f.x , f.k1 , f.k2 , f.k3 ,
+ standard_operations::scale_sum4< value_type , time_type , time_type , time_type >( 1.0 , dt , dt , dt ) );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( f.res ).value() , 1.6 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( f.res ).value() , 1.6 , 1.0e-10 );
+}
+
+BOOST_AUTO_TEST_CASE( for_each6 )
+{
+ fusion_fixture f;
+ fusion_algebra::for_each6()( f.res , f.x , f.k1 , f.k2 , f.k3 , f.k4 ,
+ standard_operations::scale_sum5< value_type , time_type , time_type , time_type , time_type >( 1.0 , dt , dt , dt , dt ) );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( f.res ).value() , 2.0 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( f.res ).value() , 2.0 , 1.0e-10 );
+}
+
+BOOST_AUTO_TEST_CASE( for_each7 )
+{
+ fusion_fixture f;
+ fusion_algebra::for_each7()( f.res , f.x , f.k1 , f.k2 , f.k3 , f.k4 , f.k5 ,
+ standard_operations::scale_sum6< value_type , time_type , time_type , time_type , time_type , time_type >( 1.0 , dt , dt , dt , dt , dt ) );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( f.res ).value() , 2.5 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( f.res ).value() , 2.5 , 1.0e-10 );
+}
+
+BOOST_AUTO_TEST_CASE( for_each8 )
+{
+ fusion_fixture f;
+ fusion_algebra::for_each8()( f.res , f.x , f.k1 , f.k2 , f.k3 , f.k4 , f.k5 , f.k6 ,
+ standard_operations::scale_sum7< value_type , time_type , time_type , time_type , time_type , time_type , time_type >( 1.0 , dt , dt , dt , dt , dt ,dt ) );
+ BOOST_CHECK_CLOSE( fusion::at_c< 0 >( f.res ).value() , 3.1 , 1.0e-10 );
+ BOOST_CHECK_CLOSE( fusion::at_c< 1 >( f.res ).value() , 3.1 , 1.0e-10 );
+}
+
+
+BOOST_AUTO_TEST_CASE( reduce )
+{
+ double sum = fusion_algebra::reduce()( fusion::make_vector( 1.0 , 2.0 , 3.0 ) , std::plus< double >() , 0.0 );
+ BOOST_CHECK_CLOSE( sum , 6.0 , 1.0e-10 );
+}
+
+
+BOOST_AUTO_TEST_SUITE_END()

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/standard_algebra.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/standard_algebra.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/standard_algebra.cpp 2011-01-22 14:46:19 EST (Sat, 22 Jan 2011)
@@ -5,7 +5,7 @@
  * Author: karsten
  */
 
-#define BOOST_TEST_MODULE odeint_dense_output_dopri5
+#define BOOST_TEST_MODULE odeint_standard_algebra
 
 #include <cmath>
 #include <complex>


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