Integrands in C or Fortran ======================================= .. moduleauthor:: G. Peter Lepage .. |Integrator| replace:: :class:`vegas.Integrator` .. |AdaptiveMap| replace:: :class:`vegas.AdaptiveMap` .. |vegas| replace:: :mod:`vegas` .. |WAvg| replace:: :class:`vegas.RunningWAvg` .. |chi2| replace:: :math:`\chi^2` .. |x| replace:: x .. |y| replace:: y Older implementations of the |vegas| algorithm have been used extensively in C and Fortran codes. The Python implementation described here uses a more powerful algorithm. It is relatively straightforward to combine this version with integrands coded in C or Fortran. Such integrands are usually substantially faster than integrands coded directly in Python; they are similar in speed to optimized Cython code. There are many ways to access C and Fortran integrands from Python. Here we review a few of the options. :mod:`cffi` for C ................... The simplest way to access an integrand coded in C is to use the :mod:`cffi` module in Python. To illustrate, consider the following integrand, written in C and stored in file ``cfcn.c``: .. code-block:: C // file cfcn.c #include double fcn(double x[], int dim) { int i; double xsq = 0.0; for(i=0; i