Jack Fearnley on Tue, 05 May 2009 22:57:33 +0200


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

Re: Updating an old C program which uses parilib


Bill Allombert wrote:
On Tue, May 05, 2009 at 10:58:16AM -0400, Jack Fearnley wrote:
  
I am trying to run a program I wrote and ran successfully some years  
back.  It computes Dirichlet twists of elliptic L-functions.  The  
program uses  lisGEN which seems no longer to exist.  The usage is
ee = smallinitell(lisGEN(stdin));
where stdin contains [0,1,0,4,4] for example.

There seems to be no exact replacement for this function so I am using  
scanf to read the five coefficients as longs and then using mkvecn to  
package the coefficients into a vector.
scanf("%ld %ld %ld %ld %ld",&c1,&c2,&c3,&c4,&c5);
       printf("%ld %ld %ld %ld %ld \n",c1,c2,c3,c4,c5);
   eee=mkvecn(5,(GEN)c1,(GEN)c2,(GEN)c3,(GEN)c4,(GEN)c5);
   ee = smallinitell(eee);

Where ee and eee are defined as GEN.

The printed result is


0 1 0 4 4

 ***   segmentation fault: bug in PARI or calling program.
 ***   Error in the PARI system. End of program.

1) Is there an exact replacement for lisGEN?
    

yes, gp_read_stream. thought it seems we forgot to add it to the COMPAT
file.

  
2) Am I doing something stupid?

In previous variations to solve this problem  I have encountered stack  
overflow and an 'undefined' gzero.
    

Filling my answer below should not be interpreted as a positive answer
to your question :) anyway it appears that the line
eee=mkvecn(5,(GEN)c1,(GEN)c2,(GEN)c3,(GEN)c4,(GEN)c5);
cannot work: casting C long integer to GEN using (GEN) does not
work: you must use stoi:
mkvecn(5,stoi(c1),stoi(c2),stoi(c3),stoi(c4),stoi(c5));

  
3) Where did gzero go?
    

It has been renamed to gen_0, see the COMPAT file.

Cheers,
Bill.

  
Many thanks Bill!  My program now works.
Jack Fearnley