Here is the toric code example which I found from :https://pymatching.readthedocs.io/en/latest/toric-code-example.html
def repetition_code(n): row_ind, col_ind = zip(*((i, j) for i in range(n) for j in (i, (i+1)%n))) data = np.ones(2*n, dtype=np.uint8) return csr_matrix((data, (row_ind, col_ind))) def toric_code_x_stabilisers(L): """ Sparse check matrix for the X stabilisers of a toric code with lattice size L, constructed as the hypergraph product of two repetition codes. """ Hr = repetition_code(L) H = hstack( [kron(Hr, eye(Hr.shape)), kron(eye(Hr.shape), Hr.T)], dtype=np.uint8 ) H.data = H.data % 2 H.eliminate_zeros() return csr_matrix(H)
My problem is I want to switch this code to the surface code but I do not know how. I do not want to use STIM. In surface code, we have x and z stabilizers. I will add also a Z stabilizer function. This is fine but I do not know what will be different in this code to make it a surface code. It seemed to me X stabilizers can stay same. Probably I should change something(which can be boundaries) in the repetition code function, but I do not know how.
Can someone explain to me what I should change and how? Thanks