test_heuman_lambda.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright John Maddock 2015.
  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. #ifdef _MSC_VER
  6. # pragma warning(disable : 4756) // overflow in constant arithmetic
  7. // Constants are too big for float case, but this doesn't matter for test.
  8. #endif
  9. #include <boost/math/concepts/real_concept.hpp>
  10. #define BOOST_TEST_MAIN
  11. #include <boost/test/unit_test.hpp>
  12. #include <boost/test/tools/floating_point_comparison.hpp>
  13. #include <boost/math/special_functions/math_fwd.hpp>
  14. #include <boost/math/constants/constants.hpp>
  15. #include <boost/array.hpp>
  16. #include "functor.hpp"
  17. #include "handle_test_result.hpp"
  18. #include "table_type.hpp"
  19. #ifndef SC_
  20. #define SC_(x) static_cast<typename table_type<T>::type>(BOOST_JOIN(x, L))
  21. #endif
  22. template <class Real, typename T>
  23. void do_test_heuman_lambda(const T& data, const char* type_name, const char* test)
  24. {
  25. #if !(defined(ERROR_REPORTING_MODE) && !defined(HEUMAN_LAMBDA_FUNCTION_TO_TEST))
  26. typedef Real value_type;
  27. std::cout << "Testing: " << test << std::endl;
  28. #ifdef HEUMAN_LAMBDA_FUNCTION_TO_TEST
  29. value_type(*fp2)(value_type, value_type) = HEUMAN_LAMBDA_FUNCTION_TO_TEST;
  30. #elif defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
  31. value_type (*fp2)(value_type, value_type) = boost::math::ellint_d<value_type, value_type>;
  32. #else
  33. value_type(*fp2)(value_type, value_type) = boost::math::heuman_lambda;
  34. #endif
  35. boost::math::tools::test_result<value_type> result;
  36. result = boost::math::tools::test_hetero<Real>(
  37. data,
  38. bind_func<Real>(fp2, 1, 0),
  39. extract_result<Real>(2));
  40. handle_test_result(result, data[result.worst()], result.worst(),
  41. type_name, "heuman_lambda", test);
  42. std::cout << std::endl;
  43. #endif
  44. }
  45. template <typename T>
  46. void test_spots(T, const char* type_name)
  47. {
  48. BOOST_MATH_STD_USING
  49. // Function values calculated on http://functions.wolfram.com/
  50. // Note that Mathematica's EllipticE accepts k^2 as the second parameter.
  51. static const boost::array<boost::array<T, 3>, 5> data1 = {{
  52. { { SC_(0.25), SC_(0.5), SC_(0.231195544262270355901990821099667428154924832224446817213200) } },
  53. { { SC_(-0.25), SC_(0.5), SC_(-0.231195544262270355901990821099667428154924832224446817213200) } },
  54. { { SC_(0), SC_(0.5), SC_(0) } },
  55. { { SC_(1), T(0.5), SC_(0.792745183008071035953588061452801838417979005666066982987549) } },
  56. { { SC_(1), T(0), SC_(0.841470984807896506652502321630298999622563060798371065672751) } },
  57. }};
  58. do_test_heuman_lambda<T>(data1, type_name, "Elliptic Integral Jacobi Zeta: Mathworld Data");
  59. #include "heuman_lambda_data.ipp"
  60. do_test_heuman_lambda<T>(heuman_lambda_data, type_name, "Elliptic Integral Heuman Lambda: Random Data");
  61. }