forked from JanKapala/quantum-octo-broccoli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Register.py
32 lines (25 loc) · 794 Bytes
/
Register.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
from Qubit import Qubit
class Register:
def __init__(self, n):
self.qubits = []
for i in range(n):
self.qubits.append(Qubit())
def size(self):
return len(self.qubits)
def kroneckerize(self):
last = self.qubits[0].state
if self.size() == 1:
return last
for i in range(1,self.size()):
last = np.kron(last, self.qubits[i].state)
return last
def __repr__(self):
result = "["
for i in range(self.size()):
if not i == 0:
result += " "
result += "{}".format(self.qubits[i])
if i < self.size()-1:
result += "\n"
result += "]"
return result