File: h1curve.cc

package info (click to toggle)
eclib 20190909-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,196 kB
  • sloc: cpp: 47,090; makefile: 251; sh: 122
file content (218 lines) | stat: -rw-r--r-- 6,124 bytes parent folder | download | duplicates (2)
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
// FILE H1CURVE.CC: Program to list curves
//////////////////////////////////////////////////////////////////////////
//
// Copyright 1990-2012 John Cremona
//
// This file is part of the eclib package.
//
// eclib 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; either version 2 of the License, or (at your
// option) any later version.
//
// eclib is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with eclib; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
//
//////////////////////////////////////////////////////////////////////////
//
#include <fstream>
#include <eclib/compproc.h>
#include <eclib/moddata.h>
#include <eclib/symb.h>
#include <eclib/cusp.h>
#include <eclib/homspace.h>
#include <eclib/oldforms.h>
#include <eclib/curve.h>     //from qcurves
#include <eclib/cperiods.h>     //from qcurves, for computing conductors
#include <eclib/newforms.h>
#include <eclib/periods.h>

#ifndef SINGLE   // so Makefile can override
#define AUTOLOOP
#endif

#define LMFDB_ORDER       // if defined, sorts newforms into LMFDB order before output

// If this is defined, the fisc6 output is placed in subdirectory
// fixc6 in file fixc6/fixc6.N (one per level); otherwise it is all
// put in ./fixc6.extra
//#define FIXC6_OUTPUT_TO_SUBDIR

#define BOOKORDER       // if defined, sorts newforms/curves into order
                        // in the Book (relevant up to 500 only)
#include <eclib/curvesort.h>

vector<pair<int,int> > bad_ones; // holds bad (n,i) list

int checkap(const level* iN, const newform& nf, CurveRed& CR, long pmax=100);

int main(void)
{
  int prec0 = 75;
  int maxprec = 300;
  int prec = prec0;
  int delta_prec = 30;
  set_precision(prec);
 int verb=0;
#ifdef SINGLE
 verb=1;
#else
 cout<<"See detail? "; cin>>verb;
#endif
 int limit,n=1;
#ifdef AUTOLOOP
 cout<<"Enter first and last N: ";cin>>n>>limit;
 n--; cout<<endl;
 cout<<endl<<"Table of curves computed from newforms via periods"<<endl;
#ifdef BOOKORDER
 cout<<"(reordered to agree with Book for levels up to 1000)"<<endl;
#endif
#ifdef LMFDB_ORDER
 cout<<"(reordered to agree with LMFDB for levels over 1000)"<<endl;
#endif
 if(!verb)
   {
     cout << "\nN \t# \t";
     cout<<"[a1,a2,a3,a4,a6]";
     cout<<"\t\tConductor\n";
   }
 while (n<limit) { n++;
#else
 while (n>0) { cout<<"Enter level: "; cin>>n;
#endif
 if (n>0)
{
 newforms nf(n,verb);
 int noldap=25;
 nf.createfromdata(1,noldap,0); // do not create from scratch if data absent
 #ifdef LMFDB_ORDER
 nf.sort();
 #endif
 int nnf = nf.n1ds;
 int inf = 1;
#ifndef SINGLE
 if(verb>1) nf.display();
#else
// if(nnf>1)
   {
     cout << "Enter form number (between 1 and "<<nnf<<"): "; cin>>inf;
     if((inf<1)||(inf>nnf))
       {
	 cout << "Not in range!\n"; inf=1; nnf=0;
       }
     else nnf=inf;
   }
#endif

 for(int xi=inf-1; xi<nnf; xi++)
   { int i = xi;
#ifdef BOOKORDER
     i=booknumber0(n,i);
#endif
     if(verb) cout << "\nForm number " << i+1 << ": " << endl;
     else     cout << n << "\t" << codeletter(xi) << "\t";
     //#ifdef SINGLE
     if(verb) nf.nflist[i].display();
     //#endif

     bigfloat rperiod;
     Curve C;
     Curvedata CD;
     CurveRed CR;
     bigint nc;
     prec = prec0-delta_prec;
     set_precision(prec);
     C = Curve();
     while (C.isnull() && (prec<maxprec))
       {
	 prec += delta_prec;
	 set_precision(prec);
	 C = nf.getcurve(i, -1, rperiod, verb);
         if (!C.isnull())
           {
             CD = Curvedata(C,1);  // The 1 causes minimalization
             CR = CurveRed(CD);
             nc = getconductor(CR);
             if(n!=nc) C = Curve();  // wrong conductor; reset to null curve
           }
       }
     if(C.isnull())
       {
         cout << "bad curve, even after trying precision up to "<<maxprec<<endl;
	 bad_ones.push_back(pair<int,int>(n,i+1));
       }
     else
       {
         if(getdiscr(Curvedata(C,0))!=getdiscr(CD))
           {
             cout << "Non-minimal curve = \t" << C << ", minimal curve = \t";
           }
         else if(verb) cout << "Curve = \t";
         cout << (Curve)CD << "\t";
         cout << "N = " << nc;
         if(n!=nc)
           {
             cout<<" ------WRONG CONDUCTOR!";
           }
         else
           {
             if(!checkap(&nf, nf.nflist[i],  CR))
               cout<<" ----- a_p do not agree!";
             //     else
             //     cout<<" ----- a_p agree for p<100";
           }
         cout<<endl;
       }
#ifdef SINGLE
     bigint c6=getc6(CD),  c4=getc4(CD);
     char* f = new char[20];
#ifdef FIXC6_OUTPUT_TO_SUBDIR
     sprintf(f,"fixc6/fixc6.%ld",n);
#else
     sprintf(f,"fixc6.extra");
#endif
     ofstream xout(f,ios::app);
     delete[] f;
     xout<<" "<<n<<" "<<(i+1)<<" "<<c6<<endl;
     xout.close();
     cout<<"c4: "<<n<<" "<<(i+1)<<" "<<c4<<endl;
     cout<<"c6: "<<n<<" "<<(i+1)<<" "<<c6<<endl;
#endif
     if(verb) cout<<endl;
   }
}       // end of if(n)
}       // end of while()

 if (bad_ones.size()>0)
   {
     cout<<"\nNumber of bad curves: "<<bad_ones.size()<<endl;
     cout<<"List of bad curves\n";
     for(unsigned int i=0; i<bad_ones.size(); i++)
       cout<<bad_ones[i].first<<" "<<bad_ones[i].second<<"\n";
     cout<<endl;
   }
}       // end of main()

int checkap(const level* iN, const newform& nf, CurveRed& CR, long pmax)
{
  vector<long> aplist = nf.aplist;
  vector<long> primelist = primes(aplist.size());
  unsigned int i;
  bigint ap, p=BIGINT(0);
  int ok=1, ok1;
  for(i=0; (i<aplist.size())&&(p<=pmax); i++)
    {
      p=primelist[i];
      ap=Trace_Frob(CR,p);
      ok1 =  (ap==BIGINT(aplist[i]));
      if(!ok1) cout<<"p="<<p<<": ap(E)="<<ap<<" but ap(f)="<<aplist[i]<<endl;
      ok = ok && ok1;
    }
  return ok;
}