Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brute force clifford #33

Merged
merged 8 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions pauliopt/clifford/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ def string_repr(self, sep=" ", sign_sep="| "):
out = ""
for i in range(self.n_qubits):
for j in range(self.n_qubits):
x_str = ["I", "X", "Z", "Y"][int(self.x_out(i, j))]
z_str = ["I", "X", "Z", "Y"][int(self.z_out(i, j))]
x_str = ["I", "X", "Z", "Y"][int(self._x_out(i, j))]
z_str = ["I", "X", "Z", "Y"][int(self._z_out(i, j))]
out += f"{x_str}/{z_str}" + sep
out += sign_sep + f"{'+' if self.signs[i] == 0 else '-'} \n"
return out

def x_out(self, row, col):
def _x_out(self, row, col):
"""
Get the X operator in row `row` and column `col`.

Expand All @@ -189,7 +189,7 @@ def x_out(self, row, col):
"""
return self.tableau[row, col] + 2 * self.tableau[row, col + self.n_qubits]

def z_out(self, row, col):
def _z_out(self, row, col):
"""
Get the Z operator in row `row` and column `col`.

Expand All @@ -202,6 +202,30 @@ def z_out(self, row, col):
+ 2 * self.tableau[row + self.n_qubits, col + self.n_qubits]
)

@property
def x_matrix(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should do a vectorised version of this

"""
Binary matrix representing the X-Basis of the clifford tableau.
:return:
"""
x_matrx = np.zeros((self.n_qubits, self.n_qubits), dtype=int)
for i in range(self.n_qubits):
for j in range(self.n_qubits):
x_matrx[i, j] = self._x_out(i, j)
return x_matrx

@property
def z_matrix(self):
"""
Binary matrix representing the Z-Basis of the clifford tableau.
:return:
"""
z_matrx = np.zeros((self.n_qubits, self.n_qubits), dtype=int)
for i in range(self.n_qubits):
for j in range(self.n_qubits):
z_matrx[i, j] = self._z_out(i, j)
return z_matrx

def _xor_row(self, i, j):
"""
XOR the value of row j to row i and adjust the signs accordingly.
Expand Down
Loading
Loading