diff --git a/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/Jamfile b/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/Jamfile index 3a5ddf51..0f0cf771 100644 --- a/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/Jamfile +++ b/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/Jamfile @@ -24,6 +24,10 @@ exe odeint_rk4 : odeint_rk4.cpp ; +exe odeint_rk4_def_alg + : odeint_rk4_def_alg.cpp + ; + exe nr_rk4 : nr_rk4.cpp ; @@ -46,6 +50,10 @@ exe odeint_rk54ck : odeint_rk54ck.cpp ; +exe odeint_rk54ck_def_alg + : odeint_rk54ck_def_alg.cpp + ; + exe gsl_rk54ck : gsl_rk54ck.cpp libgsl libgslcblas ; \ No newline at end of file diff --git a/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4.cpp b/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4.cpp index 755759c8..e7e6e763 100644 --- a/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4.cpp +++ b/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4.cpp @@ -36,9 +36,8 @@ typedef boost::timer timer_type; typedef boost::array< double , 3 > state_type; -typedef boost::numeric::odeint::explicit_rk4< state_type > rk4_odeint_type; -//typedef boost::numeric::odeint::explicit_rk4< state_type , double , state_type , double , -// boost::numeric::odeint::array_algebra > rk4_odeint_type; +typedef boost::numeric::odeint::explicit_rk4< state_type , double , state_type , double , + boost::numeric::odeint::array_algebra > rk4_odeint_type; inline void lorenz( const state_type &x , state_type &dxdt , const double t ) diff --git a/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4_def_alg.cpp b/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4_def_alg.cpp new file mode 100644 index 00000000..8a53a2d9 --- /dev/null +++ b/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4_def_alg.cpp @@ -0,0 +1,84 @@ +/* + * odeint_rk4.cpp + * + * Created on: Apr 28, 2011 + * Author: mario + */ + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#define tab "\t" + +using namespace std; +using namespace boost::accumulators; + +typedef accumulator_set< + double , stats< tag::mean , tag::variance > + > accumulator_type; + +ostream& operator<<( ostream& out , accumulator_type &acc ) +{ + out << boost::accumulators::mean( acc ) << tab; +// out << boost::accumulators::variance( acc ) << tab; + return out; +} + +typedef boost::timer timer_type; + + +typedef boost::array< double , 3 > state_type; +typedef boost::numeric::odeint::explicit_rk4< state_type > rk4_odeint_type; + +inline void lorenz( const state_type &x , state_type &dxdt , const double t ) +{ + const double sigma = 10.0; + const double R = 28.0; + const double b = 8.0 / 3.0; + 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]; +} + + +const size_t loops = 20; + +int main( int argc , char **argv ) +{ + rk4_odeint_type rk4_odeint; + + const size_t num_of_steps = 20000000; + const double dt = 1E-10; + + accumulator_type acc; + timer_type timer; + + srand( 12312354 ); + + for( size_t n=0 ; n +#include + +#include + +#include +#include +#include +#include +#include + +#define tab "\t" + +using namespace std; +using namespace boost::accumulators; + +typedef accumulator_set< + double , stats< tag::mean , tag::variance > + > accumulator_type; + +ostream& operator<<( ostream& out , accumulator_type &acc ) +{ + out << boost::accumulators::mean( acc ) << tab; +// out << boost::accumulators::variance( acc ) << tab; + return out; +} + +typedef boost::timer timer_type; + + +typedef boost::array< double , 3 > state_type; +typedef boost::numeric::odeint::explicit_error_rk54_ck< state_type > rk54_ck_odeint_type; + + +inline void lorenz( const state_type &x , state_type &dxdt , const double t ) +{ + const double sigma = 10.0; + const double R = 28.0; + const double b = 8.0 / 3.0; + 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]; +} + + +const size_t loops = 20; + +int main( int argc , char **argv ) +{ + rk54_ck_odeint_type rk54_ck_odeint; + + const size_t num_of_steps = 20000000; + const double dt = 1E-4; + + accumulator_type acc; + timer_type timer; + + srand( 12312354 ); + + for( size_t n=0 ; n