gsl_specfunc__hyperg_2F0.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* specfunc/hyperg_2F0.c
  2. *
  3. * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. /* Author: G. Jungman */
  20. #include "gsl__config.h"
  21. #include "gsl_math.h"
  22. #include "gsl_errno.h"
  23. #include "gsl_sf_hyperg.h"
  24. #include "gsl_specfunc__error.h"
  25. #include "gsl_specfunc__hyperg.h"
  26. int
  27. gsl_sf_hyperg_2F0_e(const double a, const double b, const double x, gsl_sf_result * result)
  28. {
  29. if(x < 0.0) {
  30. /* Use "definition" 2F0(a,b,x) = (-1/x)^a U(a,1+a-b,-1/x).
  31. */
  32. gsl_sf_result U;
  33. double pre = pow(-1.0/x, a);
  34. int stat_U = gsl_sf_hyperg_U_e(a, 1.0+a-b, -1.0/x, &U);
  35. result->val = pre * U.val;
  36. result->err = GSL_DBL_EPSILON * fabs(result->val) + pre * U.err;
  37. return stat_U;
  38. }
  39. else if(x == 0.0) {
  40. result->val = 1.0;
  41. result->err = 0.0;
  42. return GSL_SUCCESS;
  43. }
  44. else {
  45. /* Use asymptotic series. ??
  46. */
  47. /* return hyperg_2F0_series(a, b, x, -1, result, &prec); */
  48. DOMAIN_ERROR(result);
  49. }
  50. }
  51. /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
  52. #include "gsl_specfunc__eval.h"
  53. double gsl_sf_hyperg_2F0(const double a, const double b, const double x)
  54. {
  55. EVAL_RESULT(gsl_sf_hyperg_2F0_e(a, b, x, &result));
  56. }