setup.hpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // Copyright 2013 John Maddock. Distributed under the Boost
  2. // Software License, Version 1.0. (See accompanying file
  3. // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  4. #ifndef BOOST_MP_MATH_SETUP_HPP
  5. #define BOOST_MP_MATH_SETUP_HPP
  6. #ifdef _MSC_VER
  7. #define _SCL_SECURE_NO_WARNINGS
  8. #endif
  9. #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
  10. #undef BOOST_MATH_SMALL_CONSTANT
  11. #define BOOST_MATH_SMALL_CONSTANT(x) x
  12. #if !defined(TEST_MPF_50) && !defined(TEST_BACKEND) && !defined(TEST_CPP_DEC_FLOAT) && !defined(TEST_MPFR_50) && !defined(TEST_FLOAT128) && !defined(TEST_CPP_BIN_FLOAT)
  13. #define TEST_MPF_50
  14. #define TEST_MPFR_50
  15. #define TEST_CPP_DEC_FLOAT
  16. #define TEST_FLOAT128
  17. #define TEST_CPP_BIN_FLOAT
  18. #ifdef _MSC_VER
  19. #pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!")
  20. #endif
  21. #ifdef __GNUC__
  22. #pragma warning "CAUTION!!: No backend type specified so testing everything.... this will take some time!!"
  23. #endif
  24. #endif
  25. #if defined(TEST_MPF_50)
  26. #include <boost/multiprecision/gmp.hpp>
  27. #include <boost/multiprecision/debug_adaptor.hpp>
  28. #define MPF_TESTS /*test(number<gmp_float<18> >(), "number<gmp_float<18> >");*/ \
  29. mpf_float::default_precision(20); \
  30. test(mpf_float(), "number<gmp_float<0> > (20 digit precision)"); \
  31. mpf_float::default_precision(35); \
  32. test(mpf_float(), "number<gmp_float<0> > (35 digit precision)"); \
  33. test(number<gmp_float<30> >(), "number<gmp_float<30> >"); \
  34. test(number<gmp_float<35> >(), "number<gmp_float<35> >"); \
  35. /* there should be at least one test with expression templates off: */ \
  36. test(number<gmp_float<35>, et_off>(), "number<gmp_float<35>, et_off>");
  37. #define MPF_SMALL_TESTS /*test(number<gmp_float<18> >(), "number<gmp_float<18> >");*/ \
  38. test(number<gmp_float<30> >(), "number<gmp_float<30> >"); \
  39. test(number<gmp_float<35> >(), "number<gmp_float<35> >"); \
  40. /* there should be at least one test with expression templates off: */ \
  41. test(number<gmp_float<35>, et_off>(), "number<gmp_float<35>, et_off>"); \
  42. mpf_float::default_precision(20); \
  43. test(mpf_float(), "number<gmp_float<0> > (20 digit precision)"); \
  44. mpf_float::default_precision(35); \
  45. test(mpf_float(), "number<gmp_float<0> > (35 digit precision)");
  46. typedef boost::multiprecision::number<boost::multiprecision::gmp_float<18> > test_type_1;
  47. typedef boost::multiprecision::number<boost::multiprecision::gmp_float<30> > test_type_2;
  48. typedef boost::multiprecision::number<boost::multiprecision::gmp_float<35> > test_type_3;
  49. typedef boost::multiprecision::number<boost::multiprecision::gmp_float<35>, boost::multiprecision::et_off> test_type_4;
  50. typedef boost::multiprecision::mpf_float test_type_5;
  51. #else
  52. #define MPF_TESTS
  53. #define MPF_SMALL_TESTS
  54. #endif
  55. #if defined(TEST_MPFR_50)
  56. #include <boost/multiprecision/mpfr.hpp>
  57. #define MPFR_TESTS \
  58. test(number<mpfr_float_backend<18> >(), "number<mpfr_float_backend<18> >"); \
  59. test(number<mpfr_float_backend<30> >(), "number<mpfr_float_backend<30> >"); \
  60. test(number<mpfr_float_backend<35> >(), "number<mpfr_float_backend<35> >"); \
  61. /* Test variable precision at 2 different precisions - checks our ability to handle dynamic changes in precision */ \
  62. mpfr_float::default_precision(20); \
  63. test(mpfr_float(), "number<mpfr_float_backend<0> > (20-digit precision)"); \
  64. mpfr_float::default_precision(35); \
  65. test(mpfr_float(), "number<mpfr_float_backend<0> > (35-digit precision)");
  66. typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<18> > test_type_1;
  67. typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<30> > test_type_2;
  68. typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<35> > test_type_3;
  69. typedef boost::multiprecision::mpfr_float test_type_4;
  70. #else
  71. #define MPFR_TESTS
  72. #endif
  73. #ifdef TEST_BACKEND
  74. #include <boost/multiprecision/concepts/mp_number_archetypes.hpp>
  75. #endif
  76. #ifdef TEST_CPP_DEC_FLOAT
  77. #include <boost/multiprecision/cpp_dec_float.hpp>
  78. #define CPP_DEC_FLOAT_TESTS \
  79. test(number<cpp_dec_float<18> >(), "number<cpp_dec_float<18> >"); \
  80. test(number<cpp_dec_float<30> >(), "number<cpp_dec_float<30> >"); \
  81. test(number<cpp_dec_float<35, long long, std::allocator<char> > >(), "number<cpp_dec_float<35, long long, std::allocator<char> > >");
  82. typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<18> > test_type_1;
  83. typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<30> > test_type_2;
  84. typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<35, long long, std::allocator<char> > > test_type_3;
  85. #else
  86. #define CPP_DEC_FLOAT_TESTS
  87. #endif
  88. #ifdef TEST_CPP_BIN_FLOAT
  89. #include <boost/multiprecision/cpp_bin_float.hpp>
  90. #include <boost/multiprecision/debug_adaptor.hpp>
  91. //#define CPP_BIN_FLOAT_TESTS test(number<debug_adaptor<cpp_bin_float_quad::backend_type>, et_off>(), "cpp_bin_float_quad");
  92. #define CPP_BIN_FLOAT_TESTS test(cpp_bin_float_quad(), "cpp_bin_float_quad");
  93. //typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::cpp_bin_float_quad::backend_type>, boost::multiprecision::et_off> test_type_1;
  94. typedef boost::multiprecision::cpp_bin_float_quad test_type_1;
  95. #else
  96. #define CPP_BIN_FLOAT_TESTS
  97. #endif
  98. #ifdef TEST_FLOAT128
  99. #include <boost/multiprecision/float128.hpp>
  100. #define FLOAT128_TESTS test(float128(), "float128");
  101. typedef boost::multiprecision::float128 test_type_1;
  102. #else
  103. #define FLOAT128_TESTS
  104. #endif
  105. #ifndef BOOST_MATH_TEST_TYPE
  106. #define BOOST_TEST_MAIN
  107. #include <boost/test/unit_test.hpp>
  108. #include <boost/test/floating_point_comparison.hpp>
  109. #endif
  110. #define ALL_TESTS \
  111. MPF_TESTS \
  112. MPFR_TESTS \
  113. CPP_DEC_FLOAT_TESTS \
  114. FLOAT128_TESTS \
  115. CPP_BIN_FLOAT_TESTS
  116. #define ALL_SMALL_TESTS \
  117. MPF_SMALL_TESTS \
  118. MPFR_TESTS \
  119. CPP_DEC_FLOAT_TESTS \
  120. FLOAT128_TESTS \
  121. CPP_BIN_FLOAT_TESTS
  122. #endif