| Bill Allombert on Thu, 02 Jun 2005 23:55:56 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Proposed elldata database at the PARI workshop |
On Thu, Jun 02, 2005 at 01:24:30AM +0200, Bill Allombert wrote:
> On Wed, Jun 01, 2005 at 03:02:42PM +0200, Bill Allombert wrote:
> > > If I'm allowed to add one more wishlist item: a function ellgens(E),
> > > returning the generators of the rational elliptic curve E. This
> > > shouldn't be too hard to implement using ellidentify() and then looking
> > > up the generators of the curbe.
> > >
> > > Hypothetical example:
> > > gp> E = ellinit("9744C2");
> > > gp> ellgens(E)
> > > %40 = [[-11, 14], [-10, 18]]
Done. Please find a new, non-cumulative, patch that allow to do the
above: (with parisize >=8000000).
? E = ellinit("9744C2");
? ellgens(E)
%2 = [[-11, 14], [-10, 18]]
but it is quite inefficient since that do a double-look up, so you can
do instead:
? ellgens("9744C2")
%2 = [[-11, 14], [-10, 18]]
ellgens(E): if E is an elliptic curve as output by ellinit(), return the
generators of the Mordell-Weyl group associated to the curve. This
function depends on the curve being referenced in the elldata database.
I am not sure ellgens() is the best name we could find (or the best
interface). Maybe ellmwgen() or ellmordellweyl() ?
Cheers,
Bill.
Index: src/headers/paridecl.h
===================================================================
RCS file: /home/cvs/pari/src/headers/paridecl.h,v
retrieving revision 1.490
diff -u -r1.490 paridecl.h
--- src/headers/paridecl.h 2 Jun 2005 18:11:36 -0000 1.490
+++ src/headers/paridecl.h 2 Jun 2005 20:41:59 -0000
@@ -867,12 +867,16 @@
GEN ellap0(GEN e, GEN p, long flag);
GEN elleisnum(GEN om, long k, long flag, long prec);
GEN elleta(GEN om, long prec);
+GEN ellgens(GEN E);
GEN ellglobalred(GEN e1);
GEN ellheight0(GEN e, GEN a, long flag,long prec);
+GEN ellidentify(GEN E);
GEN ellinit0(GEN x,long flag,long prec);
GEN elllocalred(GEN e, GEN p1);
GEN ellminimalmodel(GEN E, GEN *ptv);
long ellrootno(GEN e, GEN p);
+GEN ellsearch(GEN A);
+GEN ellsearchcurve(GEN A);
GEN ellsigma(GEN om, GEN z, long flag, long prec);
GEN elltaniyama(GEN e, long prec);
GEN elltors0(GEN e, long flag);
Index: src/modules/elliptic.c
===================================================================
RCS file: /home/cvs/pari/src/modules/elliptic.c,v
retrieving revision 1.176
diff -u -r1.176 elliptic.c
--- src/modules/elliptic.c 2 Jun 2005 10:52:35 -0000 1.176
+++ src/modules/elliptic.c 2 Jun 2005 20:44:28 -0000
@@ -148,6 +148,8 @@
{
pari_sp av = avma;
GEN y = cgetg(14,t_VEC);
+ if (typ(x)==t_STR)
+ x=gel(ellsearchcurve(x),2);
smallinitell0(x,y); return gerepilecopy(av,y);
}
@@ -408,6 +410,8 @@
initell(GEN x, long prec)
{
pari_sp av = avma;
+ if (typ(x)==t_STR)
+ x=gel(ellsearchcurve(x),2);
return gerepilecopy(av, initell0(x,prec));
}
--- /dev/null Wed Jul 2 16:24:28 2003
+++ src/modules/elldata.c Thu Jun 2 23:19:47 2005
@@ -0,0 +1,189 @@
+/* $Id: $
+
+Copyright (C) 2005 The PARI group.
+
+This file is part of the PARI/GP package.
+
+PARI/GP is free software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation. It is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY WHATSOEVER.
+
+Check the License for details. You should have received a copy of it, along
+with the package; see the file 'COPYING'. If not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/********************************************************************/
+/** **/
+/** INTERFACE TO JOHN CREMONA ELLIPTIC CURVES DATABASE **/
+/** **/
+/********************************************************************/
+#include "pari.h"
+#include "paripriv.h"
+
+static long
+strtoclass(const char *s)
+{
+ int c=0;
+ while (*s && *s<='9') s++;
+ if (!*s) return -1;
+ while ('A'<=*s && *s<='Z')
+ c=26*c+*(s++)-'A';
+ return c;
+}
+
+/*Take a curve name like "100A2" and set
+ * f to the conductor, (100)
+ * c to the isogeny class (in base 26), ("A" or 1)
+ * i to the curve index (2).
+ * return 0 if garbage is found at the end.
+ */
+static int
+ellparsename(const char *s, long *f, long *c, long *i)
+{
+ *f=-1; *c=-1; *i=-1;
+ if (*s<'0' || *s>'9') return !*s;
+ *f=0;
+ while ('0'<=*s && *s<='9')
+ *f=10**f+*(s++)-'0';
+ if (*s<'A' || *s>'Z') return !*s;
+ *c=0;
+ while ('A'<=*s && *s<='Z')
+ *c=26**c+*(s++)-'A';
+ if (*s<'0' || *s>'9') return !*s;
+ *i=0;
+ while ('0'<=*s && *s<='9')
+ *i=10**i+*(s++)-'0';
+ return !*s;
+}
+
+GEN
+ellcondfile(long f)
+{
+ long n=f/1000;
+ char *s = gpmalloc(strlen(pari_datadir) + 13 + 20);
+ FILE *stream;
+ GEN V;
+ sprintf(s, "%s/elldata/ell%ld", pari_datadir, n);
+ stream = fopen(s,"r");
+ if (!stream)
+ err(talker,"Elliptic curves files not available for conductor %ld\n"
+ "[missing %s]",f,s);
+ V = lisGEN(stream);
+ if (!V || typ(V)!=t_VEC )
+ err(talker,"Elliptic files %s not compatible\n",s);
+ fclose(stream);
+ free(s);
+ return V;
+}
+
+GEN
+ellcondlist(long f)
+{
+ pari_sp ltop=avma;
+ GEN V=ellcondfile(f);
+ long i;
+ for (i=1; i<lg(V); i++)
+ if (cmpis(gmael(V,i,1), f)>=0)
+ break;
+ if (i==lg(V) || !equalis(gmael(V,i,1), f))
+ {
+ avma=ltop;
+ return cgetg(1,t_VEC);
+ }
+ return gerepilecopy(ltop, vecslice(gel(V,i),2, lg(gel(V,i))-1));
+}
+
+static GEN
+ellsearchbyname(GEN V, GEN name)
+{
+ long j;
+ for (j=1; j<lg(V); j++)
+ if (gequal(gmael(V,j,1), name))
+ return gel(V,j);
+ err(talker,"No such elliptic curve");
+ return NULL;
+}
+
+static GEN
+ellsearchbyclass(GEN V, long c)
+{
+ long i,j,n;
+ GEN res;
+ for (n=0,j=1; j<lg(V); j++)
+ if (strtoclass(GSTR(gmael(V,j,1)))==c)
+ n++;
+ res=cgetg(n+1,t_VEC);
+ for (i=1,j=1; j<lg(V); j++)
+ if (strtoclass(GSTR(gmael(V,j,1)))==c)
+ res[i++]=V[j];
+ return res;
+}
+
+GEN
+ellsearch(GEN A)
+{
+ pari_sp ltop=avma;
+ long f, c, i;
+ GEN V;
+ if (typ(A)==t_INT)
+ {
+ f=itos(A);
+ c=-1;
+ i=-1;
+ }
+ else if (typ(A)==t_STR)
+ {
+ if (!ellparsename(GSTR(A),&f,&c,&i))
+ err(talker,"Incorrect curve name in ellsearch");
+ }
+ else
+ err(typeer,"ellsearch");
+ V=ellcondlist(f);
+ if (c<0)
+ return V;
+ if (i<0)
+ return gerepilecopy(ltop, ellsearchbyclass(V,c));
+ return gerepilecopy(ltop, ellsearchbyname(V,A));
+}
+
+GEN
+ellsearchcurve(GEN name)
+{
+ pari_sp ltop=avma;
+ long f, c, i;
+ if (!ellparsename(GSTR(name),&f,&c,&i))
+ err(talker,"Incorrect curve name in ellsearch");
+ if (f<0 || c<0 || i<0)
+ err(talker,"Incomplete curve name in ellsearch");
+ return gerepilecopy(ltop, ellsearchbyname(ellcondlist(f), name));
+}
+
+GEN
+ellidentify(GEN E)
+{
+ pari_sp ltop=avma;
+ GEN G, V, M;
+ long j;
+ checkell(E);
+ G=ellglobalred(E);
+ V=ellcondlist(itos(gel(G,1)));
+ M=vecslice(coordch(E,gel(G,2)),1,5);
+ for (j=1; j<lg(V); j++)
+ if (gequal(gmael(V,j,2), M))
+ return gerepilecopy(ltop, mkvec2(gel(V,j),gel(G,2)));
+ err(talker,"No such elliptic curve in database");
+ return NULL;
+}
+
+GEN
+ellgens(GEN E)
+{
+ pari_sp ltop=avma;
+ GEN V;
+ if (typ(E)==t_STR)
+ V=ellsearchcurve(E);
+ else
+ V=gel(ellidentify(E), 1);
+ return gerepilecopy(ltop, gel(V,3));
+}
--- /dev/null Wed Jul 2 16:24:28 2003
+++ src/functions/elliptic_curves/ellsearch Mon May 23 00:06:14 2005
@@ -0,0 +1,9 @@
+Function: ellsearch
+Section: elliptic_curves
+C-Name: ellsearch
+Prototype: G
+Help: ellsearch(N): if N is an integer, it is taken as a conductor else if N is
+ a string, it can be a curve name ("11A1"), a isogeny class ("11A") or a
+ conductor "11". Return all curves in the elldata database that match the
+ property.
+
--- /dev/null Wed Jul 2 16:24:28 2003
+++ src/functions/elliptic_curves/ellidentify Sun May 15 22:11:53 2005
@@ -0,0 +1,8 @@
+Function: ellidentify
+Section: elliptic_curves
+C-Name: ellidentify
+Prototype: G
+Help: ellidentify(E): if E is an elliptic curve as output by ellinit(),
+ return [[name, M],C] where name is the name of the curve in J.E.Cremona
+ database, M the minimal model and C the curve changes (see ellchangecurve).
+
--- /dev/null Wed Jul 2 16:24:28 2003
+++ src/functions/elliptic_curves/ellgens Thu Jun 2 23:11:41 2005
@@ -0,0 +1,8 @@
+Function: ellgens
+Section: elliptic_curves
+C-Name: ellgens
+Prototype: G
+Help: ellgens(E): if E is an elliptic curve as output by ellinit(),
+ return the generators of the Mordell-Weyl group associated to the curve.
+ This function depends on the curve being referenced in the elldata database.
+