Brian Silverman | 7c33ab2 | 2018-08-04 17:14:51 -0700 | [diff] [blame^] | 1 | /* Boost check_mkl.cpp test file |
| 2 | |
| 3 | Copyright 2010-2011 Mario Mulansky |
| 4 | Copyright 2011 Karsten Ahnert |
| 5 | |
| 6 | This file tests the odeint library with the intel mkl blas1 routines |
| 7 | |
| 8 | Distributed under the Boost Software License, Version 1.0. |
| 9 | (See accompanying file LICENSE_1_0.txt or |
| 10 | copy at http://www.boost.org/LICENSE_1_0.txt) |
| 11 | */ |
| 12 | |
| 13 | #define BOOST_TEST_MODULE test_mkl |
| 14 | |
| 15 | #include <boost/test/unit_test.hpp> |
| 16 | |
| 17 | #include <boost/numeric/odeint/stepper/euler.hpp> |
| 18 | #include <boost/numeric/odeint/stepper/runge_kutta4.hpp> |
| 19 | #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp> |
| 20 | #include <boost/numeric/odeint/external/mkl/mkl_operations.hpp> |
| 21 | |
| 22 | using namespace boost::numeric::odeint; |
| 23 | |
| 24 | typedef double value_type; |
| 25 | typedef boost::array< value_type , 1 > state_type; |
| 26 | |
| 27 | |
| 28 | void constant_system( state_type &x , state_type &dxdt , value_type t ) |
| 29 | { |
| 30 | dxdt[0] = 1.0; |
| 31 | } |
| 32 | |
| 33 | const double eps = 1E-14; |
| 34 | |
| 35 | |
| 36 | BOOST_AUTO_TEST_CASE( test_mkl ) |
| 37 | { |
| 38 | |
| 39 | //to use mkl routines we have to use the vector_space_algebra and the mkl_operations |
| 40 | runge_kutta4< state_type , value_type , state_type , value_type , vector_space_algebra , mkl_operations > stepper; |
| 41 | state_type x; |
| 42 | x[0] = 0.0; |
| 43 | |
| 44 | stepper.do_step( constant_system , x , 0.0 , 0.1 ); |
| 45 | |
| 46 | using std::abs; |
| 47 | |
| 48 | std::cout << x[0] << " ?= " << 0.1 << std::endl; |
| 49 | BOOST_CHECK_SMALL( abs( x[0] - 0.1 ) , eps ); |
| 50 | |
| 51 | } |