sf_concept_check_gamma.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // Copyright John Maddock 2012.
  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. // This tests that cpp_dec_float_50 meets our
  7. // conceptual requirements when used with Boost.Math.
  8. //
  9. #ifdef _MSC_VER
  10. #define _SCL_SECURE_NO_WARNINGS
  11. #pragma warning(disable : 4800)
  12. #pragma warning(disable : 4512)
  13. #pragma warning(disable : 4127)
  14. #pragma warning(disable : 4512)
  15. #pragma warning(disable : 4503) // decorated name length exceeded, name was truncated
  16. #endif
  17. #include <boost/container_hash/hash.hpp>
  18. #include <libs/math/test/compile_test/poison.hpp>
  19. #if !defined(TEST_MPF_50) && !defined(TEST_BACKEND) && !defined(TEST_MPZ) && !defined(TEST_CPP_DEC_FLOAT) && !defined(TEST_MPFR_50) && !defined(TEST_MPFR_6) && !defined(TEST_MPFR_15) && !defined(TEST_MPFR_17) && !defined(TEST_MPFR_30) && !defined(TEST_CPP_DEC_FLOAT_NO_ET) && !defined(TEST_LOGGED_ADAPTER) && !defined(TEST_CPP_BIN_FLOAT)
  20. #define TEST_MPF_50
  21. #define TEST_BACKEND
  22. #define TEST_MPZ
  23. #define TEST_MPFR_50
  24. #define TEST_MPFR_6
  25. #define TEST_MPFR_15
  26. #define TEST_MPFR_17
  27. #define TEST_MPFR_30
  28. #define TEST_CPP_DEC_FLOAT
  29. #define TEST_CPP_DEC_FLOAT_NO_ET
  30. #define TEST_LOGGED_ADAPTER
  31. #define TEST_CPP_BIN_FLOAT
  32. #ifdef _MSC_VER
  33. #pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!")
  34. #endif
  35. #ifdef __GNUC__
  36. #pragma warning "CAUTION!!: No backend type specified so testing everything.... this will take some time!!"
  37. #endif
  38. #endif
  39. #if defined(TEST_MPF_50) || defined(TEST_MPZ)
  40. #include <boost/multiprecision/gmp.hpp>
  41. #endif
  42. #ifdef TEST_BACKEND
  43. #include <boost/multiprecision/concepts/mp_number_archetypes.hpp>
  44. #endif
  45. #if defined(TEST_CPP_DEC_FLOAT) || defined(TEST_CPP_DEC_FLOAT_NO_ET) || defined(TEST_LOGGED_ADAPTER)
  46. #include <boost/multiprecision/cpp_dec_float.hpp>
  47. #endif
  48. #if defined(TEST_MPFR_50) || defined(TEST_MPFR_6) || defined(TEST_MPFR_15) || defined(TEST_MPFR_17) || defined(TEST_MPFR_30)
  49. #include <boost/multiprecision/mpfr.hpp>
  50. #endif
  51. #if defined(TEST_CPP_BIN_FLOAT)
  52. #include <boost/multiprecision/cpp_bin_float.hpp>
  53. #endif
  54. #ifdef TEST_LOGGED_ADAPTER
  55. #include <boost/multiprecision/logged_adaptor.hpp>
  56. #endif
  57. #include <boost/math/special_functions.hpp>
  58. template <class T>
  59. void test_extra(T)
  60. {
  61. T v1, v2, v3;
  62. int i;
  63. boost::math::tgamma(v1);
  64. boost::math::tgamma1pm1(v1);
  65. boost::math::lgamma(v1);
  66. boost::math::lgamma(v1, &i);
  67. boost::math::digamma(v1);
  68. boost::math::tgamma_ratio(v1, v2);
  69. boost::math::tgamma_delta_ratio(v1, v2);
  70. boost::math::factorial<T>(i);
  71. boost::math::unchecked_factorial<T>(i);
  72. i = boost::math::max_factorial<T>::value;
  73. boost::math::double_factorial<T>(i);
  74. boost::math::rising_factorial(v1, i);
  75. boost::math::falling_factorial(v1, i);
  76. boost::math::gamma_p_derivative(v2, v3);
  77. boost::math::tgamma(v1, v2);
  78. boost::math::tgamma_lower(v1, v2);
  79. boost::math::gamma_p(v1, v2);
  80. boost::math::gamma_q(v1, v2);
  81. boost::math::gamma_p_inv(v1, v2);
  82. boost::math::gamma_q_inv(v1, v2);
  83. boost::math::gamma_p_inva(v1, v2);
  84. boost::math::gamma_q_inva(v1, v2);
  85. boost::math::erf(v1);
  86. boost::math::erfc(v1);
  87. boost::math::erf_inv(v1);
  88. boost::math::erfc_inv(v1);
  89. }
  90. void foo()
  91. {
  92. #ifdef TEST_BACKEND
  93. test_extra(boost::multiprecision::concepts::mp_number_float_architype());
  94. #endif
  95. #ifdef TEST_MPF_50
  96. test_extra(boost::multiprecision::mpf_float_50());
  97. #endif
  98. #ifdef TEST_MPFR_50
  99. test_extra(boost::multiprecision::mpfr_float_50());
  100. #endif
  101. #ifdef TEST_MPFR_6
  102. test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<6> >());
  103. #endif
  104. #ifdef TEST_MPFR_15
  105. test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<15> >());
  106. #endif
  107. #ifdef TEST_MPFR_17
  108. test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<17> >());
  109. #endif
  110. #ifdef TEST_MPFR_30
  111. test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<30> >());
  112. #endif
  113. #ifdef TEST_CPP_DEC_FLOAT
  114. test_extra(boost::multiprecision::cpp_dec_float_50());
  115. #endif
  116. #ifdef TEST_CPP_BIN_FLOAT
  117. test_extra(boost::multiprecision::cpp_bin_float_50());
  118. #endif
  119. #ifdef TEST_CPP_DEC_FLOAT_NO_ET
  120. test_extra(boost::multiprecision::number<boost::multiprecision::cpp_dec_float<100>, boost::multiprecision::et_off>());
  121. #endif
  122. #ifdef TEST_LOGGED_ADAPTER
  123. typedef boost::multiprecision::number<boost::multiprecision::logged_adaptor<boost::multiprecision::cpp_dec_float<50> > > num_t;
  124. test_extra(num_t());
  125. #endif
  126. }
  127. int main()
  128. {
  129. foo();
  130. }