-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQGates.py
95 lines (65 loc) · 1.18 KB
/
QGates.py
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
H='Hadamard'
X='Not'
Y='Pauli Y'
Z='Pauli Z'
CH='Controlled Hadamard'
CX='Controlled Not'
CY='Controlled Y'
CZ='Controlled Z'
S='Clifford S'
SC='Clifford S Conjugate'
T='SquareRoot S'
TC='T Conjugate'
SWAP='Swap'
#CSWAP='Controlled Swap' pending because of arity 3
gateArity={
H:1,
X:1,
Y:1,
Z:1,
#
# CH:2,
CX:2,
# CY:2,
# CZ:2,
#
S:1,
# SC:1,
#
# T:1,
# TC:1,
#
# SWAP:2
}
gateName={
H:'h',
X:'x',
Y:'y',
Z:'z',
CH:'ch',
CX:'cx',
CY:'cy',
CZ:'cz',
S:'s',
SC:'sdg',
T:'t',
TC:'tdg',
SWAP:'swap'
}
def oracleBernsteinVazirani(a):
count=len(a)
l=[]
for i in a:
if i=='1':
l.append(('Controlled Not',count,0))
count-=1
return l
def oracleDeutschJozsa(case):
if case==0:
return []
elif case==1:
return [(CX,0,1)]
elif case==2:
return [(X,1),(CX,0,1)]
elif case==3:
return [(X,1)]