-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroverDiscreteTimeCode.cpp
More file actions
135 lines (118 loc) · 4.87 KB
/
Copy pathGroverDiscreteTimeCode.cpp
File metadata and controls
135 lines (118 loc) · 4.87 KB
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
#include <iostream>
#include <cmath>
#include <complex>
using namespace std;
int main()
{
for (int c = 50000; c < 50001; c++) {
for (int d = 0; d < 250; d++) {
int i, j;
complex<long double> res[4][4];
complex<long double> ans[4][1];
double N = c;
double param = 45;
double param1 = 70;
double param2 = 0;
complex<long double> y (-cos(param2*3.141592653589793238/180), -sin(param2*3.141592653589793238 / 180));
complex<long double> PI = (3.14159, 0);
int r = d;
complex<long double> mati[4][1] = { { complex<long double>(cos(param * 3.141592653589793238 / 180)/ sqrt(N),0) },{ complex<long double>(sin(param * 3.141592653589793238 / 180)*(sqrt(N-2)) / sqrt(N),0) },{ complex<long double>(sqrt(2)*sin(param * 3.141592653589793238 / 180)/sqrt(N), 0)},{ complex<long double>(cos(param * 3.141592653589793238 / 180)*sqrt(N-1)/sqrt(N),0) } };
complex<long double> matii[4][1] = { { (1 / N) },{ sqrt((N - 1)*(N - 2)) / N },{ sqrt(2 * (N - 1)) / N },{ sqrt(N - 1) / N } };
complex<long double> res2[4][4];
complex<long double> mmat1[4][4];
complex<long double> mmat2[4][4];
complex<long double> mmmat1[4][4];
complex<long double> mmmat2[4][4];
complex<long double> mat1[4][4] = { { complex<long double>(pow(real(y),2.0)-pow(imag(y),2.0),2*real(y)*imag(y)), complex<long double>((pow(real(y),2.0)-pow(imag(y),2.0)-2*real(y)+1)/N,(2*real(y)*imag(y)-2*imag(y))/N), complex<long double>(2*(pow(real(y),2.0)-pow(imag(y),2.0))-2*real(y),2*2*real(y)*imag(y)-2*imag(y)), complex<long double>(pow(real(y),2.0)-pow(imag(y),2.0)-1,2*real(y)*imag(y)) },
{ 0,1,0,0 },{ 0,complex<long double>((real(y)-1)/N, imag(y)/N), complex<long double>(real(y),imag(y)), 0 },{ 0,0,0,1 } };
complex<long double> mat2[4][4] = { { 1,0,0,0 },{ 4 / N,1,4,0 },{ -2 / N,0,-1,0 },{ 0,0,0,1 } };
complex<long double> mat5[4][4] = { {1,1 / N,2,1},{0, sqrt((N -1)*(N - 2)) / N,0,0}, {0,sqrt(2 * (N - 1)) / N,sqrt(2 * (N -1)), 0},{0,sqrt(N - 1) / N,0,sqrt(N - 1)} };
complex<long double> mat6[4][4] = { {1,2 / sqrt((N - 1)*(N -2)),-sqrt(2) / sqrt(N - 1),-1/ sqrt(N - 1)},{0,N / sqrt((N - 1)*(N -2)),0,0},{0,-1 / sqrt((N -1)*(N - 2)),1 / sqrt(2 * (N - 1)),0},{0,-1 / sqrt((N - 1)*(N -2)),0,1 / sqrt(N-1)} };
complex<long double> mat7[4][4] = { {complex<long double>(cos(param1 * 3.141592653589793238 / 180),sin(param1 * 3.141592653589793238 / 180)),0,0,0},{0,1,0,0,},{0,0,1,0},{0,0,0,complex<long double>(cos(param1 * 3.141592653589793238 / 180),sin(param1 * 3.141592653589793238 / 180)) } };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
complex<long double> ini (0,0);
mmat1[i][j] = ini;
complex<long double> sum (0,0);
for (int k = 0; k < 4; k++) {
sum += mat1[i][k] * mat6[k][j];
}
mmat1[i][j] = sum;
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
mmmat1[i][j] = (0, 0);
complex<long double> sum (0, 0);
for (int k = 0; k < 4; k++) {
sum += mat5[i][k] * mmat1[k][j];
}
mmmat1[i][j] = sum;
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
mmat2[i][j] = (0,0);
complex<long double> sum (0,0);
for (int k = 0; k < 4; k++) {
sum += mat2[i][k] * mat6[k][j];
}
mmat2[i][j] = sum;
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
mmmat2[i][j] = (0, 0);
complex<long double> sum (0,0);
for (int k = 0; k < 4; k++) {
sum += mat5[i][k] * mmat2[k][j];
}
mmmat2[i][j] = sum;
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
res[i][j] = (0, 0);
complex<long double> sum (0,0);
for (int k = 0; k < 4; k++) {
sum += mmmat2[i][k] * mmmat1[k][j];
}
res[i][j] = sum;
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
res2[i][j] = (0, 0);
complex<long double> sum (0, 0);
for (int k = 0; k < 4; k++) {
sum += mat7[i][k] * res[k][j];
}
res2[i][j] = sum;
}
}
complex<long double> res1[4][4] = { { 1,0,0,0 },{ 0,1,0,0 },{ 0,0,1,0 },{ 0,0,0,1 } };
for (int l = 0; l < r; l++) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
complex<long double> sum (0,0);
for (int k = 0; k < 4; k++) {
sum += res1[i][k] * res2[k][j];
}
res1[i][j] = sum;
}
}
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 1; j++) {
ans[i][j] = (0,0);
for (int k = 0; k < 4; k++) {
ans[i][j] += res1[i][k] * mati[k][j];
}
}
}
cout << "(" << d << "," << pow(abs(ans[0][0]),2.0) + pow(abs(ans[0][2]),2.0) << ")" << " ";
cout << "\n";
}
}
return 0;
}