/* Cremona Table Input and Ellini */ #include "pari.h" static int ctopened = 0; static FILE *ctfp; GEN ellcremona(char *instr) { long ltop; long a = 11,c = 1; char b = 'A'; long aa,cc,ee,ff; char bb,dd[100]; char linein[200],*l; FILE *fp; GEN cremonatable,outvec; long j=0; ltop = avma; cremonatable = flisexpr("cremonatable"); if (typ(cremonatable) != t_STR) err(talker,"the cremona table has not been correctly set"); fp = fopen(GSTR(cremonatable),"r"); avma = ltop; sscanf(instr,"%i%c%i",&a,&b,&c); while ((l = fgets(linein,200,fp)) != NULL) { sscanf(linein,"%i %c %i",&aa,&bb,&cc); if ((a == aa) && (b == bb) && (c == cc)) { sscanf(linein,"%i %c %i %s",&aa,&bb,&cc,dd); break; } } if (l == NULL) err(talker,"could not find elliptic curve in table"); fclose(fp); return flisexpr(dd); } void ellctopen(void) { long ltop; GEN cremonatable; if (ctopened) err(talker,"cremona table already open"); ltop = avma; cremonatable = flisexpr("cremonatable"); if (typ(cremonatable) != t_STR) err(talker,"the cremona table has not been correctly set"); ctfp = fopen(GSTR(cremonatable),"r"); avma = ltop; ctopened = 1; } GEN ellctgetline(void) { long aa,cc,ee,ff; char bb,dd[100]; char linein[200],lineout[300]; if (!ctopened) err(talker,"the cremona table must first be opened with ellctopen"); if (fgets(linein,200,ctfp) != NULL) { sscanf(linein,"%i %c %i %s %i %i",&aa,&bb,&cc,dd,&ee,&ff); sprintf(lineout,"[%i,\"%c\",%i,%s,%i,%i]",aa,bb,cc,dd,ee,ff); } else { sprintf(lineout,"\"EOF\""); } return flisexpr(lineout); } void ellctclose(void) { ctopened = 0; fclose(ctfp); }