Thomas Papanikolaou on Fri, 22 May 1998 14:06:32 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

A C++ interface for pari-2.0.8


Dear All,

I would like to announce the availability of a C++ interface for
pari-2.0.8. This is an alpha release, it shows however the spirit
I follow in the development. Please, take this email as an invitation
to send suggestions and comments. The main WWW address will be

	http://www.math.u-bordeaux.fr/~papanik/pali.html

The distribution contains the source, examples and (incomplete)
documentation in DVI, PS and HTML. Feel free to download it 

	http://www.math.u-bordeaux.fr/~papanik/distrib/PaLi.tar.gz

There is CONFIG file in the main directory which has to be edited
*manually*. In a later version it will be produced by the PARI
configuration system.


-----------------------------------------------------------------------
Here is a brief description:

The C++ interface encapsulates the "type" GEN into a C++ class called
gen. This class (together with some helper classes) can do the following
for you:

	* automatic stack initialization
	* automatic garbage collecting (no gerepile is necessary anymore; 
          however there is a standard way of combining the "old" and the
          "new" style)
	* reference-counting and delayed evaluation (to avoid annoying
          copying introduced by the method used for automatic garbage
          collecting; read the documentation for this)
	* algebraic operator syntax through operator overloading (higher
          readability)
	* garbage-collected versions of all functions declared in
          paridecl.h (done by scripts)


Example:

The following is the bench.gp program of the pari-2.0.8 distribution

{
  u=v=p=q=1;
  for (k=1, 1000,
    w = u+v; u = v; v = w;
    p *= w; q = lcm(q,w);
    if (k%50 == 0,
      print(k " " log(p)/log(q))
    )
  )
}

This program is rewritten in the C++ interface as

#include <PaLi/genpari++.h>

int main()
{
  gen u, v, p, q, w;
  int k, prec = 5;

  u = v = p = q = 1;
  for (k = 1; k <= 1000; k++)
  {
    w = u + v;
    u = v;
    v = w;
    p = p * w;
    q = _glcm (q, w);
    if ((k % 50) == 0)
      cout << k << " " << _glog (p, prec) / _glog (q, prec) << "\n";
  }

  return 0;
}

(the underscores denote garbage-collected functions)

As you see, apart from the declarations the two programs (GP/C++)
are the same. More examples are included in the distribution.


	Best
		Thomas


PS I call the whole project PaLi since I aim to provide a clear interface
   between Pari and the LiDIA library. I hope that the resulting code will
   allow to use the two systems as if they were one.


Thomas Papanikolaou (PhD)  email: papanik@math.u-bordeaux.fr
A2X - Laboratoire d'Algorithmique Arithmétique eXpérimentale 
351, cours de la Libération, 33 405 Talence cedex, France