3 #include <ginac/ginac.h>
5 // Yes, we are using CUBA (should be installed on the system!)
9 * Demonstrates the use of compile_ex with the CUBA library.
11 * The user can enter an expression on the command line. This expression is
12 * compiled via compile_ex and integrated over the region 0 <= x,y <= 1 with
13 * the help of the CUBA library (http://www.feynarts.de/cuba).
19 // Let the user enter a expression
20 symbol x("x"), y("y");
22 cout << "Enter an expression containing 'x' and/or 'y': ";
24 // Expression now in expr
27 cout << "start integration of " << expr << " ..." << endl;
29 // Some definitions for VEGAS
40 // Some variables for VEGAS
41 int comp, nregions, neval, fail;
42 double integral[NCOMP], error[NCOMP], prob[NCOMP];
44 // Our function pointer that points to the compiled ex
46 compile_ex(lst(expr), lst(x,y), fp);
49 // By invocation of compile() the expression in expr is converted into the
50 // appropriate function pointer
51 Vegas(NDIM, NCOMP, fp,
52 EPSREL, EPSABS, VERBOSE, MINEVAL, MAXEVAL, NSTART, NINCREASE,
53 &neval, &fail, integral, error, prob);
56 cout << "result: " << integral[0] << endl;