Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71868 - sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4
From: karsten.ahnert_at_[hidden]
Date: 2011-05-11 02:52:33


Author: karsten
Date: 2011-05-11 02:52:32 EDT (Wed, 11 May 2011)
New Revision: 71868
URL: http://svn.boost.org/trac/boost/changeset/71868

Log:
performance test for taylor v4
Added:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/taylor_lorenz_evol_adaptive_statistics.cpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/Jamfile | 1 +
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/taylor.hpp | 11 +++++------
   2 files changed, 6 insertions(+), 6 deletions(-)

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/Jamfile 2011-05-11 02:52:32 EDT (Wed, 11 May 2011)
@@ -11,3 +11,4 @@
     ;
 
 exe taylor_main : taylor_main.cpp ;
+exe taylor_lorenz_evol_adaptive_statistics : taylor_lorenz_evol_adaptive_statistics.cpp ;
\ No newline at end of file

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/taylor.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/taylor.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/taylor.hpp 2011-05-11 02:52:32 EDT (Wed, 11 May 2011)
@@ -392,7 +392,8 @@
         typedef state_type deriv_type;
         typedef std::tr1::array< state_type , order_value > derivs_type;
 
- taylor( void ) : m_derivs() , m_dt_fac( 1.0 ) { }
+ taylor( value_type rel_error = 1.0e-14 )
+ : m_derivs() , m_dt_fac( 1.0 ) , m_rel_error( rel_error ) { }
 
     order_type order( void ) const
     {
@@ -424,9 +425,6 @@
         template< class System >
         void try_step( System sys , const state_type &in , time_type &t , state_type &out , time_type &dt )
         {
- // this is the max rel error and should be parametrized
- const double dt0 = 1.0e-17;
-
                 BOOST_STATIC_ASSERT(( boost::fusion::traits::is_sequence< System >::value ));
                 BOOST_STATIC_ASSERT(( size_t( boost::fusion::result_of::size< System >::value ) == dim ));
 
@@ -439,7 +437,7 @@
                         max_error = std::max( error , max_error );
                 }
 
- dt = pow( dt0 / max_error , 1.0 / double( order_value ) );
+ dt = pow( m_rel_error / max_error , 1.0 / double( order_value ) );
 // clog << dt << tab << max_error << tab << in[0] << tab << in[1] << tab << in[2] << tab;
 // clog << m_derivs[0][0] << tab << m_derivs[0][1] << tab << m_derivs[0][2] << tab << m_dt_fac << endl;
 
@@ -542,7 +540,8 @@
 private:
 
         derivs_type m_derivs;
- double m_dt_fac;
+ time_type m_dt_fac;
+ value_type m_rel_error;
 
 };
 

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/taylor_lorenz_evol_adaptive_statistics.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/taylor/taylor_v4/taylor_lorenz_evol_adaptive_statistics.cpp 2011-05-11 02:52:32 EDT (Wed, 11 May 2011)
@@ -0,0 +1,123 @@
+/*
+ * main.cpp
+ *
+ * Created on: Apr 2, 2011
+ * Author: karsten
+ */
+
+#include <iostream>
+#include <fstream>
+
+#include "taylor.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;
+
+const double sigma = 10.0;
+const double R = 28.0;
+const double b = 8.0 / 3.0;
+
+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_rel_values;
+ double m_t_end;
+
+ run( const vector< double > &eps_rel_values , double t_end )
+ : 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 j=0 ; j<m_eps_rel_values.size() ; ++j )
+ {
+ double eps_rel = m_eps_rel_values[j];
+
+ taylor_type taylor( eps_rel );
+
+ state_type x = {{ 10.0 , 10.0 , 10.0 }};
+
+ timer.restart();
+ size_t steps_taylor = 0;
+ double t = 0.0 , dt = 1.0;
+ while( t < m_t_end )
+ {
+ taylor.try_step(
+ fusion::make_vector
+ (
+ sigma * ( arg2 - arg1 ) ,
+ R * arg1 - arg2 - arg1 * arg3 ,
+ arg1 * arg2 - b * arg3
+ ) , x , t , dt );
+ steps_taylor++;
+ }
+ double time_taylor = timer.elapsed();
+
+ fout << j << tab << eps_rel << tab;
+ fout << steps_taylor << tab << time_taylor;
+ 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_rel_values;
+
+ 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 , 5 , 30 > order_values;
+ mpl::for_each< order_values >( run( eps_rel_values , t_end ) );
+
+
+
+ return 0;
+}


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