-
Notifications
You must be signed in to change notification settings - Fork 1
/
ShorError.m
100 lines (90 loc) · 2.02 KB
/
ShorError.m
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
clear;
clc;
fprintf('Running...\n');
%Creat GATE:
gate2CN=[ 1 0 0 0 0 0 0 0;
0 1 0 0 0 0 0 0;
0 0 1 0 0 0 0 0;
0 0 0 1 0 0 0 0;
0 0 0 0 0 0 0 1;
0 0 0 0 0 0 1 0;
0 0 0 0 0 1 0 0;
0 0 0 0 1 0 0 0];
gate2CT=[ 1 0 0 0 0 0 0 0;
0 1 0 0 0 0 0 0;
0 0 1 0 0 0 0 0;
0 0 0 0 0 0 0 1;
0 0 0 0 1 0 0 0;
0 0 0 0 0 1 0 0;
0 0 0 0 0 0 1 0;
0 0 0 1 0 0 0 0;
];
%-----------------------
gate1=kron(gateCNE(4),eye(2^5));
gate2=kron(gateCNE(7),eye(2^2));
H=hadamard(1);
tem1=kron(H,eye(2^2));
tem2=kron(tem1,tem1);
gate3=kron(tem2,tem1);
tem1=kron(gate2CN,gate2CN);
gate4=kron(tem1,gate2CN);
gate5=gate4;
tem=kron(gate2CT,gate2CT);
gate6=kron(tem,gate2CT);
gate7=gate3;
gate8=gate2;
gate9=gate1;
gate10=kron(gate2CTE,eye(2^2));
%-----------------------
%Creat ERRORS:
Ygate=[0 -i;
i 0];
Error0=eye(2^9);
Error1=kron(-i*Ygate,eye(2^8));
tem=kron(eye(2^1),-i*Ygate);
Error2=kron(tem,eye(2^7));
tem=kron(eye(2^2),-i*Ygate);
Error3=kron(tem,eye(2^6));
tem=kron(eye(2^3),-i*Ygate);
Error4=kron(tem,eye(2^5));
tem=kron(eye(2^4),-i*Ygate);
Error5=kron(tem,eye(2^4));
tem=kron(eye(2^5),-i*Ygate);
Error6=kron(tem,eye(2^3));
tem=kron(eye(2^6),-i*Ygate);
Error7=kron(tem,eye(2^2));
tem=kron(eye(2^7),-i*Ygate);
Error8=kron(tem,eye(2^1));
Error9=kron(eye(2^8),-i*Ygate);
%-----------------------
%Setup qubit input:
q_zero=qubit0(1);
q_one=qubit1(1);
q1=(3/5)*q_zero+(4/5)*q_one;
q2=qubit0(8);
%-----------------------
%Init
Phi1=kron(q1,q2);
Phi2=gate1*Phi1;
Phi3=gate2*Phi2;
Phi4=gate3*Phi3;
Phi5=gate4*Phi4;
%Applying Error
Phi6=Error7*Phi5;
%-----------------------
Phi7=gate5*Phi6;
Phi8=gate6*Phi7;
Phi9=gate7*Phi8;
Phi10=gate8*Phi9;
Phi11=gate9*Phi10;
Phi12=gate10*Phi11;
%-----------------------
final=[];
[m,n]=size(Phi12);
for i=1:m
%if Phi7(i,n) ~= 0
if Phi12(i,n) >= eps
final=[final Phi12(i,n)];
end
end
fprintf('Finished!\n');