Bill Allombert on Sun, 6 Apr 2003 19:54:25 +0200

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

Re: very simple Pari program

On Sun, Apr 06, 2003 at 01:00:00PM -0400, Allan Adler wrote:
> Here is a very simple Pari 2.1.4 program I wrote.
> #include "pari.h"
> main()
> {
>  printf("%d\n",qfbhclassno(28));
> }
> I tried to compile it on a *86 system running RedHat Linux 7.1:
> gcc classnos.c -lm -lpari -I.
> Here is what happened:
> In file included from pari.h:70,
>                  from classnos.c:3:
> parigen.h:22: warning: redefinition of `ulong'
> /usr/include/sys/types.h: 144: warning: `ulong' previously declared here
> /tmp/ccEqSW6i.o: In function `main':
> /tmp/ccEqSW6i.o(.text+0xf): undefined reference fo `qfbhclassno'
> collect2: ld returned 1 exit status

Here a correct program:

#include "pari.h"
  pari_init(4000000, 50000);/*Init pari*/

%gcc qfb.c -lpari -lm

Here some more detail:
--- pari_init(4000000, 50000);
This initialize PARI. This must be called once at the start of your
program.  The number correspond to the message
parisize = 4000000, primelimit = 500000
that appear at the start of GP.

--- stoi(28): this build the PARI object equal to 28.
--- hclassno: this is the C name of the qfbhclassno function,

? ??qfbhclassno
   The library syntax is hclassno(x).

--- pariputsf() is the PARI equivalent of printf. it support the
   special format type %Z to print PARI objects.

You can look at the examples/matexp.c file.

I agree all this difference between GP and PARI are tedious. That
why I wrote GP2C. This is a program that automatically generate
C code from a GP script (without the call to pari_init currently).

for example if you give 
print(qfbclassno(28)) to GP2C it will output 


GP2C is available at