Bill Allombert on Fri, 07 Dec 2007 01:51:54 +0100


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

Re: Writing t_INT, T_FRAC to a file using the PARI library


On Wed, Dec 05, 2007 at 02:08:32AM +0100, Karim Belabas wrote:
> * Iftikhar Burhanuddin [2007-12-05 01:35]:
> > How does one write data of type t_INT, t_FRAC to a file using the PARI
> > library?
> > 
> > (Using write0/write1 functions results in the numerator and denominator of
> > a t_FRAC to be written one after the other, making it impossible
> > to determine the numerator and denominator.)
> 
> In libpari, the second argument of the functions write* and print* is a
> vector of GENs [ to be printed / written ]. Use
> 
>   write1(file, mkvec(x))
> 
> 
> Another possibility (more flexible):
> 
> void
> pari_fprintf(FILE *f, GEN x)
> {
>   char *s = GEN2str(x)
>   fprintf(F, "%s", s); free(s);
> }

Probably you mean GENtostr ? because GEN2str does not seem to
exist.

Cheers,
Bill.