Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:03:50

0001 /* monte/gsl_monte_vegas.h
0002  * 
0003  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Michael Booth
0004  * Copyright (C) 2009 Brian Gough
0005  * 
0006  * This program is free software; you can redistribute it and/or modify
0007  * it under the terms of the GNU General Public License as published by
0008  * the Free Software Foundation; either version 3 of the License, or (at
0009  * your option) any later version.
0010  * 
0011  * This program is distributed in the hope that it will be useful, but
0012  * WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * General Public License for more details.
0015  * 
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0019  */
0020 
0021 /* header for the gsl "vegas" routines.  Mike Booth, May 1998 */
0022 
0023 #ifndef __GSL_MONTE_VEGAS_H__
0024 #define __GSL_MONTE_VEGAS_H__
0025 
0026 #include <stdlib.h>
0027 #include <gsl/gsl_rng.h>
0028 #include <gsl/gsl_monte.h>
0029 
0030 #undef __BEGIN_DECLS
0031 #undef __END_DECLS
0032 #ifdef __cplusplus
0033 # define __BEGIN_DECLS extern "C" {
0034 # define __END_DECLS }
0035 #else
0036 # define __BEGIN_DECLS /* empty */
0037 # define __END_DECLS /* empty */
0038 #endif
0039 
0040 __BEGIN_DECLS
0041 
0042 enum {GSL_VEGAS_MODE_IMPORTANCE = 1, 
0043       GSL_VEGAS_MODE_IMPORTANCE_ONLY = 0, 
0044       GSL_VEGAS_MODE_STRATIFIED = -1};
0045 
0046 typedef struct {
0047   /* grid */
0048   size_t dim;
0049   size_t bins_max;
0050   unsigned int bins;
0051   unsigned int boxes; /* these are both counted along the axes */
0052   double * xi;
0053   double * xin;
0054   double * delx;
0055   double * weight;
0056   double vol;
0057 
0058   double * x;
0059   int * bin;
0060   int * box;
0061   
0062   /* distribution */
0063   double * d;
0064 
0065   /* control variables */
0066   double alpha;
0067   int mode;
0068   int verbose;
0069   unsigned int iterations;
0070   int stage;
0071 
0072   /* scratch variables preserved between calls to vegas1/2/3  */
0073   double jac;
0074   double wtd_int_sum; 
0075   double sum_wgts;
0076   double chi_sum;
0077   double chisq;
0078 
0079   double result;
0080   double sigma;
0081 
0082   unsigned int it_start;
0083   unsigned int it_num;
0084   unsigned int samples;
0085   unsigned int calls_per_box;
0086 
0087   FILE * ostream;
0088 
0089 } gsl_monte_vegas_state;
0090 
0091 int gsl_monte_vegas_integrate(gsl_monte_function * f, 
0092                               double xl[], double xu[], 
0093                               size_t dim, size_t calls,
0094                               gsl_rng * r,
0095                               gsl_monte_vegas_state *state,
0096                               double* result, double* abserr);
0097 
0098 gsl_monte_vegas_state* gsl_monte_vegas_alloc(size_t dim);
0099 
0100 int gsl_monte_vegas_init(gsl_monte_vegas_state* state);
0101 
0102 void gsl_monte_vegas_free (gsl_monte_vegas_state* state);
0103 
0104 double gsl_monte_vegas_chisq (const gsl_monte_vegas_state* state);
0105 void gsl_monte_vegas_runval (const gsl_monte_vegas_state* state, double * result, double * sigma);
0106 
0107 typedef struct {
0108   double alpha;
0109   size_t iterations;
0110   int stage;
0111   int mode;
0112   int verbose;
0113   FILE * ostream;
0114 } gsl_monte_vegas_params;
0115 
0116 void gsl_monte_vegas_params_get (const gsl_monte_vegas_state * state,
0117                  gsl_monte_vegas_params * params);
0118 
0119 void gsl_monte_vegas_params_set (gsl_monte_vegas_state * state,
0120                  const gsl_monte_vegas_params * params);
0121 
0122 __END_DECLS
0123 
0124 #endif /* __GSL_MONTE_VEGAS_H__ */
0125