Skip to content

Commit

Permalink
Make RZZ a subclass of ParityPhase.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlyongemallo committed Oct 21, 2023
1 parent 635f829 commit 6d1fa44
Showing 1 changed file with 10 additions and 18 deletions.
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

0 comments on commit 6d1fa44

Please sign in to comment.