Karim Belabas on Fri, 06 Feb 2009 10:56:18 +0100


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

Re: Programming with PARI in C++


* Justin Sweeney [2009-02-05 22:48]:
> 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?

Sorry, I don't understand the problem: as most PARI functions, nextprime
indeed takes and returns a GEN, which is typedef'ed to long *. Can you
post a specific (small) fragment of code that you believe should
compile, but does not ?

Just in case: if your problem is how to pass (and recover) an ordinary
long int, use something like itos( nextprime(stoi(10)) ), which of
course will overflow if the returned value is too large.

If you use the pari-testing branch from our svn, i.e version 2.4.3
(development), you may directly use unextprime(). 

Cheers,

    K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux.fr/  [PARI/GP]
`