-
Notifications
You must be signed in to change notification settings - Fork 0
/
_add_gates.py
47 lines (38 loc) · 1.1 KB
/
_add_gates.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
""" Useful additional gates as projectQ Gate subclasses
"""
from projectq.ops import SelfInverseGate
import numpy as np
# two-qubit same-Pauli gates
class XXGate(SelfInverseGate):
""" Pauli-XX gate class """
def __str__(self):
return "XX"
@property
def matrix(self):
return np.matrix([[0, 0, 0, 1],
[0, 0, 1, 0],
[0, 1, 0, 0],
[1, 0, 0, 0]])
XX = XXGate()
class YYGate(SelfInverseGate):
""" Pauli-YY gate class """
def __str__(self):
return "YY"
@property
def matrix(self):
return np.matrix([[0, 0, 0, -1],
[0, 0, 1, 0],
[0, 1, 0, 0],
[-1, 0, 0, 0]])
YY = YYGate()
class ZZGate(SelfInverseGate):
""" Pauli-ZZ gate class """
def __str__(self):
return "ZZ"
@property
def matrix(self):
return np.matrix([[1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, 1]])
ZZ = ZZGate()