-
Notifications
You must be signed in to change notification settings - Fork 1
/
modularity_modp.cc
226 lines (208 loc) · 7.51 KB
/
modularity_modp.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// FILE modularity.cc: checks individual ap against input values for given level(s)
#include <fstream>
#include "newforms.h"
long prime_index(const Quadprime& P)
{
return find(Quadprimes::list.begin(), Quadprimes::list.end(), P) - Quadprimes::list.begin();
}
int main(void)
{
cerr << "Program modularity: for given field and level, reads newforms from\n";
cerr << "file (which should exist already), and computes Hecke eigenvalues for\n";
cerr << "a list of input primes, checking the values against input values, modulo a prime p.\n";
cerr << "----------------------------------------------------------------\n\n";
cerr << "Input format:\n";
cerr << "<field> <level> <modulus> <nforms> <nprimes>\n";
cerr << "followed by nprimes lines each containing a prime's coefficients (2 integers) and nforms integers:\n";
cerr << "<prime> <ap_1> <ap_2> ... <ap_nforms>\n";
cerr << "----------------------------------------------------------------\n\n";
// maxpnorm is the maximum norm of precomputed primes. It should be
// large enough to include all prime factors of levels computed,
long d, maxpnorm(250000);
cerr<<"Enter field: \n";
cin >> d;
Quad::field(d,maxpnorm);
Qideal N;
int verbose=0, showforms=0;
//cerr << "Verbose? "; cin>>verbose;
//cerr << "Display newforms (1/0)? "; cin>>showforms;
cerr<<"Enter level (ideal label or generator): \n";
cin>>N;
if (verbose)
cout << ">>>> Level " << ideal_label(N) <<" = "<<gens_string(N)<<", norm = "<<N.norm()<<" <<<<" << endl;
cerr<<"Enter prime p: \n";
int p;
cin>>p;
if (verbose)
cout << "(working modulo " << p << ")" << endl;
int nforms, nprimes;
cerr<<"Enter number of newforms and number of primes to check: \n";
cin >> nforms >> nprimes;
newforms nf(N,verbose>1);
nf.read_from_file_or_find();
if (verbose && showforms)
nf.display();
int nnf = nf.n1ds;
int nap = nf.nap;
if((nnf==0)||(nap==0))
{
if (verbose)
cout<<"No newforms."<<endl;
else
cout<<"?"<<endl;
exit(0);
}
if (verbose)
cerr << "There are " << nnf << " newforms on file, with a_P for the first " << nap << " primes P (with index 0.." << (nap-1) << ")" << endl;
// primes_needed will be a list of the (quad) primes for which
// values of a_p will be input, and prime_indexes will be a list of
// the index (starting at 0) of these in the standard list
// quadprimes of all primes
Quadprime P;
vector<Quadprime> primes_needed(nprimes);
vector<int> prime_indexes(nprimes);
long maxnormp=0, maxip=0;
long ip, np, ap, nform, kform;
int computation_needed = 0;
vector< vector<long> > apvecs_in(nforms);
vector< vector<long> > apvecs_comp(nnf);
for (nform=0; nform<nforms; nform++)
{
apvecs_in[nform].resize(nprimes);
}
for (nform=0; nform<nnf; nform++)
{
apvecs_comp[nform].resize(nprimes);
}
// Read in primes and ap:
for(np=0; np<nprimes; np++)
{
// if(verbose)
// cerr << "Enter a prime P (label, or 2 integers if principal) followed by "<<nforms<<" ap: "<<endl;
cin >> P;
for (nform=0; nform<nforms; nform++)
{
cin >> ap;
apvecs_in[nform][np] = posmod(ap,p);
}
primes_needed[np] = P;
prime_indexes[np] = ip = prime_index(P);
if (ip>maxip)
maxip = ip;
long normp = I2long(P.norm());
if (normp>maxnormp)
maxnormp = normp;
// if(verbose)
// cerr << "P = " << P <<" (index "<<ip<<", norm "<<normp<<"): a_P = "<<ap<<endl;
} // end of prime loop
// See whether we need to compute more ap:
if(verbose)
cerr << "Largest prime index (based at 0) for which we need ap is " << maxip <<"."<<endl;
if (maxip>nap-1)
{
computation_needed = 1;
if(verbose)
{
cout << "No stored ap for P = " << P << " which has index " << ip << "(starting from 0): only " << nap << " a_P are on file." << endl;
cout << "We'll have to compute the modular symbol space and eigenspaces in order to compute a_P" << endl;
}
}
else
{
if(verbose)
{
cout << "All required a_P are on file (the last is for the " << maxip << "th prime, and we have " << nap << ")" << endl;
}
}
if (computation_needed) // Compute ap for these primes
{
if(verbose>1) cout << "Making homspace and bases..."<<flush;
nf.makebases();
if(verbose>1)
cout << "done."<<endl;
for(np=0; np<nprimes; np++)
{
P = primes_needed[np];
vector<long> apv = nf.apvec(P);
if(verbose)
cerr << "List of a_P for P="<<P<<": "<<apv<<endl;
for (nform=0; nform<nnf; nform++)
apvecs_comp[nform][np] = posmod(apv[nform], p);
} // end of prime loop
}
else // Extract the ap for these primes from the newform data
{
for(np=0; np<nprimes; np++)
for (nform=0; nform<nnf; nform++)
apvecs_comp[nform][np] = posmod(nf.nflist[nform].aplist[prime_indexes[np]], p);
}
// Find each input ap list in the newforms aplists:
for (nform=0; nform<nforms; nform++)
{
int n_matches = 0;
vector<long> apvec_in = apvecs_in[nform];
if (verbose)
cout << "Input Hecke eigenvalue data a_P (mod "<<p<<") = " << apvec_in << endl;
if (Quad::class_group_2_rank==0)
{
for (kform=0; kform<nnf; kform++)
{
string code = codeletter(kform);
if (verbose)
cout << "Comparing with computed form "<<code
<<", a_P (mod "<<p<<") = " << apvecs_comp[kform] << endl;
if (apvecs_comp[kform] == apvec_in)
{
if (verbose)
cout << " input data MATCHES newform "<< code <<endl;
else
{
if (n_matches>0) cout << " ";
cout << code;
}
n_matches++;
}
}
}
else // even class number must look at unramified quadratic twists
{
int nfm = 0;
for (kform=0; kform<nnf; kform++)
{
auto twists = disc_factors_mod_D(nf.nflist[kform].CMD);
vector<long> apvec = apvecs_comp[kform];
for (auto twist = twists.begin(); twist!=twists.end(); ++twist)
{
string code = codeletter(nfm++);
vector<long> apvec_twist = apvec;
// Twist the ap:
auto Pi = primes_needed.begin();
auto aPi = apvec_twist.begin();
for (; aPi!=apvec_twist.end(); ++Pi, ++aPi)
(*aPi) = posmod(*aPi * Pi->genus_character(*twist), p);
if (verbose)
cout << " - comparing with computed form "<<code<<" with ap = " << apvec_twist << endl;
if (apvec_twist == apvec_in)
{
if (verbose)
cout << " input data MATCHES newform "<< code <<endl;
else
{
if (n_matches>0) cout << " ";
cout << code;
}
n_matches++;
}
}
}
}
if (!verbose) cout <<endl;
if (n_matches==0)
{
if (verbose)
cout << " - has NO match" << endl;
else
cout << "?"<<endl;
}
}
} // end of main()