summaryrefslogtreecommitdiff
path: root/libs/numeric/odeint/performance/generic_odeint_rk4_lorenz.cpp
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
commit08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch)
tree7a7053ceb8874b28ec4b868d4c49b500008a102e /libs/numeric/odeint/performance/generic_odeint_rk4_lorenz.cpp
parentbb4dd8289b351fae6b55e303f189127a394a1edd (diff)
downloadboost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'libs/numeric/odeint/performance/generic_odeint_rk4_lorenz.cpp')
-rw-r--r--libs/numeric/odeint/performance/generic_odeint_rk4_lorenz.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/libs/numeric/odeint/performance/generic_odeint_rk4_lorenz.cpp b/libs/numeric/odeint/performance/generic_odeint_rk4_lorenz.cpp
new file mode 100644
index 0000000000..0d09756463
--- /dev/null
+++ b/libs/numeric/odeint/performance/generic_odeint_rk4_lorenz.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2011 Mario Mulansky
+ * Copyright 2012 Karsten Ahnert
+ *
+ * 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)
+ */
+
+
+#include <boost/array.hpp>
+
+//#include <boost/numeric/odeint/stepper/explicit_generic_rk.hpp>
+#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
+#include <boost/numeric/odeint/algebra/array_algebra.hpp>
+
+#include "rk_performance_test_case.hpp"
+
+#include "lorenz.hpp"
+
+using namespace boost::numeric::odeint;
+
+typedef boost::array< double , 3 > state_type;
+
+/*
+typedef explicit_generic_rk< 4 , 4 , state_type , double , state_type , double , array_algebra > rk4_type;
+
+typedef rk4_type::coef_a_type coef_a_type;
+typedef rk4_type::coef_b_type coef_b_type;
+typedef rk4_type::coef_c_type coef_c_type;
+
+const boost::array< double , 1 > a1 = {{ 0.5 }};
+const boost::array< double , 2 > a2 = {{ 0.0 , 0.5 }};
+const boost::array< double , 3 > a3 = {{ 0.0 , 0.0 , 1.0 }};
+
+const coef_a_type a = fusion::make_vector( a1 , a2 , a3 );
+const coef_b_type b = {{ 1.0/6 , 1.0/3 , 1.0/3 , 1.0/6 }};
+const coef_c_type c = {{ 0.0 , 0.5 , 0.5 , 1.0 }};
+*/
+
+typedef runge_kutta4< state_type , double , state_type , double , array_algebra > rk4_type;
+
+
+class rk4_wrapper
+{
+
+public:
+
+ rk4_wrapper()
+ // : m_stepper( a , b , c )
+ {}
+
+ void reset_init_cond()
+ {
+ m_x[0] = 10.0 * rand() / RAND_MAX;
+ m_x[1] = 10.0 * rand() / RAND_MAX;
+ m_x[2] = 10.0 * rand() / RAND_MAX;
+ m_t = 0.0;
+ }
+
+ inline void do_step( const double dt )
+ {
+ m_stepper.do_step( lorenz(), m_x , m_t , dt );
+ }
+
+ double state( const size_t i ) const
+ { return m_x[i]; }
+
+private:
+ state_type m_x;
+ double m_t;
+ rk4_type m_stepper;
+};
+
+
+
+int main()
+{
+ srand( 12312354 );
+
+ rk4_wrapper stepper;
+
+ run( stepper );
+}