Karim Belabas on Wed, 05 Dec 2007 02:35:10 +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


* 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);
}

    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]
`