check_mkl.cpp 1.3 KB

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