Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AndrewVSutherland
GitHub Repository: AndrewVSutherland/lmfdb
Path: blob/main/scripts/local_fields/lfprep.gp
1128 views
1
/* This gp script converts data from the format of the JR local field database
2
and puts in a form for the lmfdb import script.
3
4
To run this script, you need copies of all of JR local field database
5
data files under file-src. It needs to look up subfields to check the
6
number of automorphisms to correctly compute the multiplicity of a
7
subfield (since the fields themselves are classified up to isomorphism.
8
*/
9
/*
10
{
11
u'_id': ObjectId('4e637c7f0eb55b7f65000000'),
12
u'aut': 1,
13
u'c': 2,
14
u'coeffs': [-2, 0, 0, 1],
15
u'e': 3,
16
u'eisen': u'y^3 - 2',
17
u'f': 1,
18
u'gal': [3, 2],
19
u'galT': 2,
20
u'gms': u'2/3',
21
u'hw': u'$1$',
22
u'inertia': [3, u't', [3, 1], u'<i>C</i><sub>3</sub>'],
23
u'label': u'2.3.2.1',
24
u'n': 3,
25
u'p': 2,
26
u'rf': [1, 1],
27
u'slopes': u'[]',
28
u't': 3,
29
u'u': 2,
30
u'unram': u't + 1'}
31
*/
32
/* Top slope is not done here, it is done in the import script */
33
34
\r padic.gp
35
\r panayi.gp
36
37
countroots(f,g,p,nf,pr,early)=return(panayi(f,g,p,1,early));
38
39
labels=readvec("label-data");
40
/* Format [13,2,1,[-13, 0, 1],"13.2.1.1"] (p, deg, Vecrev, label) */
41
42
findlabelpol(pol)=for(k=1,#labels,if(labels[k][4]==pol && labels[k][1]==p && labels[k][2]==n, return(k)));return(0);
43
44
labelhash=List();
45
findlabeldat(p,n,c)=for(k=1,#labelhash,if(labelhash[k][1]==p && labelhash[k][2]==n && labelhash[k][3]==c, return(k))); return(0);
46
{
47
for(j=1,#labels,
48
k=findlabeldat(labels[j][1],labels[j][2],labels[j][3]);
49
if(k==0, listput(labelhash,[labels[j][1],labels[j][2],labels[j][3],1]),
50
labelhash[k][3] += 1));
51
}
52
53
54
55
/* Fix the conversion */
56
prinhw(p,invec,j,temp) = temp = (1-hilbert(2,myquaddisc(invec,p),p)+ \
57
qhw(invec,p)+(1-j)) % 4; ;return(prinhwsimple(temp));
58
59
prinhwsimple(temp) = if(temp==0, return("$1$"), \
60
if(temp==1, return("$-i$"), \
61
if(temp==2, return("$-1$"), \
62
return("$i$"))));
63
64
myquaddisc(invec,p, temp) = return(if(invec[2]==0, quaddisc(invec[1]), \
65
if(p==2, return(quaddisc(5*invec[1]))); \
66
temp=1; while(kronecker(prime(temp),p) != -1, temp=temp+1); \
67
quaddisc(prime(temp)*invec[1])));
68
69
getdisc(poly, p) = return(pdiscclass(poldisc(poly), p));
70
71
pdiscclass(disc,p) =
72
{
73
local(tdis, expo);
74
tdis = disc;
75
expo=valuation(tdis,p); tdis = tdis/p^expo;
76
expo = expo % 2;
77
if(p==2, tdis = tdis % 8, tdis = tdis % p);
78
return(if(p==2, if(tdis==1, [p^expo, 0], if(tdis==5, [p^expo, 1], \
79
if(tdis == 7, [- p^expo, 0], [- p^expo, 1]))), \
80
[p^expo, if(kronecker(tdis,p)==1,0,1)]));
81
}
82
83
84
85
qhw(tdis, p) =
86
{
87
my(myval);
88
89
return(if(tdis[1]==1, 0,
90
if(p<7,
91
if(p==2,
92
if(tdis==[2,0], 0,
93
if((tdis==[-2,0]) || (tdis==[-1,0]) || (tdis==[-1,1]), 3,
94
if(tdis==[2,1], 2, 1))),
95
if(p==3, if(tdis==[3,0], 1, 3),
96
if(tdis==[5,1], 2, 0))),
97
if((p % 4) == 3,
98
if(tdis==[p,1], 3, (4-qhw(getdisc(x^2-p,2),2)) % 4),
99
if(tdis[2]==0, 0, myval=1;
100
while(kronecker(prime(myval), p) != -1, myval = myval+1);
101
(4-(1-kronecker(-1,prime(myval)))/2-
102
qhw(getdisc(x^2-kronecker(-1,prime(myval))
103
*prime(myval)*p,prime(myval)),prime(myval))) %4)))));
104
}
105
106
findsubaut(pol, p)=
107
{
108
my(d=poldegree(pol));
109
for(k=1,#subf[d], if(subf[d][k][1]==pol, return(subf[d][k][2])));
110
error("Cannot find subfield ", pol);
111
}
112
113
subconv(p,f,slist)=
114
{
115
if(!slist, return([]));
116
slist = concat(apply(z->z[2], slist));
117
return(apply(z->[Vecrev(z), countroots(z,f,p)/findsubaut(z,p)], slist));
118
}
119
120
/* Fix the count */
121
mylabel(l) =
122
{
123
my(cnt,k);
124
k=findlabelpol(Vecrev(l[6]));
125
if(k, return(labels[k][5]));
126
k=findlabeldat(l[1],l[5],l[2]);
127
if(k,
128
labelhash[k][4] += 1;
129
cnt=labelhash[k][4];
130
/* print("incrementing ", [l[1],l[5],l[2],cnt]); */
131
, /* else */
132
listput(labelhash, [l[1],l[5],l[2],1]);
133
/* print("new ", [l[1],l[5],l[2],1]); */
134
cnt = 1
135
);
136
return(Str(l[1],".",l[5],".",l[2],".",cnt));
137
}
138
139
doinertia(e9, n)=
140
{
141
if(e9[2]=="e", if(n==1, return(["t", [1,1]]), return(["i", [1,1]])));
142
return([e9[2], e9[3]]);
143
}
144
145
inf = concat(readvec("infile"));
146
p=inf[1][1];
147
n=inf[1][5];
148
dis= divisors(n);
149
dis = vector(max(0,#dis-2),h,dis[h+1]);
150
subf = if(#dis,vector(dis[#dis]),[]);
151
{
152
for(k=1,#dis,
153
temp=read(Str("file-src/p",p,"d",dis[k],"all"));
154
subf[dis[k]]= apply(z->[z[6],z[22]], temp)
155
);
156
}
157
158
for(j=1,#inf,if(#inf[j]<25, inf[j]=concat(inf[j],vector(25-#inf[j]))))
159
{
160
inf=apply(z->print1(".");[z[22], z[2], Vecrev(z[6]), z[3], Str(subst(z[12][2],x,y)), z[4],
161
z[7][3], z[7][3][2], Str(z[21]),
162
prinhw(z[1],z[14],z[17]),
163
doinertia(z[9],z[5]),
164
mylabel(z),
165
z[5], z[1], z[14], Str(z[10]), z[11][1], z[11][2], Str(subst(z[12][1],x,t)),
166
subconv(z[1], z[6], z[18]),
167
Vecrev(z[25])]
168
,inf);
169
}
170
171
for(j=1,#inf, write("lfdata", inf[j]))
172
173
174