Karim Belabas on Sat, 08 Dec 2007 15:40:50 +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


* Bill Allombert [2007-12-07 01:51]:
> 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.

Indeed, thanks. (N.B: The name pari_fprintf() is a misnomer, since we don't
allow a format.)

    K.B.
--
Karim Belabas                  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]
`