1 // periods.h : class for integrating newforms
2 //////////////////////////////////////////////////////////////////////////
3 //
4 // Copyright 1990-2012 John Cremona
5 //
6 // This file is part of the eclib package.
7 //
8 // eclib is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2 of the License, or (at your
11 // option) any later version.
12 //
13 // eclib is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 // for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with eclib; if not, write to the Free Software Foundation,
20 // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef _ECLIB_PERIODS_H
25 #define _ECLIB_PERIODS_H      1
26 
27 #include <eclib/newforms.h>
28 
29 #define PI Pi()
30 //#ifndef TWOPI
31 //#define TWOPI ((2*PI))
32 //#endif
33 //#ifndef LOG10
34 #define LOG10 log(10)
35 //#endif
36 const bigfloat eps = to_bigfloat(1.0e-16);   // ?? mindouble;
37 #define EULERGAMMA Euler()
38 
39 bigfloat myg0(bigfloat x);
40 bigfloat myg1(bigfloat x);
41 bigfloat myg2(bigfloat x);
42 bigfloat myg3(bigfloat x);
43 
44 class character {
45 private:
46   long modul;
47   int *chartable;
48   void init();
49 public:
50   character(long m=1);
51   ~character();
52   void reset(long m);
modulus(void)53   long modulus(void) {return modul;}
operator()54   int operator()(long n) {return chartable[n%modul];}
55 };
56 
57 class summer {
58 protected:
59   bigfloat sum1, sum2;  // sum2 not necessarily used
60   long limit, limit1, limit2;
61   bigfloat rootlimit, rootmod, factor, factor1, factor2, rp, ip;
62   long type;
63   long N, nap;  vector<long> aplist;  vector<long> primelist;
64   vector<long> an_cache;  // holds a_n for n up to rootlimit
65   vector<long> a2p_cache;  // holds a_n for n=2^e up to rootlimit
66   vector<long> a3p_cache;  // holds a_n for n=3^e up to rootlimit
67   vector<long> a5p_cache;  // holds a_n for n=5^e up to rootlimit
68   vector<long> a7p_cache;  // holds a_n for n=7^e up to rootlimit
69   long n2p,n3p,n5p,n7p;
70   void initaplist(const level* iN, const vector<long>& apl);
func1(long n)71   virtual bigfloat func1(long n) {return to_bigfloat(0);}
func2(long n)72   virtual bigfloat func2(long n) {return to_bigfloat(0);}
73   virtual void use(long n, long an)=0;
74   void use1(long n, long an);
75   void use2(long n, long an);
76   void use2357(long n, long an);
77   void add(long n, long pindex, long y, long z);
78   void add2357(long n, long pindex, long y, long z);
79   void sumit(void);             // do the sum
80 public:
~summer()81   virtual ~summer() {;}
82   virtual void compute(void)=0;         // ditto with pre and post-processing
rper(void)83   bigfloat rper(void) {return rp;}
iper(void)84   bigfloat iper(void) {return ip;}
getperiods()85   Cperiods getperiods() {Cperiods per(rp,ip,type);  return per;}
86 };
87 
88 class periods_via_lfchi :public summer {
89 private:
90   character chi1, chi2;
91   long mplus, mminus, dp0;
use(long n,long an)92   void use(long n, long an) {use2(n,an);}
func1(long n)93   bigfloat func1(long n) { return to_bigfloat(chi1(n)) * pow(factor1,to_bigfloat(n)); }
func2(long n)94   bigfloat func2(long n) { return to_bigfloat(chi2(n)) * pow(factor2,to_bigfloat(n)); }
95 public:
96   periods_via_lfchi (const level* iN, const newform* f);
97   void compute(void);
98 };
99 
100 class periods_direct :public summer {
101 private:
102   long eps_N, a, b, c, d;
103   bigfloat theta1,theta2;
104   vector<bigfloat> ctab, stab;  // array of cos(j*2*pi/d), sin(j*2*pi/d), for j mod d
105   void use(long n, long an);
106 
107 public:
108   periods_direct (const level* iN, const newform* f);
109   void compute(void);
110   void compute(long ta, long tb, long tc, long td);
111                                // period of (a,b;Nc,d) in Gamma_0(N)
112 };
113 
114 class part_period :public summer {
115 private:
116   bigfloat efactor,x0,y0,xn;
func1(long n)117   bigfloat func1(long n) { xn=to_bigfloat(n); efactor = exp(-xn*y0);
118 			   return efactor*cos(xn*x0); }
func2(long n)119   bigfloat func2(long n) { return efactor*sin(xn*x0); }
use(long n,long an)120   void use(long n, long an) {use2(n,an);}
121 
122 public:
123   part_period (const level* iN, const newform* f);
~part_period()124   ~part_period () {;}
125   void compute(const bigcomplex& z0);
126   void compute();
getperiod()127   bigcomplex getperiod() {return bigcomplex(rp,ip);}
128 };
129 
130 bigfloat G(int r, bigfloat x);  // G_r(x)
131 
132 class ldash1 : public summer {
133 private:
134   long r;
135   int computed;
136   bigfloat ld1;
137   bigfloat G(bigfloat x);  // G_r(x)
138   void init(const level* N, const vector<long>& f_aplist, long f_sfe, const rational& f_loverp);
use(long n,long an)139   void use(long n, long an) {use1(n,an);}
func1(long n)140   bigfloat func1(long n) { return -G(factor1*to_bigfloat(n)); }
141 public:
142   ldash1 (const level* iN, const newform* f);
143   ldash1 (const newforms* nf, long i);  // the i'th newform
144   void compute(void);
rank()145   long rank() {compute(); return r;}
value()146   bigfloat value() {compute(); return ld1;}
147 //
148 // NB this value is equal to r!*L^{(r)}(f,1) -- note the r! factor!
149 //
150 };
151 
152 class lfchi : public summer {
153 private:
154   long limit0;
155   bigfloat val;
156   character chi;
func1(long n)157   bigfloat func1(long n) { return chi(n)*pow(factor1,to_bigfloat(n));}
use(long n,long an)158   void use(long n, long an) {use1(n,an);}
159 public:
160   lfchi (const level* iN, const newform* f);
161   void compute(long ell);
compute(void)162   void compute(void) {;} // not called but has to exist;
value(void)163   bigfloat value(void) {return val;}
scaled_value(void)164   bigfloat scaled_value(void) {return sqrt(to_bigfloat(chi.modulus()))*val;}
165 };
166 
167 vector<long> resort_aplist(const level* iN,
168 			   const vector<long>& primelist,
169 			   const vector<long>& apl);
170 
171 
172 #endif
173