|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72163 - in sandbox/odeint/branches/karsten: boost/numeric/odeint/stepper boost/numeric/odeint/stepper/detail libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2011-05-25 15:01:05
Author: karsten
Date: 2011-05-25 15:01:04 EDT (Wed, 25 May 2011)
New Revision: 72163
URL: http://svn.boost.org/trac/boost/changeset/72163
Log:
adams moulton, sry will not compile
Added:
sandbox/odeint/branches/karsten/libs/numeric/odeint/test/adams_moulton.cpp (contents, props changed)
Text files modified:
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_moulton.hpp | 39 ++++++++++-----------
sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp | 71 +++++++++++++++++++--------------------
sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile | 1
3 files changed, 55 insertions(+), 56 deletions(-)
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_moulton.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_moulton.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_moulton.hpp 2011-05-25 15:01:04 EDT (Wed, 25 May 2011)
@@ -53,10 +53,13 @@
void initialize( void )
{
+ boost::numeric::odeint::construct( m_dxdt );
+ m_size_adjuster.register_state( 0 , m_dxdt );
}
void copy( const adam_moulton &stepper )
{
+ boost::numeric::odeint::copy( stepper.m_dxdt , m_dxdt );
}
public :
@@ -83,13 +86,13 @@
adam_moulton( void )
- : m_coefficients()
+ : m_coefficients() , m_dxdt() , m_size_adjuster()
{
initialize();
}
adam_moulton( const adam_moulton &stepper )
- : m_coefficients()
+ : m_coefficients() , m_dxdt() , m_size_adjuster()
{
initialize();
copy( stepper );
@@ -107,35 +110,31 @@
*
* solves the forwarding problem
*/
- template< class System , class StateInOut >
- void do_step( System system , StateInOut &x , const time_type &t , const time_type &dt , const )
+ template< class System , class StateIn , class StateOut , class ABBuf >
+ void do_step( System system , const StateIn &in , const StateOut &out , const time_type &t , const const ABBuf &buf )
{
- do_step( system , x , t , x , dt );
- }
-
- template< class System , class StateInOut >
- void do_step( System system , const StateInOut &x , const time_type &t , const time_type &dt )
- {
- do_step( system , x , t , x , dt );
- }
-
-
-
-
-
-
-
-
+ typename boost::unwrap_reference< System >::type &sys = system;
+ m_size_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
+ sys( in , m_dxdt , t );
+ // detail::call_algebra< steps , algebra_type , operations_type >()( in , out , buf , m_coefficients , dt );
+ }
+ template< class StateType >
+ void adjust_size( const StateType &x )
+ {
+ m_size_adjuster.adjust_size();
+ }
private:
const detail::adams_moulton_coefficients< value_type , steps > m_coefficients;
+ deriv_type m_dxdt;
+ size_adjuster< deriv_type > m_size_adjuster;
};
Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp 2011-05-25 15:01:04 EDT (Wed, 25 May 2011)
@@ -38,8 +38,8 @@
adam_moulton_coefficients( void )
: boost::array< Value , 2 >()
{
- (*this)[0] = static_cast< Value >( 3.0 ) / static_cast< Value >( 2.0 );
- (*this)[1] = -static_cast< Value >( 1.0 ) / static_cast< Value >( 2.0 );
+ (*this)[0] = static_cast< Value >( 1.0 ) / static_cast< Value >( 2.0 );
+ (*this)[1] = static_cast< Value >( 1.0 ) / static_cast< Value >( 2.0 );
}
};
@@ -51,9 +51,9 @@
adam_moulton_coefficients( void )
: boost::array< Value , 3 >()
{
- (*this)[0] = static_cast< Value >( 23.0 ) / static_cast< Value >( 12.0 );
- (*this)[1] = -static_cast< Value >( 4.0 ) / static_cast< Value >( 3.0 );
- (*this)[2] = static_cast< Value >( 5.0 ) / static_cast< Value >( 12.0 );
+ (*this)[0] = static_cast< Value >( 5.0 ) / static_cast< Value >( 12.0 );
+ (*this)[1] = static_cast< Value >( 2.0 ) / static_cast< Value >( 3.0 );
+ (*this)[2] = -static_cast< Value >( 1.0 ) / static_cast< Value >( 12.0 );
}
};
@@ -65,10 +65,10 @@
adam_moulton_coefficients( void )
: boost::array< Value , 4 >()
{
- (*this)[0] = static_cast< Value >( 55.0 ) / static_cast< Value >( 24.0 );
- (*this)[1] = -static_cast< Value >( 59.0 ) / static_cast< Value >( 24.0 );
- (*this)[2] = static_cast< Value >( 37.0 ) / static_cast< Value >( 24.0 );
- (*this)[3] = -static_cast< Value >( 3.0 ) / static_cast< Value >( 8.0 );
+ (*this)[0] = static_cast< Value >( 3.0 ) / static_cast< Value >( 8.0 );
+ (*this)[1] = static_cast< Value >( 19.0 ) / static_cast< Value >( 24.0 );
+ (*this)[2] = -static_cast< Value >( 5.0 ) / static_cast< Value >( 24.0 );
+ (*this)[3] = static_cast< Value >( 1.0 ) / static_cast< Value >( 24.0 );
}
};
@@ -80,11 +80,11 @@
adam_moulton_coefficients( void )
: boost::array< Value , 5 >()
{
- (*this)[0] = static_cast< Value >( 1901.0 ) / static_cast< Value >( 720.0 );
- (*this)[1] = -static_cast< Value >( 1387.0 ) / static_cast< Value >( 360.0 );
- (*this)[2] = static_cast< Value >( 109.0 ) / static_cast< Value >( 30.0 );
- (*this)[3] = -static_cast< Value >( 637.0 ) / static_cast< Value >( 360.0 );
- (*this)[4] = static_cast< Value >( 251.0 ) / static_cast< Value >( 720.0 );
+ (*this)[0] = static_cast< Value >( 251.0 ) / static_cast< Value >( 720.0 );
+ (*this)[1] = static_cast< Value >( 323.0 ) / static_cast< Value >( 360.0 );
+ (*this)[2] = -static_cast< Value >( 11.0 ) / static_cast< Value >( 30.0 );
+ (*this)[3] = static_cast< Value >( 53.0 ) / static_cast< Value >( 360.0 );
+ (*this)[4] = -static_cast< Value >( 19.0 ) / static_cast< Value >( 720.0 );
}
};
@@ -96,16 +96,15 @@
adam_moulton_coefficients( void )
: boost::array< Value , 6 >()
{
- (*this)[0] = static_cast< Value >( 4277.0 ) / static_cast< Value >( 1440.0 );
- (*this)[1] = -static_cast< Value >( 2641.0 ) / static_cast< Value >( 480.0 );
- (*this)[2] = static_cast< Value >( 4991.0 ) / static_cast< Value >( 720.0 );
- (*this)[3] = -static_cast< Value >( 3649.0 ) / static_cast< Value >( 720.0 );
- (*this)[4] = static_cast< Value >( 959.0 ) / static_cast< Value >( 480.0 );
- (*this)[5] = -static_cast< Value >( 95.0 ) / static_cast< Value >( 288.0 );
+ (*this)[0] = static_cast< Value >( 95.0 ) / static_cast< Value >( 288.0 );
+ (*this)[1] = static_cast< Value >( 1427.0 ) / static_cast< Value >( 1440.0 );
+ (*this)[2] = -static_cast< Value >( 133.0 ) / static_cast< Value >( 240.0 );
+ (*this)[3] = static_cast< Value >( 241.0 ) / static_cast< Value >( 720.0 );
+ (*this)[4] = -static_cast< Value >( 173.0 ) / static_cast< Value >( 1440.0 );
+ (*this)[5] = static_cast< Value >( 3.0 ) / static_cast< Value >( 160.0 );
}
};
-
template< class Value >
class adam_moulton_coefficients< Value , 7 > : public boost::array< Value , 7 >
{
@@ -113,13 +112,13 @@
adam_moulton_coefficients( void )
: boost::array< Value , 7 >()
{
- (*this)[0] = static_cast< Value >( 198721.0 ) / static_cast< Value >( 60480.0 );
- (*this)[1] = -static_cast< Value >( 18637.0 ) / static_cast< Value >( 2520.0 );
- (*this)[2] = static_cast< Value >( 235183.0 ) / static_cast< Value >( 20160.0 );
- (*this)[3] = -static_cast< Value >( 10754.0 ) / static_cast< Value >( 945.0 );
- (*this)[4] = static_cast< Value >( 135713.0 ) / static_cast< Value >( 20160.0 );
- (*this)[5] = -static_cast< Value >( 5603.0 ) / static_cast< Value >( 2520.0 );
- (*this)[6] = static_cast< Value >( 19087.0 ) / static_cast< Value >( 60480.0 );
+ (*this)[0] = static_cast< Value >( 19087.0 ) / static_cast< Value >( 60480.0 );
+ (*this)[1] = static_cast< Value >( 2713.0 ) / static_cast< Value >( 2520.0 );
+ (*this)[2] = -static_cast< Value >( 15487.0 ) / static_cast< Value >( 20160.0 );
+ (*this)[3] = static_cast< Value >( 586.0 ) / static_cast< Value >( 945.0 );
+ (*this)[4] = -static_cast< Value >( 6737.0 ) / static_cast< Value >( 20160.0 );
+ (*this)[5] = static_cast< Value >( 263.0 ) / static_cast< Value >( 2520.0 );
+ (*this)[6] = -static_cast< Value >( 863.0 ) / static_cast< Value >( 60480.0 );
}
};
@@ -131,14 +130,14 @@
adam_moulton_coefficients( void )
: boost::array< Value , 8 >()
{
- (*this)[0] = static_cast< Value >( 16083.0 ) / static_cast< Value >( 4480.0 );
- (*this)[1] = -static_cast< Value >( 1152169.0 ) / static_cast< Value >( 120960.0 );
- (*this)[2] = static_cast< Value >( 242653.0 ) / static_cast< Value >( 13440.0 );
- (*this)[3] = -static_cast< Value >( 296053.0 ) / static_cast< Value >( 13440.0 );
- (*this)[4] = static_cast< Value >( 2102243.0 ) / static_cast< Value >( 120960.0 );
- (*this)[5] = -static_cast< Value >( 115747.0 ) / static_cast< Value >( 13440.0 );
- (*this)[6] = static_cast< Value >( 32863.0 ) / static_cast< Value >( 13440.0 );
- (*this)[7] = -static_cast< Value >( 5257.0 ) / static_cast< Value >( 17280.0 );
+ (*this)[0] = static_cast< Value >( 5257.0 ) / static_cast< Value >( 17280.0 );
+ (*this)[1] = static_cast< Value >( 139849.0 ) / static_cast< Value >( 120960.0 );
+ (*this)[2] = -static_cast< Value >( 4511.0 ) / static_cast< Value >( 4480.0 );
+ (*this)[3] = static_cast< Value >( 123133.0 ) / static_cast< Value >( 120960.0 );
+ (*this)[4] = -static_cast< Value >( 88547.0 ) / static_cast< Value >( 120960.0 );
+ (*this)[5] = static_cast< Value >( 1537.0 ) / static_cast< Value >( 4480.0 );
+ (*this)[6] = -static_cast< Value >( 11351.0 ) / static_cast< Value >( 120960.0 );
+ (*this)[7] = static_cast< Value >( 275.0 ) / static_cast< Value >( 24192.0 );
}
};
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-05-25 15:01:04 EDT (Wed, 25 May 2011)
@@ -29,6 +29,7 @@
[ run rosenbrock4.cpp ]
[ run is_pair.cpp ]
[ run adams_bashforth.cpp ]
+ [ run adams_moulton.cpp ]
[ run adams_bashforth_moulton.cpp ]
[ run generic_stepper.cpp ]
: <testing.launcher>valgrind
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/adams_moulton.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/adams_moulton.cpp 2011-05-25 15:01:04 EDT (Wed, 25 May 2011)
@@ -0,0 +1,129 @@
+/*
+ * adams_moulton.cpp
+ *
+ * Created on: May 25, 2011
+ * Author: karsten
+ */
+
+#define BOOST_TEST_MODULE odeint_adams_moulton
+
+#include <utility>
+
+#include <boost/array.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+#include <boost/mpl/list.hpp>
+#include <boost/mpl/size_t.hpp>
+#include <boost/mpl/range_c.hpp>
+
+
+#include <boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp>
+#include <boost/numeric/odeint/stepper/detail/rotating_buffer.hpp>
+#include <boost/numeric/odeint/stepper/adams_moulton.hpp>
+
+using namespace boost::unit_test;
+using namespace boost::numeric::odeint;
+
+typedef double value_type;
+
+struct lorenz
+{
+ template< class State , class Deriv , class Value >
+ void operator()( const State &_x , Deriv &_dxdt , const Value &dt ) const
+ {
+ const value_type sigma = 10.0;
+ const value_type R = 28.0;
+ const value_type b = 8.0 / 3.0;
+
+ typename boost::range_iterator< const State >::type x = boost::begin( _x );
+ typename boost::range_iterator< Deriv >::type dxdt = boost::begin( _dxdt );
+
+ dxdt[0] = sigma * ( x[1] - x[0] );
+ dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
+ dxdt[2] = x[0]*x[1] - b * x[2];
+ }
+};
+
+BOOST_AUTO_TEST_SUITE( adams_moulton_test )
+
+BOOST_AUTO_TEST_CASE( test_adams_moulton_coefficients )
+{
+// detail::adams_bashforth_coefficients< value_type , 1 > c1;
+// detail::adams_bashforth_coefficients< value_type , 2 > c2;
+// detail::adams_bashforth_coefficients< value_type , 3 > c3;
+// detail::adams_bashforth_coefficients< value_type , 4 > c4;
+// detail::adams_bashforth_coefficients< value_type , 5 > c5;
+// detail::adams_bashforth_coefficients< value_type , 6 > c6;
+// detail::adams_bashforth_coefficients< value_type , 7 > c7;
+// detail::adams_bashforth_coefficients< value_type , 8 > c8;
+}
+
+BOOST_AUTO_TEST_CASE( test_copying )
+{
+ typedef boost::array< double , 1 > state_type;
+ typedef adams_moulton< 2 , state_type > stepper_type;
+
+// stepper_type s1;
+// s1.step_storage()[0][0] = 1.5;
+// s1.step_storage()[1][0] = 2.25;
+//
+// stepper_type s2( s1 );
+// BOOST_CHECK_CLOSE( s1.step_storage()[0][0] , s2.step_storage()[0][0] , 1.0e-14 );
+// BOOST_CHECK_CLOSE( s1.step_storage()[1][0] , s2.step_storage()[1][0] , 1.0e-14 );
+// BOOST_CHECK( ( &(s1.step_storage()[0]) ) != ( &(s2.step_storage()[0]) ) );
+//
+// stepper_type s3;
+// state_type *p1 = &( s3.step_storage()[0] ) , *p2 = &( s3.step_storage()[1] );
+// s3 = s1;
+// BOOST_CHECK( p1 == ( &( s3.step_storage()[0] ) ) );
+// BOOST_CHECK( p2 == ( &( s3.step_storage()[1] ) ) );
+//
+// BOOST_CHECK_CLOSE( s1.step_storage()[0][0] , s3.step_storage()[0][0] , 1.0e-14 );
+// BOOST_CHECK_CLOSE( s1.step_storage()[1][0] , s3.step_storage()[1][0] , 1.0e-14 );
+}
+
+typedef boost::mpl::range_c< size_t , 1 , 6 > vector_of_steps;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_init_and_steps , step_type , vector_of_steps )
+{
+ const static size_t steps = step_type::value;
+ typedef boost::array< value_type , 3 > state_type;
+
+ adams_moulton< steps , state_type > stepper;
+// state_type x = {{ 10.0 , 10.0 , 10.0 }};
+// const value_type dt = 0.01;
+// value_type t = 0.0;
+//
+// stepper.initialize( lorenz() , x , t , dt );
+// BOOST_CHECK_CLOSE( t , value_type( steps - 1 ) * dt , 1.0e-14 );
+//
+// stepper.do_step( lorenz() , x , t , dt );
+}
+
+BOOST_AUTO_TEST_CASE( test_instantiation )
+{
+// typedef boost::array< double , 3 > state_type;
+// adams_bashforth< 1 , state_type > s1;
+// adams_bashforth< 2 , state_type > s2;
+// adams_bashforth< 3 , state_type > s3;
+// adams_bashforth< 4 , state_type > s4;
+// adams_bashforth< 5 , state_type > s5;
+// adams_bashforth< 6 , state_type > s6;
+// adams_bashforth< 7 , state_type > s7;
+// adams_bashforth< 8 , state_type > s8;
+//
+// state_type x = {{ 10.0 , 10.0 , 10.0 }};
+// value_type t = 0.0 , dt = 0.01;
+// s1.do_step( lorenz() , x , t , dt );
+// s2.do_step( lorenz() , x , t , dt );
+// s3.do_step( lorenz() , x , t , dt );
+// s4.do_step( lorenz() , x , t , dt );
+// s5.do_step( lorenz() , x , t , dt );
+// s6.do_step( lorenz() , x , t , dt );
+//// s7.do_step( lorenz() , x , t , dt );
+//// s8.do_step( lorenz() , x , t , dt );
+}
+
+
+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