Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63647 - in sandbox/odeint/branches/karsten: boost/numeric boost/numeric/odeint boost/numeric/odeint/container_traits boost/numeric/odeint/integrate_functions boost/numeric/odeint/steppers libs/numeric/odeint/examples libs/numeric/odeint/performance libs/numeric/odeint/stuff libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2010-07-05 07:09:07


Author: karsten
Date: 2010-07-05 07:09:04 EDT (Mon, 05 Jul 2010)
New Revision: 63647
URL: http://svn.boost.org/trac/boost/changeset/63647

Log:
reorganizing my branch
Added:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/examples/harmonic_oscillator.cpp (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gsl_vector_adaptor.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/vector_space_1d.hpp (contents, props changed)
Removed:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/container_traits/
   sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate_functions/
   sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate_functions.hpp
   sandbox/odeint/branches/karsten/boost/numeric/odeint/steppers/
   sandbox/odeint/branches/karsten/boost/numeric/odeint/steppers.hpp
   sandbox/odeint/branches/karsten/libs/numeric/odeint/performance/
   sandbox/odeint/branches/karsten/libs/numeric/odeint/stuff/
Text files modified:
   sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp | 3
   sandbox/odeint/branches/karsten/libs/numeric/odeint/examples/Jamfile | 5
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp | 315 +++++++++++++++++++--------------------
   3 files changed, 154 insertions(+), 169 deletions(-)

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp 2010-07-05 07:09:04 EDT (Mon, 05 Jul 2010)
@@ -17,8 +17,5 @@
 
 #include <boost/config.hpp>
 
-#include <boost/numeric/odeint/container_traits.hpp>
-#include <boost/numeric/odeint/steppers.hpp>
-#include <boost/numeric/odeint/integrate_functions.hpp>
 
 #endif // BOOST_NUMERIC_ODEINT_HPP

Deleted: sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate_functions.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate_functions.hpp 2010-07-05 07:09:04 EDT (Mon, 05 Jul 2010)
+++ (empty file)
@@ -1,19 +0,0 @@
-/*
- boost header: boost/numeric/odeint/integrate_functions.hpp
-
- Copyright 2009 Karsten Ahnert
- Copyright 2009 Mario Mulansky
- Copyright 2009 Andre Bergner
-
- 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_INTEGRATE_FUNCTIONS_HPP_INCLUDED
-#define BOOST_BOOST_NUMERIC_ODEINT_INTEGRATE_FUNCTIONS_HPP_INCLUDED
-
-#include <boost/numeric/odeint/integrate_functions/integrator_constant_stepsize.hpp>
-#include <boost/numeric/odeint/integrate_functions/integrator_adaptive_stepsize.hpp>
-
-#endif //BOOST_BOOST_NUMERIC_ODEINT_INTEGRATE_FUNCTIONS_HPP_INCLUDED

Deleted: sandbox/odeint/branches/karsten/boost/numeric/odeint/steppers.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/steppers.hpp 2010-07-05 07:09:04 EDT (Mon, 05 Jul 2010)
+++ (empty file)
@@ -1,33 +0,0 @@
-/*
- boost header: boost/numeric/odeint/steppers.hpp
-
- Copyright 2009 Karsten Ahnert
- Copyright 2009 Mario Mulansky
- Copyright 2009 Andre Bergner
-
- 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_STEPPERS_HPP_INCLUDED
-#define BOOST_BOOST_NUMERIC_ODEINT_STEPPERS_HPP_INCLUDED
-
-// steppers
-#include <boost/numeric/odeint/steppers/stepper_euler.hpp>
-
-
-// error steppers
-#include <boost/numeric/odeint/steppers/stepper_half_step.hpp>
-
-
-// hamiltonian steppers
-#include <boost/numeric/odeint/steppers/hamiltonian_stepper_euler.hpp>
-
-
-// controlled steppers
-#include <boost/numeric/odeint/steppers/error_checker_standard.hpp>
-#include <boost/numeric/odeint/steppers/controlled_stepper_standard.hpp>
-
-
-#endif //BOOST_BOOST_NUMERIC_ODEINT_STEPPERS_HPP_INCLUDED

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/examples/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/examples/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/examples/Jamfile 2010-07-05 07:09:04 EDT (Mon, 05 Jul 2010)
@@ -12,6 +12,5 @@
     : build-dir .
     ;
 
-exe doc_harm_osc : doc_harm_osc.cpp ;
-exe doc_integrate : doc_integrate.cpp ;
-exe solar_system : solar_system.cpp point_type.hpp ;
+# exe harmonic_oscillator : harmonic_oscillator.cpp ;
+# exe solar_system : solar_system.cpp point_type.hpp ;

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/examples/harmonic_oscillator.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/examples/harmonic_oscillator.cpp 2010-07-05 07:09:04 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,70 @@
+#include <iostream>
+
+#include <boost/numeric/odeint.hpp>
+
+//[ rhs_function
+/* The type of container used to hold the state vector */
+typedef std::vector<double> state_type;
+
+const double gam = 0.15;
+
+/* The rhs of x' = f(x) */
+void harmonic_oscillator(const state_type &x, state_type &dxdt, const double t)
+{
+ dxdt[0] = x[1];
+ dxdt[1] = -x[0] - gam*x[1];
+}
+//]
+
+//[ rhs_class
+class harm_osc {
+
+ double m_gam;
+
+public:
+ harm_osc( double gam ) : m_gam(gam) { }
+
+ void operator() (const state_type &x, state_type &dxdt, const double t)
+ {
+ dxdt[0] = x[1];
+ dxdt[1] = -x[0] - m_gam*x[1];
+ }
+};
+//]
+
+int main(int argc, char **argv)
+{
+ using namespace std;
+ using namespace boost::numeric::odeint;
+
+ //[ state_initialization
+ state_type x(2);
+ x[0] = 1.0; // start at x=1.0, p=0.0
+ x[1] = 0.0;
+ //]
+
+ //[ integration
+ vector<double> times;
+ vector<state_type> x_t_vec;
+
+ size_t steps = integrate( harmonic_oscillator ,
+ x , 0.0 , 10.0 ,
+ back_inserter( times ) ,
+ back_inserter( x_t_vec ) );
+ //]
+
+ /* the same as above using the class */
+ /*
+ harm_osc ho(0.15);
+ steps = integrate( ho ,
+ x , 0.0 , 10.0 ,
+ back_inserter( times ) ,
+ back_inserter( x_t_vec ) );
+ */
+
+ //[ output
+ for( size_t i=0; i<=steps; i++ ) { //initial state is 0th entry
+ cout << times[i] << '\t' << x_t_vec[i][0] << '\t' << x_t_vec[i][1] << '\n';
+ }
+ //]
+}

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp 2010-07-05 07:09:04 EDT (Mon, 05 Jul 2010)
@@ -15,12 +15,8 @@
 
 #include <boost/test/unit_test.hpp>
 
-#include <boost/numeric/odeint/steppers/stepper_euler.hpp>
-#include <boost/numeric/odeint/steppers/stepper_half_step.hpp>
-#include <boost/numeric/odeint/steppers/controlled_stepper_standard.hpp>
-
 using namespace boost::unit_test;
-using namespace boost::numeric::odeint;
+// using namespace boost::numeric::odeint;
 
 
 
@@ -37,171 +33,164 @@
 
 const double eps = 1.0e-14;
 
-template< class Stepper >
-void check_stepper_concept( Stepper &stepper ,
- typename Stepper::order_type order_step )
-{
- typedef Stepper stepper_type;
- typedef typename stepper_type::container_type container_type;
- typedef typename stepper_type::traits_type traits_type;
- typedef typename stepper_type::value_type value_type;
- typedef typename stepper_type::order_type order_type;
- typedef typename stepper_type::time_type time_type;
-
- constant_system< container_type > con;
-
- BOOST_CHECK_EQUAL( order_step , stepper.order_step() );
-
- container_type x( 1 , 0.0 ) ;
- stepper.adjust_size( x );
- stepper.do_step( con , x , 0.0 , 0.1 );
- 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_SMALL( fabs( x[0] - 0.2 ) , eps );
-
- stepper_type stepper2( x );
- stepper_type stepper3;
-}
-
-
-
-
-template< class ErrorStepper >
-void check_error_stepper_concept(
- ErrorStepper &stepper ,
- typename ErrorStepper::order_type order_error_step ,
- typename ErrorStepper::order_type order_error )
-{
- typedef ErrorStepper stepper_type;
- typedef typename stepper_type::container_type container_type;
- typedef typename stepper_type::traits_type traits_type;
- typedef typename stepper_type::value_type value_type;
- typedef typename stepper_type::order_type order_type;
- typedef typename stepper_type::time_type time_type;
-
- constant_system< container_type > con;
-
- BOOST_CHECK_EQUAL( order_error_step , stepper.order_error_step() );
- BOOST_CHECK_EQUAL( order_error , stepper.order_error() );
-
- container_type x( 1 , 0.0 ) , xerr( 1 , 0.0 );
- stepper.adjust_size( x );
-
- stepper.do_step( con , x , 0.0 , 0.1 , xerr );
- 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_SMALL( fabs( x[0] - 0.2 ) , eps );
- BOOST_CHECK_SMALL( fabs( xerr[0] ) , eps );
-
- stepper_type stepper2( x );
- stepper_type stepper3;
-}
-
-
-
-
-
-template< class ControlledErrorStepper >
-void check_controlled_stepper_concept(
- ControlledErrorStepper &stepper
- )
-{
- typedef ControlledErrorStepper stepper_type;
- typedef typename stepper_type::container_type container_type;
- typedef typename stepper_type::traits_type traits_type;
- typedef typename stepper_type::value_type value_type;
- typedef typename stepper_type::order_type order_type;
- typedef typename stepper_type::time_type time_type;
-
+//template< class Stepper >
+//void check_stepper_concept( Stepper &stepper ,
+// typename Stepper::order_type order_step )
+//{
+// typedef Stepper stepper_type;
+// typedef typename stepper_type::container_type container_type;
+// typedef typename stepper_type::traits_type traits_type;
+// typedef typename stepper_type::value_type value_type;
+// typedef typename stepper_type::order_type order_type;
+// typedef typename stepper_type::time_type time_type;
+//
 // constant_system< container_type > con;
-
- container_type x( 1 , 0.0 );
- stepper.adjust_size( x );
-}
-
-
-
-
-
-void test_euler_concept()
-{
- stepper_euler< std::vector<double> > stepper;
- check_stepper_concept( stepper , 1 );
-}
-
-
-
-void test_half_step_euler_concept()
-{
- stepper_half_step< stepper_euler< std::vector< double > > > stepper;
- check_stepper_concept( stepper , 1 );
- check_error_stepper_concept( stepper , 1 , 2 );
-}
-
-/*
-void test_midpoint_concept()
-{
- stepper_midpoint< std::vector< double > > stepper;
- stepper.set_step_number( 4 );
- unsigned short step_number = stepper.get_step_number();
- step_number = 5; // no warnings
- check_stepper_concept( stepper , 2 );
-}
-
-void test_rk4_classical_concept()
-{
- stepper_rk4_classical< std::vector<double> > stepper;
- check_stepper_concept( stepper , 4 );
-}
-
-void test_rk4_concept()
-{
- stepper_rk4< std::vector<double> > stepper;
- 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 );
-}
-*/
-
-void test_controlled_stepper_standard_concept()
-{
- typedef stepper_euler< std::vector< double > > stepper_type;
- typedef controlled_stepper_standard< stepper_type > controlled_stepper_type;
-
- controlled_stepper_type stepper( 1.0 , 1.0 , 1.0 , 1.0 );
- check_controlled_stepper_concept( stepper );
- }
-
+//
+// BOOST_CHECK_EQUAL( order_step , stepper.order_step() );
+//
+// container_type x( 1 , 0.0 ) ;
+// stepper.adjust_size( x );
+// stepper.do_step( con , x , 0.0 , 0.1 );
+// 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_SMALL( fabs( x[0] - 0.2 ) , eps );
+//
+// stepper_type stepper2( x );
+// stepper_type stepper3;
+//}
+//
+//
+//
+//
+//template< class ErrorStepper >
+//void check_error_stepper_concept(
+// ErrorStepper &stepper ,
+// typename ErrorStepper::order_type order_error_step ,
+// typename ErrorStepper::order_type order_error )
+//{
+// typedef ErrorStepper stepper_type;
+// typedef typename stepper_type::container_type container_type;
+// typedef typename stepper_type::traits_type traits_type;
+// typedef typename stepper_type::value_type value_type;
+// typedef typename stepper_type::order_type order_type;
+// typedef typename stepper_type::time_type time_type;
+//
+// constant_system< container_type > con;
+//
+// BOOST_CHECK_EQUAL( order_error_step , stepper.order_error_step() );
+// BOOST_CHECK_EQUAL( order_error , stepper.order_error() );
+//
+// container_type x( 1 , 0.0 ) , xerr( 1 , 0.0 );
+// stepper.adjust_size( x );
+//
+// stepper.do_step( con , x , 0.0 , 0.1 , xerr );
+// 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_SMALL( fabs( x[0] - 0.2 ) , eps );
+// BOOST_CHECK_SMALL( fabs( xerr[0] ) , eps );
+//
+// stepper_type stepper2( x );
+// stepper_type stepper3;
+//}
+//
+//
+//
+//
+//
+//template< class ControlledErrorStepper >
+//void check_controlled_stepper_concept(
+// ControlledErrorStepper &stepper
+// )
+//{
+// typedef ControlledErrorStepper stepper_type;
+// typedef typename stepper_type::container_type container_type;
+// typedef typename stepper_type::traits_type traits_type;
+// typedef typename stepper_type::value_type value_type;
+// typedef typename stepper_type::order_type order_type;
+// typedef typename stepper_type::time_type time_type;
+//
+//// constant_system< container_type > con;
+//
+// container_type x( 1 , 0.0 );
+// stepper.adjust_size( x );
+//}
+//
+//
+//
+//
+//
+//void test_euler_concept()
+//{
+// stepper_euler< std::vector<double> > stepper;
+// check_stepper_concept( stepper , 1 );
+//}
+//
+//
+//
+//void test_half_step_euler_concept()
+//{
+// stepper_half_step< stepper_euler< std::vector< double > > > stepper;
+// check_stepper_concept( stepper , 1 );
+// check_error_stepper_concept( stepper , 1 , 2 );
+//}
+//
+///*
+//void test_midpoint_concept()
+//{
+// stepper_midpoint< std::vector< double > > stepper;
+// stepper.set_step_number( 4 );
+// unsigned short step_number = stepper.get_step_number();
+// step_number = 5; // no warnings
+// check_stepper_concept( stepper , 2 );
+//}
+//
+//void test_rk4_classical_concept()
+//{
+// stepper_rk4_classical< std::vector<double> > stepper;
+// check_stepper_concept( stepper , 4 );
+//}
+//
+//void test_rk4_concept()
+//{
+// stepper_rk4< std::vector<double> > stepper;
+// 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 );
+//}
+//*/
+//
+//void test_controlled_stepper_standard_concept()
+//{
+// typedef stepper_euler< std::vector< double > > stepper_type;
+// typedef controlled_stepper_standard< stepper_type > controlled_stepper_type;
+//
+// controlled_stepper_type stepper( 1.0 , 1.0 , 1.0 , 1.0 );
+// check_controlled_stepper_concept( stepper );
+// }
+//
 
 
 test_suite* init_unit_test_suite( int argc, char* argv[] )
 {
     test_suite *test = BOOST_TEST_SUITE("check stepper concepts");
 
- test->add( BOOST_TEST_CASE( &test_euler_concept ) );
- test->add( BOOST_TEST_CASE( &test_half_step_euler_concept ) );
-/* 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 ) );*/
- test->add( BOOST_TEST_CASE( &test_controlled_stepper_standard_concept ) );
+// test->add( BOOST_TEST_CASE( &test_euler_concept ) );
 
     return test;
 }

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gsl_vector_adaptor.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gsl_vector_adaptor.hpp 2010-07-05 07:09:04 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,42 @@
+/*
+ boost header: xyz/gsl_vector_adaptor.hpp
+
+ Copyright 2009 Karsten Ahnert
+ Copyright 2009 Mario Mulansky
+ Copyright 2009 Andre Bergner
+
+ 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 GSL_VECTOR_ADAPTOR_HPP_INCLUDED
+#define GSL_VECTOR_ADAPTOR_HPP_INCLUDED
+
+#include <gsl/gsl_vector.h>
+
+namespace boost
+{
+ // ToDo define gsl_vector_iterator which increments x by stride
+
+ template<>
+ struct range_iterator< gsl_vector >
+ {
+ typedef double* type;
+ };
+
+ template<>
+ range_iterator< gsl_vector > begin( gsl_vector &r )
+ {
+ return r.data;
+ }
+
+ template<>
+ range_iterator< gsl_vector > end( gsl_vector &r )
+ {
+ return r.data + r.size;
+ }
+
+}
+
+#endif // GSL_VECTOR_ADAPTOR_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/vector_space_1d.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/vector_space_1d.hpp 2010-07-05 07:09:04 EDT (Mon, 05 Jul 2010)
@@ -0,0 +1,68 @@
+/*
+ boost header: xyz/vector_space_1d.hpp
+
+ Copyright 2009 Karsten Ahnert
+ Copyright 2009 Mario Mulansky
+ Copyright 2009 Andre Bergner
+
+ 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 VECTOR_SPACE_1D_HPP_INCLUDED
+#define VECTOR_SPACE_1D_HPP_INCLUDED
+
+#include <boost/operators.hpp>
+
+template< class T >
+struct vector_space_1d :
+ boost::additive1< vector_space_1d< T > ,
+ boost::additive2< vector_space_1d< T > , T ,
+ boost::multiplicative2< vector_space_1d< T > , T
+ > > >
+{
+ typedef T value_type;
+
+ value_type m_x;
+
+ vector_space_1d( void ) : m_x( 0.0 ) {}
+
+ vector_space_1d& operator+=( const vector_space_1d& p )
+ {
+ m_x += p.m_x;
+ return *this;
+ }
+
+ vector_space_1d& operator-=( const vector_space_1d& p )
+ {
+ m_x -= p.m_x;
+ return *this;
+ }
+
+ vector_space_1d& operator+=( const value_type& val )
+ {
+ m_x += val;
+ return *this;
+ }
+
+ vector_space_1d& operator-=( const value_type& val )
+ {
+ m_x -= val;
+ return *this;
+ }
+
+ vector_space_1d& operator*=( const value_type &val )
+ {
+ m_x *= val;
+ return *this;
+ }
+
+ vector_space_1d& operator/=( const value_type &val )
+ {
+ m_x /= val;
+ return *this;
+ }
+};
+
+#endif // VECTOR_SPACE_1D_HPP_INCLUDED


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