[GiNaC-devel] (no subject)

Chris Dams Chris.Dams at mi.infn.it
Tue Jun 20 12:41:08 CEST 2006


Dear all (but especially Jens),

I noticed that Jens wrote functions for compiling expressions but that
they are undocumented. So I decided to write a small test to see if it
works for me. I wrote the following program

#include <iostream>
#include <ginac/ginac.h>

using namespace std;
using namespace GiNaC;

int main()
{  int numtries = 100000000;
   symbol x("x");
   ex f = 2*x;
   FP_dim1 myfun = compile(f, x);
   cout << "using compiled" << endl;
   for(int i=0; i<numtries; ++i)
      myfun(2);
   cout << "using uncompiled" << endl;
   for(int i=0; i<numtries; ++i)
      f.subs(x==2);
   return 0;
}

compiled it using

g++ -O2 `ginac-config --cppflags`   test.C  `ginac-config --libs` -o test

and noticed that the compiled function takes a lot less time to complete
then the other one (actually I am still waiting for the other one...). Is
this the right way of using this function? I am guessing now that an
FP_cuba-thingy takes the number of arguments as a first parameter, the
values of the arguments as a second parameter, the number of results as a
third parameter and the results as a fourth parameter. Is this guess
right? I also note the presence of a ginac-excompiler script. What is the
use of this if compiling is as simple as shown above? Wouldn't it be
awfully nice if this would be documented, instead of having the users
guess?

Best wishes,
Chris



More information about the GiNaC-devel mailing list