@@ -15,12 +15,13 @@ class CNOTBlocksGraphCircuit(GraphCircuit):
15
15
the CNOT gates can be considered to be classical CNOT gates,
16
16
and the ideal outcome is deterministic.
17
17
"""
18
+
18
19
def __init__ (
19
- self ,
20
- n_physical_qubits : int ,
21
- input_state : Tuple [int ],
22
- n_layers : int ,
23
- ) -> None :
20
+ self ,
21
+ n_physical_qubits : int ,
22
+ input_state : Tuple [int ],
23
+ n_layers : int ,
24
+ ) -> None :
24
25
"""Initialisation method.
25
26
26
27
:param n_physical_qubits: The maximum number of physical qubits
@@ -35,6 +36,9 @@ def __init__(
35
36
:type n_layers: int
36
37
"""
37
38
39
+ self .input_state = input_state
40
+ self .n_layers = n_layers
41
+
38
42
# The number of rows of CNOT blocks
39
43
# note that this is one less than the number of entries in the
40
44
# input state as each CNOT has two inputs.
@@ -53,7 +57,6 @@ def __init__(
53
57
super ().__init__ (n_physical_qubits = n_physical_qubits )
54
58
55
59
for layer in range (n_layers ):
56
-
57
60
# If this is the first layer then the control qubit of the first row needs
58
61
# to be initialised. If not then the control vertex is taken from
59
62
# the layer before.
@@ -65,7 +68,6 @@ def __init__(
65
68
control_vertex = cnot_block_vertex_list [layer - 1 ][0 ][4 ]
66
69
67
70
for row in range (n_rows ):
68
-
69
71
# for each block the 0th qubit is the control.
70
72
cnot_block_vertex_list [layer ][row ].append (control_vertex )
71
73
@@ -122,13 +124,11 @@ def __init__(
122
124
# If this is not the 0th layer then the previous layer
123
125
# can be measured.
124
126
if layer > 0 :
125
-
126
127
# If this is the 1th later then the inputs of the previous
127
128
# layer (the 0th layer) will not have been measured and should now be.
128
129
# Note that or other layers they will have been measured by this point
129
130
# as they are the 4th and 5th vertices of previous layers.
130
131
if layer == 1 :
131
-
132
132
# If this is the 0th row then we need to measure the input
133
133
# control. It is not necessary in general as it would be the
134
134
# output target of previous blocks.
@@ -196,7 +196,7 @@ def __init__(
196
196
)
197
197
198
198
@property
199
- def output_state (self ) -> Tuple [int ]:
199
+ def output_state (self ) -> Tuple [int , ... ]:
200
200
"""The ideal output bit string.
201
201
202
202
:return: The ideal output bit string.
@@ -205,5 +205,5 @@ def output_state(self) -> Tuple[int]:
205
205
output_state = list (self .input_state )
206
206
for _ in range (self .n_layers ):
207
207
for i in range (len (self .input_state ) - 1 ):
208
- output_state [i + 1 ] = output_state [i ] ^ output_state [i + 1 ]
208
+ output_state [i + 1 ] = output_state [i ] ^ output_state [i + 1 ]
209
209
return tuple (output_state )
0 commit comments