gsl_monte_vegas.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* monte/gsl_monte_vegas.h
  2. *
  3. * Copyright (C) 1996, 1997, 1998, 1999, 2000 Michael Booth
  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. /* header for the gsl "vegas" routines. Mike Booth, May 1998 */
  20. #ifndef __GSL_MONTE_VEGAS_H__
  21. #define __GSL_MONTE_VEGAS_H__
  22. #include "gsl_rng.h"
  23. #include "gsl_monte.h"
  24. #undef __BEGIN_DECLS
  25. #undef __END_DECLS
  26. #ifdef __cplusplus
  27. # define __BEGIN_DECLS extern "C" {
  28. # define __END_DECLS }
  29. #else
  30. # define __BEGIN_DECLS /* empty */
  31. # define __END_DECLS /* empty */
  32. #endif
  33. __BEGIN_DECLS
  34. enum {GSL_VEGAS_MODE_IMPORTANCE = 1,
  35. GSL_VEGAS_MODE_IMPORTANCE_ONLY = 0,
  36. GSL_VEGAS_MODE_STRATIFIED = -1};
  37. typedef struct {
  38. /* grid */
  39. size_t dim;
  40. size_t bins_max;
  41. unsigned int bins;
  42. unsigned int boxes; /* these are both counted along the axes */
  43. double * xi;
  44. double * xin;
  45. double * delx;
  46. double * weight;
  47. double vol;
  48. double * x;
  49. int * bin;
  50. int * box;
  51. /* distribution */
  52. double * d;
  53. /* control variables */
  54. double alpha;
  55. int mode;
  56. int verbose;
  57. unsigned int iterations;
  58. int stage;
  59. /* scratch variables preserved between calls to vegas1/2/3 */
  60. double jac;
  61. double wtd_int_sum;
  62. double sum_wgts;
  63. double chi_sum;
  64. double chisq;
  65. double result;
  66. double sigma;
  67. unsigned int it_start;
  68. unsigned int it_num;
  69. unsigned int samples;
  70. unsigned int calls_per_box;
  71. FILE * ostream;
  72. } gsl_monte_vegas_state;
  73. int gsl_monte_vegas_integrate(gsl_monte_function * f,
  74. double xl[], double xu[],
  75. size_t dim, size_t calls,
  76. gsl_rng * r,
  77. gsl_monte_vegas_state *state,
  78. double* result, double* abserr);
  79. gsl_monte_vegas_state* gsl_monte_vegas_alloc(size_t dim);
  80. int gsl_monte_vegas_init(gsl_monte_vegas_state* state);
  81. void gsl_monte_vegas_free (gsl_monte_vegas_state* state);
  82. __END_DECLS
  83. #endif /* __GSL_MONTE_VEGAS_H__ */