test_policy_sf.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // (C) Copyright John Maddock 2007.
  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. #define BOOST_TEST_MAIN
  6. #include <boost/test/unit_test.hpp>
  7. #include <boost/test/tools/floating_point_comparison.hpp>
  8. #include <boost/math/special_functions.hpp>
  9. //
  10. // DESCRIPTION:
  11. // ~~~~~~~~~~~~
  12. //
  13. // This file provides very basic sanity checks for the special functions
  14. // declared with BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS, basically we
  15. // just want to make sure that the inline forwarding functions do
  16. // actually forward to the right function!!
  17. //
  18. namespace test{
  19. typedef boost::math::policies::policy<> policy;
  20. BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(policy)
  21. }
  22. #define TEST_POLICY_SF(call)\
  23. BOOST_CHECK_EQUAL(boost::math::call , test::call)
  24. //
  25. // Prevent some macro conflicts just in case:
  26. //
  27. #undef fpclassify
  28. #undef isnormal
  29. #undef isinf
  30. #undef isfinite
  31. #undef isnan
  32. BOOST_AUTO_TEST_CASE( test_main )
  33. {
  34. int i;
  35. TEST_POLICY_SF(tgamma(3.0));
  36. TEST_POLICY_SF(tgamma1pm1(0.25));
  37. TEST_POLICY_SF(lgamma(50.0));
  38. TEST_POLICY_SF(lgamma(50.0, &i));
  39. TEST_POLICY_SF(digamma(12.0));
  40. TEST_POLICY_SF(tgamma_ratio(12.0, 13.5));
  41. TEST_POLICY_SF(tgamma_delta_ratio(100.0, 0.25));
  42. TEST_POLICY_SF(factorial<double>(8));
  43. TEST_POLICY_SF(unchecked_factorial<double>(3));
  44. TEST_POLICY_SF(double_factorial<double>(5));
  45. TEST_POLICY_SF(rising_factorial(20.5, 5));
  46. TEST_POLICY_SF(falling_factorial(10.2, 7));
  47. TEST_POLICY_SF(tgamma(12.0, 13.0));
  48. TEST_POLICY_SF(tgamma_lower(12.0, 13.0));
  49. TEST_POLICY_SF(gamma_p(12.0, 13.0));
  50. TEST_POLICY_SF(gamma_q(12.0, 15.0));
  51. TEST_POLICY_SF(gamma_p_inv(12.0, 0.25));
  52. TEST_POLICY_SF(gamma_q_inv(15.0, 0.25));
  53. TEST_POLICY_SF(gamma_p_inva(12.0, 0.25));
  54. TEST_POLICY_SF(gamma_q_inva(12.0, 0.25));
  55. TEST_POLICY_SF(erf(2.5));
  56. TEST_POLICY_SF(erfc(2.5));
  57. TEST_POLICY_SF(erf_inv(0.25));
  58. TEST_POLICY_SF(erfc_inv(0.25));
  59. TEST_POLICY_SF(beta(12.0, 15.0));
  60. TEST_POLICY_SF(beta(12.0, 15.0, 0.25));
  61. TEST_POLICY_SF(betac(12.0, 15.0, 0.25));
  62. TEST_POLICY_SF(ibeta(12.0, 15.0, 0.25));
  63. TEST_POLICY_SF(ibetac(12.0, 15.0, 0.25));
  64. TEST_POLICY_SF(ibeta_inv(12.0, 15.0, 0.25));
  65. TEST_POLICY_SF(ibetac_inv(12.0, 15.0, 0.25));
  66. TEST_POLICY_SF(ibeta_inva(12.0, 0.75, 0.25));
  67. TEST_POLICY_SF(ibetac_inva(12.0, 0.75, 0.25));
  68. TEST_POLICY_SF(ibeta_invb(12.0, 0.75, 0.25));
  69. TEST_POLICY_SF(ibetac_invb(12.0, 0.75, 0.25));
  70. TEST_POLICY_SF(gamma_p_derivative(12.0, 15.0));
  71. TEST_POLICY_SF(ibeta_derivative(12.0, 15.75, 0.25));
  72. TEST_POLICY_SF(fpclassify(12.0));
  73. TEST_POLICY_SF(isfinite(12.0));
  74. TEST_POLICY_SF(isnormal(12.0));
  75. TEST_POLICY_SF(isnan(12.0));
  76. TEST_POLICY_SF(isinf(12.0));
  77. TEST_POLICY_SF(log1p(0.0025));
  78. TEST_POLICY_SF(expm1(0.0025));
  79. TEST_POLICY_SF(cbrt(30.0));
  80. TEST_POLICY_SF(sqrt1pm1(0.0025));
  81. TEST_POLICY_SF(powm1(1.0025, 12.0));
  82. TEST_POLICY_SF(legendre_p(5, 0.75));
  83. TEST_POLICY_SF(legendre_p(7, 3, 0.75));
  84. TEST_POLICY_SF(legendre_q(5, 0.75));
  85. TEST_POLICY_SF(legendre_next(2, 0.25, 12.0, 5.0));
  86. TEST_POLICY_SF(legendre_next(2, 2, 0.25, 12.0, 5.0));
  87. TEST_POLICY_SF(laguerre(5, 12.2));
  88. TEST_POLICY_SF(laguerre(7, 3, 5.0));
  89. TEST_POLICY_SF(laguerre_next(2, 5.0, 12.0, 5.0));
  90. TEST_POLICY_SF(laguerre_next(5, 3, 5.0, 20.0, 10.0));
  91. TEST_POLICY_SF(hermite(1, 2.0));
  92. TEST_POLICY_SF(hermite_next(2, 2.0, 3.0, 2.0));
  93. TEST_POLICY_SF(spherical_harmonic_r(5, 4, 0.75, 0.25));
  94. TEST_POLICY_SF(spherical_harmonic_i(5, 4, 0.75, 0.25));
  95. TEST_POLICY_SF(ellint_1(0.25));
  96. TEST_POLICY_SF(ellint_1(0.25, 0.75));
  97. TEST_POLICY_SF(ellint_2(0.25));
  98. TEST_POLICY_SF(ellint_2(0.25, 0.75));
  99. TEST_POLICY_SF(ellint_3(0.25, 0.75));
  100. TEST_POLICY_SF(ellint_3(0.25, 0.125, 0.75));
  101. TEST_POLICY_SF(ellint_rc(3.0, 5.0));
  102. TEST_POLICY_SF(ellint_rd(2.0, 3.0, 4.0));
  103. TEST_POLICY_SF(ellint_rf(2.0, 3.0, 4.0));
  104. TEST_POLICY_SF(ellint_rj(2.0, 3.0, 5.0, 0.25));
  105. TEST_POLICY_SF(hypot(5.0, 3.0));
  106. TEST_POLICY_SF(sinc_pi(3.0));
  107. TEST_POLICY_SF(sinhc_pi(2.0));
  108. TEST_POLICY_SF(asinh(12.0));
  109. TEST_POLICY_SF(acosh(5.0));
  110. TEST_POLICY_SF(atanh(0.75));
  111. TEST_POLICY_SF(sin_pi(5.0));
  112. TEST_POLICY_SF(cos_pi(6.0));
  113. TEST_POLICY_SF(cyl_neumann(2.0, 5.0));
  114. TEST_POLICY_SF(cyl_neumann(2, 5.0));
  115. TEST_POLICY_SF(cyl_bessel_j(2.0, 5.0));
  116. TEST_POLICY_SF(cyl_bessel_j(2, 5.0));
  117. TEST_POLICY_SF(cyl_bessel_i(3.0, 5.0));
  118. TEST_POLICY_SF(cyl_bessel_i(3, 5.0));
  119. TEST_POLICY_SF(cyl_bessel_k(3.0, 5.0));
  120. TEST_POLICY_SF(cyl_bessel_k(3, 5.0));
  121. TEST_POLICY_SF(sph_bessel(3, 5.0));
  122. TEST_POLICY_SF(sph_bessel(3, 5));
  123. TEST_POLICY_SF(sph_neumann(3, 5.0));
  124. TEST_POLICY_SF(sph_neumann(3, 5));
  125. }