tools_roots_inc_test.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright John Maddock 2006.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. //
  6. // Basic sanity check that header <boost/math/tools/roots.hpp>
  7. // #includes all the files that it needs to.
  8. //
  9. #include <boost/math/tools/roots.hpp>
  10. #include <boost/math/tools/tuple.hpp>
  11. #include <utility> // for std::pair, our headers don't know what tuple type is to be used, we have to supply it.
  12. //
  13. // Note this header includes no other headers, this is
  14. // important if this test is to be meaningful:
  15. //
  16. inline void check_result_imp(std::pair<float, float>, std::pair<float, float>){}
  17. inline void check_result_imp(std::pair<double, double>, std::pair<double, double>){}
  18. inline void check_result_imp(std::pair<long double, long double>, std::pair<long double, long double>){}
  19. #include "test_compile_result.hpp"
  20. void compile_and_link_test()
  21. {
  22. typedef double (*F)(double);
  23. typedef std::pair<double, double> (*F2)(double);
  24. typedef boost::math::tuple<double, double, double> (*F3)(double);
  25. typedef boost::math::tools::eps_tolerance<double> Tol;
  26. Tol tol(u);
  27. boost::uintmax_t max_iter = 0;
  28. F f = 0;
  29. F2 f2 = 0;
  30. F3 f3 = 0;
  31. check_result<std::pair<double, double> >(boost::math::tools::bisect<F, double, Tol>(f, d, d, tol, max_iter));
  32. check_result<std::pair<double, double> >(boost::math::tools::bisect<F, double, Tol>(f, d, d, tol));
  33. check_result<double>(boost::math::tools::newton_raphson_iterate<F2, double>(f2, d, d, d, i, max_iter));
  34. check_result<double>(boost::math::tools::halley_iterate<F3, double>(f3, d, d, d, i, max_iter));
  35. check_result<double>(boost::math::tools::schroder_iterate<F3, double>(f3, d, d, d, i, max_iter));
  36. }