Bill Allombert on Mon, 16 May 2005 15:43:42 +0200


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

Re: Proposed elldata database at the PARI workshop


Hello PARI-dev,

Please find a patch in attachment that implement 2 GP functions
ellsearch and ellidentify. You will need the elldata package available
here: <http://pari.math.u-bordeaux.fr/~bill/elldata.tar.gz>

ellsearch() search the database for conductors, isogeny classes or curves:

? ellsearch(121)
%8 = [["121A1", [1, 1, 1, -30, -76]], ["121A2", [1, 1, 1, -305, 7888]], ["121B1", [0, -1, 1, -7, 10]], ["121B2", [0, -1, 1, -887, -10143]], ["121C1", [1, 1, 0,
-2, -7]], ["121C2", [1, 1, 0, -3632, 82757]], ["121D1", [0, -1, 1, -40, -221]],
["121D2", [0, -1, 1, -1250, 31239]], ["121D3", [0, -1, 1, -946260, 354609639]]]
? ellsearch("121A")
%9 = [["121A1", [1, 1, 1, -30, -76]], ["121A2", [1, 1, 1, -305, 7888]]]
? ellsearch("121A1")
%10 = ["121A1", [1, 1, 1, -30, -76]]
ellidentify return the name, the minimal model and the coordinate
change:
? ellidentify(ellinit([0,0,0,0,-432]))
%12 = [["27A1", [0, 0, 1, 0, -7]], [2, 0, 0, 4]]

Do you have proposal for better name for theses functions and idea for
extension ?

I already plan to add the Mordell-Weil group structure to the database.

Cheers,
Bill.

Index: src/headers/paridecl.h
===================================================================
RCS file: /home/cvs/pari/src/headers/paridecl.h,v
retrieving revision 1.478
diff -u -r1.478 paridecl.h
--- src/headers/paridecl.h	13 May 2005 23:57:49 -0000	1.478
+++ src/headers/paridecl.h	15 May 2005 20:13:11 -0000
@@ -867,6 +867,7 @@
 GEN     elleta(GEN om, long prec);
 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);
@@ -875,6 +876,7 @@
 GEN     elltaniyama(GEN e, long prec);
 GEN     elltors0(GEN e, long flag);
 GEN     ellwp0(GEN e, GEN z, long flag, long prec, long PREC);
+GEN     ellsearch(GEN A);
 GEN     ellzeta(GEN om, GEN z, long prec);
 GEN     ghell(GEN e, GEN a, long prec);
 GEN     ghell2(GEN e, GEN a, long prec);
--- /dev/null	Wed Jul  2 16:24:28 2003
+++ src/modules/elldata.c	Mon May 16 14:47:15 2005
@@ -0,0 +1,159 @@
+/* $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, vecextract_i(gel(V,i),2, lg(gel(V,i))-1)); 
+}
+
+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;
+}
+
+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 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=vecextract_i(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;
+}
--- /dev/null	Wed Jul  2 16:24:28 2003
+++ src/functions/elliptic_curves/ellsearch	Sun May 15 22:12:01 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).
+