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

Make RZZ a subclass of ParityPhase. #173

Merged
merged 1 commit into from
Oct 22, 2023
Merged
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
28 changes: 10 additions & 18 deletions pyzx/circuit/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,24 +725,6 @@ def to_graph(self, g, q_mapper, c_mapper):
for gate in self.to_basic_gates():
gate.to_graph(g, q_mapper, c_mapper)

class RZZ(Gate):
name = 'RZZ'
qasm_name = 'rzz'
print_phase = True
def __init__(self, control: int, target: int, phase: FractionLike) -> None:
self.target = target
self.control = control
self.phase = phase

def to_basic_gates(self):
return [CNOT(control=self.control,target=self.target),
ZPhase(self.target,phase=self.phase),
CNOT(control=self.control,target=self.target)]

def to_graph(self, g, q_mapper, c_mapper):
for gate in self.to_basic_gates():
gate.to_graph(g, q_mapper, c_mapper)

class CPhase(CRZ):
name = 'CPhase'
qasm_name = 'cp'
Expand Down Expand Up @@ -820,6 +802,16 @@ def tcount(self):
return 1 if self.phase.denominator > 2 else 0


class RZZ(ParityPhase):
name = 'RZZ'
qasm_name = 'rzz'
def __init__(self, control: int, target: int, phase: FractionLike) -> None:
self.control = control
self.target = target
self.targets = (control, target)
self.phase = phase


class FSim(Gate):
name = 'FSim'
qsim_name = 'fs'
Expand Down