File: h1first.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 (191 lines) | stat: -rw-r--r-- 5,601 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
// FILE h1first.cc :  h1 (full space)
//////////////////////////////////////////////////////////////////////////
//
// 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/marith.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>

#ifndef SINGLE   // so Makefile can override
#define AUTOLOOP
#endif
#define SHOWCURVES
#define LMFDB_ORDER       // if defined, sorts newforms into LMFDB order before output

int main(void)
{
  int verbose,output,curve_output,n=130;
  cout << "Program h1first.  Using METHOD = " << METHOD << endl;
  cerr << "Verbose output? "; cin>>verbose;
  cerr << "Output updated newform data? "; cin>>output;
  cerr << "Output updated curve file? (0/1) ";  cin >> curve_output;
  string curve_filename;
#ifdef AUTOLOOP
  int limit=210;
  cerr<<"Enter first and last N: ";cin>>n>>limit;  n--;
  while (n<limit) { n++;
#else
#ifndef SINGLE
  while (n>0)
#endif
    { cout<<"\n\nEnter level: "; cin>>n;
#endif
  if (n>0)
    {
      if (curve_output)
        curve_filename=single_curve_filename(n);
      else
        curve_filename="no";
      if(verbose) cout << "\n\n";
      cout << ">>>Level " << n << "<<<" << endl;
      newforms nf(n,verbose>1);
      if(verbose)
        {
          cout << "Reading newform data from file..." << flush;
        }
      nf.createfromdata(1,0,0);
      long nnf = nf.n1ds;
      if(verbose)
        {
          cout << "done: " << nnf << " newforms." << endl;
        }
      if(nnf==0)
        {
          cout << "No newforms.\n";
          cout << "Finished level "<<n<<endl;
#ifdef SINGLE
          exit(0);
#else
          continue;
#endif
        }
#ifdef LMFDB_ORDER
      nf.sort();
#endif
      int all_nf = 1; // default; means do all
      int inf = 1;
#ifdef SINGLE
      all_nf = 0;
      nf.nf_subset.clear();
      cout << "Enter list of form numbers (between 1 and "<<nnf<<"), ending with 0: ";
      cin>>inf;
      while((inf>0)&&(inf<=nnf))
        {
          nf.nf_subset.push_back(inf-1); // actually count from 0 despite UI using 1 as base
          cin>>inf;
        }
      nnf = nf.nf_subset.size();
      cout << endl;
      if(verbose)
        {
          cout << "Working on " << nnf << " newforms: " << nf.nf_subset << " ..." << endl;
        }
#endif
      if(verbose)
        {
          cout << "Finding +1 eigenvectors..." << flush;
        }
      nf.makebases(1, all_nf);
      if(verbose)
        {
          cout << "done.\nNow finding -1 eigenvectors..." << flush;
        }
      nf.set_sign(-1);
      nf.makebases(1, all_nf);
      if(verbose)
        {
          cout << "done.\nNow filling in data for newforms..."<<flush;
        }
      if(verbose)
        {
          cout << "about to call merge" << endl;
        }
      nf.merge(all_nf);

      if(verbose)
        {
          cout << "done.\nUpdated newform(s): ";
          if (all_nf)
            {
              nf.display();
            }
          else
            {
              cout<<"updated newforms "<<nf.nf_subset<<":"<<endl;
              vector<int>::const_iterator nfi;
              for(nfi = nf.nf_subset.begin(); nfi!=nf.nf_subset.end(); nfi++)
                {
                  cout<<"# "<<(*nfi)<<":\t"<<endl;
                  nf.nflist[*nfi].display();
                }
            }
        }
      if(output)
        {
          nf.output_to_file();
          if(verbose)
            cout << "saved updated newform data to file" << endl;
        }

#ifdef SHOWCURVES
      // Now we compute the curves (all, unless one_only)
      if(verbose) cout<<"Computing "<<nnf<<" curves...\n";
      vector<int> forms;
      if (all_nf)
        {
          for(int i=0; i<nf.n1ds; i++) forms.push_back(i);
        }
      else
        {
          for(int i=0; i<nnf; i++) forms.push_back(nf.nf_subset[i]);
        }
      vector<int> failures = nf.showcurves(forms,0,curve_filename);
      if(failures.size()>0)
        {
          cout<<"No curve found for "<<failures.size()<<" forms: "<<failures<<endl;
        }
      else
        {
          if(verbose) cout<<"All curves found OK"<<endl;
          if (!all_nf && curve_output)
            {
              if(verbose)
                cout<<"Recomputing all curves and outputting to "<<curve_filename<<endl;
              forms.clear();
              for(int i=0; i<nf.n1ds; i++) forms.push_back(i);
              nf.showcurves(forms,verbose,curve_filename);
            }
        }

#endif
    }       // end of if(n)
    }       // end of while()
  if(verbose) cout<<"Finished"<<endl;
  }       // end of main()