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

Permute all variables of the Steane code #114

Merged
merged 6 commits into from
Jan 2, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
compute the swap of CRegs
perlinm committed Dec 17, 2024
commit e1dd9f6a1dfe2c7046b8e21841a116b5bf56e2cd
22 changes: 11 additions & 11 deletions python/quantum-pecos/src/pecos/qeclib/steane/steane_class.py
Original file line number Diff line number Diff line change
@@ -162,9 +162,7 @@ def prep_t_plus_state(
d=self.d,
a=self.a,
out=self.scratch,
reject=self.scratch[
2
], # the first two bits of self.scratch are used by "out"
reject=self.scratch[2], # the first two bits of self.scratch are used by "out"
flag_x=self.flag_x,
flag_z=self.flag_z,
flags=self.flags,
@@ -420,11 +418,13 @@ def qec(self, flag_bit: Bit | None = None):

def permute(self, other: Steane):
"""Permute this code block (including both quantum and classical registers) with another."""
# collect all variables in self and other, noting that self.a may or may not be in self.vars
self_vars = [var for var in self.vars if var is not self.a] + [self.a]
other_vars = [var for var in other.vars if var is not other.a] + [other.a]
permutes = [
Permute(self_var, other_var)
for self_var, other_var in zip(self_vars, other_vars)
]
return Block(*permutes)
block = Block(
Permute(self.d, other.d),
Permute(self.a, other.a),
)
for var_a, var_b in zip(self.vars, other.vars):
if isinstance(var_a, CReg):
block.extend(var_a.set(var_a ^ var_b))
block.extend(var_a.set(var_b ^ var_a))
block.extend(var_a.set(var_a ^ var_b))
return block