test_beta_hooks.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // (C) Copyright John Maddock 2006.
  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. #ifndef BOOST_MATH_TEST_BETA_OTHER_HOOKS_HPP
  6. #define BOOST_MATH_TEST_BETA_OTHER_HOOKS_HPP
  7. #ifdef TEST_CEPHES
  8. namespace other{
  9. extern "C" {
  10. double beta(double, double);
  11. float betaf(float, float);
  12. long double betal(long double, long double);
  13. double incbet(double, double, double);
  14. float incbetf(float, float, float);
  15. long double incbetl(long double, long double, long double);
  16. }
  17. inline float beta(float a, float b)
  18. { return betaf(a, b); }
  19. inline long double beta(long double a, long double b)
  20. {
  21. #ifdef BOOST_MSVC
  22. return beta((double)a, (double)b);
  23. #else
  24. return betal(a, b);
  25. #endif
  26. }
  27. inline float ibeta(float a, float b, float x)
  28. { return incbetf(a, b, x); }
  29. inline double ibeta(double a, double b, double x)
  30. { return incbet(a, b, x); }
  31. inline long double ibeta(long double a, long double b, long double x)
  32. {
  33. #ifdef BOOST_MSVC
  34. return incbet((double)a, (double)b, (double)x);
  35. #else
  36. return incbetl(a, b);
  37. #endif
  38. }
  39. }
  40. #define TEST_OTHER
  41. #endif
  42. #ifdef TEST_GSL
  43. #include <gsl/gsl_sf_gamma.h>
  44. #include <gsl/gsl_errno.h>
  45. #include <gsl/gsl_message.h>
  46. namespace other{
  47. inline float beta(float a, float b)
  48. { return (float)gsl_sf_beta(a, b); }
  49. inline double beta(double a, double b)
  50. { return gsl_sf_beta(a, b); }
  51. inline long double beta(long double a, long double b)
  52. { return gsl_sf_beta(a, b); }
  53. inline float ibeta(float a, float b, float x)
  54. { return (float)gsl_sf_beta_inc(a, b, x); }
  55. inline double ibeta(double a, double b, double x)
  56. { return gsl_sf_beta_inc(a, b, x); }
  57. inline long double ibeta(long double a, long double b, long double x)
  58. {
  59. return gsl_sf_beta_inc((double)a, (double)b, (double)x);
  60. }
  61. }
  62. #define TEST_OTHER
  63. #endif
  64. #ifdef TEST_BRATIO
  65. namespace other{
  66. extern "C" int bratio_(double*a, double*b, double*x, double*y, double*w, double*w1, int*ierr);
  67. inline float ibeta(float a, float b, float x)
  68. {
  69. double a_ = a;
  70. double b_ = b;
  71. double x_ = x;
  72. double y_ = 1-x_;
  73. double w, w1;
  74. int ierr = 0;
  75. bratio_(&a_, &b_, &x_, &y_, &w, &w1, &ierr);
  76. return w;
  77. }
  78. inline double ibeta(double a, double b, double x)
  79. {
  80. double a_ = a;
  81. double b_ = b;
  82. double x_ = x;
  83. double y_ = 1-x_;
  84. double w, w1;
  85. int ierr = 0;
  86. bratio_(&a_, &b_, &x_, &y_, &w, &w1, &ierr);
  87. return w;
  88. }
  89. inline long double ibeta(long double a, long double b, long double x)
  90. {
  91. double a_ = a;
  92. double b_ = b;
  93. double x_ = x;
  94. double y_ = 1-x_;
  95. double w, w1;
  96. int ierr = 0;
  97. bratio_(&a_, &b_, &x_, &y_, &w, &w1, &ierr);
  98. return w;
  99. }
  100. }
  101. #define TEST_OTHER
  102. #endif
  103. #ifdef TEST_OTHER
  104. namespace other{
  105. boost::math::concepts::real_concept beta(boost::math::concepts::real_concept, boost::math::concepts::real_concept){ return 0; }
  106. boost::math::concepts::real_concept ibeta(boost::math::concepts::real_concept, boost::math::concepts::real_concept, boost::math::concepts::real_concept){ return 0; }
  107. }
  108. #endif
  109. #endif