test_erf.cpp 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ///////////////////////////////////////////////////////////////
  2. // Copyright 2011 John Maddock. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  5. #include "setup.hpp"
  6. #include "table_type.hpp"
  7. #define TEST_UDT
  8. #include <boost/math/special_functions/math_fwd.hpp>
  9. #include "libs/math/test/test_erf.hpp"
  10. void expected_results()
  11. {
  12. //
  13. // Define the max and mean errors expected for
  14. // various compilers and platforms.
  15. //
  16. add_expected_result(
  17. ".*", // compiler
  18. ".*", // stdlib
  19. ".*", // platform
  20. ".*gmp_float<18>.*", // test type(s)
  21. "Erf Function:.*", // test data group
  22. "erfc?", 2200, 1500); // test function
  23. add_expected_result(
  24. ".*", // compiler
  25. ".*", // stdlib
  26. ".*", // platform
  27. ".*gmp_float<18>.*", // test type(s)
  28. "Inverse Erf.*", // test data group
  29. "erfc?_inv", 2200, 1500); // test function
  30. #ifdef BOOST_INTEL
  31. add_expected_result(
  32. ".*", // compiler
  33. ".*", // stdlib
  34. ".*", // platform
  35. "float128", // test type(s)
  36. "Erf Function:.*", // test data group
  37. "erfc?", 15000, 1000); // test function
  38. #endif
  39. add_expected_result(
  40. ".*", // compiler
  41. ".*", // stdlib
  42. ".*", // platform
  43. ".*cpp_bin_float.*", // test type(s)
  44. "Erf Function:.*", // test data group
  45. "erfc?", 3000, 1000); // test function
  46. add_expected_result(
  47. ".*", // compiler
  48. ".*", // stdlib
  49. ".*", // platform
  50. ".*mpfr_float_backend<0>.*", // test type(s)
  51. ".*", // test data group
  52. ".*", 600, 100); // test function
  53. add_expected_result(
  54. ".*", // compiler
  55. ".*", // stdlib
  56. ".*", // platform
  57. ".*", // test type(s)
  58. "Erf Function:.*", // test data group
  59. "erfc?", 300, 200); // test function
  60. add_expected_result(
  61. ".*", // compiler
  62. ".*", // stdlib
  63. ".*", // platform
  64. ".*", // test type(s)
  65. "Inverse Erf.*", // test data group
  66. "erfc?_inv", 60, 20); // test function
  67. //
  68. // Finish off by printing out the compiler/stdlib/platform names,
  69. // we do this to make it easier to mark up expected error rates.
  70. //
  71. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  72. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  73. }
  74. template <class T>
  75. void test(T t, const char* p)
  76. {
  77. test_erf(t, p);
  78. }
  79. BOOST_AUTO_TEST_CASE(test_main)
  80. {
  81. using namespace boost::multiprecision;
  82. expected_results();
  83. //
  84. // Test at:
  85. // 18 decimal digits: tests 80-bit long double approximations
  86. // 30 decimal digits: tests 128-bit long double approximations
  87. // 35 decimal digits: tests arbitrary precision code
  88. //
  89. ALL_TESTS
  90. }