|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70962 - sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor
From: karsten.ahnert_at_[hidden]
Date: 2011-04-03 15:48:23
Author: karsten
Date: 2011-04-03 15:48:22 EDT (Sun, 03 Apr 2011)
New Revision: 70962
URL: http://svn.boost.org/trac/boost/changeset/70962
Log:
* taylor stepper
Added:
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_controller.hpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_adaptive.cpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_adaptive_statistics.cpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_direct.cpp (contents, props changed)
- copied, changed from r70937, /sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol.cpp
Removed:
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol.cpp
Text files modified:
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/Jamfile | 4 +
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor.hpp | 70 ++++++++++++++++++++++++++++++++++++---
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_direct.cpp | 1
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_main.cpp | 17 ++++++--
4 files changed, 80 insertions(+), 12 deletions(-)
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/Jamfile 2011-04-03 15:48:22 EDT (Sun, 03 Apr 2011)
@@ -11,4 +11,6 @@
;
exe taylor_main : taylor_main.cpp ;
-exe taylor_lorenz_evol : taylor_lorenz_evol.cpp ;
+exe taylor_lorenz_evol_direct : taylor_lorenz_evol_direct.cpp ;
+exe taylor_lorenz_evol_adaptive : taylor_lorenz_evol_adaptive.cpp ;
+exe taylor_lorenz_evol_adaptive_statistics : taylor_lorenz_evol_adaptive_statistics.cpp ;
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor.hpp 2011-04-03 15:48:22 EDT (Sun, 03 Apr 2011)
@@ -151,31 +151,89 @@
public:
static const size_t dim = N;
- static const size_t order = Order;
+ static const size_t order_value = Order;
typedef double value_type;
typedef value_type time_type;
+ typedef unsigned short order_type;
typedef std::tr1::array< value_type , dim > state_type;
- typedef std::tr1::array< state_type , order > derivs_type;
+ typedef state_type deriv_type;
+ typedef std::tr1::array< state_type , order_value > derivs_type;
+
+ order_type order( void ) const
+ {
+ return order_value;
+ }
+
+ order_type stepper_order( void ) const
+ {
+ return order_value;
+ }
+
+ order_type error_order( void ) const
+ {
+ return order_value - 1;
+ }
+
template< class System >
- void do_step( System sys , state_type &x , value_type t , value_type dt )
+ void do_step( System sys , state_type &x , time_type t , time_type dt )
{
+ BOOST_STATIC_ASSERT(( boost::fusion::traits::is_sequence< System >::value ));
+ BOOST_STATIC_ASSERT(( size_t( boost::fusion::result_of::size< System >::value ) == dim ));
+
+ do_step( sys , x , t , x , dt );
+ }
+
+ template< class System >
+ void do_step( System sys , const state_type &in , time_type t , state_type &out , time_type dt )
+ {
+ BOOST_STATIC_ASSERT(( boost::fusion::traits::is_sequence< System >::value ));
+ BOOST_STATIC_ASSERT(( size_t( boost::fusion::result_of::size< System >::value ) == dim ));
+
+ for( size_t i=0 ; i<Order ; ++i )
+ {
+ boost::mpl::for_each< boost::mpl::range_c< size_t , 0 , dim > >( make_eval_derivs( sys , in , m_derivs , i , dt ) );
+ }
+ for( size_t i=0 ; i<N ; ++i )
+ {
+ out[i] = in[i];
+ for( size_t k=0 ; k<order_value ; ++k )
+ out[i] += m_derivs[k][i];
+ }
+ }
+
+ template< class System >
+ void do_step( System sys , state_type &x , time_type t , time_type dt , state_type &xerr )
+ {
+ BOOST_STATIC_ASSERT(( boost::fusion::traits::is_sequence< System >::value ));
+ BOOST_STATIC_ASSERT(( size_t( boost::fusion::result_of::size< System >::value ) == dim ));
+ BOOST_STATIC_ASSERT(( order_value > 1 ));
+
+ do_step( sys , x , t , x , dt , xerr );
+ }
+
+ template< class System >
+ void do_step( System sys , const state_type &in , time_type t , state_type &out , time_type dt , state_type &xerr )
+ {
BOOST_STATIC_ASSERT(( boost::fusion::traits::is_sequence< System >::value ));
BOOST_STATIC_ASSERT(( size_t( boost::fusion::result_of::size< System >::value ) == dim ));
+ BOOST_STATIC_ASSERT(( order_value > 1 ));
for( size_t i=0 ; i<Order ; ++i )
{
- boost::mpl::for_each< boost::mpl::range_c< size_t , 0 , dim > >( make_eval_derivs( sys , x , m_derivs , i , dt ) );
+ boost::mpl::for_each< boost::mpl::range_c< size_t , 0 , dim > >( make_eval_derivs( sys , in , m_derivs , i , dt ) );
}
for( size_t i=0 ; i<N ; ++i )
{
- for( size_t k=0 ; k<order ; ++k )
- x[i] += m_derivs[k][i];
+ out[i] = in[i];
+ for( size_t k=0 ; k<order_value ; ++k )
+ out[i] += m_derivs[k][i];
+ xerr[i] = m_derivs[order_value-1][i];
}
}
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_controller.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_controller.hpp 2011-04-03 15:48:22 EDT (Sun, 03 Apr 2011)
@@ -0,0 +1,148 @@
+/*
+ boost header: NUMERIC_ODEINT_STEPPER/controlled_error_stepper.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_NUMERIC_ODEINT_STEPPER_TAYLOR_CONTROLLER_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_STEPPER_TAYLOR_CONTROLLER_HPP_INCLUDED
+
+#include <cmath>
+
+#include <boost/numeric/odeint/algebra/range_algebra.hpp>
+#include <boost/numeric/odeint/algebra/default_operations.hpp>
+#include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
+#include <boost/numeric/odeint/stepper/controlled_error_stepper.hpp>
+
+
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+/*
+ * explicit stepper version
+ */
+template
+<
+ class TaylorStepper
+>
+class taylor_controller
+{
+
+public:
+
+ typedef TaylorStepper stepper_type;
+ typedef typename stepper_type::state_type state_type;
+ typedef typename stepper_type::value_type value_type;
+ typedef typename stepper_type::deriv_type deriv_type;
+ typedef typename stepper_type::time_type time_type;
+ typedef typename stepper_type::order_type order_type;
+ typedef default_error_checker< value_type > error_checker_type;
+ typedef controlled_stepper_tag stepper_category;
+
+
+ taylor_controller(
+ value_type eps_abs = static_cast< value_type >( 1.0e-6 ) ,
+ value_type eps_rel = static_cast< value_type >( 1.0e-6 ) ,
+ value_type a_x = static_cast< value_type >( 1.0 ) ,
+ value_type a_dxdt = static_cast< value_type >( 1.0 ) ,
+ const stepper_type &stepper = stepper_type()
+ )
+ : m_stepper( stepper ) ,
+ m_error_checker( eps_abs , eps_rel , a_x , a_dxdt ) ,
+ m_xerr() , m_xnew()
+ {
+ }
+
+
+ template< class System >
+ controlled_step_result try_step( System system , state_type &x , time_type &t , time_type &dt )
+ {
+ controlled_step_result res = try_step( system , x , t , m_xnew , dt );
+ if( ( res == success_step_size_increased ) || ( res == success_step_size_unchanged ) )
+ {
+ x = m_xnew;
+ }
+ return res;
+ }
+
+
+ template< class System >
+ controlled_step_result try_step( System system , state_type &in , time_type &t , state_type &out , time_type &dt )
+ {
+ using std::max;
+ using std::min;
+ using std::pow;
+
+ // do one step with error calculation
+ m_stepper.do_step( system , in , t , out , dt , m_xerr );
+
+ value_type max_rel_error = m_error_checker.error( in , m_stepper.get_last_derivs()[0] , m_xerr , dt );
+
+ if( max_rel_error > 1.1 )
+ {
+ // error too large - decrease dt ,limit scaling factor to 0.2 and reset state
+ dt *= max( 0.9 * pow( max_rel_error , -1.0 / ( m_stepper.error_order() - 1.0 ) ) , 0.2 );
+ return step_size_decreased;
+ }
+ else
+ {
+ if( max_rel_error < 0.5 )
+ {
+ //error too small - increase dt and keep the evolution and limit scaling factor to 5.0
+ t += dt;
+ dt *= min( 0.9 * pow( max_rel_error , -1.0 / m_stepper.stepper_order() ) , 5.0 );
+ return success_step_size_increased;
+ }
+ else
+ {
+ t += dt;
+ return success_step_size_unchanged;
+ }
+ }
+ }
+
+
+ stepper_type& stepper( void )
+ {
+ return m_stepper;
+ }
+
+ const stepper_type& stepper( void ) const
+ {
+ return m_stepper;
+ }
+
+
+private:
+
+
+
+ stepper_type m_stepper;
+ error_checker_type m_error_checker;
+ state_type m_xerr;
+ state_type m_xnew;
+};
+
+
+
+
+
+
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif // BOOST_NUMERIC_ODEINT_STEPPER_TAYLOR_CONTROLLER_HPP_INCLUDED
Deleted: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol.cpp 2011-04-03 15:48:22 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,79 +0,0 @@
-/*
- * main.cpp
- *
- * Created on: Apr 2, 2011
- * Author: karsten
- */
-
-#include <iostream>
-
-#include "taylor.hpp"
-
-#include <boost/numeric/odeint/stepper/explicit_rk4.hpp>
-#include <boost/fusion/include/make_vector.hpp>
-
-template< typename T , size_t N >
-std::ostream& operator<<( std::ostream& out , const std::tr1::array< T , N > &x )
-{
- if( !x.empty() ) out << x[0];
- for( size_t i=1 ; i<x.size() ; ++i ) out << "\t" << x[i];
- return out;
-}
-
-typedef boost::numeric::odeint::taylor< 3 , 11 > taylor_type;
-typedef taylor_type::state_type state_type;
-typedef boost::numeric::odeint::explicit_rk4< state_type > rk4_type;
-
-const double sigma = 10.0;
-const double R = 28.0;
-const double b = 8.0 / 3.0;
-
-void lorenz( const state_type &x , state_type &dxdt , double t )
-{
- 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];
-}
-
-
-
-
-
-namespace fusion = boost::fusion;
-
-using namespace std;
-using namespace boost::numeric::odeint;
-
-using boost::numeric::odeint::taylor_adf::arg1;
-using boost::numeric::odeint::taylor_adf::arg2;
-using boost::numeric::odeint::taylor_adf::arg3;
-
-int main( int argc , char **argv )
-{
- taylor_type tay;
- rk4_type rk4;
-
-
- state_type x1 = {{ 10.0 , 10.0 , 10.0 }} , x2 = x1;
-
- const double dt = 0.1;
- double t = 0.0;
- for( size_t i=0 ; i<10000 ; ++i , t += dt )
- {
- tay.do_step(
- fusion::make_vector
- (
- sigma * ( arg2 - arg1 ) ,
- R * arg1 - arg2 - arg1 * arg3 ,
- arg1 * arg2 - b * arg3
- ) ,
- x1 , t , dt );
-
- rk4.do_step( lorenz , x2 , t , dt );
-
- cout << t << "\t" << x1 << "\t" << x2 << "\n";
- }
-
-
- return 0;
-}
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_adaptive.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_adaptive.cpp 2011-04-03 15:48:22 EDT (Sun, 03 Apr 2011)
@@ -0,0 +1,106 @@
+/*
+ * main.cpp
+ *
+ * Created on: Apr 2, 2011
+ * Author: karsten
+ */
+
+#include <iostream>
+#include <fstream>
+
+#include "taylor.hpp"
+#include "taylor_controller.hpp"
+
+#include <boost/numeric/odeint/stepper/explicit_error_rk54_ck.hpp>
+#include <boost/numeric/odeint/stepper/controlled_error_stepper.hpp>
+#include <boost/numeric/odeint/integrate/integrate_adaptive.hpp>
+
+#include <boost/fusion/include/make_vector.hpp>
+#include <boost/spirit/include/phoenix.hpp>
+
+template< typename T , size_t N >
+std::ostream& operator<<( std::ostream& out , const std::tr1::array< T , N > &x )
+{
+ if( !x.empty() ) out << x[0];
+ for( size_t i=1 ; i<x.size() ; ++i ) out << "\t" << x[i];
+ return out;
+}
+
+typedef boost::numeric::odeint::taylor< 3 , 20 > taylor_type;
+typedef taylor_type::state_type state_type;
+typedef boost::numeric::odeint::explicit_error_rk54_ck< state_type > rk54_type;
+
+const double sigma = 10.0;
+const double R = 28.0;
+const double b = 8.0 / 3.0;
+
+void lorenz( const state_type &x , state_type &dxdt , double t )
+{
+ 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];
+}
+
+
+
+
+
+namespace fusion = boost::fusion;
+namespace phoenix = boost::phoenix;
+
+using namespace std;
+using namespace boost::numeric::odeint;
+
+using boost::numeric::odeint::taylor_adf::arg1;
+using boost::numeric::odeint::taylor_adf::arg2;
+using boost::numeric::odeint::taylor_adf::arg3;
+
+struct streaming_observer
+{
+ std::ostream& m_out;
+
+ streaming_observer( std::ostream &out ) : m_out( out ) { }
+
+ template< class State >
+ void operator()( const State &x , double t ) const
+ {
+ m_out << t;
+ for( size_t i=0 ; i<x.size() ; ++i ) m_out << "\t" << x[i];
+ m_out << "\n";
+ }
+};
+
+
+int main( int argc , char **argv )
+{
+ double eps_abs = 1.0e-6;
+ double eps_rel = 1.0e-6;
+ if( argc > 2 )
+ {
+ eps_abs = atof( argv[1] );
+ eps_rel = atof( argv[2] );
+ }
+
+
+ rk54_type rk54_plain;
+ controlled_error_stepper< rk54_type > rk54( rk54_plain , default_error_checker< double >( eps_abs , eps_rel ) );
+ taylor_controller< taylor_type > taylor_controller( eps_abs , eps_rel );
+
+ state_type x1 = {{ 10.0 , 10.0 , 10.0 }} , x2 = x1;
+
+ ofstream fout( "lorenz_rk54.dat" );
+ size_t steps_rk54 = integrate_adaptive( rk54 , lorenz , x1 , 0.0 , 50.0 , 0.1 , streaming_observer( fout ) );
+ clog << "Steps RK 54 : " << steps_rk54 << endl;;
+
+ ofstream fout2( "lorenz_taylor.dat" );
+ size_t steps_taylor = integrate_adaptive( taylor_controller ,
+ fusion::make_vector
+ (
+ sigma * ( arg2 - arg1 ) ,
+ R * arg1 - arg2 - arg1 * arg3 ,
+ arg1 * arg2 - b * arg3
+ ) , x2 , 0.0 , 50.0 , 0.1 , streaming_observer( fout2 ) );
+ clog << "Steps Taylor : " << steps_taylor << endl;
+
+ return 0;
+}
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_adaptive_statistics.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_adaptive_statistics.cpp 2011-04-03 15:48:22 EDT (Sun, 03 Apr 2011)
@@ -0,0 +1,166 @@
+/*
+ * main.cpp
+ *
+ * Created on: Apr 2, 2011
+ * Author: karsten
+ */
+
+#include <iostream>
+#include <fstream>
+
+#include "taylor.hpp"
+#include "taylor_controller.hpp"
+
+#include <boost/numeric/odeint/stepper/explicit_error_rk54_ck.hpp>
+#include <boost/numeric/odeint/stepper/controlled_error_stepper.hpp>
+#include <boost/numeric/odeint/integrate/integrate_adaptive.hpp>
+
+#include <boost/fusion/include/make_vector.hpp>
+#include <boost/spirit/include/phoenix.hpp>
+#include <boost/assign.hpp>
+#include <boost/timer.hpp>
+
+#include <boost/mpl/range_c.hpp>
+#include <boost/mpl/for_each.hpp>
+
+#define tab "\t"
+
+template< typename T , size_t N >
+std::ostream& operator<<( std::ostream& out , const std::tr1::array< T , N > &x )
+{
+ if( !x.empty() ) out << x[0];
+ for( size_t i=1 ; i<x.size() ; ++i ) out << "\t" << x[i];
+ return out;
+}
+
+typedef std::tr1::array< double , 3 > state_type;
+
+typedef boost::numeric::odeint::explicit_error_rk54_ck< state_type > rk54_type;
+
+const double sigma = 10.0;
+const double R = 28.0;
+const double b = 8.0 / 3.0;
+
+void lorenz( const state_type &x , state_type &dxdt , double t )
+{
+ 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];
+}
+
+
+namespace fusion = boost::fusion;
+namespace phoenix = boost::phoenix;
+namespace mpl = boost::mpl;
+
+using namespace std;
+using namespace boost::numeric::odeint;
+using namespace boost::assign;
+
+using boost::numeric::odeint::taylor_adf::arg1;
+using boost::numeric::odeint::taylor_adf::arg2;
+using boost::numeric::odeint::taylor_adf::arg3;
+
+struct run
+{
+ vector< double > m_eps_abs_values;
+ vector< double > m_eps_rel_values;
+ double m_t_end;
+
+ run( const vector< double > &eps_abs_values , const vector< double > &eps_rel_values , double t_end )
+ : m_eps_abs_values( eps_abs_values ) , m_eps_rel_values( eps_rel_values ) , m_t_end( t_end ){ }
+
+ template< class Order >
+ void operator()( Order ) const
+ {
+ static const size_t order = Order::value;
+ typedef boost::numeric::odeint::taylor< 3 , order > taylor_type;
+
+ boost::timer timer;
+
+ char str[512] = "";
+ sprintf( str , "dat/lorenz_taylor_%02d.dat" , int( order ) );
+ ofstream fout( str );
+
+ for( size_t i=0 ; i<m_eps_abs_values.size() ; ++i )
+ {
+ for( size_t j=0 ; j<m_eps_rel_values.size() ; ++j )
+ {
+ double eps_abs = m_eps_abs_values[i];
+ double eps_rel = m_eps_rel_values[j];
+
+ taylor_controller< taylor_type > taylor_controller( eps_abs , eps_rel );
+
+ state_type x = {{ 10.0 , 10.0 , 10.0 }};
+
+ timer.restart();
+ size_t steps_taylor = integrate_adaptive( taylor_controller ,
+ fusion::make_vector
+ (
+ sigma * ( arg2 - arg1 ) ,
+ R * arg1 - arg2 - arg1 * arg3 ,
+ arg1 * arg2 - b * arg3
+ ) , x , 0.0 , m_t_end , 0.1 );
+ double time_taylor = timer.elapsed();
+
+ fout << i << tab << j << tab << eps_abs << tab << eps_rel << tab;
+ fout << steps_taylor << tab << time_taylor;
+ fout << endl;
+ }
+ fout << endl;
+ }
+
+
+ }
+};
+
+
+
+
+int main( int argc , char **argv )
+{
+ if( argc != 2 )
+ {
+ cerr << "usage taylor_lorenz_eval_adaptive_statistics t_end" << endl;
+ return -1;
+ }
+ double t_end = atof( argv[1] );
+
+ vector< double > eps_abs_values;
+ vector< double > eps_rel_values;
+
+ eps_abs_values += 1.0e1 , 1.0 , 1.0e-1 , 1.0e-2 , 1.0e-3 , 1.0e-4 , 1.0e-5 , 1.0e-6 , 1.0e-7 , 1.0e-8 , 1.0e-9 , 1.0e-10 , 1.0e-11 , 1.0e-12 , 1.0e-13 , 1.0e-14;
+ eps_rel_values += 1.0e-1 , 1.0e-2 , 1.0e-3 , 1.0e-4 , 1.0e-5 , 1.0e-6 , 1.0e-7 , 1.0e-8 , 1.0e-9 , 1.0e-10 , 1.0e-11 , 1.0e-12 , 1.0e-13 , 1.0e-14;
+
+
+ typedef mpl::range_c< size_t , 2 , 30 > order_values;
+ mpl::for_each< order_values >( run( eps_abs_values , eps_rel_values , t_end ) );
+
+
+ boost::timer timer;
+ ofstream fout( "dat/lorenz_rk54.dat" );
+ for( size_t i=0 ; i<eps_abs_values.size() ; ++i )
+ {
+ for( size_t j=0 ; j<eps_rel_values.size() ; ++j )
+ {
+ double eps_abs = eps_abs_values[i];
+ double eps_rel = eps_rel_values[i];
+
+ rk54_type rk54_plain;
+ controlled_error_stepper< rk54_type > rk54( rk54_plain , default_error_checker< double >( eps_abs , eps_rel ) );
+
+ state_type x = {{ 10.0 , 10.0 , 10.0 }};
+
+ timer.restart();
+ size_t steps_rk54 = integrate_adaptive( rk54 , lorenz , x , 0.0 , t_end , 0.1 );
+ double time_rk54 = timer.elapsed();
+
+ fout << i << tab << j << tab << eps_abs << tab << eps_rel << tab;
+ fout << steps_rk54 << tab << time_rk54 << tab;
+ fout << endl;
+ }
+ fout << endl;
+ }
+
+ return 0;
+}
Copied: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_direct.cpp (from r70937, /sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol.cpp)
==============================================================================
--- /sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_lorenz_evol_direct.cpp 2011-04-03 15:48:22 EDT (Sun, 03 Apr 2011)
@@ -10,6 +10,7 @@
#include "taylor.hpp"
#include <boost/numeric/odeint/stepper/explicit_rk4.hpp>
+
#include <boost/fusion/include/make_vector.hpp>
template< typename T , size_t N >
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_main.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_main.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_main.cpp 2011-04-03 15:48:22 EDT (Sun, 03 Apr 2011)
@@ -49,13 +49,15 @@
int main( int argc , char **argv )
{
+ cout.precision( 14 );
+
taylor_type t;
- state_type x = {{ 10.0 , 10.0 , 10.0 }} , dxdt = {{ 0.0 , 0.0 , 0.0 }} , xerr = {{ 0.0 , 0.0 , 0.0 }};
+ state_type in = {{ 10.0 , 10.0 , 10.0 }} , dxdt = {{ 0.0 , 0.0 , 0.0 }} , xerr = {{ 0.0 , 0.0 , 0.0 }} , out = {{ 0.0 ,0.0 , 0.0 }};
- lorenz( x , dxdt , 0.0 );
+ lorenz( in , dxdt , 0.0 );
- cout << x << endl;
+ cout << in << endl;
cout << dxdt << endl << endl;
t.do_step(
@@ -65,9 +67,14 @@
R * arg1 - arg2 - arg1 * arg3 ,
arg1 * arg2 - b * arg3
) ,
- x , 0.0 , 0.1 );
+ in , 0.0 , out , 0.1 , xerr );
- cout.precision( 14 );
+
+
+ cout << in << endl;
+ cout << dxdt << endl;
+ cout << xerr << endl;
+ cout << out << endl << endl;
const derivs_type &derivs = t.get_last_derivs();
for( size_t i=0 ; i<derivs.size() ; ++i )
cout << derivs[i] << endl;
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