File: nfhpmcurve.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 (214 lines) | stat: -rw-r--r-- 6,122 bytes parent folder | download
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
// FILE nfhpmcurve.cc main newform- and curve-finding program
//////////////////////////////////////////////////////////////////////////
//
// 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 <eclib/interface.h>
#include <eclib/timer.h>
#include <eclib/xsplit.h>
#include <eclib/moddata.h>
#include <eclib/symb.h>
#include <eclib/cusp.h>
#include <eclib/homspace.h>
#include <eclib/oldforms.h>
#include <eclib/cperiods.h>     //from qcurves, for computing conductors
#include <eclib/newforms.h>
#include <eclib/periods.h>
#include <eclib/pcprocs.h>

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

#define MAXNAP 20000
#define BITPREC0 100  // initial bit precision
#define BITPRECX  20  // step-size for increasing bit precision
#define BITPRECMAX 300  // maximum bit precision

int main(void)
{
 init_time();
 start_time();
 long n=110, stopp, stopp0; 
 long prec0=BITPREC0;
 int output, verbose;

 cout << "Program nfhpmcurve.  Using METHOD = " << METHOD 
      << " to find newforms" << endl;
#ifdef MODULAR
 cout << "MODULUS for linear algebra = " << MODULUS << endl;
#endif
 cout << "Verbose output? "; cin>>verbose;
 cout << "How many primes for Hecke eigenvalues? ";
 cin  >> stopp0; cout << endl;
 output=1; 
 cout << "Output newforms to file? (0/1) ";  cin >> output;
#ifdef AUTOLOOP
 int limit;
 cout<<"Enter first and last N: ";cin>>n>>limit; n--;
 while (n<limit) { n++;
#else
     while (n>0) { cout<<"Enter level: "; cin>>n;
#endif
 if (n>0)
{
  cout << "\n>>>Level " << n;
  // Temporary code to skip non-square-free levels
  //
  //  if(!is_squarefree(n)) {cout<<" --not square-free, skipping!\n"; continue;}
  //
  if(verbose)cout<<endl; else cout<< ":\t"<<flush;
  if(!is_valid_conductor(n))
    {
      cout<<"Not a valid conductor!"<<endl;
      if (output) // output extended full nf data and small nf data
	{
	  output_to_file_no_newforms(n,1,0);
	  output_to_file_no_newforms(n,1,1);
	}
      cout << "Finished level "<<n<<endl;
      continue;
    }
  int plus=1, cuspidal=0;
  newforms nf(n,verbose); 
  int noldap=25; // stopp0 must be at least this big!
  if (stopp0<noldap) stopp0=noldap;
  nf.createfromscratch(1,noldap);
#ifdef LMFDB_ORDER
  nf.sort();
  nf.make_projcoord(); // needed for when we add more ap
#endif
  if(verbose) nf.display();
  else          cout << nf.n1ds << " newform(s) found."<<endl;
  stopp=stopp0;
  nf.addap(stopp);

  long nnf = nf.n1ds, inf; 
  if(nnf==0)
    {
      cout << "No newforms.\n";
      cout << "Finished level "<<n<<endl;
      if(output)  // output extended full nf data and small nf data
	{
	  nf.output_to_file(1,0);
	  nf.output_to_file(1,1);
	}
      continue;
    }

  // Thus far, as in tmanin

  if(verbose)
    {
      cout << endl;
      cout << "Creating minus space..."<<endl;
    }
  nf.set_sign(-1);
  if(verbose)
    {
      cout<<"sign = "<<nf.get_sign()<<endl;
    }
  nf.makebases(1);
  if(verbose)
    {
      cout << "...finished creating minus data."<<endl<<endl;
      nf.display();
      cout << "Filling in data for newforms..."<<endl;
    }
  nf.set_sign(0);
  nf.merge();
  if(verbose) 
    {
      cout << "...finished filling in full data."<<endl;
      cout << "Updated newforms: ";
      nf.display();
    }
  if(output)  // output extended full nf data and small nf data
    {
      nf.output_to_file(1,0);
      nf.output_to_file(1,1);
    }
  // Now we compute the curves
  cout<<"Computing "<<nnf<<" curves...\n";

  long fac=nf.sqfac;
  if(verbose&&(fac>1)) cout<<"c4 factor " << fac << endl;

  stopp = stopp0; // will be increased if necessary
  set_precision(prec0);
  bigfloat rperiod;
  vector<int> forms;
  for(inf=0; inf<nnf; inf++) forms.push_back(inf);

  while(forms.size()>0)
    {
      forms = nf.showcurves(forms,verbose,"no");
      if(forms.size()==0)
	{
	  cout<<"All curves found successfully!"<<endl;
	  cout << "Finished level "<<n<<endl;
	  if(output)  // output extended full nf data and small nf data
	    {
	      nf.output_to_file(1,0);
	      nf.output_to_file(1,1);
	    }
	}
      else
	{      
	  cout<<forms.size()<<" curve(s) missing: ";
	  for(vector<int>::const_iterator inf=forms.begin(); inf!=forms.end(); inf++)
	    cout<<(*inf+1)<<" ";
	  cout<<endl;
	  int newstopp;
	  if(stopp<500) 
	    newstopp=2*stopp;
	  else
	    newstopp=stopp+500;
	  if(newstopp>MAXNAP)
	    {
	      cout<<"Cannot compute more ap, something must be wrong in newform data"<<endl;
	    }
          else
            {
              cout<<"Computing some more ap: from "<<stopp+1<<" to "
                  <<newstopp<<"..."<<endl;
              nf.set_sign(1);
              nf.makeh1(1);
              nf.addap(newstopp);
              stopp=newstopp;
              if(output)  // output extended full nf data and small nf data
                {
                  nf.output_to_file(1,0);
                  nf.output_to_file(1,1);
                }
#ifdef MPFP
              if(bit_precision()<BITPRECMAX) 
                {
                  set_precision(bit_precision()+BITPRECX);
                  cout << "Now working with bit precision "<<bit_precision()<< endl;
                }
#endif
            }
        }
    }
 }       // end of if(n>0)
     }  // end of while(n>0) or while(n<limit)
 }       // end of main()