gsl_integration.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /* integration/gsl_integration.h
  2. *
  3. * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
  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. #ifndef __GSL_INTEGRATION_H__
  20. #define __GSL_INTEGRATION_H__
  21. #include <stdlib.h>
  22. #include "gsl_math.h"
  23. #undef __BEGIN_DECLS
  24. #undef __END_DECLS
  25. #ifdef __cplusplus
  26. # define __BEGIN_DECLS extern "C" {
  27. # define __END_DECLS }
  28. #else
  29. # define __BEGIN_DECLS /* empty */
  30. # define __END_DECLS /* empty */
  31. #endif
  32. __BEGIN_DECLS
  33. /* Workspace for adaptive integrators */
  34. typedef struct
  35. {
  36. size_t limit;
  37. size_t size;
  38. size_t nrmax;
  39. size_t i;
  40. size_t maximum_level;
  41. double *alist;
  42. double *blist;
  43. double *rlist;
  44. double *elist;
  45. size_t *order;
  46. size_t *level;
  47. }
  48. gsl_integration_workspace;
  49. gsl_integration_workspace *
  50. gsl_integration_workspace_alloc (const size_t n);
  51. void
  52. gsl_integration_workspace_free (gsl_integration_workspace * w);
  53. /* Workspace for QAWS integrator */
  54. typedef struct
  55. {
  56. double alpha;
  57. double beta;
  58. int mu;
  59. int nu;
  60. double ri[25];
  61. double rj[25];
  62. double rg[25];
  63. double rh[25];
  64. }
  65. gsl_integration_qaws_table;
  66. gsl_integration_qaws_table *
  67. gsl_integration_qaws_table_alloc (double alpha, double beta, int mu, int nu);
  68. int
  69. gsl_integration_qaws_table_set (gsl_integration_qaws_table * t,
  70. double alpha, double beta, int mu, int nu);
  71. void
  72. gsl_integration_qaws_table_free (gsl_integration_qaws_table * t);
  73. /* Workspace for QAWO integrator */
  74. enum gsl_integration_qawo_enum { GSL_INTEG_COSINE, GSL_INTEG_SINE };
  75. typedef struct
  76. {
  77. size_t n;
  78. double omega;
  79. double L;
  80. double par;
  81. enum gsl_integration_qawo_enum sine;
  82. double *chebmo;
  83. }
  84. gsl_integration_qawo_table;
  85. gsl_integration_qawo_table *
  86. gsl_integration_qawo_table_alloc (double omega, double L,
  87. enum gsl_integration_qawo_enum sine,
  88. size_t n);
  89. int
  90. gsl_integration_qawo_table_set (gsl_integration_qawo_table * t,
  91. double omega, double L,
  92. enum gsl_integration_qawo_enum sine);
  93. int
  94. gsl_integration_qawo_table_set_length (gsl_integration_qawo_table * t,
  95. double L);
  96. void
  97. gsl_integration_qawo_table_free (gsl_integration_qawo_table * t);
  98. /* Definition of an integration rule */
  99. typedef void gsl_integration_rule (const gsl_function * f,
  100. double a, double b,
  101. double *result, double *abserr,
  102. double *defabs, double *resabs);
  103. void gsl_integration_qk15 (const gsl_function * f, double a, double b,
  104. double *result, double *abserr,
  105. double *resabs, double *resasc);
  106. void gsl_integration_qk21 (const gsl_function * f, double a, double b,
  107. double *result, double *abserr,
  108. double *resabs, double *resasc);
  109. void gsl_integration_qk31 (const gsl_function * f, double a, double b,
  110. double *result, double *abserr,
  111. double *resabs, double *resasc);
  112. void gsl_integration_qk41 (const gsl_function * f, double a, double b,
  113. double *result, double *abserr,
  114. double *resabs, double *resasc);
  115. void gsl_integration_qk51 (const gsl_function * f, double a, double b,
  116. double *result, double *abserr,
  117. double *resabs, double *resasc);
  118. void gsl_integration_qk61 (const gsl_function * f, double a, double b,
  119. double *result, double *abserr,
  120. double *resabs, double *resasc);
  121. void gsl_integration_qcheb (gsl_function * f, double a, double b,
  122. double *cheb12, double *cheb24);
  123. /* The low-level integration rules in QUADPACK are identified by small
  124. integers (1-6). We'll use symbolic constants to refer to them. */
  125. enum
  126. {
  127. GSL_INTEG_GAUSS15 = 1, /* 15 point Gauss-Kronrod rule */
  128. GSL_INTEG_GAUSS21 = 2, /* 21 point Gauss-Kronrod rule */
  129. GSL_INTEG_GAUSS31 = 3, /* 31 point Gauss-Kronrod rule */
  130. GSL_INTEG_GAUSS41 = 4, /* 41 point Gauss-Kronrod rule */
  131. GSL_INTEG_GAUSS51 = 5, /* 51 point Gauss-Kronrod rule */
  132. GSL_INTEG_GAUSS61 = 6 /* 61 point Gauss-Kronrod rule */
  133. };
  134. void
  135. gsl_integration_qk (const int n, const double xgk[],
  136. const double wg[], const double wgk[],
  137. double fv1[], double fv2[],
  138. const gsl_function *f, double a, double b,
  139. double * result, double * abserr,
  140. double * resabs, double * resasc);
  141. int gsl_integration_qng (const gsl_function * f,
  142. double a, double b,
  143. double epsabs, double epsrel,
  144. double *result, double *abserr,
  145. size_t * neval);
  146. int gsl_integration_qag (const gsl_function * f,
  147. double a, double b,
  148. double epsabs, double epsrel, size_t limit,
  149. int key,
  150. gsl_integration_workspace * workspace,
  151. double *result, double *abserr);
  152. int gsl_integration_qagi (gsl_function * f,
  153. double epsabs, double epsrel, size_t limit,
  154. gsl_integration_workspace * workspace,
  155. double *result, double *abserr);
  156. int gsl_integration_qagiu (gsl_function * f,
  157. double a,
  158. double epsabs, double epsrel, size_t limit,
  159. gsl_integration_workspace * workspace,
  160. double *result, double *abserr);
  161. int gsl_integration_qagil (gsl_function * f,
  162. double b,
  163. double epsabs, double epsrel, size_t limit,
  164. gsl_integration_workspace * workspace,
  165. double *result, double *abserr);
  166. int gsl_integration_qags (const gsl_function * f,
  167. double a, double b,
  168. double epsabs, double epsrel, size_t limit,
  169. gsl_integration_workspace * workspace,
  170. double *result, double *abserr);
  171. int gsl_integration_qagp (const gsl_function * f,
  172. double *pts, size_t npts,
  173. double epsabs, double epsrel, size_t limit,
  174. gsl_integration_workspace * workspace,
  175. double *result, double *abserr);
  176. int gsl_integration_qawc (gsl_function *f,
  177. const double a, const double b, const double c,
  178. const double epsabs, const double epsrel, const size_t limit,
  179. gsl_integration_workspace * workspace,
  180. double * result, double * abserr);
  181. int gsl_integration_qaws (gsl_function * f,
  182. const double a, const double b,
  183. gsl_integration_qaws_table * t,
  184. const double epsabs, const double epsrel,
  185. const size_t limit,
  186. gsl_integration_workspace * workspace,
  187. double *result, double *abserr);
  188. int gsl_integration_qawo (gsl_function * f,
  189. const double a,
  190. const double epsabs, const double epsrel,
  191. const size_t limit,
  192. gsl_integration_workspace * workspace,
  193. gsl_integration_qawo_table * wf,
  194. double *result, double *abserr);
  195. int gsl_integration_qawf (gsl_function * f,
  196. const double a,
  197. const double epsabs,
  198. const size_t limit,
  199. gsl_integration_workspace * workspace,
  200. gsl_integration_workspace * cycle_workspace,
  201. gsl_integration_qawo_table * wf,
  202. double *result, double *abserr);
  203. __END_DECLS
  204. #endif /* __GSL_INTEGRATION_H__ */