File: Ldokchitser.h

package info (click to toggle)
lcalc 1.23%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 2,416 kB
  • sloc: cpp: 8,516; ansic: 4,079; makefile: 147
file content (182 lines) | stat: -rw-r--r-- 4,624 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
#ifndef Ldokchitser_H
#define Ldokchitser_H

//finding the explicit taylor series for \phi(t) using Dokchitser algo

#define MYDIGITS 5 // estimate of precision ... will be set using the precision variable

void mult_poly_taylor(Complex *, Complex *, Complex *, int );

template <class ttype>
void L_function <ttype>::
phi_series(int precision)
{
	cout << "-----------------------------------------------"<< endl << endl;
	cout << "phi series for " << name << " L_function" << endl << endl;
	
	int j,k;
		
	// constructing the equivalence classes Lambda[k] for k = 1 to N
	
	int pordtmp[a+1];
	Complex diff;
	Complex *lambda_k;
	int *l;
	
	for (j=1;j<=a;j++)
    	pordtmp[j]= 1;
    	
    for (j=1;j<=a;j++)
        for (k=1;k<=a;k++)
            if (j != k)
            {    
                diff = 2*(lambda[j] - lambda[k]);
                if((imag(diff)==0) && (fmod(real(diff),2) == 0) && (real(diff)<=0))
                {
                    pordtmp[j]+=pordtmp[k];
                    pordtmp[k]=0;
                }
            }
        	
    Complex temp_lambda_k[a];
    int temp_l[a];
    j=1;
    for (k=1;k<=a;k++)
        if (pordtmp[k]!=0)
        {
            temp_lambda_k[j]= lambda[k];
            temp_l[j]=pordtmp[k];
            j++;
        }
    
    int N = j-1;   
    lambda_k = new Complex[N+1];
    l = new int[N+1];
    for (j=1;j<=N;j++)
    {
    	lambda_k[j] = temp_lambda_k[j];
    	l[j] = temp_l[j];
    }
	
	cout << "-----------------------------------------------"<< endl << endl;
	cout << "There are "<< N << " equivalence classes Lambda[j]"<<endl;
    cout<< "The equivalence classes Lambda[j] for poles are represented by"<<endl;
    for (j=1;j<=N;j++)
    {
    	cout << "lambda_k["<<j<<"] = "<< lambda_k[j] << " with order l["<<j<<"] = "<<l[j]<<endl;
    }
    cout<<endl;
    
    // compute the values m[j] for the respective lambda_k[j]
    
    std::vector<Complex> m(N+1);
    for (j=1;j<=N;j++)
    	m[j] = -2*lambda_k[j] + 2;
	
	
	// compute sum_{k=1}^a log Gamma((s+m[j]+2*lambda[k])/2) for each j
	
	int n,fact_n;
	Complex log_Gamma[N+1][a+1][MYDIGITS+1];
        std:vector<std::vector<Complex> > sum_log_Gamma(N+1);
        for (j=1;j<=N;j++) sum_log_Gamma[j].resize(MYDIGITS+1);
	
	for (j=1;j<=N;j++)
	for (n=0;n<=MYDIGITS;n++)
			sum_log_Gamma[j][n] = 0;
	
	for (j=1;j<=N;j++)
	{
		for (k=1;k<=a;k++)
		{
			fact_n = 1;
			for (n=0;n<=MYDIGITS;n++)
			{
				if (n!=0)
					fact_n = fact_n*n;	
			
				log_Gamma[j][k][n] = pow(0.5,n)*(log_GAMMA((m[j]/2 + lambda[k]),n))/fact_n;
				sum_log_Gamma[j][n] = sum_log_Gamma[j][n] + log_Gamma[j][k][n];
			}
		}
	}	
	cout << endl;
	
	// compute the exponential taylor series for gamma = exp(sum_log_Gamma)
	
        std::vector<std::vector<std::vector<Complex> > > exp_sum_log_Gamma(N+1); // symmetric functions
        std::vector<std::vector<Complex> > gamma(N+1); // gamma(s+m[j]) for j = 1 to N
        for (j=1;j<=N;j++){
            exp_sum_log_Gamma[j].resize(MYDIGITS+1);
            gamma[j].resize(MYDIGITS+1);
        }
        for (j=1;j<=N;j++) for (n=0;n<=MYDIGITS;n++) exp_sum_log_Gamma[j][n].resize(MYDIGITS+1);
	Complex temp_gamma[MYDIGITS+1];
	Complex temp_mult_gamma[MYDIGITS+1];
	Complex temp_exp_sum_log_Gamma[MYDIGITS+1];
	int fact_n_k;
		
	for (j=1;j<=N;j++)
	{
		for (n=0;n<=MYDIGITS;n++)
			exp_sum_log_Gamma[j][0][n] = 0;			
		exp_sum_log_Gamma[j][0][0] = exp(sum_log_Gamma[j][0]);
		
		for (k=1;k<=MYDIGITS;k++)
		{
			fact_n_k = 1;
						
			for (n=0;n<=MYDIGITS;n++)
			{
				if(n%k == 0)
				{
					if (n/k != 0)
						fact_n_k = fact_n_k*(n/k);
						
					exp_sum_log_Gamma[j][k][n] = pow(sum_log_Gamma[j][k],n/k)/fact_n_k;
				}
				else
					exp_sum_log_Gamma[j][k][n] = 0;
			}
		}		
	}
	
	for (j=1;j<=N;j++)
	{
		
		for (n=0;n<=MYDIGITS;n++)
			temp_mult_gamma[n] = exp_sum_log_Gamma[j][0][n];
						
		for (k=1;k<=MYDIGITS;k++)
		{
			for (n=0;n<=MYDIGITS;n++)
			{
				temp_exp_sum_log_Gamma[n] = exp_sum_log_Gamma[j][k][n];
				temp_gamma[n] = temp_mult_gamma[n];
			}
				
			mult_poly_taylor(temp_gamma,temp_exp_sum_log_Gamma,temp_mult_gamma,MYDIGITS);
		}
		
		for (n=0;n<=MYDIGITS;n++)
			gamma[j][n] = temp_mult_gamma[n];		
					
	}
	
	cout << "-----------------------------------------------"<< endl;
    cout << "The gamma(s+m[j]) coefficients are as follows"<< endl<<endl;
    
    for(j=1;j<=N;j++)
    {
		cout<<"gamma(s+m["<<j<<"]) = "<<"gamma(s+"<<m[j]<<") = "<<gamma[j][0];
    	for (n=1;n<=MYDIGITS;n++)
    		cout << " + " << gamma[j][n] <<" s^"<<n;
    		
    	cout<<endl;
    }
    
    cout << "-----------------------------------------------"<< endl;
    
}

#endif