Skip to content

Commit 596582f

Browse files
committed
fix: fix cut inconsistency
1 parent ca943aa commit 596582f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: examples/stabilizer_simulation.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def get_binary_matrix(z_stabilizers):
6969

7070
def get_cut_binary_matrix(binary_matrix, cut):
7171
N = len(binary_matrix)
72-
new_indices = [i for i in range(N) if i not in set(cut)] + [
73-
i + N for i in range(N) if i not in set(cut)
72+
new_indices = [i for i in range(N) if i in set(cut)] + [
73+
i + N for i in range(N) if i in set(cut)
7474
]
7575
return binary_matrix[:, new_indices]
7676

@@ -117,11 +117,11 @@ def simulate_stim_circuit_with_mid_measurement(stim_circuit):
117117

118118
if __name__ == "__main__":
119119
# Number of qubits
120-
num_qubits = 8
120+
num_qubits = 10
121121
# Depth of the circuit
122-
depth = 10
122+
depth = 30
123123
# index list that is traced out to calculate the entanglement entropy
124-
cut = [i for i in range(num_qubits // 2)]
124+
cut = [i for i in range(num_qubits // 3)]
125125

126126
tc_circuit, op_list = random_clifford_circuit_with_mid_measurement(
127127
num_qubits, depth
@@ -134,8 +134,8 @@ def simulate_stim_circuit_with_mid_measurement(stim_circuit):
134134
stabilizer_tableau = simulate_stim_circuit_with_mid_measurement(stim_circuit)
135135
zs = [stabilizer_tableau.z_output(k) for k in range(len(stabilizer_tableau))]
136136
binary_matrix = get_binary_matrix(zs)
137-
bipartite_matrix = get_cut_binary_matrix(binary_matrix, cut)
138-
stim_entropy = (gf2_rank(bipartite_matrix.tolist()) - len(cut)) * np.log(2)
137+
cur_matrix = get_cut_binary_matrix(binary_matrix, cut)
138+
stim_entropy = (gf2_rank(cur_matrix.tolist()) - len(cut)) * np.log(2)
139139
print("Stim Entanglement Entropy:", stim_entropy)
140140

141141
# Entanglement entropy calculation using TensorCircuit

0 commit comments

Comments
 (0)