-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqc_gate.py
36 lines (31 loc) · 846 Bytes
/
qc_gate.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
import cmath, math
from numpy import matrix
class QuantumGates:
"""
This class defines all the Quantum Gate operation
available.
"""
# Qubit transformation matrices
# Identity Matrix
I = matrix([[1, 0],
[0, 1]])
# Hadamard Gate
H = 1 / math.sqrt(2) * matrix([[1, 1],
[1, -1]])
# PauliX
X = matrix([[0, 1],
[1, 0]])
# PauliY
Y = matrix([[0, -1j],
[1j, 0]])
# PauliZ
Z = matrix([[1, 0],
[0, -1]])
S = matrix([[1, 0],
[0, 1j]]) # Phase
T = matrix([[1, 0],
[0, cmath.exp(1j * (cmath.pi / 4))]]) # PI/8
sN = 1 / cmath.sqrt(2) * matrix([[1, -1],
[1, 1]]) # Sqrt Not
def __init__(self):
pass