Bill Allombert on Fri, 06 Feb 2009 12:29:46 +0100


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

Re: Programming with PARI in C++


On Thu, Feb 05, 2009 at 04:47:01PM -0500, Justin Sweeney wrote:
> Hello,
> 
> I am working on a project involving writing a program which uses PARI 
> functions. The program is written in C++. One of the functions I am 
> using is nextprime(x). I am having problems using this and other 
> functions in the C program. Essentially, the compiler is expecting the 
> variable 'x' in nextprime(x) to be a long int* and the function 
> apparently returns a long int*. Does anyone know anything about passing 
> variables to PARI functions in C, such as if they must be this type or 
> if that can be changed? Also, if there is somewhere that I can read more 
> about this, I would love to further my understanding of this issue. 
> Sorry this is such a general question, I am just beginning to delve into 
> this area. Thank you all!

nextprime and most PARI functions deal with GEN, not C integers. 

Please read the PARI manual availabe online at
http://pari.math.u-bordeaux.fr/pub/pari/manuals/2.3.3/libpari.pdf
or in your local installation (doc/libpari.dvi).

We provide the function stoi and itos to convert between PARI GEN
muti-precision integer and C long integers, assuming the PARI integer is
small enough to fit in a C long integers.  

You can also be interested in GP2C which can convert GP program to C
code automatically and is a good way to learn about libpari
programming.

Cheers,
Bill.